Commit eab7892d authored by Douwe Maan's avatar Douwe Maan

Merge branch 'rs-factory-nitpicks' into 'master'

More Factory cleanup

Addresses nitpicks from https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2847

See merge request !3108
parents d43c7784 7612fdba
...@@ -29,7 +29,7 @@ class Spinach::Features::ProjectMergeRequestsAcceptance < Spinach::FeatureSteps ...@@ -29,7 +29,7 @@ class Spinach::Features::ProjectMergeRequestsAcceptance < Spinach::FeatureSteps
step 'There is an open Merge Request' do step 'There is an open Merge Request' do
@user = create(:user) @user = create(:user)
@project = create(:project, :public) @project = create(:project, :public)
@project_member = create(:project_member, user: @user, project: @project, access_level: ProjectMember::DEVELOPER) @project_member = create(:project_member, :developer, user: @user, project: @project)
@merge_request = create(:merge_request, :with_diffs, :simple, source_project: @project) @merge_request = create(:merge_request, :with_diffs, :simple, source_project: @project)
end end
......
...@@ -36,7 +36,7 @@ class Spinach::Features::RevertMergeRequests < Spinach::FeatureSteps ...@@ -36,7 +36,7 @@ class Spinach::Features::RevertMergeRequests < Spinach::FeatureSteps
step 'There is an open Merge Request' do step 'There is an open Merge Request' do
@user = create(:user) @user = create(:user)
@project = create(:project, :public) @project = create(:project, :public)
@project_member = create(:project_member, user: @user, project: @project, access_level: ProjectMember::DEVELOPER) @project_member = create(:project_member, :developer, user: @user, project: @project)
@merge_request = create(:merge_request, :with_diffs, :simple, source_project: @project) @merge_request = create(:merge_request, :with_diffs, :simple, source_project: @project)
end end
......
FactoryGirl.define do FactoryGirl.define do
factory :email do factory :email do
user user
email do email { FFaker::Internet.email('alias') }
FFaker::Internet.email('alias')
end
factory :another_email do
email do
FFaker::Internet.email('another.alias')
end
end
end end
end end
...@@ -2,6 +2,26 @@ FactoryGirl.define do ...@@ -2,6 +2,26 @@ FactoryGirl.define do
factory :project_member do factory :project_member do
user user
project project
access_level { ProjectMember::MASTER } master
trait :guest do
access_level ProjectMember::GUEST
end
trait :reporter do
access_level ProjectMember::REPORTER
end
trait :developer do
access_level ProjectMember::DEVELOPER
end
trait :master do
access_level ProjectMember::MASTER
end
trait :owner do
access_level ProjectMember::OWNER
end
end end
end end
FactoryGirl.define do FactoryGirl.define do
factory :service do factory :service do
type ""
title "GitLab CI"
project project
end end
end end
...@@ -7,8 +7,8 @@ describe API::API, api: true do ...@@ -7,8 +7,8 @@ describe API::API, api: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:master) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) } let!(:master) { create(:project_member, :master, user: user, project: project) }
let!(:guest) { create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST) } let!(:guest) { create(:project_member, :guest, user: user2, project: project) }
let!(:branch_name) { 'feature' } let!(:branch_name) { 'feature' }
let!(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' } let!(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' }
......
...@@ -7,8 +7,8 @@ describe API::API, api: true do ...@@ -7,8 +7,8 @@ describe API::API, api: true do
let(:api_user) { user } let(:api_user) { user }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:developer) { create(:project_member, user: user, project: project, access_level: ProjectMember::DEVELOPER) } let!(:developer) { create(:project_member, :developer, user: user, project: project) }
let!(:reporter) { create(:project_member, user: user2, project: project, access_level: ProjectMember::REPORTER) } let!(:reporter) { create(:project_member, :reporter, user: user2, project: project) }
let(:commit) { create(:ci_commit, project: project)} let(:commit) { create(:ci_commit, project: project)}
let(:build) { create(:ci_build, commit: commit) } let(:build) { create(:ci_build, commit: commit) }
......
...@@ -6,9 +6,9 @@ describe API::CommitStatus, api: true do ...@@ -6,9 +6,9 @@ describe API::CommitStatus, api: true do
let!(:project) { create(:project) } let!(:project) { create(:project) }
let(:commit) { project.repository.commit } let(:commit) { project.repository.commit }
let(:commit_status) { create(:commit_status, commit: ci_commit) } let(:commit_status) { create(:commit_status, commit: ci_commit) }
let(:guest) { create_user(ProjectMember::GUEST) } let(:guest) { create_user(:guest) }
let(:reporter) { create_user(ProjectMember::REPORTER) } let(:reporter) { create_user(:reporter) }
let(:developer) { create_user(ProjectMember::DEVELOPER) } let(:developer) { create_user(:developer) }
let(:sha) { commit.id } let(:sha) { commit.id }
...@@ -201,9 +201,9 @@ describe API::CommitStatus, api: true do ...@@ -201,9 +201,9 @@ describe API::CommitStatus, api: true do
end end
end end
def create_user(access_level) def create_user(access_level_trait)
user = create(:user) user = create(:user)
create(:project_member, user: user, project: project, access_level: access_level) create(:project_member, access_level_trait, user: user, project: project)
user user
end end
end end
...@@ -6,8 +6,8 @@ describe API::API, api: true do ...@@ -6,8 +6,8 @@ describe API::API, api: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:master) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) } let!(:master) { create(:project_member, :master, user: user, project: project) }
let!(:guest) { create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST) } let!(:guest) { create(:project_member, :guest, user: user2, project: project) }
let!(:note) { create(:note_on_commit, author: user, project: project, commit_id: project.repository.commit.id, note: 'a comment on a commit') } let!(:note) { create(:note_on_commit, author: user, project: project, commit_id: project.repository.commit.id, note: 'a comment on a commit') }
let!(:another_note) { create(:note_on_commit, author: user, project: project, commit_id: project.repository.commit.id, note: 'another comment on a commit') } let!(:another_note) { create(:note_on_commit, author: user, project: project, commit_id: project.repository.commit.id, note: 'another comment on a commit') }
......
...@@ -12,7 +12,7 @@ describe API::API, api: true do ...@@ -12,7 +12,7 @@ describe API::API, api: true do
end end
let(:project_user2) do let(:project_user2) do
create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST) create(:project_member, :guest, user: user2, project: project)
end end
describe 'POST /projects/fork/:id' do describe 'POST /projects/fork/:id' do
......
...@@ -6,8 +6,8 @@ describe API::API, api: true do ...@@ -6,8 +6,8 @@ describe API::API, api: true do
let(:user2) { create(:user) } let(:user2) { create(:user) }
let(:user3) { create(:user) } let(:user3) { create(:user) }
let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
let(:project_member) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) } let(:project_member) { create(:project_member, :master, user: user, project: project) }
let(:project_member2) { create(:project_member, user: user3, project: project, access_level: ProjectMember::DEVELOPER) } let(:project_member2) { create(:project_member, :developer, user: user3, project: project) }
describe "GET /projects/:id/members" do describe "GET /projects/:id/members" do
before { project_member } before { project_member }
......
...@@ -12,8 +12,8 @@ describe API::API, api: true do ...@@ -12,8 +12,8 @@ describe API::API, api: true do
let(:project2) { create(:project, path: 'project2', creator_id: user.id, namespace: user.namespace) } let(:project2) { create(:project, path: 'project2', creator_id: user.id, namespace: user.namespace) }
let(:project3) { create(:project, path: 'project3', creator_id: user.id, namespace: user.namespace) } let(:project3) { create(:project, path: 'project3', creator_id: user.id, namespace: user.namespace) }
let(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') } let(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') }
let(:project_member) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) } let(:project_member) { create(:project_member, :master, user: user, project: project) }
let(:project_member2) { create(:project_member, user: user3, project: project, access_level: ProjectMember::DEVELOPER) } let(:project_member2) { create(:project_member, :developer, user: user3, project: project) }
let(:user4) { create(:user) } let(:user4) { create(:user) }
let(:project3) do let(:project3) do
create(:project, create(:project,
......
...@@ -9,8 +9,8 @@ describe API::API, api: true do ...@@ -9,8 +9,8 @@ describe API::API, api: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:master) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) } let!(:master) { create(:project_member, :master, user: user, project: project) }
let!(:guest) { create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST) } let!(:guest) { create(:project_member, :guest, user: user2, project: project) }
describe "GET /projects/:id/repository/tree" do describe "GET /projects/:id/repository/tree" do
context "authorized user" do context "authorized user" do
......
...@@ -28,9 +28,9 @@ describe API::Runners, api: true do ...@@ -28,9 +28,9 @@ describe API::Runners, api: true do
before do before do
# Set project access for users # Set project access for users
create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) create(:project_member, :master, user: user, project: project)
create(:project_member, user: user, project: project2, access_level: ProjectMember::MASTER) create(:project_member, :master, user: user, project: project2)
create(:project_member, user: user2, project: project, access_level: ProjectMember::REPORTER) create(:project_member, :reporter, user: user2, project: project)
end end
describe 'GET /runners' do describe 'GET /runners' do
......
...@@ -8,8 +8,8 @@ describe API::API, api: true do ...@@ -8,8 +8,8 @@ describe API::API, api: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:master) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) } let!(:master) { create(:project_member, :master, user: user, project: project) }
let!(:guest) { create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST) } let!(:guest) { create(:project_member, :guest, user: user2, project: project) }
describe "GET /projects/:id/repository/tags" do describe "GET /projects/:id/repository/tags" do
let(:tag_name) { project.repository.tag_names.sort.reverse.first } let(:tag_name) { project.repository.tag_names.sort.reverse.first }
......
...@@ -8,8 +8,8 @@ describe API::API do ...@@ -8,8 +8,8 @@ describe API::API do
let!(:trigger_token) { 'secure_token' } let!(:trigger_token) { 'secure_token' }
let!(:trigger_token_2) { 'secure_token_2' } let!(:trigger_token_2) { 'secure_token_2' }
let!(:project) { create(:project, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:master) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) } let!(:master) { create(:project_member, :master, user: user, project: project) }
let!(:developer) { create(:project_member, user: user2, project: project, access_level: ProjectMember::DEVELOPER) } let!(:developer) { create(:project_member, :developer, user: user2, project: project) }
let!(:trigger) { create(:ci_trigger, project: project, token: trigger_token) } let!(:trigger) { create(:ci_trigger, project: project, token: trigger_token) }
let!(:trigger2) { create(:ci_trigger, project: project, token: trigger_token_2) } let!(:trigger2) { create(:ci_trigger, project: project, token: trigger_token_2) }
let!(:trigger_request) { create(:ci_trigger_request, trigger: trigger, created_at: '2015-01-01 12:13:14') } let!(:trigger_request) { create(:ci_trigger_request, trigger: trigger, created_at: '2015-01-01 12:13:14') }
......
...@@ -6,8 +6,8 @@ describe API::API, api: true do ...@@ -6,8 +6,8 @@ describe API::API, api: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:master) { create(:project_member, user: user, project: project, access_level: ProjectMember::MASTER) } let!(:master) { create(:project_member, :master, user: user, project: project) }
let!(:developer) { create(:project_member, user: user2, project: project, access_level: ProjectMember::DEVELOPER) } let!(:developer) { create(:project_member, :developer, user: user2, project: project) }
let!(:variable) { create(:ci_variable, project: project) } let!(:variable) { create(:ci_variable, project: project) }
describe 'GET /projects/:id/variables' do describe 'GET /projects/:id/variables' do
......
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