diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 672239451..5ea2507f1 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -52,6 +52,7 @@ def update super do |user| if user.email_changed? update_email_user_ids << user.id + user.update_attribute(:valid_email, true) end end diff --git a/spec/controllers/api/v1/users_controller_spec.rb b/spec/controllers/api/v1/users_controller_spec.rb index 6e042757c..d28cb8585 100644 --- a/spec/controllers/api/v1/users_controller_spec.rb +++ b/spec/controllers/api/v1/users_controller_spec.rb @@ -482,6 +482,13 @@ def update_request expect(UserInfoChangedMailerWorker).to receive(:perform_async).with(user.id, "email") end + it "sets valid_email parameter to true" do + # updating the valid email to false before the request as it is set at true by default + user.update(valid_email: false) + update_request + expect(user.reload.valid_email).to be_truthy + end + describe "with an email that already exists" do let(:put_operations) { {users: {email: User.where.not(id: user.id).first.email}} } it "doesn't send an email to the new address if user is not valid" do