FIX: Don't try to create a reviewable user twice

This commit is contained in:
Robin Ward 2019-04-11 12:30:54 -04:00
parent 331a809738
commit d21dd521d2
2 changed files with 8 additions and 0 deletions

View File

@ -29,5 +29,7 @@ class Jobs::CreateUserReviewable < Jobs::Base
)
end
rescue ActiveRecord::RecordNotUnique
# If the reviewable is somehow queued twice, we can ignore.
end
end

View File

@ -17,6 +17,12 @@ describe Jobs::CreateUserReviewable do
expect(reviewable.payload['email']).to eq(user.email)
end
it "should not raise an error if there is a reviewable already" do
SiteSetting.must_approve_users = true
described_class.new.execute(user_id: user.id)
described_class.new.execute(user_id: user.id)
end
describe "reasons" do
it "does nothing if there's no reason" do
described_class.new.execute(user_id: user.id)