mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 14:11:16 +08:00
FIX: Constraint error when inserting the same topic group twice
If that happens, update the value instead of raising an error.
This commit is contained in:
@ -81,5 +81,12 @@ describe TopicGroup do
|
||||
expect(created_topic_group.last_read_post_number).to eq new_post_number
|
||||
expect(created_topic_group2.last_read_post_number).to eq topic2.highest_post_number
|
||||
end
|
||||
|
||||
it "will not raise an error if a topic group already exists" do
|
||||
TopicGroup.create_topic_group(user, @topic.id, 3, [])
|
||||
expect(TopicGroup.find_by(group: group, topic: @topic).last_read_post_number).to eq(3)
|
||||
TopicGroup.create_topic_group(user, @topic.id, 10, [])
|
||||
expect(TopicGroup.find_by(group: group, topic: @topic).last_read_post_number).to eq(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user