checkdin 0.2.1 → 0.2.2
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/README.rdoc +1 -1
- data/lib/checkdin/activities.rb +13 -0
- data/lib/checkdin/promotions.rb +14 -0
- data/lib/checkdin/version.rb +1 -1
- data/spec/checkdin/activities_spec.rb +26 -0
- data/spec/checkdin/promotions_spec.rb +28 -0
- metadata +1 -1
data/README.rdoc
CHANGED
data/lib/checkdin/activities.rb
CHANGED
@@ -25,5 +25,18 @@ module Checkdin
|
|
25
25
|
return_error_or_body(response)
|
26
26
|
end
|
27
27
|
|
28
|
+
# Add a vote for a single activity when voting is enabled for its promotion
|
29
|
+
#
|
30
|
+
# param [Integer] id The ID of the activity
|
31
|
+
# @param [Hash] options
|
32
|
+
# @option options Integer :user_id - The user that is performing this vote.
|
33
|
+
|
34
|
+
def add_vote_on_activity(id, options={})
|
35
|
+
response = connection.post do |req|
|
36
|
+
req.url "activities/#{id}/vote", options
|
37
|
+
end
|
38
|
+
return_error_or_body(response)
|
39
|
+
end
|
40
|
+
|
28
41
|
end
|
29
42
|
end
|
data/lib/checkdin/promotions.rb
CHANGED
@@ -24,5 +24,19 @@ module Checkdin
|
|
24
24
|
return_error_or_body(response)
|
25
25
|
end
|
26
26
|
|
27
|
+
# Get a list of activities for a promotion ordered by the number of votes they have received
|
28
|
+
#
|
29
|
+
# param [Integer] id The ID ofthe promotion
|
30
|
+
# @param [Hash] options
|
31
|
+
# @option options Integer :limit - The maximum number of records to return.
|
32
|
+
# @option options Integer :page - The page of results to return.
|
33
|
+
|
34
|
+
def promotion_votes_leaderboard(id, options={})
|
35
|
+
response = connection.get do |req|
|
36
|
+
req.url "promotions/#{id}/votes_leaderboard", options
|
37
|
+
end
|
38
|
+
return_error_or_body(response)
|
39
|
+
end
|
40
|
+
|
27
41
|
end
|
28
42
|
end
|
data/lib/checkdin/version.rb
CHANGED
@@ -43,4 +43,30 @@ describe Checkdin::Activities do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
46
|
+
|
47
|
+
context "voting for an activity" do
|
48
|
+
use_vcr_cassette
|
49
|
+
let(:result) { @client.add_vote_on_activity(18881) }
|
50
|
+
|
51
|
+
it "should make the activity's information available" do
|
52
|
+
result.activity.type.should == "twitter_status"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should register the vote" do
|
56
|
+
result.activity.vote_count.should == 6
|
57
|
+
end
|
58
|
+
|
59
|
+
context "passing an email" do
|
60
|
+
use_vcr_cassette
|
61
|
+
let(:result) { @client.add_vote_on_activity(18881, :user_id => 36)}
|
62
|
+
|
63
|
+
it "should register the vote as normal" do
|
64
|
+
result.activity.type.should == "twitter_status"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should up the vote count as normal" do
|
68
|
+
result.activity.vote_count.should == 7
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
46
72
|
end
|
@@ -32,4 +32,32 @@ describe Checkdin::Promotions do
|
|
32
32
|
result.count.should == 2
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
context "viewing the votes leaderboard for a promotion" do
|
37
|
+
use_vcr_cassette
|
38
|
+
let(:result) { @client.promotion_votes_leaderboard(54, :limit => limit) }
|
39
|
+
let(:limit) { nil }
|
40
|
+
|
41
|
+
it "should return promotion information" do
|
42
|
+
result.promotion.title.should == "A voting promotion!"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should return a list of activities ordered by vote count" do
|
46
|
+
result.promotion.votes_leaderboard.activities.first.activity.vote_count.should == 7
|
47
|
+
result.promotion.votes_leaderboard.activities.last.activity.vote_count.should == 0
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return all activities" do
|
51
|
+
result.promotion.votes_leaderboard.activities.count.should == 3
|
52
|
+
end
|
53
|
+
|
54
|
+
context "limiting the number of records returned" do
|
55
|
+
use_vcr_cassette
|
56
|
+
let(:limit) { 1 }
|
57
|
+
|
58
|
+
it "should only return limit number of records" do
|
59
|
+
result.promotion.votes_leaderboard.activities.count.should == 1
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
35
63
|
end
|