Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Assignments limit shouldn't prevent from reassigning a post #556

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [email protected]_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
15 changes: 15 additions & 0 deletions spec/lib/assigner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,21 @@ def assigned_to?(assignee)
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)
Expand Down
Loading