mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
dcbe527a82
We now test the uniqueness validation, but also rescue a DB exception in case the controller fails this check.
18 lines
436 B
Ruby
18 lines
436 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe ReviewableClaimedTopic, type: :model do
|
|
|
|
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
|