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

index complaints test

parent 90044d28
No related branches found
No related tags found
No related merge requests found
require 'acceptance_helpers'
resource 'Complaints' do
header 'Accept', 'application/json'
header 'Content-Type', 'application/json'
before { 12.times { create(:complaint) } }
let(:complaints) { Complaint.all }
get '/v1/complaints' do
parameter :limit, 'Limit of complaints'
parameter :offset, 'Offset of complaints'
let(:limit) { 12 }
let(:offset) { 0 }
example_request 'Get a list of complaints' do
# active model serializer may render model associations in different order for collections (array of items), so we're verifing only returned ids
expect(JSON.parse(response_body).map { |o| o['id'] }.sort).to eq(Complaint.limit(limit).offset(offset).pluck(:id).sort)
expect(status).to eq(200)
end
end
end
FactoryGirl.define do
factory :complaint do
user
complainable
complaint_reason
description { Faker::Lorem.paragraph }
end
end
FactoryGirl.define do
factory :complaint_reason do
reason { Faker::Lorem.paragraph }
end
end
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