summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-09-18 08:32:17 +0000
committerRémy Coutable <remy@rymai.me>2017-09-18 08:32:17 +0000
commitf0f835ad4c6231c601c0eea308bdd9109ab281e9 (patch)
treeb49d6e22dc2a35c857e36b18adae64389bd59a68
parent2b4b76495dea4f037fbd958222fcaabdaf66bd67 (diff)
parent2a966f1b4e2fc640249f3c99afcdb3f06d70aaeb (diff)
downloadgitlab-ce-f0f835ad4c6231c601c0eea308bdd9109ab281e9.tar.gz
Merge branch 'improve_spec_features_profiles_specs' into 'master'
Improve 'spec/features/profiles/*' specs Closes #37855 et #37856 See merge request gitlab-org/gitlab-ce!14317
-rw-r--r--spec/features/profiles/user_visits_profile_account_page_spec.rb3
-rw-r--r--spec/features/profiles/user_visits_profile_authentication_log_page_spec.rb16
-rw-r--r--spec/features/profiles/user_visits_profile_authentication_log_spec.rb15
-rw-r--r--spec/features/profiles/user_visits_profile_page_spec.rb16
-rw-r--r--spec/features/profiles/user_visits_profile_preferences_page_spec.rb3
-rw-r--r--spec/features/profiles/user_visits_profile_spec.rb15
-rw-r--r--spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb3
-rw-r--r--spec/support/matchers/navigation_matcher.rb6
8 files changed, 39 insertions, 38 deletions
diff --git a/spec/features/profiles/user_visits_profile_account_page_spec.rb b/spec/features/profiles/user_visits_profile_account_page_spec.rb
index 8c7233c77ad..a8c08a680d7 100644
--- a/spec/features/profiles/user_visits_profile_account_page_spec.rb
+++ b/spec/features/profiles/user_visits_profile_account_page_spec.rb
@@ -10,7 +10,6 @@ describe 'User visits the profile account page' do
end
it 'shows correct menu item' do
- expect(find('.sidebar-top-level-items > li.active')).to have_content('Account')
- expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1)
+ expect(page).to have_active_navigation('Account')
end
end
diff --git a/spec/features/profiles/user_visits_profile_authentication_log_page_spec.rb b/spec/features/profiles/user_visits_profile_authentication_log_page_spec.rb
deleted file mode 100644
index ffb504cc573..00000000000
--- a/spec/features/profiles/user_visits_profile_authentication_log_page_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'spec_helper'
-
-describe 'User visits the authentication log page' do
- let(:user) { create(:user) }
-
- before do
- sign_in(user)
-
- visit(audit_log_profile_path)
- end
-
- it 'shows correct menu item' do
- expect(find('.sidebar-top-level-items > li.active')).to have_content('Authentication log')
- expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1)
- end
-end
diff --git a/spec/features/profiles/user_visits_profile_authentication_log_spec.rb b/spec/features/profiles/user_visits_profile_authentication_log_spec.rb
new file mode 100644
index 00000000000..a50ebb29e01
--- /dev/null
+++ b/spec/features/profiles/user_visits_profile_authentication_log_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe 'User visits the authentication log' do
+ let(:user) { create(:user) }
+
+ before do
+ sign_in(user)
+
+ visit(audit_log_profile_path)
+ end
+
+ it 'shows correct menu item' do
+ expect(page).to have_active_navigation('Authentication log')
+ end
+end
diff --git a/spec/features/profiles/user_visits_profile_page_spec.rb b/spec/features/profiles/user_visits_profile_page_spec.rb
deleted file mode 100644
index 3bf6d718bc7..00000000000
--- a/spec/features/profiles/user_visits_profile_page_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'spec_helper'
-
-describe 'User visits the profile page' do
- let(:user) { create(:user) }
-
- before do
- sign_in(user)
-
- visit(profile_path)
- end
-
- it 'shows correct menu item' do
- expect(find('.sidebar-top-level-items > li.active')).to have_content('Profile')
- expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1)
- end
-end
diff --git a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb
index d1776b3d7c2..924ee0e4174 100644
--- a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb
+++ b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb
@@ -10,8 +10,7 @@ describe 'User visits the profile preferences page' do
end
it 'shows correct menu item' do
- expect(find('.sidebar-top-level-items > li.active')).to have_content('Preferences')
- expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1)
+ expect(page).to have_active_navigation('Preferences')
end
describe 'User changes their syntax highlighting theme', :js do
diff --git a/spec/features/profiles/user_visits_profile_spec.rb b/spec/features/profiles/user_visits_profile_spec.rb
new file mode 100644
index 00000000000..6601d3039ed
--- /dev/null
+++ b/spec/features/profiles/user_visits_profile_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe 'User visits their profile' do
+ let(:user) { create(:user) }
+
+ before do
+ sign_in(user)
+
+ visit(profile_path)
+ end
+
+ it 'shows correct menu item' do
+ expect(page).to have_active_navigation('Profile')
+ end
+end
diff --git a/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb b/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb
index 0b7a63b54b4..685bf44619d 100644
--- a/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb
+++ b/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb
@@ -10,7 +10,6 @@ describe 'User visits the profile SSH keys page' do
end
it 'shows correct menu item' do
- expect(find('.sidebar-top-level-items > li.active')).to have_content('SSH Keys')
- expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1)
+ expect(page).to have_active_navigation('SSH Keys')
end
end
diff --git a/spec/support/matchers/navigation_matcher.rb b/spec/support/matchers/navigation_matcher.rb
new file mode 100644
index 00000000000..5b6d9c1a4df
--- /dev/null
+++ b/spec/support/matchers/navigation_matcher.rb
@@ -0,0 +1,6 @@
+RSpec::Matchers.define :have_active_navigation do |expected|
+ match do |page|
+ expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1)
+ expect(page.find('.sidebar-top-level-items > li.active')).to have_content(expected)
+ end
+end