diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-04-21 14:05:19 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-05-05 12:11:57 -0700 |
commit | f4a2dfb46f168d3fd7309aca8631cf680456fa82 (patch) | |
tree | f77b8da2b30c7bdc32fa1796e0b4a7bee26cd4a1 /spec/features/profiles | |
parent | 240400152242924e75ea81918b5cfdcf2441549c (diff) | |
download | gitlab-ce-f4a2dfb46f168d3fd7309aca8631cf680456fa82.tar.gz |
Add happy path feature tests for redirect behavior
Diffstat (limited to 'spec/features/profiles')
-rw-r--r-- | spec/features/profiles/account_spec.rb | 60 |
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 |