grape_ape_rails 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9319abecd74d853d55d236bda20394144d4344c
4
- data.tar.gz: 6111be1dfa521795b482cac451ae1e8a4ffe6b96
3
+ metadata.gz: 9ed5d31f357458ac47e0fea4de39a228190de119
4
+ data.tar.gz: 9b497df070f5e9eb8be89d62d2b722035dcab780
5
5
  SHA512:
6
- metadata.gz: 947b19eb36e0944719cf6b5e7c9e0a506f3ab38edb234153ffe2d4fa985c66a22d4c76ea97f6d5e0c76e2b5f24c795f895a5ea6c74f5b3bc5b8f6ae5f1dab2ba
7
- data.tar.gz: a430845cf35a6f7568a6e49abc251047338029d77f20e93d070564adc4e052882235613da5d3ff62db39069609c181d51ab76192e3bc5636945effb7e04a5141
6
+ metadata.gz: 2e9ddff44eebbd29203bb36644b91a7c8c0f36ad7c8c551429b1ecdb1930073d8d7de8a2a148821f79299e9e421882f16c0c87e2d2fa09138cb55a4fb29cfee6
7
+ data.tar.gz: 6d39757e3076506730ad99544907cfc096cb12a9c405fc27185299366f01f21e357759cad029b4525d70f1534cb4e78e6aa92c2205abc9ddcc570f90a0242398
@@ -40,7 +40,8 @@ module Grape
40
40
  return %Q[{\"result\":#{MultiJson.dump(serializer)}}] if [serializer.object].flatten.size > 1
41
41
 
42
42
  serializer.root = false
43
- %Q[{\"result\":{\"#{plural}\":[#{MultiJson.dump(serializer)}]}}]
43
+ out = serializer.object.try(:empty?) ? nil : MultiJson.dump(serializer)
44
+ %Q[{\"result\":{\"#{plural}\":[#{out}]}}]
44
45
  else
45
46
  Grape::Formatter::GarJsonSerializer.call serializer.object, env
46
47
  end
@@ -1,3 +1,3 @@
1
1
  module GrapeApeRails
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
@@ -5,6 +5,13 @@ module API
5
5
 
6
6
  formatter :json, Grape::Formatter::GarActiveModelSerializers
7
7
 
8
+ resource :nothing_monkeys do
9
+ desc "Get nothing"
10
+ get '/' do
11
+ @monkeys = []
12
+ end
13
+ end
14
+
8
15
  resource :monkeys do
9
16
  desc "Get many monkeys"
10
17
  get '/' do
Binary file
@@ -27,4 +27,14 @@ describe API::V1::Monkeys do
27
27
  expect(json_result[:monkeys].size).to eql 3
28
28
  end
29
29
  end
30
+
31
+ describe "GET /nothings" do
32
+ it "returns proper empty array [], using the ActiveModelSerializers" do
33
+ 3.times { FactoryGirl.create :monkey }
34
+ req :get, "/nothing_monkeys"
35
+ expect(response.status).to eql 200
36
+ expect(json_result[:nothing_monkeys]).to eql([])
37
+ end
38
+ end
39
+
30
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape_ape_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt E. Patterson