diff --git a/spec/acceptance/collections_spec.rb b/spec/acceptance/collections_spec.rb index 8ab2ba4662e3e9bd9b3d7dc2f43b33d89d23a55a..9dd87444c7dd5f142b72c3fd2207928341acc965 100644 --- a/spec/acceptance/collections_spec.rb +++ b/spec/acceptance/collections_spec.rb @@ -8,21 +8,20 @@ resource 'Collections' do before { 12.times { create(:collection) } } - it_behaves_like "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 } @@ -35,6 +34,22 @@ resource 'Collections' do end end + delete '/v1/collections/:id' do + include_context "authenticate_user" + + let(:id) { @collection.id } + + before do + @collection = create(:collection, owner: @user) + end + + example 'Destroying a collection' do + do_request + expect(status).to eq(200) + end + + end + post '/v1/collections/:id/like' do include_context "authenticate_user"