honkster-jelly 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 8
3
- :patch: 1
3
+ :patch: 2
4
4
  :major: 0
@@ -24,7 +24,7 @@ if(!window.Jelly) Jelly = new Object();
24
24
  dataType: 'json',
25
25
  cache: false,
26
26
  success : function(callbacks) {
27
- Jelly.notifyObservers.call(observers, callbacks);
27
+ Jelly.Observers.notify.call(observers, callbacks);
28
28
  }
29
29
  }, otherParams);
30
30
  };
@@ -2,7 +2,7 @@
2
2
  * Jelly. a sweet unobtrusive javascript framework
3
3
  * for jQuery and Rails
4
4
  *
5
- * version 0.8.1
5
+ * version 0.8.2
6
6
  *
7
7
  * Copyright (c) 2009 Pivotal Labs
8
8
  * Licensed under the MIT license.
data/jelly.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jelly}
8
- s.version = "0.8.1"
8
+ s.version = "0.8.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Pivotal Labs, Inc"]
@@ -5,6 +5,7 @@ module JellyController
5
5
  def jelly_callback(callback_base_name = @action_name, options = {}, &block)
6
6
  raw_jelly_callback(options) do
7
7
  arguments = block.try(:call) || []
8
+ arguments = [arguments] unless arguments.is_a?(Array)
8
9
  jelly_callback_hash("on_#{callback_base_name}", *arguments).merge(options)
9
10
  end
10
11
  end
@@ -15,6 +15,54 @@ describe ApplicationController do
15
15
  @controller.respond_to?(:jelly_callback).should be_true
16
16
  end
17
17
 
18
+ describe "Arguments block" do
19
+ context "when an Array is returned from the block" do
20
+ it "sets the arguments to be an Array around the Hash" do
21
+ @controller.send(:jelly_callback, 'foo', :format => :json) do
22
+ ["foo", "bar"]
23
+ end
24
+ callback = JSON.parse(response.body)
25
+ callback["method"].should == "on_foo"
26
+ callback["arguments"].should == ["foo", "bar"]
27
+ end
28
+ end
29
+
30
+ context "when a non-array is returned in the block" do
31
+ context "when the argument is a Hash" do
32
+ it "sets the arguments to be an Array around the Hash" do
33
+ @controller.send(:jelly_callback, 'foo', :format => :json) do
34
+ {"foo" => "bar"}
35
+ end
36
+ callback = JSON.parse(response.body)
37
+ callback["method"].should == "on_foo"
38
+ callback["arguments"].should == [{"foo" => "bar"}]
39
+ end
40
+ end
41
+
42
+ context "when the argument is a String" do
43
+ it "sets the arguments to be an Array around the argument" do
44
+ @controller.send(:jelly_callback, 'foo', :format => :json) do
45
+ "foobar"
46
+ end
47
+ callback = JSON.parse(response.body)
48
+ callback["method"].should == "on_foo"
49
+ callback["arguments"].should == ["foobar"]
50
+ end
51
+ end
52
+
53
+ context "when the argument is a Number" do
54
+ it "sets the arguments to be an Array around the argument" do
55
+ @controller.send(:jelly_callback, 'foo', :format => :json) do
56
+ 12345
57
+ end
58
+ callback = JSON.parse(response.body)
59
+ callback["method"].should == "on_foo"
60
+ callback["arguments"].should == [12345]
61
+ end
62
+ end
63
+ end
64
+ end
65
+
18
66
  context "when given a format" do
19
67
  describe "json" do
20
68
  it "responds with a json hash, even if the request is not xhr" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honkster-jelly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pivotal Labs, Inc