From 69b4c97fb40cd7ee4fa9cde044c1eb005653ef79 Mon Sep 17 00:00:00 2001
From: Giovanne Marcelo <gms15@inf.ufpr.br>
Date: Wed, 15 Feb 2017 17:38:51 -0200
Subject: [PATCH] add index and show for object type

---
 spec/acceptance/object_types_spec.rb | 34 ++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 spec/acceptance/object_types_spec.rb

diff --git a/spec/acceptance/object_types_spec.rb b/spec/acceptance/object_types_spec.rb
new file mode 100644
index 00000000..0c2527af
--- /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
-- 
GitLab