Commit d1df15e9 authored by Patrick Derichs's avatar Patrick Derichs

Extract EE specific lines from issue.rb

Revert module include change

Aligned EE IssuesController with CE IssuesController

Aligned Issuable with CE version

Move Epic check to the right module

Extract milestone availability check from Issuable modules

Add specs for IssuableMilestoneAvailability

Remove service class and use override check on EE/Issuable instead
parent dfb1cc61
...@@ -10,11 +10,11 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -10,11 +10,11 @@ class Projects::IssuesController < Projects::ApplicationController
include SpammableActions include SpammableActions
include RecordUserLastActivity include RecordUserLastActivity
def issue_except_actions def self.issue_except_actions
%i[index calendar new create bulk_update import_csv] %i[index calendar new create bulk_update import_csv]
end end
def set_issuables_index_only_actions def self.set_issuables_index_only_actions
%i[index calendar] %i[index calendar]
end end
...@@ -25,9 +25,9 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -25,9 +25,9 @@ class Projects::IssuesController < Projects::ApplicationController
before_action :whitelist_query_limiting, only: [:create, :create_merge_request, :move, :bulk_update] before_action :whitelist_query_limiting, only: [:create, :create_merge_request, :move, :bulk_update]
before_action :check_issues_available! before_action :check_issues_available!
before_action :issue, unless: ->(c) { c.issue_except_actions.include?(c.action_name.to_sym) } before_action :issue, except: issue_except_actions
before_action :set_issuables_index, if: ->(c) { c.set_issuables_index_only_actions.include?(c.action_name.to_sym) } before_action :set_issuables_index, only: set_issuables_index_only_actions
# Allow write(create) issue # Allow write(create) issue
before_action :authorize_create_issue!, only: [:new, :create] before_action :authorize_create_issue!, only: [:new, :create]
......
...@@ -128,12 +128,6 @@ module Issuable ...@@ -128,12 +128,6 @@ module Issuable
assignees.count > 1 assignees.count > 1
end end
def milestone_available?
return true if is_a?(Epic)
project_id == milestone&.project_id || project.ancestors_upto.compact.include?(milestone&.group)
end
private private
def milestone_is_valid def milestone_is_valid
...@@ -279,6 +273,10 @@ module Issuable ...@@ -279,6 +273,10 @@ module Issuable
end end
end end
def milestone_available?
project_id == milestone&.project_id || project.ancestors_upto.compact.include?(milestone&.group)
end
def assignee_or_author?(user) def assignee_or_author?(user)
author_id == user.id || assignees.exists?(user.id) author_id == user.id || assignees.exists?(user.id)
end end
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
module EE module EE
module Issuable module Issuable
extend ActiveSupport::Concern extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
class_methods do class_methods do
def labels_hash def labels_hash
...@@ -17,6 +18,13 @@ module EE ...@@ -17,6 +18,13 @@ module EE
end end
end end
override :milestone_available?
def milestone_available?
return true if is_a?(Epic)
super
end
def supports_epic? def supports_epic?
is_a?(Issue) && project.group is_a?(Issue) && project.group
end end
......
...@@ -19,4 +19,22 @@ describe EE::Issuable do ...@@ -19,4 +19,22 @@ describe EE::Issuable do
expect(relation.labels_hash[issue_id]).to include('Feature', 'Second Label') expect(relation.labels_hash[issue_id]).to include('Feature', 'Second Label')
end end
end end
describe '#milestone_available?' do
context 'with Epic' do
let(:epic) { create(:epic) }
it 'returns true' do
expect(epic.milestone_available?).to be_truthy
end
end
context 'no Epic' do
let(:issue) { create(:issue) }
it 'returns false' do
expect(issue.milestone_available?).to be_falsy
end
end
end
end end
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