Commit 4c1af6cc authored by Toon Claes's avatar Toon Claes

Use polymorphism to implement allows_multiple_assignees?

Only Issue might allow multiple assignees, but only when the
multiple_issue_assignees feature is available. Do this check in Issue
itself, instead of a type-based check in Issuable.
parent f56aec0c
module EE
module Issuable
extend ActiveSupport::Concern
def allows_multiple_assignees?
is_a?(Issue) && project.feature_available?(:multiple_issue_assignees)
end
end
end
...@@ -23,8 +23,6 @@ module Issuable ...@@ -23,8 +23,6 @@ module Issuable
IssuableMeta = Struct.new(:upvotes, :downvotes, :notes_count, :merge_requests_count) IssuableMeta = Struct.new(:upvotes, :downvotes, :notes_count, :merge_requests_count)
included do included do
prepend EE::Issuable
cache_markdown_field :title, pipeline: :single_line cache_markdown_field :title, pipeline: :single_line
cache_markdown_field :description, issuable_state_filter_enabled: true cache_markdown_field :description, issuable_state_filter_enabled: true
......
...@@ -5,6 +5,11 @@ module EE ...@@ -5,6 +5,11 @@ module EE
author.support_bot? || super author.support_bot? || super
end end
# override
def allows_multiple_assignees?
project.feature_available?(:multiple_issue_assignees)
end
# override # override
def subscribed_without_subscriptions?(user, *) def subscribed_without_subscriptions?(user, *)
# TODO: this really shouldn't be necessary, because the support # TODO: this really shouldn't be necessary, because the support
......
require 'spec_helper' require 'spec_helper'
describe Issue do describe Issue do
describe '#allows_multiple_assignees?' do
it 'does not allow multiple assignees without license' do
stub_licensed_features(multiple_issue_assignees: false)
issue = build(:issue)
expect(issue.allows_multiple_assignees?).to be_falsey
end
it 'does not allow multiple assignees without license' do
stub_licensed_features(multiple_issue_assignees: true)
issue = build(:issue)
expect(issue.allows_multiple_assignees?).to be_truthy
end
end
describe '#weight' do describe '#weight' do
[ [
{ license: true, database: 5, expected: 5 }, { license: true, database: 5, expected: 5 },
......
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