From 76544283ea342cc82f15afb89c7c5a12eb6bfd8f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 8 Aug 2017 15:54:13 -0400 Subject: [PATCH] Manually assign `notification_email` in the User factory when stubbed 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. --- spec/factories/users.rb | 4 ++++ 1 file changed, 4 insertions(+) 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