FIX: Assignments limit shouldn't prevent from reassigning a post (#556)
At the moment, it's possible to have maximum 5 assignments per topic (that includes topic and post assignments). When trying to assign more, a message "Limit of 5 assignments per topic has been reached" appears. One possible edge case here is _reassigning_ a topic or a post. Reassignment doesn't lead to exceeding the limit, and therefore it should be possible. But at the moment we handle correctly only _topic_ reassignments, while when reassigning a _post_, we show the error message "the limit has been reached". This commit makes post reassignments work correctly too.
This commit is contained in:
parent
08c2a4e0f3
commit
51920a99c0
|
@ -547,8 +547,7 @@ class ::Assigner
|
|||
end
|
||||
|
||||
def reassign?
|
||||
return false if !@target.is_a?(Topic)
|
||||
Assignment.exists?(topic_id: @target.id, target: @target, active: true)
|
||||
Assignment.exists?(target: @target, active: true)
|
||||
end
|
||||
|
||||
def no_assignee_change?(assignee)
|
||||
|
|
|
@ -264,6 +264,21 @@ RSpec.describe Assigner do
|
|||
expect(second_assign[:success]).to eq(true)
|
||||
end
|
||||
|
||||
it "reassigns a post even when at the assignments limit" do
|
||||
posts =
|
||||
(described_class::ASSIGNMENTS_PER_TOPIC_LIMIT).times.map do
|
||||
Fabricate(:post, topic: topic)
|
||||
end
|
||||
|
||||
posts.each do |post|
|
||||
user = Fabricate(:moderator)
|
||||
described_class.new(post, admin).assign(user)
|
||||
end
|
||||
|
||||
status = described_class.new(posts.first, admin).assign(Fabricate(:moderator))
|
||||
expect(status[:success]).to eq(true)
|
||||
end
|
||||
|
||||
context "when 'allow_self_reassign' is false" do
|
||||
subject(:assign) do
|
||||
assigner.assign(moderator, note: other_note, allow_self_reassign: self_reassign)
|
||||
|
|
Loading…
Reference in New Issue