Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-04-22 00:05:19 +0300
committerMichael Kozono <mkozono@gmail.com>2017-05-05 22:11:57 +0300
commitf4a2dfb46f168d3fd7309aca8631cf680456fa82 (patch)
treef77b8da2b30c7bdc32fa1796e0b4a7bee26cd4a1 /spec/features/profiles
parent240400152242924e75ea81918b5cfdcf2441549c (diff)
Add happy path feature tests for redirect behavior
Diffstat (limited to 'spec/features/profiles')
-rw-r--r--spec/features/profiles/account_spec.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/features/profiles/account_spec.rb b/spec/features/profiles/account_spec.rb
new file mode 100644
index 00000000000..b3902a6b37f
--- /dev/null
+++ b/spec/features/profiles/account_spec.rb
@@ -0,0 +1,60 @@
+require 'rails_helper'
+
+feature 'Profile > Account', feature: true do
+ given(:user) { create(:user, username: 'foo') }
+
+ before do
+ login_as(user)
+ end
+
+ describe 'Change username' do
+ given(:new_username) { 'bar' }
+ given(:new_user_path) { "/#{new_username}" }
+ given(:old_user_path) { "/#{user.username}" }
+
+ scenario 'the user is accessible via the new path' do
+ update_username(new_username)
+ visit new_user_path
+ expect(current_path).to eq(new_user_path)
+ expect(find('.user-info')).to have_content(new_username)
+ end
+
+ scenario 'the old user path redirects to the new path' do
+ update_username(new_username)
+ visit old_user_path
+ expect(current_path).to eq(new_user_path)
+ expect(find('.user-info')).to have_content(new_username)
+ end
+
+ context 'with a project' do
+ given!(:project) { create(:project, namespace: user.namespace, path: 'project') }
+ given(:new_project_path) { "/#{new_username}/#{project.path}" }
+ given(:old_project_path) { "/#{user.username}/#{project.path}" }
+
+ after do
+ TestEnv.clean_test_path
+ end
+
+ scenario 'the project is accessible via the new path' do
+ update_username(new_username)
+ visit new_project_path
+ expect(current_path).to eq(new_project_path)
+ expect(find('h1.project-title')).to have_content(project.name)
+ end
+
+ scenario 'the old project path redirects to the new path' do
+ update_username(new_username)
+ visit old_project_path
+ expect(current_path).to eq(new_project_path)
+ expect(find('h1.project-title')).to have_content(project.name)
+ end
+ end
+ end
+end
+
+def update_username(new_username)
+ allow(user.namespace).to receive(:move_dir)
+ visit profile_account_path
+ fill_in 'user_username', with: new_username
+ click_button 'Update username'
+end