summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2017-08-08 15:54:13 -0400
committerRobert Speicher <rspeicher@gmail.com>2017-08-08 15:54:13 -0400
commit76544283ea342cc82f15afb89c7c5a12eb6bfd8f (patch)
tree450732644b4bd82c7992ea3463bc535c73a00725
parentcfabe7bf38f175b28c8c0a1bec584b6b751cbba5 (diff)
downloadgitlab-ce-rs-fix-stubbed-user-factory.tar.gz
Manually assign `notification_email` in the User factory when stubbedrs-fix-stubbed-user-factory
Because we assign this value in the model via a callback conditionally on `email_changed?`, this never gets set when using `build_stubbed`, resulting in a "can't be blank" validation error on this field. In this case, we can just assign it manually to the same value as `email`, which is generated via a sequence.
-rw-r--r--spec/factories/users.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index e60fe713bc3..0486a413fb2 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -8,6 +8,10 @@ FactoryGirl.define do
confirmation_token { nil }
can_create_group true
+ after(:stub) do |user|
+ user.notification_email = user.email
+ end
+
before(:create) do |user|
user.ensure_rss_token
end