debian-mirror-gitlab/spec/features/profiles/account_spec.rb

71 lines
2 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'rails_helper'
2018-05-09 12:01:36 +05:30
feature 'Profile > Account', :js do
2017-08-17 22:00:37 +05:30
given(:user) { create(:user, username: 'foo') }
before do
2017-09-10 17:25:29 +05:30
sign_in(user)
2017-08-17 22:00:37 +05:30
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
2017-09-10 17:25:29 +05:30
given!(:project) { create(:project, namespace: user.namespace) }
2017-08-17 22:00:37 +05:30
given(:new_project_path) { "/#{new_username}/#{project.path}" }
given(:old_project_path) { "/#{user.username}/#{project.path}" }
2017-09-10 17:25:29 +05:30
before(:context) do
TestEnv.clean_test_path
end
2018-03-17 18:26:18 +05:30
after do
2017-09-10 17:25:29 +05:30
TestEnv.clean_test_path
end
2017-08-17 22:00:37 +05:30
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)
2018-05-09 12:01:36 +05:30
expect(find('.breadcrumbs-sub-title')).to have_content('Details')
2017-08-17 22:00:37 +05:30
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)
2018-05-09 12:01:36 +05:30
expect(find('.breadcrumbs-sub-title')).to have_content('Details')
2017-08-17 22:00:37 +05:30
end
end
end
end
def update_username(new_username)
allow(user.namespace).to receive(:move_dir)
visit profile_account_path
2018-05-09 12:01:36 +05:30
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
2017-08-17 22:00:37 +05:30
end