Show "Sign in" instead of "Sign in / Register" when sign up is disabled

This commit is contained in:
Dustin Utecht 2018-07-09 14:49:33 +00:00 committed by Douwe Maan
parent 9a9b4444ac
commit 1da22cec12
2 changed files with 27 additions and 1 deletions

View File

@ -61,7 +61,9 @@
- if header_link?(:sign_in)
%li.nav-item
%div
= link_to "Sign in / Register", new_session_path(:user, redirect_to_referer: 'yes'), class: 'btn btn-sign-in'
- sign_in_text = allow_signup? ? 'Sign in / Register' : 'Sign in'
= link_to sign_in_text, new_session_path(:user, redirect_to_referer: 'yes'), class: 'btn btn-sign-in'
%button.navbar-toggler.d-block.d-sm-none{ type: 'button' }
%span.sr-only Toggle navigation

View File

@ -14,4 +14,28 @@ describe 'User page' do
expect(page).to have_link('Snippets')
end
end
context 'signup disabled' do
it 'shows the sign in link' do
stub_application_setting(signup_enabled: false)
visit(user_path(user))
page.within '.navbar-nav' do
expect(page).to have_link('Sign in')
end
end
end
context 'signup enabled' do
it 'shows the sign in and register link' do
stub_application_setting(signup_enabled: true)
visit(user_path(user))
page.within '.navbar-nav' do
expect(page).to have_link('Sign in / Register')
end
end
end
end