Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/commit_status_spec.rb')
-rw-r--r--spec/models/commit_status_spec.rb63
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index ea5e4e21039..0ee85489574 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -16,6 +16,7 @@ describe CommitStatus, :models do
it { is_expected.to belong_to(:pipeline) }
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:project) }
+ it { is_expected.to belong_to(:auto_canceled_by) }
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_inclusion_of(:status).in_array(%w(pending running failed success canceled)) }
@@ -101,6 +102,32 @@ describe CommitStatus, :models do
end
end
+ describe '#auto_canceled?' do
+ subject { commit_status.auto_canceled? }
+
+ context 'when it is canceled' do
+ before do
+ commit_status.update(status: 'canceled')
+ end
+
+ context 'when there is auto_canceled_by' do
+ before do
+ commit_status.update(auto_canceled_by: create(:ci_empty_pipeline))
+ end
+
+ it 'is auto canceled' do
+ is_expected.to be_truthy
+ end
+ end
+
+ context 'when there is no auto_canceled_by' do
+ it 'is not auto canceled' do
+ is_expected.to be_falsey
+ end
+ end
+ end
+ end
+
describe '#duration' do
subject { commit_status.duration }
@@ -297,4 +324,40 @@ describe CommitStatus, :models do
end
end
end
+
+ describe '#locking_enabled?' do
+ before do
+ commit_status.lock_version = 100
+ end
+
+ subject { commit_status.locking_enabled? }
+
+ context "when changing status" do
+ before do
+ commit_status.status = "running"
+ end
+
+ it "lock" do
+ is_expected.to be true
+ end
+
+ it "raise exception when trying to update" do
+ expect{ commit_status.save }.to raise_error(ActiveRecord::StaleObjectError)
+ end
+ end
+
+ context "when changing description" do
+ before do
+ commit_status.description = "test"
+ end
+
+ it "do not lock" do
+ is_expected.to be false
+ end
+
+ it "save correctly" do
+ expect(commit_status.save).to be true
+ end
+ end
+ end
end