test for logged out maps GET api
This commit is contained in:
parent
4875a8b0c4
commit
eaa9a662c3
2 changed files with 11 additions and 1 deletions
|
@ -87,7 +87,7 @@ class Map < ApplicationRecord
|
|||
end
|
||||
|
||||
def starred_by_user?(user)
|
||||
user&.stars&.where(map: self)&.exists?
|
||||
user&.stars&.where(map: self)&.exists? || false # return false, not nil
|
||||
end
|
||||
|
||||
def as_json(_options = {})
|
||||
|
|
|
@ -22,6 +22,16 @@ RSpec.describe 'maps API', type: :request do
|
|||
expect(response).to match_json_schema(:map)
|
||||
expect(JSON.parse(response.body)['data']['id']).to eq map.id
|
||||
end
|
||||
|
||||
describe 'logged out' do
|
||||
it 'GET commons map' do
|
||||
get "/api/v2/maps/#{map.id}"
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(response).to match_json_schema(:map)
|
||||
expect(JSON.parse(response.body)['data']['id']).to eq map.id
|
||||
end
|
||||
end
|
||||
|
||||
it 'POST /api/v2/maps' do
|
||||
post '/api/v2/maps', params: { map: map.attributes, access_token: token }
|
||||
|
|
Loading…
Add table
Reference in a new issue