collection_json_rails 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b9a0ef79365cfef15b52ed9e26cbd29c22bd01e
|
4
|
+
data.tar.gz: cc72ff0b9a2da4a313e07da85d0806e8d67cbcf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a65e5746f40197a9f62410b230bf52f1a2c4aaca5ec6d21c8639601f2d5fb10113aa1e9faac7ae4bec5058eb7d33880269a2a1cf9f96adeb54b4de5e85aca0c
|
7
|
+
data.tar.gz: 6b52b1fb434f03f5e185c6c94260f3aedf752fc76113a4dcd0906dc19783bcec7cf67b9836c804642dc2f159b0c052fe0e54e8c480a62ea79ba5ab02bcf3b73e
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_runtime_dependency "collection_json_serializer", "~> 0.3.
|
22
|
+
spec.add_runtime_dependency "collection_json_serializer", "~> 0.3.5"
|
23
23
|
|
24
24
|
spec.add_dependency "actionpack", "~> 4.0"
|
25
25
|
spec.add_dependency "railties", "~> 4.0"
|
@@ -12,6 +12,9 @@ module CollectionJson::Rails
|
|
12
12
|
if options[:json]
|
13
13
|
result[:json] = serialize(options[:json])
|
14
14
|
result[:status] = options[:status] || :ok
|
15
|
+
if is_collection_json?(result[:json])
|
16
|
+
result[:content_type] = CollectionJson::MIME_TYPE
|
17
|
+
end
|
15
18
|
end
|
16
19
|
|
17
20
|
result
|
@@ -42,6 +45,10 @@ module CollectionJson::Rails
|
|
42
45
|
resource_class = serializer_for(resource)
|
43
46
|
"#{resource_class}Serializer".safe_constantize
|
44
47
|
end
|
48
|
+
|
49
|
+
def is_collection_json?(hash)
|
50
|
+
hash.key?(:collection)
|
51
|
+
end
|
45
52
|
end
|
46
53
|
end
|
47
54
|
|
@@ -13,16 +13,24 @@ end
|
|
13
13
|
class TestRender < ActionController::TestCase
|
14
14
|
tests PostsController
|
15
15
|
|
16
|
+
def test_that_responds_with_collection_json
|
17
|
+
get :index, {}
|
18
|
+
|
19
|
+
assert_equal "application/vnd.collection+json", response.content_type
|
20
|
+
end
|
21
|
+
|
16
22
|
def test_that_objects_without_serializer_are_rendered_as_plain_json
|
17
23
|
get :without_serializer
|
18
24
|
|
19
25
|
assert_response :ok
|
26
|
+
assert_equal Mime::JSON, response.content_type
|
20
27
|
end
|
21
28
|
|
22
29
|
def test_that_render_behaves_as_usual
|
23
30
|
get :without_json
|
24
31
|
|
25
32
|
assert_response :ok
|
33
|
+
assert_equal Mime::TEXT, response.content_type
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collection_json_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carles Jove i Buxeda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: collection_json_serializer
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.3.
|
19
|
+
version: 0.3.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.3.
|
26
|
+
version: 0.3.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|