mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 04:07:33 +02:00
Disallow marking a notification as read again
This commit is contained in:
parent
1183d06c09
commit
412641cdb0
2 changed files with 8 additions and 0 deletions
|
@ -9,6 +9,7 @@ class Notification < ActiveRecord::Base
|
|||
after_initialize :set_defaults
|
||||
|
||||
def mark_as_read
|
||||
raise 'Read notification cannot be marked as read again' if read?
|
||||
self.read = true
|
||||
save
|
||||
end
|
||||
|
|
|
@ -32,4 +32,11 @@ class NotificationTest < ActiveSupport::TestCase
|
|||
@notification.reload
|
||||
assert @notification.read?
|
||||
end
|
||||
|
||||
def test_read_notification_cannot_be_marked_as_read_again
|
||||
@notification.mark_as_read
|
||||
assert_raises do
|
||||
@notification.mark_as_read
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue