acts_as_caesar 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/acts_as_caesar/rack.rb +2 -2
- data/lib/acts_as_caesar/version.rb +1 -1
- data/spec/rack_spec.rb +2 -2
- metadata +2 -2
data/lib/acts_as_caesar/rack.rb
CHANGED
@@ -41,7 +41,7 @@ module Rack
|
|
41
41
|
voter.vote_placed_on(c)
|
42
42
|
end
|
43
43
|
# return an array of vote objects
|
44
|
-
[200, {"Content-Type" => "application/json"}, [MultiJson.dump(votes.map(&:to_json))]]
|
44
|
+
[200, {"Content-Type" => "application/json"}, [MultiJson.respond_to?(:dump) ? MultiJson.dump(votes.map(&:to_json)) : MultiJson.encode(votes.map(&:to_json))]]
|
45
45
|
end
|
46
46
|
|
47
47
|
def update_vote(voter, candidate, value)
|
@@ -49,7 +49,7 @@ module Rack
|
|
49
49
|
candidate = ::ActsAsCaesar::Candidate.new(candidate)
|
50
50
|
vote = voter.update_vote(candidate, value)
|
51
51
|
# return the vote object
|
52
|
-
[200, {"Content-Type" => "application/json"}, [MultiJson.dump(vote.to_json)]]
|
52
|
+
[200, {"Content-Type" => "application/json"}, [MultiJson.respond_to?(:dump) ? MultiJson.dump(vote.to_json) : MultiJson.encode(vote.to_json)]]
|
53
53
|
end
|
54
54
|
|
55
55
|
def not_found
|
data/spec/rack_spec.rb
CHANGED
@@ -44,7 +44,7 @@ describe Rack::ActsAsCaesar do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
context "the JSON response" do
|
47
|
-
subject { MultiJson.load(last_response.body) }
|
47
|
+
subject { MultiJson.respond_to?(:load) ? MultiJson.load(last_response.body) : MultiJson.decode(last_response.body) }
|
48
48
|
|
49
49
|
it { should be_kind_of Array }
|
50
50
|
|
@@ -78,7 +78,7 @@ describe Rack::ActsAsCaesar do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should return a JSON encoded string of the new vote" do
|
81
|
-
vote = MultiJson.load(last_response.body)
|
81
|
+
vote = MultiJson.respond_to?(:load) ? MultiJson.load(last_response.body) : MultiJson.decode(last_response.body)
|
82
82
|
vote['candidate'].should == 'candidate_1'
|
83
83
|
vote['voter'].should == 'voter_1'
|
84
84
|
vote['value'].should == -1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_caesar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|