debian-mirror-gitlab/spec/views/devise/shared/_signup_box.html.haml_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

101 lines
2.9 KiB
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'devise/shared/_signup_box' do
2022-07-16 23:28:13 +05:30
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
2021-06-08 01:23:25 +05:30
before do
stub_devise
allow(view).to receive(:show_omniauth_providers).and_return(false)
allow(view).to receive(:url).and_return('_url_')
2022-07-16 23:28:13 +05:30
allow(view).to receive(:terms_path).and_return(terms_path)
allow(view).to receive(:button_text).and_return(button_text)
2021-09-04 01:27:46 +05:30
allow(view).to receive(:signup_username_data_attributes).and_return({})
2021-06-08 01:23:25 +05:30
stub_template 'devise/shared/_error_messages.html.haml' => ''
end
2022-07-16 23:28:13 +05:30
def text(translation)
format(translation,
button_text: button_text,
link_start: "<a href='#{terms_path}' target='_blank' rel='noreferrer noopener'>",
link_end: '</a>')
end
2021-06-08 01:23:25 +05:30
context 'when terms are enforced' do
before do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:enforce_terms?).and_return(true)
end
context 'when on .com' do
before do
2022-05-07 20:08:51 +05:30
allow(Gitlab).to receive(:com?).and_return(true)
2021-06-08 01:23:25 +05:30
end
it 'shows expected GitLab text' do
render
2022-07-16 23:28:13 +05:30
expect(rendered).to include(text(translation_com))
2021-06-08 01:23:25 +05:30
end
end
context 'when not on .com' do
before do
2022-05-07 20:08:51 +05:30
allow(Gitlab).to receive(:com?).and_return(false)
2021-06-08 01:23:25 +05:30
end
it 'shows expected text without GitLab' do
render
2022-07-16 23:28:13 +05:30
expect(rendered).to include(text(translation_non_com))
2021-06-08 01:23:25 +05:30
end
end
end
context 'when terms are not enforced' do
before do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:enforce_terms?).and_return(false)
2022-05-07 20:08:51 +05:30
allow(Gitlab).to receive(:com?).and_return(true)
2021-06-08 01:23:25 +05:30
end
it 'shows expected text with placeholders' do
render
2022-07-16 23:28:13 +05:30
expect(rendered).not_to include(text(translation_com))
2021-06-08 01:23:25 +05:30
end
end
2022-04-04 11:22:00 +05:30
context 'using the borderless option' do
let(:border_css_classes) { '.gl-border-gray-100.gl-border-1.gl-border-solid.gl-rounded-base' }
it 'renders with a border by default' do
render
expect(rendered).to have_selector(border_css_classes)
end
it 'renders without a border when borderless is truthy' do
render('devise/shared/signup_box', borderless: true)
expect(rendered).not_to have_selector(border_css_classes)
end
end
2021-06-08 01:23:25 +05:30
def stub_devise
allow(view).to receive(:devise_mapping).and_return(Devise.mappings[:user])
allow(view).to receive(:resource).and_return(spy)
allow(view).to receive(:resource_name).and_return(:user)
end
end