From 3fb50d587d9561f08e28a8795a1a062b3704f771 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 17 Feb 2017 10:28:38 -0500 Subject: [PATCH] FIX: invited users and new TL1 users will see their first notification highlighted --- app/models/user.rb | 2 +- spec/models/user_spec.rb | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 6ce3ce4d1e0..2841be1f5d4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -354,7 +354,7 @@ class User < ActiveRecord::Base TRACK_FIRST_NOTIFICATION_READ_DURATION = 1.week.to_i def read_first_notification? - if (trust_level > TrustLevel[0] || + if (trust_level > TrustLevel[1] || created_at < TRACK_FIRST_NOTIFICATION_READ_DURATION.seconds.ago) return true diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 75a6c32bf0b..d4bb2149b02 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1398,10 +1398,18 @@ describe User do end end - describe 'when user is not trust level 0' do + describe 'when user is trust level 1' do it 'should return the right value' do user.update_attributes!(trust_level: TrustLevel[1]) + expect(user.read_first_notification?).to eq(false) + end + end + + describe 'when user is trust level 2' do + it 'should return the right value' do + user.update_attributes!(trust_level: TrustLevel[2]) + expect(user.read_first_notification?).to eq(true) end end