rabl 0.10.0 → 0.10.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 +8 -8
- data/CHANGELOG.md +4 -0
- data/fixtures/rails3_2/test/functional/posts_controller_test.rb +12 -13
- data/fixtures/rails4/test/functional/posts_controller_test.rb +12 -13
- data/lib/rabl/engine.rb +1 -1
- data/lib/rabl/version.rb +1 -1
- data/test/engine_test.rb +24 -0
- data/test/integration/rails3_2/posts_controller_test.rb +12 -13
- data/test/integration/rails4/posts_controller_test.rb +12 -13
- metadata +2 -3
- data/TODO +0 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDMwMmY3ZDU1N2QwN2Y3OGNjZmRlOTljMGRiZGE1NDU3ZjQwYmViNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzliNzM2YThjMmUxNzg3OTdhYzc5M2FiMmVhNmEwOTljYjBjYWI5Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTQ5YWQ4ZjYwNmRiMzc4YmRlYzIyYWZhZTA4Nzk3NzAyMWQxMDNlMzU5ZDdl
|
10
|
+
M2JiOTBhYTQxNDUwZjIwZjhhYmQ0ZWMyMDFiYTkyODhkMmU0MWNhMDNjY2Y5
|
11
|
+
MGQ3NTAzZDM0YmM0NzUwNmU1YjZjZTRhOTdhNjZmYzI5NjE4ZDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmRiZjE3ZGYyZjU3M2FlZWViYjkzYjgzZjU4MTU3YjA4Y2JkZjFmNjE0NjA1
|
14
|
+
MDcyMTc2M2E2MjgyMGE2ZTI3NWZkN2IyN2MyZWE5MGJiMWM3ZWI4OGQyZDI1
|
15
|
+
NmZmMjRmMGE5YWQ3MjE5ODI0N2JkY2IwNDEzZGMwMjUzMWRlOGM=
|
data/CHANGELOG.md
CHANGED
@@ -221,19 +221,18 @@ context "PostsController" do
|
|
221
221
|
end.equals { @posts.map{ |p| cache_hit([p, nil, 'hash'])[:title] } }
|
222
222
|
end # index action, caching, json
|
223
223
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
#
|
236
|
-
# end # index action, caching, xml
|
224
|
+
context "for index action with caching in xml" do
|
225
|
+
setup do
|
226
|
+
get "/posts", format: :xml
|
227
|
+
end
|
228
|
+
|
229
|
+
asserts("contains post titles") do
|
230
|
+
doc = REXML::Document.new topic.body
|
231
|
+
doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
|
232
|
+
end.equals { @posts.map(&:title) }
|
233
|
+
|
234
|
+
asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml'] }
|
235
|
+
end # index action, caching, xml
|
237
236
|
|
238
237
|
context "for show action with caching" do
|
239
238
|
setup do
|
@@ -206,19 +206,18 @@ context "PostsController" do
|
|
206
206
|
end.equals { @posts.map { |p| cache_hit([p, nil, 'hash', 'e373525f49a3b3b044af05255e84839d'])[:title] } }
|
207
207
|
end # index action, caching, json
|
208
208
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
#
|
221
|
-
# end # index action, caching, xml
|
209
|
+
context "for index action with caching in xml" do
|
210
|
+
setup do
|
211
|
+
get "/posts", format: :xml
|
212
|
+
end
|
213
|
+
|
214
|
+
asserts("contains post titles") do
|
215
|
+
doc = REXML::Document.new topic.body
|
216
|
+
doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
|
217
|
+
end.equals { @posts.map(&:title) }
|
218
|
+
|
219
|
+
asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml', 'e83f65eee5ffb454c418a59105f222c4'] }
|
220
|
+
end # index action, caching, xml
|
222
221
|
|
223
222
|
context "for show action with caching" do
|
224
223
|
setup do
|
data/lib/rabl/engine.rb
CHANGED
@@ -269,7 +269,6 @@ module Rabl
|
|
269
269
|
@_options[:extends] = []
|
270
270
|
@_options[:root_name] = nil
|
271
271
|
@_options[:scope] = scope
|
272
|
-
@_options[:format] ||= self.request_format
|
273
272
|
end
|
274
273
|
|
275
274
|
# Caches the results of the block based on object cache_key
|
@@ -315,6 +314,7 @@ module Rabl
|
|
315
314
|
def set_instance_variables!(scope, locals, &block)
|
316
315
|
@_locals, @_scope = locals, scope
|
317
316
|
self.copy_instance_variables_from(@_scope, [:@assigns, :@helpers])
|
317
|
+
@_options[:format] ||= self.request_format
|
318
318
|
set_locals(locals)
|
319
319
|
set_source(locals, &block)
|
320
320
|
end
|
data/lib/rabl/version.rb
CHANGED
data/test/engine_test.rb
CHANGED
@@ -23,6 +23,30 @@ context "Rabl::Engine" do
|
|
23
23
|
asserts_topic.assigns :_view_path
|
24
24
|
end
|
25
25
|
|
26
|
+
context "#request_format" do
|
27
|
+
context "is json by default" do
|
28
|
+
setup do
|
29
|
+
template = RablTemplate.new("code") { "" }
|
30
|
+
template.render(Object.new)
|
31
|
+
engine = template.instance_eval('@engine')
|
32
|
+
engine.instance_eval('@_options')[:format]
|
33
|
+
end
|
34
|
+
|
35
|
+
asserts_topic.equals('json')
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with a specified format" do
|
39
|
+
setup do
|
40
|
+
template = RablTemplate.new("code", format: 'xml') { "" }
|
41
|
+
template.render(Object.new)
|
42
|
+
engine = template.instance_eval('@engine')
|
43
|
+
engine.instance_eval('@_options')[:format]
|
44
|
+
end
|
45
|
+
|
46
|
+
asserts_topic.equals('xml')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
26
50
|
context "#cache" do
|
27
51
|
context "with cache" do
|
28
52
|
setup do
|
@@ -221,19 +221,18 @@ context "PostsController" do
|
|
221
221
|
end.equals { @posts.map{ |p| cache_hit([p, nil, 'hash'])[:title] } }
|
222
222
|
end # index action, caching, json
|
223
223
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
#
|
236
|
-
# end # index action, caching, xml
|
224
|
+
context "for index action with caching in xml" do
|
225
|
+
setup do
|
226
|
+
get "/posts", format: :xml
|
227
|
+
end
|
228
|
+
|
229
|
+
asserts("contains post titles") do
|
230
|
+
doc = REXML::Document.new topic.body
|
231
|
+
doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
|
232
|
+
end.equals { @posts.map(&:title) }
|
233
|
+
|
234
|
+
asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml'] }
|
235
|
+
end # index action, caching, xml
|
237
236
|
|
238
237
|
context "for show action with caching" do
|
239
238
|
setup do
|
@@ -206,19 +206,18 @@ context "PostsController" do
|
|
206
206
|
end.equals { @posts.map { |p| cache_hit([p, nil, 'hash', 'e373525f49a3b3b044af05255e84839d'])[:title] } }
|
207
207
|
end # index action, caching, json
|
208
208
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
#
|
221
|
-
# end # index action, caching, xml
|
209
|
+
context "for index action with caching in xml" do
|
210
|
+
setup do
|
211
|
+
get "/posts", format: :xml
|
212
|
+
end
|
213
|
+
|
214
|
+
asserts("contains post titles") do
|
215
|
+
doc = REXML::Document.new topic.body
|
216
|
+
doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
|
217
|
+
end.equals { @posts.map(&:title) }
|
218
|
+
|
219
|
+
asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml', 'e83f65eee5ffb454c418a59105f222c4'] }
|
220
|
+
end # index action, caching, xml
|
222
221
|
|
223
222
|
context "for show action with caching" do
|
224
223
|
setup do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Esquenazi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -152,7 +152,6 @@ files:
|
|
152
152
|
- MIT-LICENSE
|
153
153
|
- README.md
|
154
154
|
- Rakefile
|
155
|
-
- TODO
|
156
155
|
- examples/base.json.rabl
|
157
156
|
- examples/demo.json.rabl
|
158
157
|
- examples/inherited.json.rabl
|