FIX: should not raise error when both group & site tag preferences are same. (#27704)

When tag preference in group and site settings are both used with same default notification level it will break new users signups because it tries to create duplicate records in the tag_users table which can’t happen because we have a unique index set.
This commit is contained in:
Vinoth Kannan 2024-07-04 11:53:28 +05:30 committed by GitHub
parent 55bf0e21fb
commit d1ea598fa2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View File

@ -2047,7 +2047,7 @@ class User < ActiveRecord::Base
end
end
TagUser.insert_all!(values) if values.present?
TagUser.insert_all(values) if values.present?
end
def self.purge_unactivated

View File

@ -326,14 +326,25 @@ RSpec.describe Invite do
end
context "when inviting to groups" do
it "add the user to the correct groups" do
group = Fabricate(:group)
fab!(:group)
before do
group.add_owner(invite.invited_by)
invite.invited_groups.create!(group_id: group.id)
end
it "add the user to the correct groups" do
user = invite.redeem
expect(user.groups).to contain_exactly(group)
end
it "should not raise error when both group & site tag preferences same" do
tag = Fabricate(:tag)
group.tracking_tags = [tag.name]
group.save!
SiteSetting.default_tags_tracking = tag.name
expect { invite.redeem }.not_to raise_error
end
end
context "when inviting to a topic" do