Commit ddf7a00d authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '34972-extract-ee-specific-parts-from-todosfinder' into 'master'

Extract EE specific parts from TodosFinder

See merge request gitlab-org/gitlab!19221
parents 4753e8a8 47212210
......@@ -23,10 +23,16 @@ class TodosFinder
NONE = '0'
TODO_TYPES = Set.new(%w(Issue MergeRequest Epic)).freeze
TODO_TYPES = Set.new(%w(Issue MergeRequest)).freeze
attr_accessor :current_user, :params
class << self
def todo_types
TODO_TYPES
end
end
def initialize(current_user, params = {})
@current_user = current_user
@params = params
......@@ -124,7 +130,7 @@ class TodosFinder
end
def type?
type.present? && TODO_TYPES.include?(type)
type.present? && self.class.todo_types.include?(type)
end
def type
......@@ -201,3 +207,5 @@ class TodosFinder
end
end
end
TodosFinder.prepend_if_ee('EE::TodosFinder')
# frozen_string_literal: true
module EE
module TodosFinder
extend ActiveSupport::Concern
EE_TODO_TYPES = (::TodosFinder::TODO_TYPES + %w[Epic]).freeze
class_methods do
extend ::Gitlab::Utils::Override
override :todo_types
def todo_types
EE_TODO_TYPES
end
end
end
end
......@@ -234,6 +234,19 @@ describe TodosFinder do
end
end
describe '.todo_types' do
it 'returns the expected types' do
expected_result =
if Gitlab.ee?
%w[Epic Issue MergeRequest]
else
%w[Issue MergeRequest]
end
expect(described_class.todo_types).to contain_exactly(*expected_result)
end
end
describe '#any_for_target?' do
it 'returns true if there are any todos for the given target' do
todo = create(:todo, :pending)
......
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