Commit b8a28226 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '350603-cablett-issue-team-owner' into 'master'

Replace owner check with team owner method check

See merge request gitlab-org/gitlab!78515
parents 5d67c12f 27570b9c
......@@ -584,7 +584,7 @@ class Issue < ApplicationRecord
def readable_by?(user)
if user.can_read_all_resources?
true
elsif project.owner == user
elsif project.personal? && project.team.owner?(user)
true
elsif confidential? && !assignee_or_author?(user)
project.team.member?(user, Gitlab::Access::REPORTER)
......
......@@ -107,6 +107,10 @@ class ProjectTeam
end
end
def owner?(user)
owners.include?(user)
end
def import(source_project, current_user = nil)
target_project = project
......
......@@ -77,6 +77,32 @@ RSpec.describe ProjectTeam do
end
end
describe 'owner methods' do
context 'personal project' do
let(:project) { create(:project) }
let(:owner) { project.owner }
specify { expect(project.team.owners).to contain_exactly(owner) }
specify { expect(project.team.owner?(owner)).to be_truthy }
end
context 'group project' do
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
let(:user1) { create(:user) }
let(:user2) { create(:user) }
before do
group.add_owner(user1)
group.add_owner(user2)
end
specify { expect(project.team.owners).to contain_exactly(user1, user2) }
specify { expect(project.team.owner?(user1)).to be_truthy }
specify { expect(project.team.owner?(user2)).to be_truthy }
end
end
describe '#fetch_members' do
context 'personal project' do
let(:project) { create(:project) }
......
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