Commit 9aab260b authored by Robert Speicher's avatar Robert Speicher
Browse files

Merge branch '36009-user-default-project-creator-in-factories' into 'master'

Make user/author use project.creator in most factories

Closes #36009

See merge request gitlab-org/gitlab-ce!13321
......@@ -23,7 +23,7 @@
end
after(:build) do |commit, evaluator|
allow(commit).to receive(:author).and_return(evaluator.author || build(:author))
allow(commit).to receive(:author).and_return(evaluator.author || build_stubbed(:author))
end
trait :without_author do
......
......@@ -3,13 +3,14 @@
sha '97de212e80737a608d939f648d959671fb0a0142'
ref 'master'
tag false
user
user nil
project nil
deployable factory: :ci_build
environment factory: :environment
after(:build) do |deployment, evaluator|
deployment.project ||= deployment.environment.project
deployment.user ||= deployment.project.creator
unless deployment.project.repository_exists?
allow(deployment.project.repository).to receive(:create_ref)
......
FactoryBot.define do
factory :event do
project
author factory: :user
author(factory: :user) { project.creator }
action Event::JOINED
trait(:created) { action Event::CREATED }
......
FactoryBot.define do
factory :issue do
title { generate(:title) }
author
project
author { project.creator }
trait :confidential do
confidential true
......
FactoryBot.define do
factory :merge_request do
title { generate(:title) }
author
association :source_project, :repository, factory: :project
target_project { source_project }
author { source_project.creator }
# $ git log --pretty=oneline feature..master
# 5937ac0a7beb003549fc5fd26fc247adbce4a52e Add submodule from gitlab.com
......
......@@ -6,7 +6,7 @@
factory :note do
project
note { generate(:title) }
author
author { project&.creator || create(:user) }
on_issue
factory :note_on_commit, traits: [:on_commit]
......
......@@ -3,7 +3,7 @@
skip_create
project
user factory: :user
user { project.creator }
initialize_with { new(project, user) }
end
end
FactoryBot.define do
factory :sent_notification do
project
recipient factory: :user
recipient { project.creator }
noteable { create(:issue, project: project) }
reply_key { SentNotification.reply_key }
end
......
......@@ -21,6 +21,7 @@
factory :project_snippet, parent: :snippet, class: :ProjectSnippet do
project
author { project.creator }
end
factory :personal_snippet, parent: :snippet, class: :PersonalSnippet do
......
FactoryBot.define do
factory :subscription do
user
project
user { project.creator }
subscribable factory: :issue
end
end
......@@ -3,7 +3,7 @@
FactoryBot.define do
factory :timelog do
time_spent 3600
user
issue
user { issue.project.creator }
end
end
FactoryBot.define do
factory :todo do
project
author
user
author { project.creator }
user { project.creator }
target factory: :issue
action { Todo::ASSIGNED }
......
......@@ -44,36 +44,38 @@
context 'merge requests exist' do
let!(:assigned_merge_request) do
create(:merge_request, assignee: current_user, target_project: project, source_project: project)
create(:merge_request,
assignee: current_user,
source_project: project,
author: create(:user))
end
let!(:assigned_merge_request_from_fork) do
create(:merge_request,
source_branch: 'markdown', assignee: current_user,
target_project: public_project, source_project: forked_project
)
target_project: public_project, source_project: forked_project,
author: create(:user))
end
let!(:authored_merge_request) do
create(:merge_request,
source_branch: 'markdown', author: current_user,
target_project: project, source_project: project
)
source_branch: 'markdown',
source_project: project,
author: current_user)
end
let!(:authored_merge_request_from_fork) do
create(:merge_request,
source_branch: 'feature_conflict',
author: current_user,
target_project: public_project, source_project: forked_project
)
target_project: public_project, source_project: forked_project)
end
let!(:other_merge_request) do
create(:merge_request,
source_branch: 'fix',
target_project: project, source_project: project
)
source_project: project,
author: create(:user))
end
before do
......
......@@ -3,7 +3,7 @@
describe 'Merge request > User awards emoji', :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:merge_request) { create(:merge_request, source_project: project) }
let(:merge_request) { create(:merge_request, source_project: project, author: create(:user)) }
describe 'logged in' do
before do
......
......@@ -2,12 +2,16 @@
"type": ["object", "null"],
"required": [
"id",
"name",
"username",
"state",
"avatar_url",
"web_url"
],
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"username": { "type": "string" },
"state": { "type": "string" },
"avatar_url": { "type": "string" },
"web_url": { "type": "string" }
......
......@@ -5,7 +5,7 @@
let!(:issue) { create(:issue, project: project, title: 'find me') }
let!(:confidential) { create(:issue, :confidential, project: project, title: 'mepmep find') }
let(:project) { create(:project) }
let(:user) { issue.author }
let(:user) { create(:user) }
let(:regex_match) { described_class.match("issue search find") }
subject do
......
......@@ -92,7 +92,7 @@ def expect_disallowed(*permissions)
it 'does not include the read_issue permission when the issue author is not a member of the private project' do
project = create(:project, :private)
issue = create(:issue, project: project)
issue = create(:issue, project: project, author: create(:user))
user = issue.author
expect(project.team.member?(issue.author)).to be false
......
......@@ -4,7 +4,7 @@
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:guest) { create(:user) }
let(:issue) { create(:issue, assignees: [user2]) }
let(:issue) { create(:issue, assignees: [user2], author: create(:user)) }
let(:project) { issue.project }
let!(:todo) { create(:todo, :assigned, user: user, project: project, target: issue, author: user2) }
......
......@@ -13,7 +13,8 @@
create(:issue, title: 'Old title',
description: "for #{user2.to_reference}",
assignee_ids: [user3.id],
project: project)
project: project,
author: create(:user))
end
before do
......
......@@ -4,7 +4,7 @@
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:guest) { create(:user) }
let(:merge_request) { create(:merge_request, assignee: user2) }
let(:merge_request) { create(:merge_request, assignee: user2, author: create(:user)) }
let(:project) { merge_request.project }
let!(:todo) { create(:todo, :assigned, user: user, project: project, target: merge_request, author: user2) }
......
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