Skip to content

A platform for community discussion. Free, open, simple.

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

Robin Wardd21dd521d259
diff --git a/app/jobs/regular/create_user_reviewable.rb b/app/jobs/regular/create_user_reviewable.rb
index fb1824c8aa0..07ddb22582e 100644
--- a/app/jobs/regular/create_user_reviewable.rb
+++ b/app/jobs/regular/create_user_reviewable.rb
@@ -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
diff --git a/spec/jobs/create_user_reviewable_spec.rb b/spec/jobs/create_user_reviewable_spec.rb
index acab20ba9af..a201c5c5b24 100644
--- a/spec/jobs/create_user_reviewable_spec.rb
+++ b/spec/jobs/create_user_reviewable_spec.rb
@@ -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)