diff options
Diffstat (limited to 'spec/helpers/button_helper_spec.rb')
-rw-r--r-- | spec/helpers/button_helper_spec.rb | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/spec/helpers/button_helper_spec.rb b/spec/helpers/button_helper_spec.rb index 4423560ecaa..d2c7867febb 100644 --- a/spec/helpers/button_helper_spec.rb +++ b/spec/helpers/button_helper_spec.rb @@ -26,30 +26,24 @@ describe ButtonHelper do context 'when user has password automatically set' do let(:user) { create(:user, password_automatically_set: true) } - it 'shows a password tooltip' do - expect(element.attr('class')).to include(has_tooltip_class) - expect(element.attr('data-title')).to eq('Set a password on your account to pull or push via HTTP.') + it 'shows the password text on the dropdown' do + description = element.search('.dropdown-menu-inner-content').first + + expect(description.inner_text).to eq 'Set a password on your account to pull or push via HTTP.' end end end context 'with internal auth disabled' do before do - stub_application_setting(password_authentication_enabled?: false) + stub_application_setting(password_authentication_enabled_for_git?: false) end context 'when user has no personal access tokens' do - it 'has a personal access token tooltip ' do - expect(element.attr('class')).to include(has_tooltip_class) - expect(element.attr('data-title')).to eq('Create a personal access token on your account to pull or push via HTTP.') - end - end - - context 'when user has a personal access token' do - it 'shows no tooltip' do - create(:personal_access_token, user: user) + it 'has a personal access token text on the dropdown description ' do + description = element.search('.dropdown-menu-inner-content').first - expect(element.attr('class')).not_to include(has_tooltip_class) + expect(description.inner_text).to eq 'Create a personal access token on your account to pull or push via HTTP.' end end end @@ -63,6 +57,41 @@ describe ButtonHelper do end end + describe 'ssh_button' do + let(:user) { create(:user) } + let(:project) { build_stubbed(:project) } + + def element + element = helper.ssh_clone_button(project) + + Nokogiri::HTML::DocumentFragment.parse(element).first_element_child + end + + before do + allow(helper).to receive(:current_user).and_return(user) + end + + context 'without an ssh key on the user' do + it 'shows a warning on the dropdown description' do + description = element.search('.dropdown-menu-inner-content').first + + expect(description.inner_text).to eq "You won't be able to pull or push project code via SSH until you add an SSH key to your profile" + end + end + + context 'with an ssh key on the user' do + before do + create(:key, user: user) + end + + it 'there is no warning on the dropdown description' do + description = element.search('.dropdown-menu-inner-content').first + + expect(description).to eq nil + end + end + end + describe 'clipboard_button' do let(:user) { create(:user) } let(:project) { build_stubbed(:project) } |