Commit 6c967c2b authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '36782-replace-team-user-role-with-add_role-user-in-specs' into 'master'

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

Closes #36782

See merge request gitlab-org/gitlab-ce!16069
parents 5512f0aa 27c95364
......@@ -226,7 +226,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)
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'
......
......@@ -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
......
......@@ -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
......
......@@ -41,7 +41,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)
@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' 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
......
......@@ -9,7 +9,7 @@ describe Projects::ImportsController do
before do
sign_in(user)
project.team << [user, :master]
project.add_master(user)
end
it 'renders template' do
......@@ -30,7 +30,7 @@ describe Projects::ImportsController do
before do
sign_in(user)
project.team << [user, :master]
project.add_master(user)
end
context 'when import is in progress' 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 'cannot 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
......
......@@ -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
......@@ -437,7 +437,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
......@@ -465,7 +465,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
......
......@@ -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)
......
......@@ -11,8 +11,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')
......@@ -551,7 +551,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
......
......@@ -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
......
......@@ -15,8 +15,8 @@ feature 'Dashboard > User filters todos', :js do
create(:todo, user: user_1, author: user_2, project: project_1, target: issue, action: 1)
create(:todo, user: user_1, author: user_1, project: project_2, target: merge_request, action: 2)
project_1.team << [user_1, :developer]
project_2.team << [user_1, :developer]
project_1.add_developer(user_1)
project_2.add_developer(user_1)
sign_in(user_1)
visit dashboard_todos_path
end
......@@ -66,8 +66,8 @@ feature 'Dashboard > User filters todos', :js do
create(:todo, user: user_1, author: user_3, project: project_1, target: issue, action: 1, state: :done)
create(:todo, user: user_1, author: user_4, project: project_2, target: merge_request, action: 2, state: :done)
project_1.team << [user_3, :developer]
project_2.team << [user_4, :developer]
project_1.add_developer(user_3)
project_2.add_developer(user_4)
visit dashboard_todos_path(state: 'done')
......
......@@ -9,7 +9,7 @@ feature 'Dashboard > User sorts todos' do
let(:label_3) { create(:label, title: 'label_3', project: project, priority: 3) }
before do
project.team << [user, :developer]
project.add_developer(user)
end
context 'sort options' do
......
......@@ -7,14 +7,14 @@ describe 'Dashboard > User filters projects' do
let(:project2) { create(:project, name: 'Treasure', namespace: user2.namespace) }
before do
project.team << [user, :master]
project.add_master(user)
sign_in(user)
end
describe 'filtering personal projects' do
before do
project2.team << [user, :developer]
project2.add_developer(user)
visit dashboard_projects_path
end
......
......@@ -5,7 +5,7 @@ feature 'Global search' do
let(:project) { create(:project, namespace: user.namespace) }
before do
project.team << [user, :master]
project.add_master(user)
sign_in(user)
end
......
......@@ -11,7 +11,7 @@ describe 'Awards Emoji' do
context 'authorized user' do
before do
project.team << [user, :master]
project.add_master(user)
sign_in(user)
end
......
......@@ -11,7 +11,7 @@ feature 'Issues > Labels bulk assignment' do
context 'as an allowed user', :js do
before do
project.team << [user, :master]
project.add_master(user)
sign_in user
end
......
......@@ -8,7 +8,7 @@ feature 'Resolving all open discussions in a merge request from an issue', :js d
describe 'as a user with access to the project' do
before do
project.team << [user, :master]
project.add_master(user)
sign_in user
visit project_merge_request_path(project, merge_request)
end
......@@ -81,7 +81,7 @@ feature 'Resolving all open discussions in a merge request from an issue', :js d
describe 'as a reporter' do
before do
project.team << [user, :reporter]
project.add_reporter(user)
sign_in user
visit new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid)
end
......
......@@ -8,7 +8,7 @@ feature 'Resolve an open discussion in a merge request by creating an issue' do
describe 'As a user with access to the project' do
before do
project.team << [user, :master]
project.add_master(user)
sign_in user
visit project_merge_request_path(project, merge_request)
end
......@@ -65,7 +65,7 @@ feature 'Resolve an open discussion in a merge request by creating an issue' do
describe 'as a reporter' do
before do
project.team << [user, :reporter]
project.add_reporter(user)
sign_in user
visit new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid,
discussion_to_resolve: discussion.id)
......
......@@ -20,9 +20,9 @@ describe 'Dropdown assignee', :js do
end
before do
project.team << [user, :master]
project.team << [user_john, :master]
project.team << [user_jacob, :master]
project.add_master(user)
project.add_master(user_john)
project.add_master(user_jacob)
sign_in(user)
create(:issue, project: project)
......@@ -222,7 +222,7 @@ describe 'Dropdown assignee', :js do
expect(initial_size).to be > 0
new_user = create(:user)
project.team << [new_user, :master]
project.add_master(new_user)
find('.filtered-search-box .clear-search').click
filtered_search.set('assignee')
filtered_search.send_keys(':')
......
......@@ -28,9 +28,9 @@ describe 'Dropdown author', :js do
end
before do
project.team << [user, :master]
project.team << [user_john, :master]
project.team << [user_jacob, :master]
project.add_master(user)
project.add_master(user_john)
project.add_master(user_jacob)
sign_in(user)
create(:issue, project: project)
......@@ -195,7 +195,7 @@ describe 'Dropdown author', :js do
expect(initial_size).to be > 0
new_user = create(:user)
project.team << [new_user, :master]
project.add_master(new_user)
find('.filtered-search-box .clear-search').click
filtered_search.set('author')
send_keys_to_filtered_search(':')
......
......@@ -28,7 +28,7 @@ describe 'Dropdown emoji', :js do
end
before do
project.team << [user, :master]
project.add_master(user)
create_list(:award_emoji, 2, user: user, name: 'thumbsup')
create_list(:award_emoji, 1, user: user, name: 'thumbsdown')
create_list(:award_emoji, 3, user: user, name: 'star')
......
......@@ -13,7 +13,7 @@ describe 'Dropdown hint', :js do
end
before do
project.team << [user, :master]
project.add_master(user)
create(:issue, project: project)
end
......
......@@ -29,7 +29,7 @@ describe 'Dropdown milestone', :js do
end
before do
project.team << [user, :master]
project.add_master(user)
sign_in(user)
create(:issue, project: project)
......
......@@ -8,7 +8,7 @@ describe 'Search bar', :js do
let(:filtered_search) { find('.filtered-search') }
before do
project.team << [user, :master]
project.add_master(user)
sign_in(user)
create(:issue, project: project)
......
......@@ -13,8 +13,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)
sign_in(user)
end
......
......@@ -7,7 +7,7 @@ feature 'GFM autocomplete', :js do
let(:issue) { create(:issue, project: project) }
before do
project.team << [user, :master]
project.add_master(user)
sign_in(user)
visit project_issue_path(project, issue)
......
......@@ -18,7 +18,7 @@ feature 'Issue Sidebar' do
let(:issue2) { create(:issue, project: project, author: user2) }
before do
project.team << [user, :developer]
project.add_developer(user)
visit_issue(project, issue2)
find('.block.assignee .edit-link').click
......@@ -78,7 +78,7 @@ feature 'Issue Sidebar' do
context 'as a allowed user' do
before do
project.team << [user, :developer]
project.add_developer(user)
visit_issue(project, issue)
end
......@@ -156,7 +156,7 @@ feature 'Issue Sidebar' do
context 'as a guest' do
before do
project.team << [user, :guest]
project.add_guest(user)
visit_issue(project, issue)
end
......
......@@ -13,7 +13,7 @@ feature 'issue move to another project' do
context 'user does not have permission to move issue' do
background do
old_project.team << [user, :guest]
old_project.add_guest(user)
visit issue_path(issue)
end
......@@ -31,8 +31,8 @@ feature 'issue move to another project' do
let(:cross_reference) { old_project.to_reference(new_project) }
background do
old_project.team << [user, :reporter]
new_project.team << [user, :reporter]
old_project.add_reporter(user)
new_project.add_reporter(user)
visit issue_path(issue)
end
......@@ -50,7 +50,7 @@ feature 'issue move to another project' do
end
scenario 'searching project dropdown', :js do
new_project_search.team << [user, :reporter]
new_project_search.add_reporter(user)
find('.js-move-issue').click
wait_for_requests
......@@ -66,7 +66,7 @@ feature 'issue move to another project' do
context 'user does not have permission to move the issue to a project', :js do
let!(:private_project) { create(:project, :private) }
let(:another_project) { create(:project) }
background { another_project.team << [user, :guest] }
background { another_project.add_guest(user) }
scenario 'browsing projects in projects select' do
find('.js-move-issue').click
......
......@@ -8,7 +8,7 @@ describe 'Create notes on issues', :js do
let(:note_text) { "Check #{mention.to_reference}" }
before do
project.team << [user, :developer]
project.add_developer(user)
sign_in(user)
visit project_issue_path(project, issue)
......
......@@ -17,7 +17,7 @@ describe 'New issue', :js do
recaptcha_private_key: 'test private key'
)
project.team << [user, :master]
project.add_master(user)
sign_in(user)
end
......
......@@ -6,7 +6,7 @@ feature 'Manually create a todo item from issue', :js do
let!(:user) { create(:user)}
before do
project.team << [user, :master]
project.add_master(user)
sign_in(user)
visit project_issue_path(project, issue)
end
......
......@@ -6,7 +6,7 @@ feature 'Multiple issue updating from issues#index', :js do
let!(:user) { create(:user)}
before do
project.team << [user, :master]
project.add_master(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.
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