diff --git a/app/models/user.rb b/app/models/user.rb index 97cc43c62..5eec7bed8 100644 --- a/app/models/user.rb +++ b/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) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index df3f82911..646e65d2a 100644 --- a/spec/models/user_spec.rb +++ b/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({})