added test

This commit is contained in:
Oleg Hasjanov 2021-04-19 14:10:00 +03:00
parent 2e8558a93d
commit d5af1a7fb6
2 changed files with 12 additions and 1 deletions

View file

@ -63,7 +63,7 @@ module Repp
def limit
index_params[:limit] || 200
end
def offset
index_params[:offset] || 0
end

View file

@ -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