Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewPrigorshnev committed Mar 26, 2024
1 parent 08c2a4e commit 67e7c2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/assigner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,7 @@ def already_assigned?(assign_to, type, note, status)
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)
Expand Down
14 changes: 14 additions & 0 deletions spec/lib/assigner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@ def assigned_to?(assignee)
expect(second_assign[:success]).to eq(true)
end

it "assignments limit doesn't prevent from reassigning a post" 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)
Expand Down

0 comments on commit 67e7c2c

Please sign in to comment.