Browse Source

Remove legacy user from user factory

pull/2507/head
Kat 2 years ago
parent
commit
e5a0545b96
  1. 6
      spec/factories/user.rb
  2. 2
      spec/features/user_spec.rb
  3. 1
      spec/mailers/resend_invitation_mailer_spec.rb
  4. 1
      spec/models/user_spec.rb
  5. 1
      spec/requests/organisations_controller_spec.rb

6
spec/factories/user.rb

@ -26,11 +26,5 @@ FactoryBot.define do
transient do transient do
old_user_id { SecureRandom.uuid } old_user_id { SecureRandom.uuid }
end end
after(:create) do |user, evaluator|
FactoryBot.create(:legacy_user, old_user_id: evaluator.old_user_id, user:)
user.reload
end
end end
end end

2
spec/features/user_spec.rb

@ -594,7 +594,7 @@ RSpec.describe "User Features" do
end end
before do before do
other_user.update!(initial_confirmation_sent: true, last_sign_in_at: nil) other_user.update!(initial_confirmation_sent: true, last_sign_in_at: nil, old_user_id: "old-user-id")
allow(user).to receive(:need_two_factor_authentication?).and_return(false) allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in(user) sign_in(user)
visit(user_path(other_user)) visit(user_path(other_user))

1
spec/mailers/resend_invitation_mailer_spec.rb

@ -41,6 +41,7 @@ RSpec.describe ResendInvitationMailer do
end end
it "sends an initial invitation" do it "sends an initial invitation" do
FactoryBot.create(:legacy_user, old_user_id: new_active_migrated_user.old_user_id, user: new_active_migrated_user)
expect(notify_client).to receive(:send_email).with(email_address: "new_active_migrated_user@example.com", template_id: User::BETA_ONBOARDING_TEMPLATE_ID, personalisation:).once expect(notify_client).to receive(:send_email).with(email_address: "new_active_migrated_user@example.com", template_id: User::BETA_ONBOARDING_TEMPLATE_ID, personalisation:).once
described_class.new.resend_invitation_email(new_active_migrated_user) described_class.new.resend_invitation_email(new_active_migrated_user)
end end

1
spec/models/user_spec.rb

@ -114,6 +114,7 @@ RSpec.describe User, type: :model do
end end
it "can have one or more legacy users" do it "can have one or more legacy users" do
FactoryBot.create(:legacy_user, old_user_id: user.old_user_id, user:)
expect(user.legacy_users.size).to eq(1) expect(user.legacy_users.size).to eq(1)
end end

1
spec/requests/organisations_controller_spec.rb

@ -1648,6 +1648,7 @@ RSpec.describe OrganisationsController, type: :request do
allow(notify_client).to receive(:send_email).and_return(true) allow(notify_client).to receive(:send_email).and_return(true)
user_to_reactivate = create(:user, :data_coordinator, organisation:, active: false, reactivate_with_organisation: true) user_to_reactivate = create(:user, :data_coordinator, organisation:, active: false, reactivate_with_organisation: true)
FactoryBot.create(:legacy_user, old_user_id: user_to_reactivate.old_user_id, user: user_to_reactivate)
user_not_to_reactivate = create(:user, :data_coordinator, organisation:, active: false, reactivate_with_organisation: false) user_not_to_reactivate = create(:user, :data_coordinator, organisation:, active: false, reactivate_with_organisation: false)
patch "/organisations/#{organisation.id}", headers:, params: patch "/organisations/#{organisation.id}", headers:, params:
end end

Loading…
Cancel
Save