Commit 47212210 authored by Patrick Derichs's avatar Patrick Derichs

Override todo types for EE

Create a separate TodosFinder spec file for EE

Avoid creating additional Set instances

Change todo_types to class method

Updating specs as well

Move spec files to correct locations

Remove ee stub

Remove ee specs for TodosFinder
and refactor TodosFinder specs

Apply suggestion to
ee/app/finders/ee/todos_finder.rb
parent 348d09b1
......@@ -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