diff --git a/spec/acceptance/institutions_spec.rb b/spec/acceptance/institutions_spec.rb index 5382007d40c05d3ed1d44e2871c0b566db0602b5..f09deabdd0a190821bd673443235556f17411ad6 100644 --- a/spec/acceptance/institutions_spec.rb +++ b/spec/acceptance/institutions_spec.rb @@ -25,7 +25,7 @@ resource 'Institutions' do get '/v1/institutions/:id' do let(:id) { institutions.first.id } - example 'Get a institution' do + example 'Get an institution' do do_request expect(path).to eq("/v1/institutions/#{id}") # `:id` is replaced with the value of `id` expect(response_body).to eq(Helper.serialize(Institution.find(id))) diff --git a/spec/acceptance/subjects_spec.rb b/spec/acceptance/subjects_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..077ba186e37c04bb25bb686715f51acd751c4ce8 --- /dev/null +++ b/spec/acceptance/subjects_spec.rb @@ -0,0 +1,25 @@ +require 'acceptance_helpers' + +resource 'Subjects' do + header 'Accept', 'application/json' + header 'Content-Type', 'application/json' + + before { 12.times { create(:subject) } } + + let(:subjects) { Subject.all } + + get '/v1/subjects' do + parameter :limit, 'Limit of subjects' + parameter :offset, 'Offset of subjects' + + let(:limit) { 12 } + let(:offset) { 0 } + + example_request 'Get a list of subjects' 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(Subject.limit(limit).offset(offset).pluck(:id).sort) + expect(status).to eq(200) + end + end + +end diff --git a/spec/factories/institutions.rb b/spec/factories/institutions.rb index ce3c0c4d3824059e33ea650986d5f464936c069a..734bf3b978b93a9d6f1fae7e103f526b3be46fad 100644 --- a/spec/factories/institutions.rb +++ b/spec/factories/institutions.rb @@ -1,5 +1,5 @@ FactoryGirl.define do - factory :institution do |m| + factory :institution do name { Faker::Name.name } description { Faker::Lorem.paragraph } address { Faker::Address.street_address } diff --git a/spec/factories/subjects.rb b/spec/factories/subjects.rb new file mode 100644 index 0000000000000000000000000000000000000000..33b6d895076c0ca0b424366cfbf6a9e141bab60d --- /dev/null +++ b/spec/factories/subjects.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :subject do + name { Faker::Name.name } + end +end