Commit 2dac8f44 authored by Robert Speicher's avatar Robert Speicher

Remove implicit dependency on `gitlab_sign_in` assigning `@user`

We shouldn't be using instance variables in specs to begin with, and
depending on this implicit behavior of `gitlab_sign_in` would have made
it more difficult to change to `sign_in` where possible.

...we've also gone ahead and changed to `sign_in` where possible.
parent 1c64fa08
......@@ -4,10 +4,11 @@ describe 'Commits' do
include CiStatusHelper
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
describe 'CI' do
before do
gitlab_sign_in :user
sign_in(user)
stub_ci_pipeline_to_return_yaml_file
end
......@@ -27,7 +28,7 @@ describe 'Commits' do
let!(:status) { create(:generic_commit_status, pipeline: pipeline) }
before do
project.team << [@user, :reporter]
project.team << [user, :reporter]
end
describe 'Commit builds' do
......@@ -52,7 +53,7 @@ describe 'Commits' do
context 'when logged as developer' do
before do
project.team << [@user, :developer]
project.team << [user, :developer]
end
describe 'Project commits' do
......@@ -146,7 +147,7 @@ describe 'Commits' do
context "when logged as reporter" do
before do
project.team << [@user, :reporter]
project.team << [user, :reporter]
build.update_attributes(artifacts_file: artifacts_file)
visit ci_status_path(pipeline)
end
......@@ -187,11 +188,10 @@ describe 'Commits' do
context 'viewing commits for a branch' do
let(:branch_name) { 'master' }
let(:user) { create(:user) }
before do
project.team << [user, :master]
gitlab_sign_in(user)
sign_in(user)
visit namespace_project_commits_path(project.namespace, project, branch_name)
end
......
require 'spec_helper'
describe "GitLab Flavored Markdown", feature: true do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:issue) { create(:issue, project: project) }
let(:fred) do
......@@ -10,8 +11,8 @@ describe "GitLab Flavored Markdown", feature: true do
end
before do
gitlab_sign_in(:user)
project.add_developer(@user)
sign_in(user)
project.add_developer(user)
end
describe "for commits" do
......@@ -51,12 +52,12 @@ describe "GitLab Flavored Markdown", feature: true do
describe "for issues", feature: true, js: true do
before do
@other_issue = create(:issue,
author: @user,
assignees: [@user],
author: user,
assignees: [user],
project: project)
@issue = create(:issue,
author: @user,
assignees: [@user],
author: user,
assignees: [user],
project: project,
title: "fix #{@other_issue.to_reference}",
description: "ask #{fred.to_reference} for details")
......
This diff is collapsed.
require 'spec_helper'
describe 'Branches', feature: true do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:repository) { project.repository }
......@@ -12,8 +13,8 @@ describe 'Branches', feature: true do
context 'logged in as developer' do
before do
gitlab_sign_in :user
project.team << [@user, :developer]
sign_in(user)
project.team << [user, :developer]
end
describe 'Initial branches page' do
......@@ -27,7 +28,7 @@ describe 'Branches', feature: true 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
%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)
end
......@@ -64,14 +65,14 @@ describe 'Branches', feature: true do
describe 'Delete protected branch' do
before do
project.add_user(@user, :master)
project.add_user(user, :master)
visit namespace_project_protected_branches_path(project.namespace, project)
set_protected_branch_name('fix')
click_on "Protect"
within(".protected-branches-list") { expect(page).to have_content('fix') }
expect(ProtectedBranch.count).to eq(1)
project.add_user(@user, :developer)
project.add_user(user, :developer)
end
it 'does not allow devleoper to removes protected branch', js: true do
......@@ -87,8 +88,8 @@ describe 'Branches', feature: true do
context 'logged in as master' do
before do
gitlab_sign_in :user
project.team << [@user, :master]
sign_in(user)
project.team << [user, :master]
end
describe 'Delete protected branch' do
......
require 'spec_helper'
describe 'Cherry-pick Commits' do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:master_pickable_commit) { project.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') }
let(:master_pickable_merge) { project.commit('e56497bb5f03a90a51293fc6d516788730953899') }
before do
gitlab_sign_in :user
project.team << [@user, :master]
sign_in(user)
project.team << [user, :master]
visit namespace_project_commit_path(project.namespace, project, master_pickable_commit.id)
end
......
......@@ -7,7 +7,7 @@ feature 'Triggers', feature: true, js: true do
let(:guest_user) { create(:user) }
before do
gitlab_sign_in(user)
sign_in(user)
@project = create(:empty_project)
@project.team << [user, :master]
......@@ -33,7 +33,7 @@ feature 'Triggers', feature: true, js: true do
# 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('.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
......@@ -61,7 +61,7 @@ feature 'Triggers', feature: true, js: true do
# 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('.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
scenario 'edit "legacy" trigger and save' do
......@@ -98,7 +98,7 @@ feature 'Triggers', feature: true, js: true do
page.accept_confirm do
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 .trigger-owner')).to have_content @user.name
expect(page.find('.triggers-list .trigger-owner')).to have_content user.name
end
end
end
......@@ -157,7 +157,7 @@ feature 'Triggers', feature: true, js: true do
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
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"]')
end
......@@ -170,7 +170,7 @@ feature 'Triggers', feature: true, js: true do
expect(page.find('.triggers-list')).to have_selector('button.btn-clipboard')
# 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"]')
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