2017-04-21 17:05:19 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Profile > Account', :js do
|
|
|
|
let(:user) { create(:user, username: 'foo') }
|
2017-04-21 17:05:19 -04:00
|
|
|
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-04-21 17:05:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Change username' do
|
2018-07-05 02:32:05 -04:00
|
|
|
let(:new_username) { 'bar' }
|
|
|
|
let(:new_user_path) { "/#{new_username}" }
|
|
|
|
let(:old_user_path) { "/#{user.username}" }
|
2017-04-21 17:05:19 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the user is accessible via the new path' do
|
2017-04-21 17:05:19 -04:00
|
|
|
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
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the old user path redirects to the new path' do
|
2017-04-21 17:05:19 -04:00
|
|
|
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
|
2018-07-05 02:32:05 -04:00
|
|
|
let!(:project) { create(:project, namespace: user.namespace) }
|
|
|
|
let(:new_project_path) { "/#{new_username}/#{project.path}" }
|
|
|
|
let(:old_project_path) { "/#{user.username}/#{project.path}" }
|
2017-04-21 17:05:19 -04:00
|
|
|
|
2017-06-14 14:18:56 -04:00
|
|
|
before(:context) do
|
|
|
|
TestEnv.clean_test_path
|
|
|
|
end
|
|
|
|
|
2017-08-10 18:31:42 -04:00
|
|
|
after do
|
2017-06-14 14:18:56 -04:00
|
|
|
TestEnv.clean_test_path
|
|
|
|
end
|
2017-04-21 17:05:19 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the project is accessible via the new path' do
|
2017-04-21 17:05:19 -04:00
|
|
|
update_username(new_username)
|
|
|
|
visit new_project_path
|
|
|
|
expect(current_path).to eq(new_project_path)
|
2018-03-23 11:00:27 -04:00
|
|
|
expect(find('.breadcrumbs-sub-title')).to have_content('Details')
|
2017-04-21 17:05:19 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'the old project path redirects to the new path' do
|
2017-04-21 17:05:19 -04:00
|
|
|
update_username(new_username)
|
|
|
|
visit old_project_path
|
|
|
|
expect(current_path).to eq(new_project_path)
|
2018-03-23 11:00:27 -04:00
|
|
|
expect(find('.breadcrumbs-sub-title')).to have_content('Details')
|
2017-04-21 17:05:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_username(new_username)
|
|
|
|
allow(user.namespace).to receive(:move_dir)
|
|
|
|
visit profile_account_path
|
2018-04-06 05:36:22 -04:00
|
|
|
|
|
|
|
fill_in 'username-change-input', with: new_username
|
|
|
|
|
|
|
|
page.find('[data-target="#username-change-confirmation-modal"]').click
|
|
|
|
|
|
|
|
page.within('.modal') do
|
|
|
|
find('.js-modal-primary-action').click
|
|
|
|
end
|
2018-06-20 13:36:15 -04:00
|
|
|
|
|
|
|
wait_for_requests
|
2017-04-21 17:05:19 -04:00
|
|
|
end
|