Skip to content

Commit

Permalink
FIX: Don't show liked consolidated notification when frequency is never.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgxworld committed Jan 16, 2019
1 parent 0b47ef6 commit f06b773
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/models/notification.rb
Expand Up @@ -152,7 +152,14 @@ def self.recent_report(user, count = nil)
.includes(:topic)

if user.user_option.like_notification_frequency == UserOption.like_notification_frequency_type[:never]
notifications = notifications.where('notification_type <> ?', Notification.types[:liked])
[
Notification.types[:liked],
Notification.types[:liked_consolidated]
].each do |notification_type|
notifications = notifications.where(
'notification_type <> ?', notification_type
)
end
end

notifications = notifications.to_a
Expand Down
21 changes: 21 additions & 0 deletions spec/models/notification_spec.rb
Expand Up @@ -303,6 +303,10 @@ def regular
fab(Notification.types[:liked], true)
end

def liked_consolidated
fab(Notification.types[:liked_consolidated], true)
end

it 'correctly finds visible notifications' do
pm
expect(Notification.visible.count).to eq(1)
Expand All @@ -322,5 +326,22 @@ def regular
expect(notifications.map { |n| n.id }).to eq([a.id, d.id, c.id])

end

describe 'for a user that does not want to be notify on liked' do
before do
user.user_option.update!(
like_notification_frequency:
UserOption.like_notification_frequency_type[:never]
)
end

it "should not return any form of liked notifications" do
notification = pm
regular
liked_consolidated

expect(Notification.recent_report(user)).to contain_exactly(notification)
end
end
end
end

0 comments on commit f06b773

Please sign in to comment.