diff --git a/app/controllers/repp/v1/registrar/notifications_controller.rb b/app/controllers/repp/v1/registrar/notifications_controller.rb index 1108d434e..23be6d7b7 100644 --- a/app/controllers/repp/v1/registrar/notifications_controller.rb +++ b/app/controllers/repp/v1/registrar/notifications_controller.rb @@ -63,7 +63,7 @@ module Repp def limit index_params[:limit] || 200 end - + def offset index_params[:offset] || 0 end diff --git a/test/integration/repp/v1/registrar/notifications_test.rb b/test/integration/repp/v1/registrar/notifications_test.rb index 9fafca443..2677d393b 100644 --- a/test/integration/repp/v1/registrar/notifications_test.rb +++ b/test/integration/repp/v1/registrar/notifications_test.rb @@ -9,6 +9,17 @@ class ReppV1RegistrarNotificationsTest < ActionDispatch::IntegrationTest @auth_headers = { 'Authorization' => token } end + def test_all_unreaded_poll_messages + notification = @user.registrar.notifications.where(read: false).order(created_at: :desc).all + get "/repp/v1/registrar/notifications/all_notifications", headers: @auth_headers + json = JSON.parse(response.body, symbolize_names: true) + + assert_response :ok + assert_equal notification.count, json[:data].count + assert_equal json[:data].first[:text], notification.first.text + assert_equal json[:data].last[:text], notification.last.text + end + def test_gets_latest_unread_poll_message notification = @user.registrar.notifications.where(read: false).order(created_at: :desc).first get "/repp/v1/registrar/notifications", headers: @auth_headers