Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/sign_up/emails/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</p>
<p><%= t('devise.registrations.close_window') %></p>

<% if FeatureManagement.enable_load_testing_mode? %>
<% if FeatureManagement.enable_load_testing_mode? && EmailAddress.find_with_email(email) %>
<%= link_to(
'CONFIRM NOW',
sign_up_create_email_confirmation_url(confirmation_token: EmailAddress.find_with_email(email).confirmation_token),
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/emails/verify.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<p><%= t('notices.use_diff_email.text_html', link_html: link_to(t('notices.use_diff_email.link'), add_email_path)) %></p>
<p><%= t('devise.registrations.close_window') %></p>

<% if FeatureManagement.enable_load_testing_mode? %>
<% if FeatureManagement.enable_load_testing_mode? && EmailAddress.find_with_email(email) %>
<%= link_to(
'CONFIRM NOW',
sign_up_create_email_confirmation_url(confirmation_token: EmailAddress.find_with_email(email).confirmation_token),
Expand Down
44 changes: 43 additions & 1 deletion spec/views/sign_up/emails/show.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require 'rails_helper'

RSpec.describe 'sign_up/emails/show.html.erb' do
let(:email) { 'foo@bar.com' }
before do
allow(view).to receive(:email).and_return('foo@bar.com')
allow(view).to receive(:email).and_return(email)
@resend_email_confirmation_form = ResendEmailConfirmationForm.new
end

Expand All @@ -23,4 +24,45 @@

expect(rendered).to have_button(t('links.resend'))
end

context 'when enable_load_testing_mode? is true and email address found' do
before do
allow(FeatureManagement).to receive(:enable_load_testing_mode?).and_return(true)
create(:email_address, confirmation_token: 'some_token', email: email)

render
end

it 'generates the correct link' do
expect(rendered).to have_link(
'CONFIRM NOW',
href: sign_up_create_email_confirmation_url(confirmation_token: 'some_token'),
id: 'confirm-now',
)
end
end

context 'when enable_load_testing_mode? is false' do
before do
allow(FeatureManagement).to receive(:enable_load_testing_mode?).and_return(false)

render
end

it 'does not generate the link' do
expect(rendered).not_to have_link('CONFIRM NOW', href: sign_up_create_email_confirmation_url)
end
end

context 'when email address not found' do
before do
allow(FeatureManagement).to receive(:enable_load_testing_mode?).and_return(true)

render
end

it 'does not generate the link' do
expect(rendered).not_to have_link('CONFIRM NOW', href: sign_up_create_email_confirmation_url)
end
end
end
68 changes: 68 additions & 0 deletions spec/views/users/emails/verify.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
require 'rails_helper'

RSpec.describe 'users/emails/verify.html.erb' do
let(:email) { 'foo@bar.com' }
before do
allow(view).to receive(:email).and_return(email)
@resend_email_confirmation_form = ResendEmailConfirmationForm.new
end

it 'has a localized title' do
expect(view).to receive(:title).with(t('titles.verify_email'))

render
end

it 'has a localized header' do
render

expect(rendered).to have_selector('h1', text: t('headings.verify_email'))
end

it 'contains link to resend confirmation page' do
render

expect(rendered).to have_button(t('links.resend'))
end

context 'when enable_load_testing_mode? is true and email address found' do
before do
allow(FeatureManagement).to receive(:enable_load_testing_mode?).and_return(true)
create(:email_address, confirmation_token: 'some_token', email: email)

render
end

it 'generates the correct link' do
expect(rendered).to have_link(
'CONFIRM NOW',
href: sign_up_create_email_confirmation_url(confirmation_token: 'some_token'),
id: 'confirm-now',
)
end
end

context 'when enable_load_testing_mode? is false' do
before do
allow(FeatureManagement).to receive(:enable_load_testing_mode?).and_return(false)

render
end

it 'does not generate the link' do
expect(rendered).not_to have_link('CONFIRM NOW', href: sign_up_create_email_confirmation_url)
end
end

context 'when email address not found' do
before do
allow(FeatureManagement).to receive(:enable_load_testing_mode?).and_return(true)

render
end

it 'does not generate the link' do
expect(rendered).not_to have_link('CONFIRM NOW', href: sign_up_create_email_confirmation_url)
end
end
end