mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 12:47:29 +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
|
after_initialize :set_defaults
|
||||||
|
|
||||||
def mark_as_read
|
def mark_as_read
|
||||||
|
raise 'Read notification cannot be marked as read again' if read?
|
||||||
self.read = true
|
self.read = true
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,4 +32,11 @@ class NotificationTest < ActiveSupport::TestCase
|
||||||
@notification.reload
|
@notification.reload
|
||||||
assert @notification.read?
|
assert @notification.read?
|
||||||
end
|
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
|
end
|
Loading…
Add table
Add a link
Reference in a new issue