Skip to content
Snippets Groups Projects
Commit 6d90788c authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

collections now use a shared_example to get a list

parent 0eb672ee
No related branches found
No related tags found
No related merge requests found
require 'acceptance_helpers'
require 'shared/examples'
resource 'Collections' do
header 'Accept', 'application/json'
......@@ -6,25 +7,26 @@ resource 'Collections' do
before { 12.times { create(:collection) } }
it_behaves_like "get a list", '/v1/collections', Collection, 'collections'
let(:collections) { Collection.all }
get '/v1/collections' do
parameter :limit, 'Limit of collections'
parameter :offset, 'Offset of collections'
let(:limit) { 12 }
let(:offset) { 0 }
example_request 'Get a list of collections' do
expect(JSON.parse(response_body).map { |o| o['id'] }.sort).to eq(Collection.limit(limit).offset(offset).pluck(:id).sort)
expect(status).to eq(200)
end
end
#
# get '/v1/collections' do
# parameter :limit, 'Limit of collections'
# parameter :offset, 'Offset of collections'
#
# let(:limit) { 12 }
# let(:offset) { 0 }
#
# example_request 'Get a list of collections' do
# expect(JSON.parse(response_body).map { |o| o['id'] }.sort).to eq(Collection.limit(limit).offset(offset).pluck(:id).sort)
# expect(status).to eq(200)
# end
# end
get '/v1/collections/:id' do
let(:id) { collections.first.id }
example 'Get a collections' do
example 'Get a collection' do
do_request
expect(path).to eq("/v1/collections/#{id}") # `:id` is replaced with the value of `id`
expect(response_body).to eq(Helper.serialize(Collection.find(id)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment