Browse Source

CLDC-2328: Testing of sent emails

pull/1680/head
Aaron Spencer 3 years ago
parent
commit
2d50657f31
  1. 4
      app/models/user.rb
  2. 17
      spec/features/user_spec.rb

4
app/models/user.rb

@ -109,11 +109,7 @@ class User < ApplicationRecord
end end
def was_migrated_from_softwire? def was_migrated_from_softwire?
let l = legacy_users
let y = old_user_id
let x = 1
legacy_users.any? || old_user_id.present? legacy_users.any? || old_user_id.present?
end end
def send_confirmation_instructions def send_confirmation_instructions

17
spec/features/user_spec.rb

@ -453,21 +453,21 @@ RSpec.describe "User Features" do
end end
end end
context "when reinviting a user" do context "when reinviting a user after initial confirmation email has been sent" do
let!(:other_user) { FactoryBot.create(:user, name: "new user", is_dpo: false, organisation: user.organisation, email: "new_user@example.com") } let!(:other_user) { FactoryBot.create(:user, name: "new user", organisation: user.organisation, email: "new_user@example.com", initial_confirmation_sent: true) }
let(:personalisation) do let(:personalisation) do
{ {
name: "new user", name: "new user",
email: "new_user@example.com", email: "new_user@example.com",
organisation: other_user.organisation.name, organisation: other_user.organisation.name,
link: include("/account/confirmation?confirmation_token="), link: include("/account/confirmation?confirmation_token=#{other_user.confirmation_token}"),
} }
end end
before do before do
other_user.update!(confirmation_token: "abc") other_user.update!(confirmation_token: "abc")
visit("/lettings-logs") visit(lettings_logs_path)
fill_in("user[email]", with: user.email) fill_in("user[email]", with: user.email)
fill_in("user[password]", with: "pAssword1") fill_in("user[password]", with: "pAssword1")
click_button("Sign in") click_button("Sign in")
@ -475,10 +475,17 @@ RSpec.describe "User Features" do
end end
it "sends and email when the resend invite link is clicked" do it "sends and email when the resend invite link is clicked" do
visit("users/#{other_user.id}/") other_user.legacy_users.destroy_all
visit(user_path(other_user))
expect(notify_client).to receive(:send_email).with(email_address: "new_user@example.com", template_id: User::RECONFIRMABLE_TEMPLATE_ID, personalisation:).once expect(notify_client).to receive(:send_email).with(email_address: "new_user@example.com", template_id: User::RECONFIRMABLE_TEMPLATE_ID, personalisation:).once
click_link("Resend invite link") click_link("Resend invite link")
end end
it "sends beta onboarding email to be sent when user is legacy" do
visit(user_path(other_user))
expect(notify_client).to receive(:send_email).with(email_address: "new_user@example.com", template_id: User::BETA_ONBOARDING_TEMPLATE_ID, personalisation:).once
click_link("Resend invite link")
end
end end
end end

Loading…
Cancel
Save