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

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