summaryrefslogtreecommitdiff
path: root/spec/models/commit_status_spec.rb
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-03-22 18:22:34 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2017-03-28 17:50:28 +0200
commitbb910c3b46fa9dde47ea3377d4463c0eae5149c7 (patch)
tree7f8b764936efc91ab89a89b31db88ef153cedeb4 /spec/models/commit_status_spec.rb
parentd70f9c85631ec16523528eabf6f470619bf7969a (diff)
downloadgitlab-ce-bb910c3b46fa9dde47ea3377d4463c0eae5149c7.tar.gz
Make CI build to use optimistic locking only on status change
Diffstat (limited to 'spec/models/commit_status_spec.rb')
-rw-r--r--spec/models/commit_status_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index ea5e4e21039..7343b735a74 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -297,4 +297,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