Commit 018ed2c4 authored by Robert Speicher's avatar Robert Speicher

Change `login_with` uses to `gitlab_sign_in`

Change single `login_via` use to `gitlab_sign_in_via`
parent 45fb1f95
......@@ -15,7 +15,7 @@ describe 'Issues Feed', feature: true do
context 'when authenticated' do
it 'renders atom feed' do
login_with user
gitlab_sign_in user
visit namespace_project_issues_path(project.namespace, project, :atom)
expect(response_headers['Content-Type']).
......
......@@ -191,7 +191,7 @@ describe 'Commits' do
before do
project.team << [user, :master]
login_with(user)
gitlab_sign_in(user)
visit namespace_project_commits_path(project.namespace, project, branch_name)
end
......
......@@ -17,7 +17,7 @@ feature 'Dashboard > Milestones', feature: true do
let!(:milestone) { create(:milestone, project: project) }
before do
project.team << [user, :master]
login_with(user)
gitlab_sign_in(user)
visit dashboard_milestones_path
end
......
......@@ -6,7 +6,7 @@ feature 'Global search', feature: true do
before do
project.team << [user, :master]
login_with(user)
gitlab_sign_in(user)
end
describe 'I search through the issues and I see pagination' do
......
......@@ -13,7 +13,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do
before do
project.team << [user, :master]
login_with(user)
gitlab_sign_in(user)
visit namespace_project_issue_path(project.namespace, project, issue)
end
......@@ -42,7 +42,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do
before do
project.team << [guest, :guest]
logout
login_with(guest)
gitlab_sign_in(guest)
visit namespace_project_issue_path(project.namespace, project, issue)
end
......@@ -82,7 +82,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do
before do
project.team << [guest, :guest]
logout
login_with(guest)
gitlab_sign_in(guest)
visit namespace_project_issue_path(project.namespace, project, issue)
end
......
......@@ -484,7 +484,7 @@ describe 'Issues', feature: true do
it 'shows assignee text', js: true do
logout
login_with guest
gitlab_sign_in guest
visit namespace_project_issue_path(project.namespace, project, issue)
expect(page).to have_content issue.assignees.first.name
......@@ -547,7 +547,7 @@ describe 'Issues', feature: true do
it 'shows milestone text', js: true do
logout
login_with guest
gitlab_sign_in guest
visit namespace_project_issue_path(project.namespace, project, issue)
expect(page).to have_content milestone.title
......
......@@ -36,7 +36,7 @@ feature 'Login', feature: true do
it 'prevents the user from logging in' do
user = create(:user, :blocked)
login_with(user)
gitlab_sign_in(user)
expect(page).to have_content('Your account has been blocked.')
end
......@@ -44,19 +44,19 @@ feature 'Login', feature: true do
it 'does not update Devise trackable attributes', :redis do
user = create(:user, :blocked)
expect { login_with(user) }.not_to change { user.reload.sign_in_count }
expect { gitlab_sign_in(user) }.not_to change { user.reload.sign_in_count }
end
end
describe 'with the ghost user' do
it 'disallows login' do
login_with(User.ghost)
gitlab_sign_in(User.ghost)
expect(page).to have_content('Invalid Login or password.')
end
it 'does not update Devise trackable attributes', :redis do
expect { login_with(User.ghost) }.not_to change { User.ghost.reload.sign_in_count }
expect { gitlab_sign_in(User.ghost) }.not_to change { User.ghost.reload.sign_in_count }
end
end
......@@ -70,7 +70,7 @@ feature 'Login', feature: true do
let(:user) { create(:user, :two_factor) }
before do
login_with(user, remember: true)
gitlab_sign_in(user, remember: true)
expect(page).to have_content('Two-Factor Authentication')
end
......@@ -167,7 +167,7 @@ feature 'Login', feature: true do
it 'shows 2FA prompt after OAuth login' do
stub_omniauth_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [saml_config])
user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: 'saml')
login_via('saml', user, 'my-uid')
gitlab_sign_in_via('saml', user, 'my-uid')
expect(page).to have_content('Two-Factor Authentication')
enter_code(user.current_otp)
......@@ -180,19 +180,19 @@ feature 'Login', feature: true do
let(:user) { create(:user) }
it 'allows basic login' do
login_with(user)
gitlab_sign_in(user)
expect(current_path).to eq root_path
end
it 'does not show a "You are already signed in." error message' do
login_with(user)
gitlab_sign_in(user)
expect(page).not_to have_content('You are already signed in.')
end
it 'blocks invalid login' do
user = create(:user, password: 'not-the-default')
login_with(user)
gitlab_sign_in(user)
expect(page).to have_content('Invalid Login or password.')
end
end
......@@ -209,7 +209,7 @@ feature 'Login', feature: true do
context 'with grace period defined' do
before do
stub_application_setting(two_factor_grace_period: 48)
login_with(user)
gitlab_sign_in(user)
end
context 'within the grace period' do
......@@ -246,7 +246,7 @@ feature 'Login', feature: true do
context 'without grace period defined' do
before do
stub_application_setting(two_factor_grace_period: 0)
login_with(user)
gitlab_sign_in(user)
end
it 'redirects to two-factor configuration page' do
......@@ -269,7 +269,7 @@ feature 'Login', feature: true do
context 'with grace period defined' do
before do
stub_application_setting(two_factor_grace_period: 48)
login_with(user)
gitlab_sign_in(user)
end
context 'within the grace period' do
......@@ -310,7 +310,7 @@ feature 'Login', feature: true do
context 'without grace period defined' do
before do
stub_application_setting(two_factor_grace_period: 0)
login_with(user)
gitlab_sign_in(user)
end
it 'redirects to two-factor configuration page' do
......
......@@ -16,7 +16,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do
describe 'merge-request-only commands' do
before do
project.team << [user, :master]
login_with(user)
gitlab_sign_in(user)
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
......@@ -52,7 +52,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do
before do
project.team << [guest, :guest]
logout
login_with(guest)
gitlab_sign_in(guest)
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
......@@ -98,7 +98,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do
before do
project.team << [guest, :guest]
logout
login_with(guest)
gitlab_sign_in(guest)
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
......@@ -127,7 +127,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do
before do
logout
another_project.team << [user, :master]
login_with(user)
gitlab_sign_in(user)
end
it 'changes target_branch in new merge_request' do
......@@ -182,7 +182,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do
before do
project.team << [guest, :guest]
logout
login_with(guest)
gitlab_sign_in(guest)
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
......
......@@ -6,7 +6,7 @@ feature 'user browses project', feature: true, js: true do
before do
project.team << [user, :master]
login_with(user)
gitlab_sign_in(user)
visit namespace_project_tree_path(project.namespace, project, project.default_branch)
end
......
......@@ -393,7 +393,7 @@ feature 'Jobs', :feature do
project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
logout_direct
login_with(create(:user))
gitlab_sign_in(create(:user))
visit namespace_project_job_path(project.namespace, project, job)
end
......
......@@ -39,7 +39,7 @@ feature 'Project', feature: true do
let(:project) { create(:empty_project, namespace: user.namespace) }
before do
login_with user
gitlab_sign_in user
create(:forked_project_link, forked_to_project: project)
visit edit_namespace_project_path(project.namespace, project)
end
......@@ -60,7 +60,7 @@ feature 'Project', feature: true do
let(:project) { create(:empty_project, namespace: user.namespace, name: 'project1') }
before do
login_with(user)
gitlab_sign_in(user)
project.team << [user, :master]
visit edit_namespace_project_path(project.namespace, project)
end
......@@ -79,7 +79,7 @@ feature 'Project', feature: true do
let(:project) { create(:empty_project, namespace: user.namespace) }
before do
login_with(user)
gitlab_sign_in(user)
project.add_user(user, Gitlab::Access::MASTER)
visit namespace_project_path(project.namespace, project)
end
......@@ -98,7 +98,7 @@ feature 'Project', feature: true do
context 'on issues page', js: true do
before do
login_with(user)
gitlab_sign_in(user)
project.add_user(user, Gitlab::Access::MASTER)
project2.add_user(user, Gitlab::Access::MASTER)
visit namespace_project_issue_path(project.namespace, project, issue)
......
......@@ -9,7 +9,7 @@ describe "Search", feature: true do
let!(:issue2) { create(:issue, project: project, author: user) }
before do
login_with(user)
gitlab_sign_in(user)
project.team << [user, :reporter]
visit search_path
end
......
......@@ -6,7 +6,7 @@ feature 'Master creates tag', feature: true do
before do
project.team << [user, :master]
login_with(user)
gitlab_sign_in(user)
end
context 'from tag list' do
......
......@@ -6,7 +6,7 @@ feature 'Master deletes tag', feature: true do
before do
project.team << [user, :master]
login_with(user)
gitlab_sign_in(user)
visit namespace_project_tags_path(project.namespace, project)
end
......
......@@ -6,7 +6,7 @@ feature 'Master updates tag', feature: true do
before do
project.team << [user, :master]
login_with(user)
gitlab_sign_in(user)
visit namespace_project_tags_path(project.namespace, project)
end
......
......@@ -5,7 +5,7 @@ feature 'Master views tags', feature: true do
before do
project.team << [user, :master]
login_with(user)
gitlab_sign_in(user)
end
context 'when project has no tags' do
......
......@@ -55,7 +55,7 @@ feature 'Task Lists', feature: true do
project.team << [user, :master]
project.team << [user2, :guest]
gitlab_sign_in(user)
login_as(user)
end
def visit_issue(project, issue)
......@@ -90,7 +90,7 @@ feature 'Task Lists', feature: true do
expect(page).to have_selector(".wiki .task-list .task-list-item .task-list-item-checkbox")
logout(:user)
gitlab_sign_in(user2)
login_as(user2)
visit current_path
wait_for_requests
......@@ -203,7 +203,7 @@ feature 'Task Lists', feature: true do
logout(:user)
gitlab_sign_in(user2)
login_as(user2)
visit current_path
expect(page).not_to have_selector('.js-task-list-container')
end
......@@ -275,7 +275,7 @@ feature 'Task Lists', feature: true do
logout(:user)
gitlab_sign_in(user2)
login_as(user2)
visit current_path
expect(page).not_to have_selector('.js-task-list-container')
end
......
......@@ -158,7 +158,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
describe "when 2FA via OTP is disabled" do
it "allows logging in with the U2F device" do
user.update_attribute(:otp_required_for_login, false)
login_with(user)
gitlab_sign_in(user)
@u2f_device.respond_to_u2f_authentication
......@@ -170,7 +170,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
describe "when 2FA via OTP is enabled" do
it "allows logging in with the U2F device" do
user.update_attribute(:otp_required_for_login, true)
login_with(user)
gitlab_sign_in(user)
@u2f_device.respond_to_u2f_authentication
......@@ -180,7 +180,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
end
it 'persists remember_me value via hidden field' do
login_with(user, remember: true)
gitlab_sign_in(user, remember: true)
@u2f_device.respond_to_u2f_authentication
expect(page).to have_content('We heard back from your U2F device')
......@@ -308,7 +308,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
describe 'when no u2f device is registered' do
before do
logout
login_with(user)
gitlab_sign_in(user)
end
it 'shows the fallback otp code UI' do
......@@ -321,7 +321,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
manage_two_factor_authentication
@u2f_device = register_u2f_device
logout
login_with(user)
gitlab_sign_in(user)
end
it 'provides a button that shows the fallback otp code UI' do
......
......@@ -24,7 +24,7 @@ feature 'Users', feature: true, js: true do
user.reload
expect(user.reset_password_token).not_to be_nil
login_with(user)
gitlab_sign_in(user)
expect(current_path).to eq root_path
user.reload
......
......@@ -17,7 +17,7 @@ shared_examples 'issuable record that supports quick actions in its description
project.team << [master, :master]
project.team << [assignee, :developer]
project.team << [guest, :guest]
login_with(master)
gitlab_sign_in(master)
end
after do
......@@ -106,7 +106,7 @@ shared_examples 'issuable record that supports quick actions in its description
context "when current user cannot close #{issuable_type}" do
before do
logout
login_with(guest)
gitlab_sign_in(guest)
visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
end
......@@ -141,7 +141,7 @@ shared_examples 'issuable record that supports quick actions in its description
context "when current user cannot reopen #{issuable_type}" do
before do
logout
login_with(guest)
gitlab_sign_in(guest)
visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
end
......@@ -171,7 +171,7 @@ shared_examples 'issuable record that supports quick actions in its description
context "when current user cannot change title of #{issuable_type}" do
before do
logout
login_with(guest)
gitlab_sign_in(guest)
visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
end
......
......@@ -14,7 +14,7 @@ module LoginHelpers
# # Provide an existing User record
# user = create(:user)
# gitlab_sign_in(user)
def gitlab_sign_in(user_or_role)
def gitlab_sign_in(user_or_role, **kwargs)
@user =
if user_or_role.is_a?(User)
user_or_role
......@@ -22,7 +22,7 @@ module LoginHelpers
create(user_or_role)
end
gitlab_sign_in_with(@user)
gitlab_sign_in_with(@user, **kwargs)
end
def gitlab_sign_in_via(provider, user, uid)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment