honkster-jelly 0.8.3 → 0.8.4
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.
data/VERSION.yml
CHANGED
data/jelly.gemspec
CHANGED
|
@@ -4,7 +4,7 @@ module JellyController
|
|
|
4
4
|
|
|
5
5
|
def jelly_callback(callback_base_name = @action_name, options = {}, &block)
|
|
6
6
|
raw_jelly_callback(options) do
|
|
7
|
-
arguments = block
|
|
7
|
+
arguments = block ? instance_eval(&block) || [] : []
|
|
8
8
|
arguments = [arguments] unless arguments.is_a?(Array)
|
|
9
9
|
jelly_callback_hash("on_#{callback_base_name}", *arguments).merge(options)
|
|
10
10
|
end
|
|
@@ -3,11 +3,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
|
|
3
3
|
describe ApplicationController do
|
|
4
4
|
|
|
5
5
|
describe "#jelly_callback" do
|
|
6
|
-
attr_reader :
|
|
6
|
+
attr_reader :template
|
|
7
7
|
before do
|
|
8
|
-
@response = Struct.new(:body).new
|
|
9
8
|
stub(@controller).render do |params|
|
|
10
|
-
|
|
9
|
+
@template = ActionView::Base.new(@controller.class.view_paths, {}, @controller)
|
|
10
|
+
template.send(:_evaluate_assigns_and_ivars)
|
|
11
|
+
response.body = ERB.new(params[:inline]).result(template.send(:binding))
|
|
11
12
|
end
|
|
12
13
|
end
|
|
13
14
|
|
|
@@ -16,6 +17,17 @@ describe ApplicationController do
|
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
describe "Arguments block" do
|
|
20
|
+
describe "self" do
|
|
21
|
+
it "runs with the binding of the ERB template" do
|
|
22
|
+
self_in_block = nil
|
|
23
|
+
@controller.send(:jelly_callback, 'foo', :format => :json) do
|
|
24
|
+
self_in_block = self
|
|
25
|
+
12345
|
|
26
|
+
end
|
|
27
|
+
self_in_block.should == template
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
19
31
|
context "when an Array is returned from the block" do
|
|
20
32
|
it "sets the arguments to be an Array around the Hash" do
|
|
21
33
|
@controller.send(:jelly_callback, 'foo', :format => :json) do
|