Replace '.team << [user, role]' with 'add_role(user)' in specs

parent a9253be0
...@@ -231,7 +231,7 @@ class Project < ActiveRecord::Base ...@@ -231,7 +231,7 @@ class Project < ActiveRecord::Base
delegate :name, to: :owner, allow_nil: true, prefix: true delegate :name, to: :owner, allow_nil: true, prefix: true
delegate :members, to: :team, prefix: true delegate :members, to: :team, prefix: true
delegate :add_user, :add_users, to: :team delegate :add_user, :add_users, to: :team
delegate :add_guest, :add_reporter, :add_developer, :add_master, to: :team delegate :add_guest, :add_reporter, :add_developer, :add_master, :add_role, to: :team
# Validations # Validations
validates :creator, presence: true, on: :create validates :creator, presence: true, on: :create
......
...@@ -7,36 +7,24 @@ class ProjectTeam ...@@ -7,36 +7,24 @@ class ProjectTeam
@project = project @project = project
end end
# Shortcut to add users
#
# Use:
# @team << [@user, :master]
# @team << [@users, :master]
#
def <<(args)
users, access, current_user = *args
if users.respond_to?(:each)
add_users(users, access, current_user: current_user)
else
add_user(users, access, current_user: current_user)
end
end
def add_guest(user, current_user: nil) def add_guest(user, current_user: nil)
self << [user, :guest, current_user] add_user(user, :guest, current_user: current_user)
end end
def add_reporter(user, current_user: nil) def add_reporter(user, current_user: nil)
self << [user, :reporter, current_user] add_user(user, :reporter, current_user: current_user)
end end
def add_developer(user, current_user: nil) def add_developer(user, current_user: nil)
self << [user, :developer, current_user] add_user(user, :developer, current_user: current_user)
end end
def add_master(user, current_user: nil) def add_master(user, current_user: nil)
self << [user, :master, current_user] add_user(user, :master, current_user: current_user)
end
def add_role(user, role, current_user: nil)
public_send(:"add_#{role}", user, current_user: current_user) # rubocop:disable GitlabSecurity/PublicSend
end end
def find_member(user_id) def find_member(user_id)
......
---
title: Replace '.team << [user, role]' with 'add_role(user)' in specs
merge_request: 16069
author: "@blackst0ne"
type: other
...@@ -14,7 +14,7 @@ Sidekiq::Testing.inline! do ...@@ -14,7 +14,7 @@ Sidekiq::Testing.inline! do
Project.all.each do |project| Project.all.each do |project|
User.all.sample(4).each do |user| User.all.sample(4).each do |user|
if project.team << [user, Gitlab::Access.values.sample] if project.add_role(user, Gitlab::Access.values.sample)
print '.' print '.'
else else
print 'F' print 'F'
......
...@@ -13,7 +13,7 @@ class Spinach::Features::GroupsManagement < Spinach::FeatureSteps ...@@ -13,7 +13,7 @@ class Spinach::Features::GroupsManagement < Spinach::FeatureSteps
step '"Mary Jane" has master access for project "Open"' do step '"Mary Jane" has master access for project "Open"' do
@user = User.find_by(name: "Mary Jane") || create(:user, name: "Mary Jane") @user = User.find_by(name: "Mary Jane") || create(:user, name: "Mary Jane")
@project = Project.find_by(name: "Open") @project = Project.find_by(name: "Open")
@project.team << [@user, :master] @project.add_master(@user)
end end
step "Group membership lock is enabled" do step "Group membership lock is enabled" do
......
...@@ -165,7 +165,7 @@ class Spinach::Features::Profile < Spinach::FeatureSteps ...@@ -165,7 +165,7 @@ class Spinach::Features::Profile < Spinach::FeatureSteps
@project = create(:project, :repository, namespace: @group) @project = create(:project, :repository, namespace: @group)
@event = create(:closed_issue_event, project: @project) @event = create(:closed_issue_event, project: @project)
@project.team << [current_user, :master] @project.add_master(current_user)
end end
step 'I should see groups I belong to' do step 'I should see groups I belong to' do
......
...@@ -48,11 +48,11 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps ...@@ -48,11 +48,11 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
step 'other projects have deploy keys' do step 'other projects have deploy keys' do
@second_project = create(:project, namespace: create(:group)) @second_project = create(:project, namespace: create(:group))
@second_project.team << [current_user, :master] @second_project.add_master(current_user)
create(:deploy_keys_project, project: @second_project) create(:deploy_keys_project, project: @second_project)
@third_project = create(:project, namespace: create(:group)) @third_project = create(:project, namespace: create(:group))
@third_project.team << [current_user, :master] @third_project.add_master(current_user)
create(:deploy_keys_project, project: @third_project, deploy_key: @second_project.deploy_keys.first) create(:deploy_keys_project, project: @third_project, deploy_key: @second_project.deploy_keys.first)
end end
......
...@@ -19,7 +19,7 @@ class Spinach::Features::GlobalSearch < Spinach::FeatureSteps ...@@ -19,7 +19,7 @@ class Spinach::Features::GlobalSearch < Spinach::FeatureSteps
step 'project has all data available for the search' do step 'project has all data available for the search' do
@project = create :project @project = create :project
@project.team << [current_user, :master] @project.add_master(current_user)
@issue = create :issue, title: 'bla-bla initial', project: @project @issue = create :issue, title: 'bla-bla initial', project: @project
@merge_request = create :merge_request, title: 'bla-bla initial', source_project: @project @merge_request = create :merge_request, title: 'bla-bla initial', source_project: @project
......
...@@ -17,7 +17,7 @@ class Spinach::Features::ProjectSearch < Spinach::FeatureSteps ...@@ -17,7 +17,7 @@ class Spinach::Features::ProjectSearch < Spinach::FeatureSteps
step 'project has all data available for the search' do step 'project has all data available for the search' do
@project = create :project, :repository @project = create :project, :repository
@project.team << [current_user, :master] @project.add_master(current_user)
@issue = create :issue, title: 'bla-bla initial', project: @project @issue = create :issue, title: 'bla-bla initial', project: @project
@merge_request = create :merge_request, title: 'bla-bla initial', source_project: @project @merge_request = create :merge_request, title: 'bla-bla initial', source_project: @project
......
...@@ -10,7 +10,7 @@ class Spinach::Features::ProjectFork < Spinach::FeatureSteps ...@@ -10,7 +10,7 @@ class Spinach::Features::ProjectFork < Spinach::FeatureSteps
step 'I am a member of project "Shop"' do step 'I am a member of project "Shop"' do
@project = create(:project, :repository, name: "Shop") @project = create(:project, :repository, name: "Shop")
@project.team << [@user, :reporter] @project.add_reporter(@user)
end end
step 'I should see the forked project page' do step 'I should see the forked project page' do
...@@ -71,7 +71,7 @@ class Spinach::Features::ProjectFork < Spinach::FeatureSteps ...@@ -71,7 +71,7 @@ class Spinach::Features::ProjectFork < Spinach::FeatureSteps
step 'There is an existent fork of the "Shop" project' do step 'There is an existent fork of the "Shop" project' do
user = create(:user, name: 'Mike') user = create(:user, name: 'Mike')
@project.team << [user, :reporter] @project.add_reporter(user)
@forked_project = Projects::ForkService.new(@project, user).execute @forked_project = Projects::ForkService.new(@project, user).execute
end end
......
...@@ -10,7 +10,7 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -10,7 +10,7 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
step 'I am a member of project "Shop"' do step 'I am a member of project "Shop"' do
@project = ::Project.find_by(name: "Shop") @project = ::Project.find_by(name: "Shop")
@project ||= create(:project, :repository, name: "Shop") @project ||= create(:project, :repository, name: "Shop")
@project.team << [@user, :reporter] @project.add_reporter(@user)
end end
step 'I have a project forked off of "Shop" called "Forked Shop"' do step 'I have a project forked off of "Shop" called "Forked Shop"' do
......
...@@ -8,7 +8,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps ...@@ -8,7 +8,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
step "I don't have write access" do step "I don't have write access" do
@project = create(:project, :repository, name: "Other Project", path: "other-project") @project = create(:project, :repository, name: "Other Project", path: "other-project")
@project.team << [@user, :reporter] @project.add_reporter(@user)
visit project_tree_path(@project, root_ref) visit project_tree_path(@project, root_ref)
end end
......
...@@ -10,7 +10,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps ...@@ -10,7 +10,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
step 'I own project "Delta"' do step 'I own project "Delta"' do
@project = ::Project.find_by(name: "Delta") @project = ::Project.find_by(name: "Delta")
@project ||= create(:project, :repository, name: "Delta", namespace: @user.namespace) @project ||= create(:project, :repository, name: "Delta", namespace: @user.namespace)
@project.team << [@user, :master] @project.add_master(@user)
end end
step 'I should see files from repository in markdown' do step 'I should see files from repository in markdown' do
......
...@@ -45,7 +45,7 @@ module SharedGroup ...@@ -45,7 +45,7 @@ module SharedGroup
group.add_user(user, role) group.add_user(user, role)
project ||= create(:project, :repository, namespace: group) project ||= create(:project, :repository, namespace: group)
create(:closed_issue_event, project: project) create(:closed_issue_event, project: project)
project.team << [user, :master] project.add_master(user)
end end
def owned_group def owned_group
......
...@@ -4,13 +4,13 @@ module SharedProject ...@@ -4,13 +4,13 @@ module SharedProject
# Create a project without caring about what it's called # Create a project without caring about what it's called
step "I own a project" do step "I own a project" do
@project = create(:project, :repository, namespace: @user.namespace) @project = create(:project, :repository, namespace: @user.namespace)
@project.team << [@user, :master] @project.add_master(@user)
end end
step "I own a project in some group namespace" do step "I own a project in some group namespace" do
@group = create(:group, name: 'some group') @group = create(:group, name: 'some group')
@project = create(:project, namespace: @group) @project = create(:project, namespace: @group)
@project.team << [@user, :master] @project.add_master(@user)
end end
step "project exists in some group namespace" do step "project exists in some group namespace" do
...@@ -22,7 +22,7 @@ module SharedProject ...@@ -22,7 +22,7 @@ module SharedProject
step 'I own project "Shop"' do step 'I own project "Shop"' do
@project = Project.find_by(name: "Shop") @project = Project.find_by(name: "Shop")
@project ||= create(:project, :repository, name: "Shop", namespace: @user.namespace, issues_template: "This issue should contain the following.", merge_requests_template: "This merge request should contain the following.") @project ||= create(:project, :repository, name: "Shop", namespace: @user.namespace, issues_template: "This issue should contain the following.", merge_requests_template: "This merge request should contain the following.")
@project.team << [@user, :master] @project.add_master(@user)
end end
step 'I disable snippets in project' do step 'I disable snippets in project' do
...@@ -40,7 +40,7 @@ module SharedProject ...@@ -40,7 +40,7 @@ module SharedProject
step 'I add a user to project "Shop"' do step 'I add a user to project "Shop"' do
@project = Project.find_by(name: "Shop") @project = Project.find_by(name: "Shop")
other_user = create(:user, name: 'Alpha') other_user = create(:user, name: 'Alpha')
@project.team << [other_user, :master] @project.add_master(other_user)
end end
# Create another specific project called "Forum" # Create another specific project called "Forum"
...@@ -49,14 +49,13 @@ module SharedProject ...@@ -49,14 +49,13 @@ module SharedProject
@project ||= create(:project, :repository, name: "Forum", namespace: @user.namespace, path: 'forum_project') @project ||= create(:project, :repository, name: "Forum", namespace: @user.namespace, path: 'forum_project')
@project.build_project_feature @project.build_project_feature
@project.project_feature.save @project.project_feature.save
@project.team << [@user, :master] @project.add_master(@user)
end end
# Create an empty project without caring about the name # Create an empty project without caring about the name
step 'I own an empty project' do step 'I own an empty project' do
@project = create(:project, @project = create(:project, name: 'Empty Project', namespace: @user.namespace)
name: 'Empty Project', namespace: @user.namespace) @project.add_master(@user)
@project.team << [@user, :master]
end end
step 'I visit my empty project page' do step 'I visit my empty project page' do
...@@ -101,11 +100,11 @@ module SharedProject ...@@ -101,11 +100,11 @@ module SharedProject
# ---------------------------------------- # ----------------------------------------
step 'I am member of a project with a guest role' do step 'I am member of a project with a guest role' do
@project.team << [@user, Gitlab::Access::GUEST] @project.add_guest(@user)
end end
step 'I am member of a project with a reporter role' do step 'I am member of a project with a reporter role' do
@project.team << [@user, Gitlab::Access::REPORTER] @project.add_reporter(@user)
end end
# ---------------------------------------- # ----------------------------------------
...@@ -245,6 +244,6 @@ module SharedProject ...@@ -245,6 +244,6 @@ module SharedProject
user = user_exists(user_name, username: user_name.gsub(/\s/, '').underscore) user = user_exists(user_name, username: user_name.gsub(/\s/, '').underscore)
project = Project.find_by(name: project_name) project = Project.find_by(name: project_name)
project ||= create(:project, visibility, name: project_name, namespace: user.namespace) project ||= create(:project, visibility, name: project_name, namespace: user.namespace)
project.team << [user, :master] project.add_master(user)
end end
end end
...@@ -13,7 +13,7 @@ describe Admin::UsersController do ...@@ -13,7 +13,7 @@ describe Admin::UsersController do
let!(:issue) { create(:issue, author: user) } let!(:issue) { create(:issue, author: user) }
before do before do
project.team << [user, :developer] project.add_developer(user)
end end
it 'deletes user and ghosts their contributions' do it 'deletes user and ghosts their contributions' do
......
...@@ -13,8 +13,8 @@ describe Boards::IssuesController do ...@@ -13,8 +13,8 @@ describe Boards::IssuesController do
let!(:list2) { create(:list, board: board, label: development, position: 1) } let!(:list2) { create(:list, board: board, label: development, position: 1) }
before do before do
project.team << [user, :master] project.add_master(user)
project.team << [guest, :guest] project.add_guest(guest)
end end
describe 'GET index', :request_store do describe 'GET index', :request_store do
...@@ -221,7 +221,7 @@ describe Boards::IssuesController do ...@@ -221,7 +221,7 @@ describe Boards::IssuesController do
let(:guest) { create(:user) } let(:guest) { create(:user) }
before do before do
project.team << [guest, :guest] project.add_guest(guest)
end end
it 'returns a forbidden 403 response' do it 'returns a forbidden 403 response' do
......
...@@ -7,8 +7,8 @@ describe Boards::ListsController do ...@@ -7,8 +7,8 @@ describe Boards::ListsController do
let(:guest) { create(:user) } let(:guest) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
project.team << [guest, :guest] project.add_guest(guest)
end end
describe 'GET index' do describe 'GET index' do
......
...@@ -17,7 +17,7 @@ describe Dashboard::MilestonesController do ...@@ -17,7 +17,7 @@ describe Dashboard::MilestonesController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
end end
it_behaves_like 'milestone tabs' it_behaves_like 'milestone tabs'
......
...@@ -8,7 +8,7 @@ describe Dashboard::TodosController do ...@@ -8,7 +8,7 @@ describe Dashboard::TodosController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
describe 'GET #index' do describe 'GET #index' do
......
...@@ -5,7 +5,7 @@ describe DashboardController do ...@@ -5,7 +5,7 @@ describe DashboardController do
let(:project) { create(:project) } let(:project) { create(:project) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -28,7 +28,7 @@ describe Groups::MilestonesController do ...@@ -28,7 +28,7 @@ describe Groups::MilestonesController do
before do before do
sign_in(user) sign_in(user)
group.add_owner(user) group.add_owner(user)
project.team << [user, :master] project.add_master(user)
end end
describe '#index' do describe '#index' do
......
...@@ -6,7 +6,7 @@ describe NotificationSettingsController do ...@@ -6,7 +6,7 @@ describe NotificationSettingsController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :developer] project.add_developer(user)
end end
describe '#create' do describe '#create' do
......
...@@ -6,7 +6,7 @@ describe Projects::AvatarsController do ...@@ -6,7 +6,7 @@ describe Projects::AvatarsController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
controller.instance_variable_set(:@project, project) controller.instance_variable_set(:@project, project)
end end
......
...@@ -7,7 +7,7 @@ describe Projects::BlameController do ...@@ -7,7 +7,7 @@ describe Projects::BlameController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
controller.instance_variable_set(:@project, project) controller.instance_variable_set(:@project, project)
end end
......
...@@ -89,7 +89,7 @@ describe Projects::BlobController do ...@@ -89,7 +89,7 @@ describe Projects::BlobController do
end end
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
...@@ -147,7 +147,7 @@ describe Projects::BlobController do ...@@ -147,7 +147,7 @@ describe Projects::BlobController do
let(:developer) { create(:user) } let(:developer) { create(:user) }
before do before do
project.team << [developer, :developer] project.add_developer(developer)
sign_in(developer) sign_in(developer)
get :edit, default_params get :edit, default_params
end end
...@@ -161,7 +161,7 @@ describe Projects::BlobController do ...@@ -161,7 +161,7 @@ describe Projects::BlobController do
let(:master) { create(:user) } let(:master) { create(:user) }
before do before do
project.team << [master, :master] project.add_master(master)
sign_in(master) sign_in(master)
get :edit, default_params get :edit, default_params
end end
...@@ -190,7 +190,7 @@ describe Projects::BlobController do ...@@ -190,7 +190,7 @@ describe Projects::BlobController do
end end
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -5,7 +5,7 @@ describe Projects::BoardsController do ...@@ -5,7 +5,7 @@ describe Projects::BoardsController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -6,8 +6,8 @@ describe Projects::BranchesController do ...@@ -6,8 +6,8 @@ describe Projects::BranchesController do
let(:developer) { create(:user) } let(:developer) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
project.team << [user, :developer] project.add_developer(user)
allow(project).to receive(:branches).and_return(['master', 'foo/bar/baz']) allow(project).to receive(:branches).and_return(['master', 'foo/bar/baz'])
allow(project).to receive(:tags).and_return(['v1.0.0', 'v2.0.0']) allow(project).to receive(:tags).and_return(['v1.0.0', 'v2.0.0'])
......
...@@ -6,7 +6,7 @@ describe Projects::CommitsController do ...@@ -6,7 +6,7 @@ describe Projects::CommitsController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
end end
describe "GET show" do describe "GET show" do
......
...@@ -8,7 +8,7 @@ describe Projects::CompareController do ...@@ -8,7 +8,7 @@ describe Projects::CompareController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
end end
it 'compare shows some diffs' do it 'compare shows some diffs' do
......
...@@ -6,7 +6,7 @@ describe Projects::CycleAnalyticsController do ...@@ -6,7 +6,7 @@ describe Projects::CycleAnalyticsController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
end end
describe 'cycle analytics not set up flag' do describe 'cycle analytics not set up flag' do
......
...@@ -5,7 +5,7 @@ describe Projects::DeployKeysController do ...@@ -5,7 +5,7 @@ describe Projects::DeployKeysController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
...@@ -48,7 +48,7 @@ describe Projects::DeployKeysController do ...@@ -48,7 +48,7 @@ describe Projects::DeployKeysController do
end end
before do before do
project2.team << [user, :developer] project2.add_developer(user)
end end
it 'returns json in a correct format' do it 'returns json in a correct format' do
......
...@@ -8,7 +8,7 @@ describe Projects::DeploymentsController do ...@@ -8,7 +8,7 @@ describe Projects::DeploymentsController do
let(:environment) { create(:environment, name: 'production', project: project) } let(:environment) { create(:environment, name: 'production', project: project) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -31,7 +31,7 @@ describe Projects::DiscussionsController do ...@@ -31,7 +31,7 @@ describe Projects::DiscussionsController do
context "when the user is authorized to resolve the discussion" do context "when the user is authorized to resolve the discussion" do
before do before do
project.team << [user, :developer] project.add_developer(user)
end end
context "when the discussion is not resolvable" do context "when the discussion is not resolvable" do
...@@ -92,7 +92,7 @@ describe Projects::DiscussionsController do ...@@ -92,7 +92,7 @@ describe Projects::DiscussionsController do
context "when the user is authorized to resolve the discussion" do context "when the user is authorized to resolve the discussion" do
before do before do
project.team << [user, :developer] project.add_developer(user)
end end
context "when the discussion is not resolvable" do context "when the discussion is not resolvable" do
......
...@@ -7,7 +7,7 @@ describe Projects::FindFileController do ...@@ -7,7 +7,7 @@ describe Projects::FindFileController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
controller.instance_variable_set(:@project, project) controller.instance_variable_set(:@project, project)
end end
......
...@@ -51,7 +51,7 @@ describe Projects::ForksController do ...@@ -51,7 +51,7 @@ describe Projects::ForksController do
context 'when user is a member of the Project' do context 'when user is a member of the Project' do
before do before do
forked_project.team << [project.creator, :developer] forked_project.add_developer(project.creator)
end end
it 'sees the project listed' do it 'sees the project listed' do
......
...@@ -6,7 +6,7 @@ describe Projects::GraphsController do ...@@ -6,7 +6,7 @@ describe Projects::GraphsController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
end end
describe 'GET languages' do describe 'GET languages' do
......
...@@ -7,7 +7,7 @@ describe Projects::GroupLinksController do ...@@ -7,7 +7,7 @@ describe Projects::GroupLinksController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -5,7 +5,7 @@ describe Projects::HooksController do ...@@ -5,7 +5,7 @@ describe Projects::HooksController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -6,7 +6,7 @@ describe Projects::ImportsController do ...@@ -6,7 +6,7 @@ describe Projects::ImportsController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
end end
describe 'GET #show' do describe 'GET #show' do
...@@ -15,7 +15,7 @@ describe Projects::ImportsController do ...@@ -15,7 +15,7 @@ describe Projects::ImportsController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
end end
it 'renders template' do it 'renders template' do
......
...@@ -37,7 +37,7 @@ describe Projects::IssuesController do ...@@ -37,7 +37,7 @@ describe Projects::IssuesController do
context 'internal issue tracker' do context 'internal issue tracker' do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
it_behaves_like "issuables list meta-data", :issue it_behaves_like "issuables list meta-data", :issue
...@@ -69,7 +69,7 @@ describe Projects::IssuesController do ...@@ -69,7 +69,7 @@ describe Projects::IssuesController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
allow(Kaminari.config).to receive(:default_per_page).and_return(1) allow(Kaminari.config).to receive(:default_per_page).and_return(1)
end end
...@@ -116,7 +116,7 @@ describe Projects::IssuesController do ...@@ -116,7 +116,7 @@ describe Projects::IssuesController do
context 'internal issue tracker' do context 'internal issue tracker' do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
it 'builds a new issue' do it 'builds a new issue' do
...@@ -127,7 +127,7 @@ describe Projects::IssuesController do ...@@ -127,7 +127,7 @@ describe Projects::IssuesController do
it 'fills in an issue for a merge request' do it 'fills in an issue for a merge request' do
project_with_repository = create(:project, :repository) project_with_repository = create(:project, :repository)
project_with_repository.team << [user, :developer] project_with_repository.add_developer(user)
mr = create(:merge_request_with_diff_notes, source_project: project_with_repository) mr = create(:merge_request_with_diff_notes, source_project: project_with_repository)
get :new, namespace_id: project_with_repository.namespace, project_id: project_with_repository, merge_request_to_resolve_discussions_of: mr.iid get :new, namespace_id: project_with_repository.namespace, project_id: project_with_repository, merge_request_to_resolve_discussions_of: mr.iid
...@@ -153,7 +153,7 @@ describe Projects::IssuesController do ...@@ -153,7 +153,7 @@ describe Projects::IssuesController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
external = double external = double
allow(project).to receive(:external_issue_tracker).and_return(external) allow(project).to receive(:external_issue_tracker).and_return(external)
...@@ -329,7 +329,7 @@ describe Projects::IssuesController do ...@@ -329,7 +329,7 @@ describe Projects::IssuesController do
it 'does not list confidential issues for project members with guest role' do it 'does not list confidential issues for project members with guest role' do
sign_in(member) sign_in(member)
project.team << [member, :guest] project.add_guest(member)
get_issues get_issues
...@@ -354,7 +354,7 @@ describe Projects::IssuesController do ...@@ -354,7 +354,7 @@ describe Projects::IssuesController do
it 'lists confidential issues for project members' do it 'lists confidential issues for project members' do
sign_in(member) sign_in(member)
project.team << [member, :developer] project.add_developer(member)
get_issues get_issues
...@@ -394,7 +394,7 @@ describe Projects::IssuesController do ...@@ -394,7 +394,7 @@ describe Projects::IssuesController do
it 'returns 404 for project members with guest role' do it 'returns 404 for project members with guest role' do
sign_in(member) sign_in(member)
project.team << [member, :guest] project.add_guest(member)
go(id: unescaped_parameter_value.to_param) go(id: unescaped_parameter_value.to_param)
expect(response).to have_gitlab_http_status :not_found expect(response).to have_gitlab_http_status :not_found
...@@ -416,7 +416,7 @@ describe Projects::IssuesController do ...@@ -416,7 +416,7 @@ describe Projects::IssuesController do
it "returns #{http_status[:success]} for project members" do it "returns #{http_status[:success]} for project members" do
sign_in(member) sign_in(member)
project.team << [member, :developer] project.add_developer(member)
go(id: unescaped_parameter_value.to_param) go(id: unescaped_parameter_value.to_param)
expect(response).to have_gitlab_http_status http_status[:success] expect(response).to have_gitlab_http_status http_status[:success]
...@@ -450,7 +450,7 @@ describe Projects::IssuesController do ...@@ -450,7 +450,7 @@ describe Projects::IssuesController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
it_behaves_like 'restricted action', success: 200 it_behaves_like 'restricted action', success: 200
...@@ -594,7 +594,7 @@ describe Projects::IssuesController do ...@@ -594,7 +594,7 @@ describe Projects::IssuesController do
let(:deleted_user) { create(:user) } let(:deleted_user) { create(:user) }
before do before do
project.team << [user, :developer] project.add_developer(user)
issue.update!(last_edited_by: deleted_user, last_edited_at: Time.now) issue.update!(last_edited_by: deleted_user, last_edited_at: Time.now)
...@@ -638,7 +638,7 @@ describe Projects::IssuesController do ...@@ -638,7 +638,7 @@ describe Projects::IssuesController do
def post_new_issue(issue_attrs = {}, additional_params = {}) def post_new_issue(issue_attrs = {}, additional_params = {})
sign_in(user) sign_in(user)
project = create(:project, :public) project = create(:project, :public)
project.team << [user, :developer] project.add_developer(user)
post :create, { post :create, {
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
...@@ -655,7 +655,7 @@ describe Projects::IssuesController do ...@@ -655,7 +655,7 @@ describe Projects::IssuesController do
let(:project) { merge_request.source_project } let(:project) { merge_request.source_project }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in user sign_in user
end end
...@@ -829,7 +829,7 @@ describe Projects::IssuesController do ...@@ -829,7 +829,7 @@ describe Projects::IssuesController do
def post_spam def post_spam
admin = create(:admin) admin = create(:admin)
create(:user_agent_detail, subject: issue) create(:user_agent_detail, subject: issue)
project.team << [admin, :master] project.add_master(admin)
sign_in(admin) sign_in(admin)
post :mark_as_spam, { post :mark_as_spam, {
namespace_id: project.namespace, namespace_id: project.namespace,
......
...@@ -374,7 +374,7 @@ describe Projects::JobsController do ...@@ -374,7 +374,7 @@ describe Projects::JobsController do
let(:role) { :master } let(:role) { :master }
before do before do
project.team << [user, role] project.add_role(user, role)
sign_in(user) sign_in(user)
post_erase post_erase
......
...@@ -6,7 +6,7 @@ describe Projects::LabelsController do ...@@ -6,7 +6,7 @@ describe Projects::LabelsController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -5,7 +5,7 @@ describe Projects::MattermostsController do ...@@ -5,7 +5,7 @@ describe Projects::MattermostsController do
let!(:user) { create(:user) } let!(:user) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -6,7 +6,7 @@ describe Projects::MergeRequests::CreationsController do ...@@ -6,7 +6,7 @@ describe Projects::MergeRequests::CreationsController do
let(:fork_project) { create(:forked_project_with_submodules) } let(:fork_project) { create(:forked_project_with_submodules) }
before do before do
fork_project.team << [user, :master] fork_project.add_master(user)
sign_in(user) sign_in(user)
end end
...@@ -86,7 +86,7 @@ describe Projects::MergeRequests::CreationsController do ...@@ -86,7 +86,7 @@ describe Projects::MergeRequests::CreationsController do
let(:other_project) { create(:project, :repository) } let(:other_project) { create(:project, :repository) }
before do before do
other_project.team << [user, :master] other_project.add_master(user)
end end
context 'when the path exists in the diff' do context 'when the path exists in the diff' do
......
...@@ -151,7 +151,7 @@ describe Projects::MergeRequests::DiffsController do ...@@ -151,7 +151,7 @@ describe Projects::MergeRequests::DiffsController do
let(:other_project) { create(:project) } let(:other_project) { create(:project) }
before do before do
other_project.team << [user, :master] other_project.add_master(user)
diff_for_path(old_path: existing_path, new_path: existing_path, project_id: other_project) diff_for_path(old_path: existing_path, new_path: existing_path, project_id: other_project)
end end
......
...@@ -11,7 +11,7 @@ describe Projects::MilestonesController do ...@@ -11,7 +11,7 @@ describe Projects::MilestonesController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
controller.instance_variable_set(:@project, project) controller.instance_variable_set(:@project, project)
end end
......
...@@ -32,7 +32,7 @@ describe Projects::NotesController do ...@@ -32,7 +32,7 @@ describe Projects::NotesController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
it 'passes last_fetched_at from headers to NotesFinder' do it 'passes last_fetched_at from headers to NotesFinder' do
...@@ -351,7 +351,7 @@ describe Projects::NotesController do ...@@ -351,7 +351,7 @@ describe Projects::NotesController do
before do before do
sign_in(note.author) sign_in(note.author)
project.team << [note.author, :developer] project.add_developer(note.author)
end end
it "updates the note" do it "updates the note" do
...@@ -372,7 +372,7 @@ describe Projects::NotesController do ...@@ -372,7 +372,7 @@ describe Projects::NotesController do
context 'user is the author of a note' do context 'user is the author of a note' do
before do before do
sign_in(note.author) sign_in(note.author)
project.team << [note.author, :developer] project.add_developer(note.author)
end end
it "returns status 200 for html" do it "returns status 200 for html" do
...@@ -389,7 +389,7 @@ describe Projects::NotesController do ...@@ -389,7 +389,7 @@ describe Projects::NotesController do
context 'user is not the author of a note' do context 'user is not the author of a note' do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
it "returns status 404" do it "returns status 404" do
...@@ -403,7 +403,7 @@ describe Projects::NotesController do ...@@ -403,7 +403,7 @@ describe Projects::NotesController do
describe 'POST toggle_award_emoji' do describe 'POST toggle_award_emoji' do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
it "toggles the award emoji" do it "toggles the award emoji" do
...@@ -445,7 +445,7 @@ describe Projects::NotesController do ...@@ -445,7 +445,7 @@ describe Projects::NotesController do
context "when the user is authorized to resolve the note" do context "when the user is authorized to resolve the note" do
before do before do
project.team << [user, :developer] project.add_developer(user)
end end
context "when the note is not resolvable" do context "when the note is not resolvable" do
...@@ -506,7 +506,7 @@ describe Projects::NotesController do ...@@ -506,7 +506,7 @@ describe Projects::NotesController do
context "when the user is authorized to resolve the note" do context "when the user is authorized to resolve the note" do
before do before do
project.team << [user, :developer] project.add_developer(user)
end end
context "when the note is not resolvable" do context "when the note is not resolvable" do
......
...@@ -21,7 +21,7 @@ describe Projects::ProjectMembersController do ...@@ -21,7 +21,7 @@ describe Projects::ProjectMembersController do
context 'when user does not have enough rights' do context 'when user does not have enough rights' do
before do before do
project.team << [user, :developer] project.add_developer(user)
end end
it 'returns 404' do it 'returns 404' do
...@@ -37,7 +37,7 @@ describe Projects::ProjectMembersController do ...@@ -37,7 +37,7 @@ describe Projects::ProjectMembersController do
context 'when user has enough rights' do context 'when user has enough rights' do
before do before do
project.team << [user, :master] project.add_master(user)
end end
it 'adds user to members' do it 'adds user to members' do
...@@ -106,7 +106,7 @@ describe Projects::ProjectMembersController do ...@@ -106,7 +106,7 @@ describe Projects::ProjectMembersController do
context 'when member is found' do context 'when member is found' do
context 'when user does not have enough rights' do context 'when user does not have enough rights' do
before do before do
project.team << [user, :developer] project.add_developer(user)
end end
it 'returns 404' do it 'returns 404' do
...@@ -121,7 +121,7 @@ describe Projects::ProjectMembersController do ...@@ -121,7 +121,7 @@ describe Projects::ProjectMembersController do
context 'when user has enough rights' do context 'when user has enough rights' do
before do before do
project.team << [user, :master] project.add_master(user)
end end
it '[HTML] removes user from members' do it '[HTML] removes user from members' do
...@@ -164,7 +164,7 @@ describe Projects::ProjectMembersController do ...@@ -164,7 +164,7 @@ describe Projects::ProjectMembersController do
context 'when member is found' do context 'when member is found' do
context 'and is not an owner' do context 'and is not an owner' do
before do before do
project.team << [user, :developer] project.add_developer(user)
end end
it 'removes user from members' do it 'removes user from members' do
...@@ -181,7 +181,7 @@ describe Projects::ProjectMembersController do ...@@ -181,7 +181,7 @@ describe Projects::ProjectMembersController do
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:project, namespace: user.namespace) }
before do before do
project.team << [user, :master] project.add_master(user)
end end
it 'does not remove himself from the project' do it 'does not remove himself from the project' do
...@@ -248,7 +248,7 @@ describe Projects::ProjectMembersController do ...@@ -248,7 +248,7 @@ describe Projects::ProjectMembersController do
context 'when member is found' do context 'when member is found' do
context 'when user does not have enough rights' do context 'when user does not have enough rights' do
before do before do
project.team << [user, :developer] project.add_developer(user)
end end
it 'returns 404' do it 'returns 404' do
...@@ -263,7 +263,7 @@ describe Projects::ProjectMembersController do ...@@ -263,7 +263,7 @@ describe Projects::ProjectMembersController do
context 'when user has enough rights' do context 'when user has enough rights' do
before do before do
project.team << [user, :master] project.add_master(user)
end end
it 'adds user to members' do it 'adds user to members' do
...@@ -285,8 +285,8 @@ describe Projects::ProjectMembersController do ...@@ -285,8 +285,8 @@ describe Projects::ProjectMembersController do
let(:member) { create(:user) } let(:member) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
another_project.team << [member, :guest] another_project.add_guest(member)
sign_in(user) sign_in(user)
end end
...@@ -300,7 +300,7 @@ describe Projects::ProjectMembersController do ...@@ -300,7 +300,7 @@ describe Projects::ProjectMembersController do
context 'when user can access source project members' do context 'when user can access source project members' do
before do before do
another_project.team << [user, :guest] another_project.add_guest(user)
end end
include_context 'import applied' include_context 'import applied'
...@@ -332,7 +332,7 @@ describe Projects::ProjectMembersController do ...@@ -332,7 +332,7 @@ describe Projects::ProjectMembersController do
context 'when creating owner' do context 'when creating owner' do
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
...@@ -348,7 +348,7 @@ describe Projects::ProjectMembersController do ...@@ -348,7 +348,7 @@ describe Projects::ProjectMembersController do
context 'when create master' do context 'when create master' do
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -6,7 +6,7 @@ describe Projects::RefsController do ...@@ -6,7 +6,7 @@ describe Projects::RefsController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
describe 'GET #logs_tree' do describe 'GET #logs_tree' do
......
...@@ -7,7 +7,7 @@ describe Projects::ReleasesController do ...@@ -7,7 +7,7 @@ describe Projects::ReleasesController do
let!(:tag) { release.tag } let!(:tag) { release.tag }
before do before do
project.team << [user, :developer] project.add_developer(user)
sign_in(user) sign_in(user)
end end
......
...@@ -17,7 +17,7 @@ describe Projects::RepositoriesController do ...@@ -17,7 +17,7 @@ describe Projects::RepositoriesController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :developer] project.add_developer(user)
sign_in(user) sign_in(user)
end end
......
...@@ -9,7 +9,7 @@ describe Projects::ServicesController do ...@@ -9,7 +9,7 @@ describe Projects::ServicesController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
end end
describe '#test' do describe '#test' do
......
...@@ -5,7 +5,7 @@ describe Projects::Settings::CiCdController do ...@@ -5,7 +5,7 @@ describe Projects::Settings::CiCdController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -5,7 +5,7 @@ describe Projects::Settings::IntegrationsController do ...@@ -5,7 +5,7 @@ describe Projects::Settings::IntegrationsController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -5,7 +5,7 @@ describe Projects::Settings::SlacksController do ...@@ -5,7 +5,7 @@ describe Projects::Settings::SlacksController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -8,7 +8,7 @@ describe Projects::TemplatesController do ...@@ -8,7 +8,7 @@ describe Projects::TemplatesController do
let(:body) { JSON.parse(response.body) } let(:body) { JSON.parse(response.body) }
before do before do
project.team << [user, :developer] project.add_developer(user)
sign_in(user) sign_in(user)
end end
......
...@@ -20,7 +20,7 @@ describe Projects::TodosController do ...@@ -20,7 +20,7 @@ describe Projects::TodosController do
context 'when authorized' do context 'when authorized' do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
it 'creates todo for issue' do it 'creates todo for issue' do
...@@ -88,7 +88,7 @@ describe Projects::TodosController do ...@@ -88,7 +88,7 @@ describe Projects::TodosController do
context 'when authorized' do context 'when authorized' do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
it 'creates todo for merge request' do it 'creates todo for merge request' do
......
...@@ -7,7 +7,7 @@ describe Projects::TreeController do ...@@ -7,7 +7,7 @@ describe Projects::TreeController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
controller.instance_variable_set(:@project, project) controller.instance_variable_set(:@project, project)
end end
......
...@@ -6,7 +6,7 @@ describe Projects::VariablesController do ...@@ -6,7 +6,7 @@ describe Projects::VariablesController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
end end
describe 'POST #create' do describe 'POST #create' do
......
...@@ -102,7 +102,7 @@ describe ProjectsController do ...@@ -102,7 +102,7 @@ describe ProjectsController do
render_views render_views
before do before do
project.team << [user, :developer] project.add_developer(user)
project.project_feature.update_attribute(:repository_access_level, ProjectFeature::DISABLED) project.project_feature.update_attribute(:repository_access_level, ProjectFeature::DISABLED)
end end
...@@ -236,7 +236,7 @@ describe ProjectsController do ...@@ -236,7 +236,7 @@ describe ProjectsController do
allow_any_instance_of(EE::Project) allow_any_instance_of(EE::Project)
.to receive(:above_size_limit?).and_return(true) .to receive(:above_size_limit?).and_return(true)
project.team << [user, :master] project.add_master(user)
end end
it 'shows the over size limit warning message for project members' do it 'shows the over size limit warning message for project members' do
...@@ -460,7 +460,7 @@ describe ProjectsController do ...@@ -460,7 +460,7 @@ describe ProjectsController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
allow(Gitlab.config.incoming_email).to receive(:enabled).and_return(true) allow(Gitlab.config.incoming_email).to receive(:enabled).and_return(true)
end end
...@@ -488,7 +488,7 @@ describe ProjectsController do ...@@ -488,7 +488,7 @@ describe ProjectsController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
allow(Gitlab.config.incoming_email).to receive(:enabled).and_return(true) allow(Gitlab.config.incoming_email).to receive(:enabled).and_return(true)
end end
......
...@@ -265,13 +265,13 @@ describe UploadsController do ...@@ -265,13 +265,13 @@ describe UploadsController do
context "when the user has access to the project" do context "when the user has access to the project" do
before do before do
project.team << [user, :master] project.add_master(user)
end end
context "when the user is blocked" do context "when the user is blocked" do
before do before do
user.block user.block
project.team << [user, :master] project.add_master(user)
end end
it "redirects to the sign in page" do it "redirects to the sign in page" do
...@@ -465,13 +465,13 @@ describe UploadsController do ...@@ -465,13 +465,13 @@ describe UploadsController do
context "when the user has access to the project" do context "when the user has access to the project" do
before do before do
project.team << [user, :master] project.add_master(user)
end end
context "when the user is blocked" do context "when the user is blocked" do
before do before do
user.block user.block
project.team << [user, :master] project.add_master(user)
end end
it "redirects to the sign in page" do it "redirects to the sign in page" do
......
...@@ -91,7 +91,7 @@ describe UsersController do ...@@ -91,7 +91,7 @@ describe UsersController do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
push_data = Gitlab::DataBuilder::Push.build_sample(project, user) push_data = Gitlab::DataBuilder::Push.build_sample(project, user)
...@@ -117,7 +117,7 @@ describe UsersController do ...@@ -117,7 +117,7 @@ describe UsersController do
allow_any_instance_of(User).to receive(:contributed_projects_ids).and_return([project.id]) allow_any_instance_of(User).to receive(:contributed_projects_ids).and_return([project.id])
sign_in(user) sign_in(user)
project.team << [user, :developer] project.add_developer(user)
end end
it 'assigns @calendar_date' do it 'assigns @calendar_date' do
......
...@@ -5,7 +5,7 @@ describe Projects::BoardsController do ...@@ -5,7 +5,7 @@ describe Projects::BoardsController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -10,7 +10,7 @@ shared_examples 'approvals' do ...@@ -10,7 +10,7 @@ shared_examples 'approvals' do
before do before do
merge_request.update_attribute :approvals_before_merge, 2 merge_request.update_attribute :approvals_before_merge, 2
project.team << [approver.user, :developer] project.add_developer(approver.user)
end end
describe 'approve' do describe 'approve' do
......
...@@ -415,7 +415,7 @@ describe 'Scoped issue boards', :js do ...@@ -415,7 +415,7 @@ describe 'Scoped issue boards', :js do
before do before do
stub_licensed_features(scoped_issue_boards: false) stub_licensed_features(scoped_issue_boards: false)
project.team << [user, :master] project.add_master(user)
login_as(user) login_as(user)
visit project_boards_path(project) visit project_boards_path(project)
......
...@@ -23,7 +23,7 @@ describe 'Issue Boards', :js do ...@@ -23,7 +23,7 @@ describe 'Issue Boards', :js do
before do before do
stub_licensed_features(multiple_issue_assignees: true) stub_licensed_features(multiple_issue_assignees: true)
project.team << [user, :master] project.add_master(user)
project.team.add_developer(user2) project.team.add_developer(user2)
gitlab_sign_in(user) gitlab_sign_in(user)
......
...@@ -14,8 +14,8 @@ describe 'New/edit issue', :js do ...@@ -14,8 +14,8 @@ describe 'New/edit issue', :js do
let!(:issue) { create(:issue, project: project, assignees: [user], milestone: milestone) } let!(:issue) { create(:issue, project: project, assignees: [user], milestone: milestone) }
before do before do
project.team << [user, :master] project.add_master(user)
project.team << [user2, :master] project.add_master(user2)
allow_any_instance_of(ApplicationHelper).to receive(:collapsed_sidebar?).and_return(true) allow_any_instance_of(ApplicationHelper).to receive(:collapsed_sidebar?).and_return(true)
......
...@@ -35,7 +35,7 @@ describe 'Project settings > [EE] repository' do ...@@ -35,7 +35,7 @@ describe 'Project settings > [EE] repository' do
let(:user2) { create(:user) } let(:user2) { create(:user) }
before do before do
project.team << [user2, :master] project.add_master(user2)
visit project_settings_repository_path(project) visit project_settings_repository_path(project)
end end
......
...@@ -8,7 +8,7 @@ describe 'Project settings > [EE] Merge Requests', :js do ...@@ -8,7 +8,7 @@ describe 'Project settings > [EE] Merge Requests', :js do
before do before do
gitlab_sign_in(user) gitlab_sign_in(user)
project.team << [user, :master] project.add_master(user)
end end
context 'issuable default templates feature not available' do context 'issuable default templates feature not available' do
......
...@@ -11,7 +11,7 @@ describe 'Project settings > [EE] Merge Requests', :js do ...@@ -11,7 +11,7 @@ describe 'Project settings > [EE] Merge Requests', :js do
before do before do
sign_in(user) sign_in(user)
project.team << [user, :master] project.add_master(user)
group.add_developer(user) group.add_developer(user)
group.add_developer(group_member) group.add_developer(group_member)
end end
......
...@@ -5,7 +5,7 @@ describe 'Project settings > [EE] repository' do ...@@ -5,7 +5,7 @@ describe 'Project settings > [EE] repository' do
let(:project) { create(:project_empty_repo) } let(:project) { create(:project_empty_repo) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -12,7 +12,7 @@ describe 'Project variables EE', :js do ...@@ -12,7 +12,7 @@ describe 'Project variables EE', :js do
variable_environment_scope: variable_environment_scope) variable_environment_scope: variable_environment_scope)
login_as(user) login_as(user)
project.team << [user, :master] project.add_master(user)
project.variables << variable project.variables << variable
visit project_settings_ci_cd_path(project) visit project_settings_ci_cd_path(project)
......
...@@ -25,7 +25,7 @@ describe API::Issues, :mailer do ...@@ -25,7 +25,7 @@ describe API::Issues, :mailer do
set(:milestone) { create(:milestone, title: '1.0.0', project: project) } set(:milestone) { create(:milestone, title: '1.0.0', project: project) }
before(:all) do before(:all) do
project.team << [user, :reporter] project.add_reporter(user)
end end
describe "GET /issues" do describe "GET /issues" do
......
...@@ -5,7 +5,7 @@ describe Issues::BuildService do ...@@ -5,7 +5,7 @@ describe Issues::BuildService do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.team << [user, :developer] project.add_developer(user)
end end
context 'with an issue template' do context 'with an issue template' do
......
...@@ -13,7 +13,7 @@ describe IssueLinks::CreateService do ...@@ -13,7 +13,7 @@ describe IssueLinks::CreateService do
before do before do
stub_licensed_features(related_issues: true) stub_licensed_features(related_issues: true)
project.team << [user, :developer] project.add_developer(user)
end end
subject { described_class.new(issue, user, params).execute } subject { described_class.new(issue, user, params).execute }
...@@ -89,7 +89,7 @@ describe IssueLinks::CreateService do ...@@ -89,7 +89,7 @@ describe IssueLinks::CreateService do
end end
before do before do
another_project.team << [user, :developer] another_project.add_developer(user)
end end
it 'creates relationships' do it 'creates relationships' do
......
...@@ -9,7 +9,7 @@ describe IssueLinks::ListService do ...@@ -9,7 +9,7 @@ describe IssueLinks::ListService do
before do before do
stub_licensed_features(related_issues: true) stub_licensed_features(related_issues: true)
project.team << [user, user_role] project.add_role(user, user_role)
end end
describe '#execute' do describe '#execute' do
......
...@@ -4,7 +4,7 @@ RSpec.shared_examples "protected tags > access control > EE" do ...@@ -4,7 +4,7 @@ RSpec.shared_examples "protected tags > access control > EE" do
let(:roles) { ProtectedRefAccess::HUMAN_ACCESS_LEVELS.except(0) } let(:roles) { ProtectedRefAccess::HUMAN_ACCESS_LEVELS.except(0) }
before do before do
users.each { |user| project.team << [user, :developer] } users.each { |user| project.add_developer(user) }
groups.each { |group| project.project_group_links.create(group: group, group_access: Gitlab::Access::DEVELOPER) } groups.each { |group| project.project_group_links.create(group: group, group_access: Gitlab::Access::DEVELOPER) }
end end
...@@ -74,7 +74,7 @@ RSpec.shared_examples "protected tags > access control > EE" do ...@@ -74,7 +74,7 @@ RSpec.shared_examples "protected tags > access control > EE" do
it "prepends selected users that can create" do it "prepends selected users that can create" do
users = create_list(:user, 21) users = create_list(:user, 21)
users.each { |user| project.team << [user, :developer] } users.each { |user| project.add_developer(user) }
visit project_protected_tags_path(project) visit project_protected_tags_path(project)
......
...@@ -8,7 +8,7 @@ shared_examples "protected branches > access control > EE" do ...@@ -8,7 +8,7 @@ shared_examples "protected branches > access control > EE" do
let(:groups) { create_list(:group, 5) } let(:groups) { create_list(:group, 5) }
before do before do
users.each { |user| project.team << [user, :developer] } users.each { |user| project.add_developer(user) }
groups.each { |group| project.project_group_links.create(group: group, group_access: Gitlab::Access::DEVELOPER) } groups.each { |group| project.project_group_links.create(group: group, group_access: Gitlab::Access::DEVELOPER) }
end end
...@@ -83,7 +83,7 @@ shared_examples "protected branches > access control > EE" do ...@@ -83,7 +83,7 @@ shared_examples "protected branches > access control > EE" do
it "prepends selected users that can #{git_operation} to" do it "prepends selected users that can #{git_operation} to" do
users = create_list(:user, 21) users = create_list(:user, 21)
users.each { |user| project.team << [user, :developer] } users.each { |user| project.add_developer(user) }
visit project_protected_branches_path(project) visit project_protected_branches_path(project)
......
...@@ -14,9 +14,9 @@ describe 'GlobalSearch' do ...@@ -14,9 +14,9 @@ describe 'GlobalSearch' do
stub_application_setting(elasticsearch_search: true, elasticsearch_indexing: true) stub_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
Gitlab::Elastic::Helper.create_empty_index Gitlab::Elastic::Helper.create_empty_index
project.team << [member, :developer] project.add_developer(member)
project.team << [external_member, :developer] project.add_developer(external_member)
project.team << [guest, :guest] project.add_guest(guest)
end end
after do after do
......
...@@ -88,7 +88,7 @@ describe "Admin::Projects" do ...@@ -88,7 +88,7 @@ describe "Admin::Projects" do
describe 'add admin himself to a project' do describe 'add admin himself to a project' do
before do before do
project.team << [user, :master] project.add_master(user)
end end
it 'adds admin a to a project as developer', :js do it 'adds admin a to a project as developer', :js do
...@@ -110,8 +110,8 @@ describe "Admin::Projects" do ...@@ -110,8 +110,8 @@ describe "Admin::Projects" do
describe 'admin remove himself from a project' do describe 'admin remove himself from a project' do
before do before do
project.team << [user, :master] project.add_master(user)
project.team << [current_user, :developer] project.add_developer(current_user)
end end
it 'removes admin from the project' do it 'removes admin from the project' do
......
...@@ -8,8 +8,8 @@ describe "Dashboard Issues Feed" do ...@@ -8,8 +8,8 @@ describe "Dashboard Issues Feed" do
let!(:project2) { create(:project) } let!(:project2) { create(:project) }
before do before do
project1.team << [user, :master] project1.add_master(user)
project2.team << [user, :master] project2.add_master(user)
end end
describe "atom feed" do describe "atom feed" do
......
...@@ -26,7 +26,7 @@ describe "Dashboard Feed" do ...@@ -26,7 +26,7 @@ describe "Dashboard Feed" do
let(:note) { create(:note, noteable: issue, author: user, note: 'Bug confirmed', project: project) } let(:note) { create(:note, noteable: issue, author: user, note: 'Bug confirmed', project: project) }
before do before do
project.team << [user, :master] project.add_master(user)
issue_event(issue, user) issue_event(issue, user)
note_event(note, user) note_event(note, user)
visit dashboard_projects_path(:atom, rss_token: user.rss_token) visit dashboard_projects_path(:atom, rss_token: user.rss_token)
......
...@@ -9,7 +9,7 @@ describe 'Issues Feed' do ...@@ -9,7 +9,7 @@ describe 'Issues Feed' do
let!(:issue) { create(:issue, author: user, assignees: [assignee], project: project) } let!(:issue) { create(:issue, author: user, assignees: [assignee], project: project) }
before do before do
project.team << [user, :developer] project.add_developer(user)
group.add_developer(user) group.add_developer(user)
end end
......
...@@ -47,7 +47,7 @@ describe "User Feed" do ...@@ -47,7 +47,7 @@ describe "User Feed" do
let!(:push_event_payload) { create(:push_event_payload, event: push_event) } let!(:push_event_payload) { create(:push_event_payload, event: push_event) }
before do before do
project.team << [user, :master] project.add_master(user)
issue_event(issue, user) issue_event(issue, user)
note_event(note, user) note_event(note, user)
merge_request_event(merge_request, user) merge_request_event(merge_request, user)
......
...@@ -52,7 +52,7 @@ describe 'Auto deploy' do ...@@ -52,7 +52,7 @@ describe 'Auto deploy' do
context 'when user configured kubernetes from Integration > Kubernetes' do context 'when user configured kubernetes from Integration > Kubernetes' do
before do before do
create :kubernetes_service, project: project create :kubernetes_service, project: project
project.team << [user, :master] project.add_master(user)
sign_in user sign_in user
end end
...@@ -65,7 +65,7 @@ describe 'Auto deploy' do ...@@ -65,7 +65,7 @@ describe 'Auto deploy' do
context 'when user configured kubernetes from CI/CD > Clusters' do context 'when user configured kubernetes from CI/CD > Clusters' do
before do before do
create(:cluster, :provided_by_gcp, projects: [project]) create(:cluster, :provided_by_gcp, projects: [project])
project.team << [user, :master] project.add_master(user)
sign_in user sign_in user
end end
......
...@@ -12,7 +12,7 @@ describe 'Issue Boards add issue modal', :js do ...@@ -12,7 +12,7 @@ describe 'Issue Boards add issue modal', :js do
let!(:issue2) { create(:issue, project: project, title: 'hij', description: 'klm') } let!(:issue2) { create(:issue, project: project, title: 'hij', description: 'klm') }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
......
...@@ -13,8 +13,8 @@ describe 'Issue Boards', :js do ...@@ -13,8 +13,8 @@ describe 'Issue Boards', :js do
let!(:user2) { create(:user) } let!(:user2) { create(:user) }
before do before do
project.team << [user, :master] project.add_master(user)
project.team << [user2, :master] project.add_master(user2)
set_cookie('sidebar_collapsed', 'true') set_cookie('sidebar_collapsed', 'true')
...@@ -569,7 +569,7 @@ describe 'Issue Boards', :js do ...@@ -569,7 +569,7 @@ describe 'Issue Boards', :js do
let(:user_guest) { create(:user) } let(:user_guest) { create(:user) }
before do before do
project.team << [user_guest, :guest] project.add_guest(user_guest)
sign_out(:user) sign_out(:user)
sign_in(user_guest) sign_in(user_guest)
visit project_board_path(project, board) visit project_board_path(project, board)
......
...@@ -13,7 +13,7 @@ describe 'Issue Boards', :js do ...@@ -13,7 +13,7 @@ describe 'Issue Boards', :js do
let!(:issue3) { create(:labeled_issue, project: project, title: 'testing 3', labels: [label], relative_position: 1) } let!(:issue3) { create(:labeled_issue, project: project, title: 'testing 3', labels: [label], relative_position: 1) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
......
...@@ -10,7 +10,7 @@ describe 'Issue Boards add issue modal filtering', :js do ...@@ -10,7 +10,7 @@ describe 'Issue Boards add issue modal filtering', :js do
let!(:issue1) { create(:issue, project: project) } let!(:issue1) { create(:issue, project: project) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
end end
...@@ -76,7 +76,7 @@ describe 'Issue Boards add issue modal filtering', :js do ...@@ -76,7 +76,7 @@ describe 'Issue Boards add issue modal filtering', :js do
let!(:issue) { create(:issue, project: project, author: user2) } let!(:issue) { create(:issue, project: project, author: user2) }
before do before do
project.team << [user2, :developer] project.add_developer(user2)
visit_board visit_board
end end
...@@ -99,7 +99,7 @@ describe 'Issue Boards add issue modal filtering', :js do ...@@ -99,7 +99,7 @@ describe 'Issue Boards add issue modal filtering', :js do
let!(:issue) { create(:issue, project: project, assignees: [user2]) } let!(:issue) { create(:issue, project: project, assignees: [user2]) }
before do before do
project.team << [user2, :developer] project.add_developer(user2)
visit_board visit_board
end end
......
...@@ -14,7 +14,7 @@ describe 'Multiple Issue Boards', :js do ...@@ -14,7 +14,7 @@ describe 'Multiple Issue Boards', :js do
context 'authorized user' do context 'authorized user' do
before do before do
project.team << [user, :master] project.add_master(user)
login_as(user) login_as(user)
...@@ -151,7 +151,7 @@ describe 'Multiple Issue Boards', :js do ...@@ -151,7 +151,7 @@ describe 'Multiple Issue Boards', :js do
context 'with multiple issue boards disabled' do context 'with multiple issue boards disabled' do
before do before do
stub_licensed_features(multiple_issue_boards: false) stub_licensed_features(multiple_issue_boards: false)
project.team << [user, :master] project.add_master(user)
login_as(user) login_as(user)
end end
......
...@@ -8,7 +8,7 @@ describe 'Issue Boards new issue', :js do ...@@ -8,7 +8,7 @@ describe 'Issue Boards new issue', :js do
context 'authorized user' do context 'authorized user' do
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
......
...@@ -26,7 +26,7 @@ describe 'Commits' do ...@@ -26,7 +26,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.add_reporter(user)
end end
describe 'Commit builds' do describe 'Commit builds' do
...@@ -51,7 +51,7 @@ describe 'Commits' do ...@@ -51,7 +51,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.add_developer(user)
end end
describe 'Project commits' do describe 'Project commits' do
...@@ -145,7 +145,7 @@ describe 'Commits' do ...@@ -145,7 +145,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.add_reporter(user)
build.update_attributes(legacy_artifacts_file: artifacts_file) build.update_attributes(legacy_artifacts_file: artifacts_file)
visit pipeline_path(pipeline) visit pipeline_path(pipeline)
end end
...@@ -188,7 +188,7 @@ describe 'Commits' do ...@@ -188,7 +188,7 @@ describe 'Commits' do
let(:branch_name) { 'master' } let(:branch_name) { 'master' }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
visit project_commits_path(project, branch_name) visit project_commits_path(project, branch_name)
end end
......
...@@ -95,7 +95,7 @@ feature 'Cycle Analytics', :js do ...@@ -95,7 +95,7 @@ feature 'Cycle Analytics', :js do
before do before do
user.update_attribute(:preferred_language, 'es') user.update_attribute(:preferred_language, 'es')
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
visit project_cycle_analytics_path(project) visit project_cycle_analytics_path(project)
wait_for_requests wait_for_requests
......
...@@ -6,8 +6,8 @@ RSpec.describe 'Dashboard Archived Project' do ...@@ -6,8 +6,8 @@ RSpec.describe 'Dashboard Archived Project' do
let(:archived_project) { create(:project, :archived) } let(:archived_project) { create(:project, :archived) }
before do before do
project.team << [user, :master] project.add_master(user)
archived_project.team << [user, :master] archived_project.add_master(user)
sign_in(user) sign_in(user)
......
...@@ -8,7 +8,7 @@ feature 'Tooltips on .timeago dates', :js do ...@@ -8,7 +8,7 @@ feature 'Tooltips on .timeago dates', :js do
context 'on the activity tab' do context 'on the activity tab' do
before do before do
project.team << [user, :master] project.add_master(user)
Event.create( project: project, author_id: user.id, action: Event::JOINED, Event.create( project: project, author_id: user.id, action: Event::JOINED,
updated_at: created_date, created_at: created_date) updated_at: created_date, created_at: created_date)
...@@ -27,7 +27,7 @@ feature 'Tooltips on .timeago dates', :js do ...@@ -27,7 +27,7 @@ feature 'Tooltips on .timeago dates', :js do
context 'on the snippets tab' do context 'on the snippets tab' do
before do before do
project.team << [user, :master] project.add_master(user)
create(:snippet, author: user, updated_at: created_date, created_at: created_date) create(:snippet, author: user, updated_at: created_date, created_at: created_date)
sign_in user sign_in user
......
...@@ -12,7 +12,7 @@ RSpec.describe 'Dashboard Issues' do ...@@ -12,7 +12,7 @@ RSpec.describe 'Dashboard Issues' do
let!(:other_issue) { create :issue, project: project } let!(:other_issue) { create :issue, project: project }
before do before do
[project, project_with_issues_disabled].each { |project| project.team << [current_user, :master] } [project, project_with_issues_disabled].each { |project| project.add_master(current_user) }
sign_in(current_user) sign_in(current_user)
visit issues_dashboard_path(assignee_id: current_user.id) visit issues_dashboard_path(assignee_id: current_user.id)
end end
......
...@@ -16,7 +16,7 @@ feature 'Dashboard > Milestones' do ...@@ -16,7 +16,7 @@ feature 'Dashboard > Milestones' do
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:project, namespace: user.namespace) }
let!(:milestone) { create(:milestone, project: project) } let!(:milestone) { create(:milestone, project: project) }
before do before do
project.team << [user, :master] project.add_master(user)
sign_in(user) sign_in(user)
visit dashboard_milestones_path visit dashboard_milestones_path
end end
......
...@@ -5,7 +5,7 @@ feature 'Project member activity', :js do ...@@ -5,7 +5,7 @@ feature 'Project member activity', :js do
let(:project) { create(:project, :public, name: 'x', namespace: user.namespace) } let(:project) { create(:project, :public, name: 'x', namespace: user.namespace) }
before do before do
project.team << [user, :master] project.add_master(user)
end end
def visit_activities_and_wait_with_event(event_type) def visit_activities_and_wait_with_event(event_type)
......
...@@ -6,7 +6,7 @@ feature 'Dashboard Projects' do ...@@ -6,7 +6,7 @@ feature 'Dashboard Projects' do
let(:project2) { create(:project, :public, name: 'Community project') } let(:project2) { create(:project, :public, name: 'Community project') }
before do before do
project.team << [user, :developer] project.add_developer(user)
sign_in(user) sign_in(user)
end end
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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