Skip to content

Commit 23f820e

Browse files
committed
Notificaiton.read! now required user argument.
```rb Notificaiton.read!(current_user, params[:ids]) ``` Add `POST /notifications/read` API for markup ids as read.
1 parent 3162b19 commit 23f820e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

app/controllers/notifications/notifications_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def index
1111

1212
def read
1313
Notification.read!(current_user, params[:ids])
14+
render json: { ok: 1 }
1415
end
1516

1617
def clean

test/integration/navigation_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ class NavigationTest < ActionDispatch::IntegrationTest
5050
end
5151
end
5252

53+
test "POST /read" do
54+
sign_in @current_user
55+
notes = create_list(:notification, 3, user: @current_user)
56+
post "/notifications/read", params: { ids: notes.collect(&:id) }
57+
assert_response :success
58+
notes.each do |note|
59+
assert_equal true, note.reload.read?
60+
end
61+
end
62+
5363
test "DELETE /clean without login" do
5464
delete "/notifications/clean"
5565
assert_required_user

0 commit comments

Comments
 (0)