summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-07-08 12:38:08 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-07-08 12:39:03 +0200
commit638a5f492541fa3f658b4fd3090dda624e4cf4c9 (patch)
treed152e32eb6cf97e20fd4a905b180176fedd5dc83 /spec/models
parent52cc9a572484a87cea542448e6d439b7c6032e04 (diff)
downloadgitlab-ci-allow-per-job-failure.tar.gz
Allow to defined per-job allow_failure parameterallow-per-job-failure
It allows to ignore status of specific job when computed for commit
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/build_spec.rb69
-rw-r--r--spec/models/project_services/hip_chat_message_spec.rb9
-rw-r--r--spec/models/project_services/slack_message_spec.rb13
3 files changed, 57 insertions, 34 deletions
diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb
index 8bc9807..7e1c7e9 100644
--- a/spec/models/build_spec.rb
+++ b/spec/models/build_spec.rb
@@ -2,22 +2,23 @@
#
# Table name: builds
#
-# id :integer not null, primary key
-# project_id :integer
-# status :string(255)
-# finished_at :datetime
-# trace :text
-# created_at :datetime
-# updated_at :datetime
-# started_at :datetime
-# runner_id :integer
-# commit_id :integer
-# coverage :float
-# commands :text
-# options :text
-# job_id :integer
-# name :string(255)
-# deploy :boolean default(FALSE)
+# id :integer not null, primary key
+# project_id :integer
+# status :string(255)
+# finished_at :datetime
+# trace :text
+# created_at :datetime
+# updated_at :datetime
+# started_at :datetime
+# runner_id :integer
+# commit_id :integer
+# coverage :float
+# commands :text
+# job_id :integer
+# name :string(255)
+# deploy :boolean default(FALSE)
+# options :text
+# allow_failure :boolean default(FALSE), not null
#
require 'spec_helper'
@@ -126,6 +127,42 @@ describe Build do
end
end
+ describe :ignored? do
+ subject { build.ignored? }
+
+ context 'if build is not allowed to fail' do
+ before { build.allow_failure = false }
+
+ context 'and build.status is success' do
+ before { build.status = 'success' }
+
+ it { should be_false }
+ end
+
+ context 'and build.status is failed' do
+ before { build.status = 'failed' }
+
+ it { should be_false }
+ end
+ end
+
+ context 'if build is allowed to fail' do
+ before { build.allow_failure = true }
+
+ context 'and build.status is success' do
+ before { build.status = 'success' }
+
+ it { should be_false }
+ end
+
+ context 'and build.status is failed' do
+ before { build.status = 'failed' }
+
+ it { should be_true }
+ end
+ end
+ end
+
describe :trace do
subject { build.trace_html }
diff --git a/spec/models/project_services/hip_chat_message_spec.rb b/spec/models/project_services/hip_chat_message_spec.rb
index 1afe3ed..f1ad875 100644
--- a/spec/models/project_services/hip_chat_message_spec.rb
+++ b/spec/models/project_services/hip_chat_message_spec.rb
@@ -6,12 +6,7 @@ describe HipChatMessage do
let(:project) { FactoryGirl.create(:project) }
context "One build" do
- let(:commit) do
- commit = FactoryGirl.create(:commit, project: project)
- commit.push_data[:ci_yaml_file] = YAML.dump({rspec: { script: 'pwd' }})
- commit.save
- commit
- end
+ let(:commit) { FactoryGirl.create(:commit_with_one_job, project: project) }
let(:build) do
commit.create_builds
@@ -42,7 +37,7 @@ describe HipChatMessage do
end
context "Several builds" do
- let(:commit) {commit = FactoryGirl.create(:commit, project: project)}
+ let(:commit) { FactoryGirl.create(:commit_with_two_jobs, project: project) }
let(:build) do
commit.builds.first
diff --git a/spec/models/project_services/slack_message_spec.rb b/spec/models/project_services/slack_message_spec.rb
index f60f89c..88e0f37 100644
--- a/spec/models/project_services/slack_message_spec.rb
+++ b/spec/models/project_services/slack_message_spec.rb
@@ -6,12 +6,7 @@ describe SlackMessage do
let(:project) { FactoryGirl.create :project }
context "One build" do
- let(:commit) do
- commit = FactoryGirl.create(:commit, project: project)
- commit.push_data[:ci_yaml_file] = YAML.dump({rspec: { script: "ls" }})
- commit.save
- commit
- end
+ let(:commit) { FactoryGirl.create(:commit_with_one_job, project: project) }
let(:build) do
commit.create_builds
@@ -48,11 +43,7 @@ describe SlackMessage do
end
context "Several builds" do
- let(:commit) {commit = FactoryGirl.create(:commit, project: project)}
-
- let(:build) do
- commit.builds.first
- end
+ let(:commit) { FactoryGirl.create(:commit_with_two_jobs, project: project) }
context 'when all matrix builds succeeded' do
let(:color) { 'good' }