mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 03:03:17 +08:00
FIX: Couldn't update category notification level
This commit is contained in:
parent
463b536b85
commit
f4c8070d09
|
@ -49,7 +49,7 @@ class CategoryUser < ActiveRecord::Base
|
||||||
def self.set_notification_level_for_category(user, level, category_id)
|
def self.set_notification_level_for_category(user, level, category_id)
|
||||||
record = CategoryUser.where(user: user, category_id: category_id).first
|
record = CategoryUser.where(user: user, category_id: category_id).first
|
||||||
|
|
||||||
return if record && record.notification_level = level
|
return if record && record.notification_level == level
|
||||||
|
|
||||||
if record.present?
|
if record.present?
|
||||||
record.notification_level = level
|
record.notification_level = level
|
||||||
|
|
|
@ -45,6 +45,26 @@ describe CategoryUser do
|
||||||
expect(TopicUser.get(topic, user).notification_level).to eq(regular)
|
expect(TopicUser.get(topic, user).notification_level).to eq(regular)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'allows updating notification level' do
|
||||||
|
category = Fabricate(:category)
|
||||||
|
user = Fabricate(:user)
|
||||||
|
|
||||||
|
CategoryUser.set_notification_level_for_category(user,
|
||||||
|
NotificationLevels.all[:watching_first_post],
|
||||||
|
category.id)
|
||||||
|
|
||||||
|
expect(CategoryUser.where(user_id: user.id,
|
||||||
|
category_id: category.id,
|
||||||
|
notification_level: NotificationLevels.all[:watching_first_post]).exists?).to eq(true)
|
||||||
|
|
||||||
|
CategoryUser.set_notification_level_for_category(user,
|
||||||
|
NotificationLevels.all[:regular],
|
||||||
|
category.id)
|
||||||
|
|
||||||
|
expect(CategoryUser.where(user_id: user.id,
|
||||||
|
category_id: category.id,
|
||||||
|
notification_level: NotificationLevels.all[:regular]).exists?).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
context 'integration' do
|
context 'integration' do
|
||||||
before do
|
before do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user