mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
FIX: skip category preference update if already set by group. (#20823)
`default_categories_*` site settings will update the category preferences on user creation. But it shouldn't update the user's category preference if a group's setting already updated it for that user.
This commit is contained in:
parent
0b05fa71ca
commit
08ff6eebad
@ -1968,7 +1968,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
CategoryUser.insert_all!(values) if values.present?
|
||||
CategoryUser.insert_all(values) if values.present?
|
||||
end
|
||||
|
||||
def set_default_tags_preferences
|
||||
|
@ -2097,6 +2097,19 @@ RSpec.describe User do
|
||||
expect(CategoryUser.lookup(user, :regular).pluck(:category_id)).to eq([category4.id])
|
||||
end
|
||||
|
||||
it "does not update category preferences if already set by group" do
|
||||
user_id = 123
|
||||
|
||||
CategoryUser.create!(
|
||||
user_id: user_id,
|
||||
category_id: category2.id,
|
||||
notification_level: CategoryUser.notification_levels[:normal],
|
||||
)
|
||||
user = Fabricate(:user, id: user_id, trust_level: 1)
|
||||
|
||||
expect(CategoryUser.lookup(user, :normal).pluck(:category_id)).to include(category2.id)
|
||||
end
|
||||
|
||||
it "does not set category preferences for staged users" do
|
||||
user = Fabricate(:user, staged: true)
|
||||
expect(CategoryUser.lookup(user, :watching).pluck(:category_id)).to eq([])
|
||||
|
Loading…
Reference in New Issue
Block a user