Commit d690225d authored by Eugenia Grieff's avatar Eugenia Grieff

Add admin issue check to create epic issue link

parent 90d966c9
...@@ -45,6 +45,7 @@ module EpicIssues ...@@ -45,6 +45,7 @@ module EpicIssues
def linkable_issue?(issue) def linkable_issue?(issue)
issue.supports_epic? && issue.supports_epic? &&
can?(current_user, :admin_issue, issue.project) &&
issuable_group_descendants.include?(issue.project.group) && issuable_group_descendants.include?(issue.project.group) &&
!previous_related_issuables.include?(issue) !previous_related_issuables.include?(issue)
end end
......
...@@ -160,9 +160,10 @@ RSpec.describe EpicIssues::CreateService do ...@@ -160,9 +160,10 @@ RSpec.describe EpicIssues::CreateService do
# threshold 24 because 6 queries are generated for each insert # threshold 24 because 6 queries are generated for each insert
# (savepoint, find, exists, relative_position get, insert, release savepoint) # (savepoint, find, exists, relative_position get, insert, release savepoint)
# and we insert 5 issues instead of 1 which we do for control count # and we insert 5 issues instead of 1 which we do for control count
# plus 4 to include additional authorization queries "SELECT MAX("project_authorizations"."access_level")"
expect { described_class.new(epic, user, params).execute } expect { described_class.new(epic, user, params).execute }
.not_to exceed_query_limit(control_count) .not_to exceed_query_limit(control_count)
.with_threshold(29) .with_threshold(33)
end end
end end
...@@ -179,6 +180,10 @@ RSpec.describe EpicIssues::CreateService do ...@@ -179,6 +180,10 @@ RSpec.describe EpicIssues::CreateService do
subject { assign_issue([Gitlab::Routing.url_helpers.namespace_project_issue_url(namespace_id: issue.project.namespace, project_id: issue.project, id: issue.iid)])} subject { assign_issue([Gitlab::Routing.url_helpers.namespace_project_issue_url(namespace_id: issue.project.namespace, project_id: issue.project, id: issue.iid)])}
before do
project2.add_reporter(user)
end
include_examples 'returns success' include_examples 'returns success'
end end
...@@ -202,6 +207,7 @@ RSpec.describe EpicIssues::CreateService do ...@@ -202,6 +207,7 @@ RSpec.describe EpicIssues::CreateService do
expect(created_link2.relative_position).to be < created_link1.relative_position expect(created_link2.relative_position).to be < created_link1.relative_position
end end
it 'orders the epic issues to the first place and moves the existing ones down' do it 'orders the epic issues to the first place and moves the existing ones down' do
existing_link = create(:epic_issue, epic: epic, issue: issue3) existing_link = create(:epic_issue, epic: epic, issue: issue3)
......
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