mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FIX: Don't log a claimed topic database error during tests
We now test the uniqueness validation, but also rescue a DB exception in case the controller fails this check.
This commit is contained in:
@ -4,11 +4,14 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe ReviewableClaimedTopic, type: :model do
|
||||
|
||||
it "ensures uniqueness" do
|
||||
claimed = Fabricate(:reviewable_claimed_topic)
|
||||
expect(-> {
|
||||
ReviewableClaimedTopic.create!(topic_id: claimed.topic_id, user_id: Fabricate(:user).id)
|
||||
}).to raise_error(ActiveRecord::RecordNotUnique)
|
||||
it "respects the uniqueness constraint" do
|
||||
topic = Fabricate(:topic)
|
||||
|
||||
ct = ReviewableClaimedTopic.new(topic_id: topic.id, user_id: Fabricate(:user).id)
|
||||
expect(ct.save).to eq(true)
|
||||
|
||||
ct = ReviewableClaimedTopic.new(topic_id: topic.id, user_id: Fabricate(:user).id)
|
||||
expect(ct.save).to eq(false)
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user