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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /spec/models/application_record_spec.rb
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/models/application_record_spec.rb')
-rw-r--r--spec/models/application_record_spec.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/spec/models/application_record_spec.rb b/spec/models/application_record_spec.rb
index d080b298e2f..6a0f2290b4c 100644
--- a/spec/models/application_record_spec.rb
+++ b/spec/models/application_record_spec.rb
@@ -67,7 +67,8 @@ RSpec.describe ApplicationRecord do
end
it 'raises a validation error if the record was not persisted' do
- expect { Suggestion.find_or_create_by!(note: nil) }.to raise_error(ActiveRecord::RecordInvalid)
+ expect { Suggestion.safe_find_or_create_by!(note: nil) }
+ .to raise_error(ActiveRecord::RecordInvalid)
end
it 'passes a block to find_or_create_by' do
@@ -75,6 +76,14 @@ RSpec.describe ApplicationRecord do
Suggestion.safe_find_or_create_by!(suggestion_attributes, &block)
end.to yield_with_args(an_object_having_attributes(suggestion_attributes))
end
+
+ it 'raises a record not found error in case of attributes mismatch' do
+ suggestion = Suggestion.safe_find_or_create_by!(suggestion_attributes)
+ attributes = suggestion_attributes.merge(outdated: !suggestion.outdated)
+
+ expect { Suggestion.safe_find_or_create_by!(attributes) }
+ .to raise_error(ActiveRecord::RecordNotFound)
+ end
end
end