diff options
Diffstat (limited to 'spec/views/devise')
-rw-r--r-- | spec/views/devise/shared/_signin_box.html.haml_spec.rb | 14 | ||||
-rw-r--r-- | spec/views/devise/shared/_signup_box.html.haml_spec.rb | 37 |
2 files changed, 39 insertions, 12 deletions
diff --git a/spec/views/devise/shared/_signin_box.html.haml_spec.rb b/spec/views/devise/shared/_signin_box.html.haml_spec.rb index 8b1af1866dc..e2aa0bb9870 100644 --- a/spec/views/devise/shared/_signin_box.html.haml_spec.rb +++ b/spec/views/devise/shared/_signin_box.html.haml_spec.rb @@ -28,6 +28,20 @@ RSpec.describe 'devise/shared/_signin_box' do end end + describe 'Base form' do + before do + stub_devise + allow(view).to receive(:captcha_enabled?).and_return(false) + allow(view).to receive(:captcha_on_login_required?).and_return(false) + end + + it 'renders user_login label' do + render + + expect(rendered).to have_content(_('Username or email')) + end + end + def stub_devise allow(view).to receive(:devise_mapping).and_return(Devise.mappings[:user]) allow(view).to receive(:resource).and_return(spy) diff --git a/spec/views/devise/shared/_signup_box.html.haml_spec.rb b/spec/views/devise/shared/_signup_box.html.haml_spec.rb index 1f0cd213f7b..b0730e6fc54 100644 --- a/spec/views/devise/shared/_signup_box.html.haml_spec.rb +++ b/spec/views/devise/shared/_signup_box.html.haml_spec.rb @@ -3,28 +3,41 @@ require 'spec_helper' RSpec.describe 'devise/shared/_signup_box' do + let(:button_text) { '_button_text_' } + let(:terms_path) { '_terms_path_' } + + let(:translation_com) do + s_("SignUp|By clicking %{button_text}, I agree that I have read and accepted "\ + "the GitLab %{link_start}Terms of Use and Privacy Policy%{link_end}") + end + + let(:translation_non_com) do + s_("SignUp|By clicking %{button_text}, I agree that I have read and accepted "\ + "the %{link_start}Terms of Use and Privacy Policy%{link_end}") + end + before do stub_devise allow(view).to receive(:show_omniauth_providers).and_return(false) allow(view).to receive(:url).and_return('_url_') - allow(view).to receive(:terms_path).and_return('_terms_path_') - allow(view).to receive(:button_text).and_return('_button_text_') + allow(view).to receive(:terms_path).and_return(terms_path) + allow(view).to receive(:button_text).and_return(button_text) allow(view).to receive(:signup_username_data_attributes).and_return({}) stub_template 'devise/shared/_error_messages.html.haml' => '' end + def text(translation) + format(translation, + button_text: button_text, + link_start: "<a href='#{terms_path}' target='_blank' rel='noreferrer noopener'>", + link_end: '</a>') + end + context 'when terms are enforced' do before do allow(Gitlab::CurrentSettings.current_application_settings).to receive(:enforce_terms?).and_return(true) end - it 'shows expected text with placeholders' do - render - - expect(rendered).to have_content('By clicking _button_text_') - expect(rendered).to have_link('Terms of Use and Privacy Policy') - end - context 'when on .com' do before do allow(Gitlab).to receive(:com?).and_return(true) @@ -33,7 +46,7 @@ RSpec.describe 'devise/shared/_signup_box' do it 'shows expected GitLab text' do render - expect(rendered).to have_content('I have read and accepted the GitLab Terms') + expect(rendered).to include(text(translation_com)) end end @@ -45,7 +58,7 @@ RSpec.describe 'devise/shared/_signup_box' do it 'shows expected text without GitLab' do render - expect(rendered).to have_content('I have read and accepted the Terms') + expect(rendered).to include(text(translation_non_com)) end end end @@ -59,7 +72,7 @@ RSpec.describe 'devise/shared/_signup_box' do it 'shows expected text with placeholders' do render - expect(rendered).not_to have_content('By clicking') + expect(rendered).not_to include(text(translation_com)) end end |