diff --git a/spec/acceptance/object_types_spec.rb b/spec/acceptance/object_types_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..0c2527af91d2b75195f99eecfe85cbfb8647b415 --- /dev/null +++ b/spec/acceptance/object_types_spec.rb @@ -0,0 +1,34 @@ +require 'acceptance_helpers' + +resource 'Object Type' do + header 'Accept', 'application/json' + header 'Content-Type', 'application/json' + + let(:object_types) { ObjectType.all } + + get '/v1/object_types' do + parameter :limit, 'Limit of object types' + parameter :offset, 'Offset of object types' + + let(:limit) { 12 } + let(:offset) { 0 } + + example_request 'Get a list of object types' 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(ObjectType.limit(limit).offset(offset).pluck(:id).sort) + expect(status).to eq(200) + end + end + + get '/v1/object_types/:id' do + let(:id) { object_types.first.id } + + example 'Get an object type' do + do_request + expect(path).to eq("/v1/object_types/#{id}") # `:id` is replaced with the value of `id` + expect(response_body).to eq(Helper.serialize(ObjectType.find(id))) + expect(status).to eq(200) + end + end + +end