summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorJose Ivan Vargas <jvargas@gitlab.com>2017-11-15 13:47:22 -0600
committerJose Ivan Vargas <jvargas@gitlab.com>2017-11-27 10:12:23 -0600
commit349e3622f92cc4c6ea51ecaac76ef7c4ea8999e3 (patch)
tree8313b2a218fae41b78ee6d64474c7345e226d48d /spec/helpers
parent2e2f0675c97ba233ab089922b231a7aac97d633a (diff)
downloadgitlab-ce-349e3622f92cc4c6ea51ecaac76ef7c4ea8999e3.tar.gz
Added ssh_button helper specs and addressed ruby code observations
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/button_helper_spec.rb55
1 files changed, 41 insertions, 14 deletions
diff --git a/spec/helpers/button_helper_spec.rb b/spec/helpers/button_helper_spec.rb
index b5222f301ba..d2c7867febb 100644
--- a/spec/helpers/button_helper_spec.rb
+++ b/spec/helpers/button_helper_spec.rb
@@ -27,9 +27,9 @@ describe ButtonHelper do
let(:user) { create(:user, password_automatically_set: true) }
it 'shows the password text on the dropdown' do
- expect(element.children.length).to eq(2)
- expect(element.children[1].name).to eq('span')
- expect(element.children[1].children[0].text).to eq('Set a password on your account to pull or push via HTTP.')
+ 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
@@ -40,18 +40,10 @@ describe ButtonHelper do
end
context 'when user has no personal access tokens' do
- it 'has a personal access token tooltip ' do
- expect(element.children.length).to eq(2)
- expect(element.children[1].name).to eq('span')
- expect(element.children[1].children[0].text).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
@@ -65,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) }