Merge pull request #1936 from internetee/1869-repp-list-access-to-poll-messages

implement get all list notifications repp endpoint
This commit is contained in:
Timo Võhmar 2021-05-06 17:27:41 +03:00 committed by GitHub
commit ca06ae6414
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 1 deletions

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