summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/commit_spec.rb19
-rw-r--r--spec/models/job_spec.rb22
2 files changed, 40 insertions, 1 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 40ccbe4..b1c1400 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -16,7 +16,7 @@ require 'spec_helper'
describe Commit do
let(:project) { FactoryGirl.create :project }
- let(:commit) { FactoryGirl.create :commit }
+ let(:commit) { FactoryGirl.create :commit, project: project }
let(:commit_with_project) { FactoryGirl.create :commit, project: project }
it { should belong_to(:project) }
@@ -159,4 +159,21 @@ describe Commit do
it { should eq(project.gitlab?) }
end
+
+ describe "run_deploy_job" do
+ before do
+ job = FactoryGirl.create :job, project: project
+ job1 = FactoryGirl.create :job, project: project
+ FactoryGirl.create :job, job_type: :deploy, project: project
+ FactoryGirl.create :build, commit: commit, status: :success, job: job
+ FactoryGirl.create :build, commit: commit, status: :success, job: job1
+ project.reload
+ end
+
+ it "creates new build for deploy" do
+ commit.run_deploy_job(commit.ref)
+
+ commit.builds.count.should == 3
+ end
+ end
end
diff --git a/spec/models/job_spec.rb b/spec/models/job_spec.rb
new file mode 100644
index 0000000..342eab7
--- /dev/null
+++ b/spec/models/job_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe Job do
+ let(:project) { FactoryGirl.create :project }
+
+ it { should belong_to(:project) }
+ it { should have_many(:builds) }
+
+ describe "run_for_ref?" do
+ it "allows run for any ref if refs params is empty" do
+ job = FactoryGirl.create :job, project: project
+ job.run_for_ref?("anything").should be_true
+ end
+
+ it "allows run for any ref in refs params" do
+ job = FactoryGirl.create :job, project: project, refs: "master, staging"
+ job.run_for_ref?("master").should be_true
+ job.run_for_ref?("staging").should be_true
+ job.run_for_ref?("anything").should be_false
+ end
+ end
+end