Browse Source

No need to explicitly trigger email, devise does that for us now

pull/580/head
baarkerlounger 3 years ago
parent
commit
17672254ba
  1. 1
      app/controllers/users_controller.rb
  2. 6
      spec/features/organisation_spec.rb

1
app/controllers/users_controller.rb

@ -51,7 +51,6 @@ class UsersController < ApplicationController
else
user = User.create(user_params.merge(org_params).merge(password_params))
if user.persisted?
user.send_reset_password_instructions
redirect_to created_user_redirect_path
else
@resource.errors.add :email, I18n.t("validations.email.taken")

6
spec/features/organisation_spec.rb

@ -7,13 +7,13 @@ RSpec.describe "User Features" do
let(:org_id) { organisation.id }
let(:set_password_template_id) { User::CONFIRMABLE_TEMPLATE_ID }
let(:notify_client) { instance_double(Notifications::Client) }
let(:reset_password_token) { "MCDH5y6Km-U7CFPgAMVS" }
let(:confirmation_token) { "MCDH5y6Km-U7CFPgAMVS" }
let(:devise_notify_mailer) { DeviseNotifyMailer.new }
before do
allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer)
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client)
allow(Devise.token_generator).to receive(:generate).and_return(reset_password_token)
allow(Devise.token_generator).to receive(:generate).and_return(confirmation_token)
allow(notify_client).to receive(:send_email).and_return(true)
sign_in user
end
@ -55,7 +55,7 @@ RSpec.describe "User Features" do
name: "New User",
email: "new_user@example.com",
organisation: organisation.name,
link: "http://localhost:3000/account/password/edit?reset_password_token=#{reset_password_token}",
link: "http://localhost:3000/account/confirmation?confirmation_token=#{confirmation_token}",
},
},
)

Loading…
Cancel
Save