summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-05-07 06:56:52 +0000
committerStan Hu <stanhu@gmail.com>2019-05-07 06:56:52 +0000
commit5925b5bbdb0ffddf4ab8be84b84747a65c2aec3c (patch)
tree0995cd59b502ce42cc1070e652921f0e296a4df3 /spec
parent6424a3ec7ee361b37a6ad853293bf7ecb0f1f95e (diff)
parentb7b852c250a95648d5954e0ead6c37b5ff8b35d9 (diff)
downloadgitlab-ce-5925b5bbdb0ffddf4ab8be84b84747a65c2aec3c.tar.gz
Merge branch 'sh-fix-activerecord-patch-mark2' into 'master'
Additional fix to handle NULL lock_version See merge request gitlab-org/gitlab-ce!28153
Diffstat (limited to 'spec')
-rw-r--r--spec/models/issue_spec.rb21
-rw-r--r--spec/models/merge_request_spec.rb21
2 files changed, 32 insertions, 10 deletions
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index 0ce4add5669..cc777cbf749 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -56,14 +56,25 @@ describe Issue do
end
describe 'locking' do
- it 'works when an issue has a NULL lock_version' do
- issue = create(:issue)
+ using RSpec::Parameterized::TableSyntax
- described_class.where(id: issue.id).update_all('lock_version = NULL')
+ where(:lock_version) do
+ [
+ [0],
+ ["0"]
+ ]
+ end
- issue.update!(lock_version: 0, title: 'locking test')
+ with_them do
+ it 'works when an issue has a NULL lock_version' do
+ issue = create(:issue)
- expect(issue.reload.title).to eq('locking test')
+ described_class.where(id: issue.id).update_all('lock_version = NULL')
+
+ issue.update!(lock_version: lock_version, title: 'locking test')
+
+ expect(issue.reload.title).to eq('locking test')
+ end
end
end
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index ec2aef6f815..c72b6e9033d 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -32,14 +32,25 @@ describe MergeRequest do
end
describe 'locking' do
- it 'works when a merge request has a NULL lock_version' do
- merge_request = create(:merge_request)
+ using RSpec::Parameterized::TableSyntax
- described_class.where(id: merge_request.id).update_all('lock_version = NULL')
+ where(:lock_version) do
+ [
+ [0],
+ ["0"]
+ ]
+ end
- merge_request.update!(lock_version: 0, title: 'locking test')
+ with_them do
+ it 'works when a merge request has a NULL lock_version' do
+ merge_request = create(:merge_request)
- expect(merge_request.reload.title).to eq('locking test')
+ described_class.where(id: merge_request.id).update_all('lock_version = NULL')
+
+ merge_request.update!(lock_version: lock_version, title: 'locking test')
+
+ expect(merge_request.reload.title).to eq('locking test')
+ end
end
end