diff options
-rw-r--r-- | changelogs/unreleased/fix-gpg-tmp-dir-removal-race-condition.yml | 5 | ||||
-rw-r--r-- | changelogs/unreleased/replace_profile_active_tab-feature.yml | 5 | ||||
-rw-r--r-- | features/profile/active_tab.feature | 29 | ||||
-rw-r--r-- | features/steps/profile/active_tab.rb | 25 | ||||
-rw-r--r-- | lib/gitlab/gpg.rb | 14 | ||||
-rw-r--r-- | spec/features/profiles/user_visits_profile_account_page_spec.rb | 16 | ||||
-rw-r--r-- | spec/features/profiles/user_visits_profile_authentication_log_page_spec.rb | 16 | ||||
-rw-r--r-- | spec/features/profiles/user_visits_profile_page_spec.rb | 16 | ||||
-rw-r--r-- | spec/features/profiles/user_visits_profile_preferences_page_spec.rb (renamed from spec/features/profiles/preferences_spec.rb) | 14 | ||||
-rw-r--r-- | spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb | 16 |
10 files changed, 94 insertions, 62 deletions
diff --git a/changelogs/unreleased/fix-gpg-tmp-dir-removal-race-condition.yml b/changelogs/unreleased/fix-gpg-tmp-dir-removal-race-condition.yml new file mode 100644 index 00000000000..e75f188913f --- /dev/null +++ b/changelogs/unreleased/fix-gpg-tmp-dir-removal-race-condition.yml @@ -0,0 +1,5 @@ +--- +title: Fixes the 500 errors caused by a race condition in GPG's tmp directory handling +merge_request: 14194 +author: Alexis Reigel +type: fixed diff --git a/changelogs/unreleased/replace_profile_active_tab-feature.yml b/changelogs/unreleased/replace_profile_active_tab-feature.yml new file mode 100644 index 00000000000..e911396a2b9 --- /dev/null +++ b/changelogs/unreleased/replace_profile_active_tab-feature.yml @@ -0,0 +1,5 @@ +--- +title: Replace the 'profile/active_tab.feature' spinach test with an rspec analog +merge_request: 14239 +author: Vitaliy @blackst0ne Klachkov +type: other diff --git a/features/profile/active_tab.feature b/features/profile/active_tab.feature deleted file mode 100644 index 21d7d6c3800..00000000000 --- a/features/profile/active_tab.feature +++ /dev/null @@ -1,29 +0,0 @@ -@profile -Feature: Profile Active Tab - Background: - Given I sign in as a user - - Scenario: On Profile Home - Given I visit profile page - Then the active main tab should be Home - And no other main tabs should be active - - Scenario: On Profile Account - Given I visit profile account page - Then the active main tab should be Account - And no other main tabs should be active - - Scenario: On Profile SSH Keys - Given I visit profile SSH keys page - Then the active main tab should be SSH Keys - And no other main tabs should be active - - Scenario: On Profile Preferences - Given I visit profile preferences page - Then the active main tab should be Preferences - And no other main tabs should be active - - Scenario: On Profile Authentication log - Given I visit Authentication log page - Then the active main tab should be Authentication log - And no other main tabs should be active diff --git a/features/steps/profile/active_tab.rb b/features/steps/profile/active_tab.rb deleted file mode 100644 index 069d4e6a23d..00000000000 --- a/features/steps/profile/active_tab.rb +++ /dev/null @@ -1,25 +0,0 @@ -class Spinach::Features::ProfileActiveTab < Spinach::FeatureSteps - include SharedAuthentication - include SharedPaths - include SharedActiveTab - - step 'the active main tab should be Home' do - ensure_active_main_tab('Profile') - end - - step 'the active main tab should be Account' do - ensure_active_main_tab('Account') - end - - step 'the active main tab should be SSH Keys' do - ensure_active_main_tab('SSH Keys') - end - - step 'the active main tab should be Preferences' do - ensure_active_main_tab('Preferences') - end - - step 'the active main tab should be Authentication log' do - ensure_active_main_tab('Authentication log') - end -end diff --git a/lib/gitlab/gpg.rb b/lib/gitlab/gpg.rb index 025f826e65f..0d5039ddf5f 100644 --- a/lib/gitlab/gpg.rb +++ b/lib/gitlab/gpg.rb @@ -69,11 +69,17 @@ module Gitlab def optimistic_using_tmp_keychain previous_dir = current_home_dir - Dir.mktmpdir do |dir| - GPGME::Engine.home_dir = dir - yield - end + tmp_dir = Dir.mktmpdir + GPGME::Engine.home_dir = tmp_dir + yield ensure + # Ignore any errors when removing the tmp directory, as we may run into a + # race condition: + # The `gpg-agent` agent process may clean up some files as well while + # `FileUtils.remove_entry` is iterating the directory and removing all + # its contained files and directories recursively, which could raise an + # error. + FileUtils.remove_entry(tmp_dir, true) GPGME::Engine.home_dir = previous_dir end end diff --git a/spec/features/profiles/user_visits_profile_account_page_spec.rb b/spec/features/profiles/user_visits_profile_account_page_spec.rb new file mode 100644 index 00000000000..8c7233c77ad --- /dev/null +++ b/spec/features/profiles/user_visits_profile_account_page_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'User visits the profile account page' do + let(:user) { create(:user) } + + before do + sign_in(user) + + visit(profile_account_path) + 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) + 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 new file mode 100644 index 00000000000..ffb504cc573 --- /dev/null +++ b/spec/features/profiles/user_visits_profile_authentication_log_page_spec.rb @@ -0,0 +1,16 @@ +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_page_spec.rb b/spec/features/profiles/user_visits_profile_page_spec.rb new file mode 100644 index 00000000000..3bf6d718bc7 --- /dev/null +++ b/spec/features/profiles/user_visits_profile_page_spec.rb @@ -0,0 +1,16 @@ +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/preferences_spec.rb b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb index c935cdfd5c4..d1776b3d7c2 100644 --- a/spec/features/profiles/preferences_spec.rb +++ b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb @@ -1,14 +1,20 @@ require 'spec_helper' -describe 'Profile > Preferences', :js do +describe 'User visits the profile preferences page' do let(:user) { create(:user) } before do sign_in(user) - visit profile_preferences_path + + visit(profile_preferences_path) + 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) end - describe 'User changes their syntax highlighting theme' do + describe 'User changes their syntax highlighting theme', :js do it 'creates a flash message' do choose 'user_color_scheme_id_5' @@ -27,7 +33,7 @@ describe 'Profile > Preferences', :js do end end - describe 'User changes their default dashboard' do + describe 'User changes their default dashboard', :js do it 'creates a flash message' do select 'Starred Projects', from: 'user_dashboard' click_button 'Save' 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 new file mode 100644 index 00000000000..0b7a63b54b4 --- /dev/null +++ b/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'User visits the profile SSH keys page' do + let(:user) { create(:user) } + + before do + sign_in(user) + + visit(profile_keys_path) + 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) + end +end |