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)
|
||||
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?
|
||||
record.notification_level = level
|
||||
|
|
|
@ -45,6 +45,26 @@ describe CategoryUser do
|
|||
expect(TopicUser.get(topic, user).notification_level).to eq(regular)
|
||||
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
|
||||
before do
|
||||
|
|
Loading…
Reference in New Issue