summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-08 16:47:02 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-08 16:47:02 +0200
commit8cc88dac27c6cb919e505266e59add66649c852b (patch)
treee8e1bf0c30ac40ba239c0cfe3c1f533067eca2d8 /spec
parent98009569315e3859bbdc6b7dce7fc921d91bbe06 (diff)
downloadgitlab-ci-8cc88dac27c6cb919e505266e59add66649c852b.tar.gz
Added advanced path validation for project
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/projects.rb3
-rw-r--r--spec/models/project_spec.rb9
-rw-r--r--spec/spec_helper.rb7
3 files changed, 16 insertions, 3 deletions
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index 6fa3561..4096cca 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -4,7 +4,8 @@ FactoryGirl.define do
factory :project do
name Faker::Name.name
token 'iPWx6WM4lhHNedGfBpPJNP'
- path '/tmp'
+ default_ref 'master'
+ path Rails.root.join('tmp', 'test_repo')
scripts 'ls'
end
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 8c4d595..3073919 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -1,15 +1,20 @@
require 'spec_helper'
describe Project do
- subject { Project.new }
+ subject { FactoryGirl.build :project }
it { should have_many(:builds) }
+ describe :path do
+ it { should allow_value(Rails.root.join('tmp', 'test_repo')).for(:path) }
+ it { should_not allow_value('/tmp').for(:path) }
+ end
+
it { should validate_presence_of :name }
- it { should validate_presence_of :path }
it { should validate_presence_of :scripts }
it { should validate_presence_of :timeout }
it { should validate_presence_of :token }
+ it { should validate_presence_of :default_ref }
end
# == Schema Information
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 657d5b9..0f235cf 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -8,6 +8,13 @@ require 'rspec/autorun'
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+test_repo_path = Rails.root.join('tmp', 'test_repo')
+
+unless File.exists?(test_repo_path)
+ `git clone https://github.com/randx/six.git #{test_repo_path}`
+end
+
RSpec.configure do |config|
config.include LoginHelpers, type: :request