Commit 2886ec6a authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rs-login_as' into 'master'

Remove implicit dependency on `gitlab_sign_in` assigning to a user instance variable

See merge request !12296
parents 2a726c24 2dac8f44
...@@ -4,10 +4,11 @@ describe 'Commits' do ...@@ -4,10 +4,11 @@ describe 'Commits' do
include CiStatusHelper include CiStatusHelper
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
describe 'CI' do describe 'CI' do
before do before do
gitlab_sign_in :user sign_in(user)
stub_ci_pipeline_to_return_yaml_file stub_ci_pipeline_to_return_yaml_file
end end
...@@ -27,7 +28,7 @@ describe 'Commits' do ...@@ -27,7 +28,7 @@ describe 'Commits' do
let!(:status) { create(:generic_commit_status, pipeline: pipeline) } let!(:status) { create(:generic_commit_status, pipeline: pipeline) }
before do before do
project.team << [@user, :reporter] project.team << [user, :reporter]
end end
describe 'Commit builds' do describe 'Commit builds' do
...@@ -52,7 +53,7 @@ describe 'Commits' do ...@@ -52,7 +53,7 @@ describe 'Commits' do
context 'when logged as developer' do context 'when logged as developer' do
before do before do
project.team << [@user, :developer] project.team << [user, :developer]
end end
describe 'Project commits' do describe 'Project commits' do
...@@ -146,7 +147,7 @@ describe 'Commits' do ...@@ -146,7 +147,7 @@ describe 'Commits' do
context "when logged as reporter" do context "when logged as reporter" do
before do before do
project.team << [@user, :reporter] project.team << [user, :reporter]
build.update_attributes(artifacts_file: artifacts_file) build.update_attributes(artifacts_file: artifacts_file)
visit ci_status_path(pipeline) visit ci_status_path(pipeline)
end end
...@@ -187,11 +188,10 @@ describe 'Commits' do ...@@ -187,11 +188,10 @@ describe 'Commits' do
context 'viewing commits for a branch' do context 'viewing commits for a branch' do
let(:branch_name) { 'master' } let(:branch_name) { 'master' }
let(:user) { create(:user) }
before do before do
project.team << [user, :master] project.team << [user, :master]
gitlab_sign_in(user) sign_in(user)
visit namespace_project_commits_path(project.namespace, project, branch_name) visit namespace_project_commits_path(project.namespace, project, branch_name)
end end
......
require 'spec_helper' require 'spec_helper'
describe "GitLab Flavored Markdown", feature: true do describe "GitLab Flavored Markdown", feature: true do
let(:user) { create(:user) }
let(:project) { create(:empty_project) } let(:project) { create(:empty_project) }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:fred) do let(:fred) do
...@@ -10,8 +11,8 @@ describe "GitLab Flavored Markdown", feature: true do ...@@ -10,8 +11,8 @@ describe "GitLab Flavored Markdown", feature: true do
end end
before do before do
gitlab_sign_in(:user) sign_in(user)
project.add_developer(@user) project.add_developer(user)
end end
describe "for commits" do describe "for commits" do
...@@ -51,12 +52,12 @@ describe "GitLab Flavored Markdown", feature: true do ...@@ -51,12 +52,12 @@ describe "GitLab Flavored Markdown", feature: true do
describe "for issues", feature: true, js: true do describe "for issues", feature: true, js: true do
before do before do
@other_issue = create(:issue, @other_issue = create(:issue,
author: @user, author: user,
assignees: [@user], assignees: [user],
project: project) project: project)
@issue = create(:issue, @issue = create(:issue,
author: @user, author: user,
assignees: [@user], assignees: [user],
project: project, project: project,
title: "fix #{@other_issue.to_reference}", title: "fix #{@other_issue.to_reference}",
description: "ask #{fred.to_reference} for details") description: "ask #{fred.to_reference} for details")
......
This diff is collapsed.
require 'spec_helper' require 'spec_helper'
describe 'Branches', feature: true do describe 'Branches', feature: true do
let(:user) { create(:user) }
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
let(:repository) { project.repository } let(:repository) { project.repository }
...@@ -12,8 +13,8 @@ describe 'Branches', feature: true do ...@@ -12,8 +13,8 @@ describe 'Branches', feature: true do
context 'logged in as developer' do context 'logged in as developer' do
before do before do
gitlab_sign_in :user sign_in(user)
project.team << [@user, :developer] project.team << [user, :developer]
end end
describe 'Initial branches page' do describe 'Initial branches page' do
...@@ -27,7 +28,7 @@ describe 'Branches', feature: true do ...@@ -27,7 +28,7 @@ describe 'Branches', feature: true do
it 'avoids a N+1 query in branches index' do it 'avoids a N+1 query in branches index' do
control_count = ActiveRecord::QueryRecorder.new { visit namespace_project_branches_path(project.namespace, project) }.count control_count = ActiveRecord::QueryRecorder.new { visit namespace_project_branches_path(project.namespace, project) }.count
%w(one two three four five).each { |ref| repository.add_branch(@user, ref, 'master') } %w(one two three four five).each { |ref| repository.add_branch(user, ref, 'master') }
expect { visit namespace_project_branches_path(project.namespace, project) }.not_to exceed_query_limit(control_count) expect { visit namespace_project_branches_path(project.namespace, project) }.not_to exceed_query_limit(control_count)
end end
...@@ -64,14 +65,14 @@ describe 'Branches', feature: true do ...@@ -64,14 +65,14 @@ describe 'Branches', feature: true do
describe 'Delete protected branch' do describe 'Delete protected branch' do
before do before do
project.add_user(@user, :master) project.add_user(user, :master)
visit namespace_project_protected_branches_path(project.namespace, project) visit namespace_project_protected_branches_path(project.namespace, project)
set_protected_branch_name('fix') set_protected_branch_name('fix')
click_on "Protect" click_on "Protect"
within(".protected-branches-list") { expect(page).to have_content('fix') } within(".protected-branches-list") { expect(page).to have_content('fix') }
expect(ProtectedBranch.count).to eq(1) expect(ProtectedBranch.count).to eq(1)
project.add_user(@user, :developer) project.add_user(user, :developer)
end end
it 'does not allow devleoper to removes protected branch', js: true do it 'does not allow devleoper to removes protected branch', js: true do
...@@ -87,8 +88,8 @@ describe 'Branches', feature: true do ...@@ -87,8 +88,8 @@ describe 'Branches', feature: true do
context 'logged in as master' do context 'logged in as master' do
before do before do
gitlab_sign_in :user sign_in(user)
project.team << [@user, :master] project.team << [user, :master]
end end
describe 'Delete protected branch' do describe 'Delete protected branch' do
......
require 'spec_helper' require 'spec_helper'
describe 'Cherry-pick Commits' do describe 'Cherry-pick Commits' do
let(:user) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) } let(:project) { create(:project, namespace: group) }
let(:master_pickable_commit) { project.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') } let(:master_pickable_commit) { project.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') }
let(:master_pickable_merge) { project.commit('e56497bb5f03a90a51293fc6d516788730953899') } let(:master_pickable_merge) { project.commit('e56497bb5f03a90a51293fc6d516788730953899') }
before do before do
gitlab_sign_in :user sign_in(user)
project.team << [@user, :master] project.team << [user, :master]
visit namespace_project_commit_path(project.namespace, project, master_pickable_commit.id) visit namespace_project_commit_path(project.namespace, project, master_pickable_commit.id)
end end
......
...@@ -7,7 +7,7 @@ feature 'Triggers', feature: true, js: true do ...@@ -7,7 +7,7 @@ feature 'Triggers', feature: true, js: true do
let(:guest_user) { create(:user) } let(:guest_user) { create(:user) }
before do before do
gitlab_sign_in(user) sign_in(user)
@project = create(:empty_project) @project = create(:empty_project)
@project.team << [user, :master] @project.team << [user, :master]
...@@ -33,7 +33,7 @@ feature 'Triggers', feature: true, js: true do ...@@ -33,7 +33,7 @@ feature 'Triggers', feature: true, js: true do
# See if "trigger creation successful" message displayed and description and owner are correct # See if "trigger creation successful" message displayed and description and owner are correct
expect(page.find('.flash-notice')).to have_content 'Trigger was created successfully.' expect(page.find('.flash-notice')).to have_content 'Trigger was created successfully.'
expect(page.find('.triggers-list')).to have_content 'trigger desc' expect(page.find('.triggers-list')).to have_content 'trigger desc'
expect(page.find('.triggers-list .trigger-owner')).to have_content @user.name expect(page.find('.triggers-list .trigger-owner')).to have_content user.name
end end
end end
...@@ -61,7 +61,7 @@ feature 'Triggers', feature: true, js: true do ...@@ -61,7 +61,7 @@ feature 'Triggers', feature: true, js: true do
# See if "trigger updated successfully" message displayed and description and owner are correct # See if "trigger updated successfully" message displayed and description and owner are correct
expect(page.find('.flash-notice')).to have_content 'Trigger was successfully updated.' expect(page.find('.flash-notice')).to have_content 'Trigger was successfully updated.'
expect(page.find('.triggers-list')).to have_content new_trigger_title expect(page.find('.triggers-list')).to have_content new_trigger_title
expect(page.find('.triggers-list .trigger-owner')).to have_content @user.name expect(page.find('.triggers-list .trigger-owner')).to have_content user.name
end end
scenario 'edit "legacy" trigger and save' do scenario 'edit "legacy" trigger and save' do
...@@ -98,7 +98,7 @@ feature 'Triggers', feature: true, js: true do ...@@ -98,7 +98,7 @@ feature 'Triggers', feature: true, js: true do
page.accept_confirm do page.accept_confirm do
expect(page.find('.flash-notice')).to have_content 'Trigger was re-assigned.' expect(page.find('.flash-notice')).to have_content 'Trigger was re-assigned.'
expect(page.find('.triggers-list')).to have_content trigger_title expect(page.find('.triggers-list')).to have_content trigger_title
expect(page.find('.triggers-list .trigger-owner')).to have_content @user.name expect(page.find('.triggers-list .trigger-owner')).to have_content user.name
end end
end end
end end
...@@ -157,7 +157,7 @@ feature 'Triggers', feature: true, js: true do ...@@ -157,7 +157,7 @@ feature 'Triggers', feature: true, js: true do
expect(page.find('.triggers-list')).not_to have_selector('button.btn-clipboard') expect(page.find('.triggers-list')).not_to have_selector('button.btn-clipboard')
# See if trigger owner name doesn't match with current_user and trigger is non-editable # See if trigger owner name doesn't match with current_user and trigger is non-editable
expect(page.find('.triggers-list .trigger-owner')).not_to have_content @user.name expect(page.find('.triggers-list .trigger-owner')).not_to have_content user.name
expect(page.find('.triggers-list')).not_to have_selector('a[title="Edit"]') expect(page.find('.triggers-list')).not_to have_selector('a[title="Edit"]')
end end
...@@ -170,7 +170,7 @@ feature 'Triggers', feature: true, js: true do ...@@ -170,7 +170,7 @@ feature 'Triggers', feature: true, js: true do
expect(page.find('.triggers-list')).to have_selector('button.btn-clipboard') expect(page.find('.triggers-list')).to have_selector('button.btn-clipboard')
# See if trigger owner name matches with current_user and is editable # See if trigger owner name matches with current_user and is editable
expect(page.find('.triggers-list .trigger-owner')).to have_content @user.name expect(page.find('.triggers-list .trigger-owner')).to have_content user.name
expect(page.find('.triggers-list')).to have_selector('a[title="Edit"]') expect(page.find('.triggers-list')).to have_selector('a[title="Edit"]')
end end
end end
......
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