Browse Source

Don't trigger confirmation emails for inactive users

pull/618/head
baarkerlounger 3 years ago
parent
commit
57a576bd26
  1. 6
      app/models/user.rb
  2. 12
      spec/models/user_spec.rb

6
app/models/user.rb

@ -90,8 +90,10 @@ class User < ApplicationRecord
old_user_id.present?
end
def skip_confirmation!
!active?
def send_confirmation_instructions
return unless active?
super
end
def need_two_factor_authentication?(_request)

12
spec/models/user_spec.rb

@ -85,6 +85,18 @@ RSpec.describe User, type: :model do
)
end
it "does not send a confirmation email to inactive users" do
expect(DeviseNotifyMailer).not_to receive(:confirmation_instructions)
described_class.create!(
name: "unconfirmed_user",
email: "unconfirmed_user@example.com",
password: "password123",
organisation: other_organisation,
role: "data_provider",
active: false,
)
end
context "when the user is a data provider" do
it "cannot assign roles" do
expect(user.assignable_roles).to eq({})

Loading…
Cancel
Save