Skip to content

Commit

Permalink
added Cell::Base#render_state_with_args.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Aug 15, 2011
1 parent d1a8402 commit f60ce89
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGES.textile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
h2. 3.6.5

h3. Bugfixes
* `Cell::TestCase#invoke` now properly accepts state-args.


h2. 3.6.4

h3. Bugfixes
Expand Down
8 changes: 6 additions & 2 deletions lib/cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def render_cell_for(controller, name, state, *args)
cell = create_cell_for(controller, name, *args) # DISCUSS: we always save options.
yield cell if block_given?

return cell.render_state(state, *args) if cell.state_accepts_args?(state)
cell.render_state(state) # backward-compat.
cell.render_state_with_args(state, *args)
end

# Creates a cell instance. Note that this method calls builders which were attached to the
Expand Down Expand Up @@ -77,6 +76,11 @@ def class_from_cell_name(cell_name)
end

module InstanceMethods
def render_state_with_args(state, *args) # TODO: remove me in 4.0.
return render_state(state, *args) if state_accepts_args?(state)
render_state(state) # backward-compat.
end

def state_accepts_args?(state)
method(state).arity != 0
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cell/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def in_view
attr_reader :last_invoke

def invoke(state, *args)
@last_invoke = self.class.controller_class.new(@controller, *args).render_state(state, *args)
@last_invoke = self.class.controller_class.new(@controller, *args).render_state_with_args(state, *args)
end
end
end

0 comments on commit f60ce89

Please sign in to comment.