Current.set(user: users(:alice)) do
topics = Topic.where(name: %w[ruby rails])
old_email = Current.user.email
new_email = '
[email protected]'
form = ProfileUpdateForm.new(
description: 'I love Ruby & Rails.',
email: new_email,
topic_ids: topics.map(&:id)
)
form.call
profile = form.profile.reload
expect(profile.topics).to contain_exactly(*topics)
expect(profile.user.email).to eq(old_email)
expect(form.email_change_request&.email).to eq(new_email)
expect(ActionMailer::Base.deliveries.size).to eq(1)
end