rabl 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
- ## 0.7.5 (unreleased)
3
+ ## 0.7.6 (unreleased)
4
+
5
+ ## 0.7.5
6
+
7
+ * Avoid incorrectly setting implicit objects for 'object false' partials
4
8
 
5
9
  ## 0.7.4
6
10
 
@@ -110,7 +110,7 @@ module Rabl
110
110
  def extends(file, options={}, &block)
111
111
  options = @options.slice(:child_root).merge(:object => @_object).merge(options)
112
112
  result = self.partial(file, options, &block)
113
- @_result.merge!(result) if result
113
+ @_result.merge!(result) if result.is_a?(Hash)
114
114
  end
115
115
 
116
116
  # resolve_condition(:if => true) => true
@@ -26,7 +26,7 @@ module Rabl
26
26
  locals.each { |k,v| instance_variable_set(:"@#{k}", v) }
27
27
  @_options[:scope] = @_scope
28
28
  @_options[:format] ||= self.request_format
29
- @_data = locals[:object] || self.default_object
29
+ @_data = locals[:object].nil? ? self.default_object : locals[:object]
30
30
  if @_options[:source_location]
31
31
  instance_eval(@_source, @_options[:source_location]) if @_source.present?
32
32
  else # without source location
@@ -1,3 +1,3 @@
1
1
  module Rabl
2
- VERSION = "0.7.4"
2
+ VERSION = "0.7.5"
3
3
  end
@@ -5,6 +5,13 @@ require File.expand_path('../models/ormless', __FILE__)
5
5
 
6
6
  context "Rabl::Engine" do
7
7
  helper(:rabl) { |t| RablTemplate.new { t } }
8
+ # context_scope 'users', [@user]
9
+ helper(:context_scope) { |name, value|
10
+ scope = Object.new
11
+ stub(scope).controller { stub(Object).controller_name { name } }
12
+ scope.instance_variable_set :"@#{name}", value
13
+ scope
14
+ }
8
15
 
9
16
  context "#initialize" do
10
17
  setup do
@@ -318,9 +325,7 @@ context "Rabl::Engine" do
318
325
  template = rabl %{
319
326
  attribute :name
320
327
  }
321
- scope = Object.new
322
- stub(scope).controller { stub(Object).controller_name { "a/b/c::d/user" } }
323
- scope.instance_variable_set :@user, User.new
328
+ scope = context_scope('user', User.new)
324
329
  template.render(scope).split
325
330
  end.equals "{\"name\":\"rabl\"}".split
326
331
 
@@ -5,6 +5,13 @@ require File.expand_path('../teststrap', __FILE__)
5
5
 
6
6
  context "Rabl::Renderer" do
7
7
  helper(:tmp_path) { @tmp_path ||= Pathname.new(Dir.mktmpdir) }
8
+ # context_scope 'users', [@user]
9
+ helper(:context_scope) { |name, value|
10
+ scope = Object.new
11
+ stub(scope).controller { stub(Object).controller_name { name } }
12
+ scope.instance_variable_set :"@#{name}", value
13
+ scope
14
+ }
8
15
 
9
16
  context "#render" do
10
17
  asserts 'renders empty array' do
@@ -137,7 +144,8 @@ context "Rabl::Renderer" do
137
144
  )
138
145
  end
139
146
 
140
- renderer = Rabl::Renderer.new('user', false, :view_path => tmp_path)
147
+ scope = context_scope('users', [User.new, User.new, User.new])
148
+ renderer = Rabl::Renderer.new('user', false, :view_path => tmp_path, :scope => scope)
141
149
  JSON.parse(renderer.render)
142
150
  end.equals(JSON.parse(%Q^{"foo":"baz", "baz":"bar" }^))
143
151
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: