mmangino-facebooker 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/facebooker/rails/publisher.rb +13 -3
- data/test/publisher_test.rb +21 -0
- metadata +1 -1
@@ -34,6 +34,7 @@ module Facebooker
|
|
34
34
|
# def publish_action(f)
|
35
35
|
# send_as :user_action
|
36
36
|
# from f
|
37
|
+
# story_size SHORT # or ONE_LINE or FULL
|
37
38
|
# data :friend=>"Mike"
|
38
39
|
# end
|
39
40
|
#
|
@@ -87,6 +88,12 @@ module Facebooker
|
|
87
88
|
#
|
88
89
|
# Publisher makes many helpers available, including the linking and asset helpers
|
89
90
|
class Publisher
|
91
|
+
|
92
|
+
#story sizes from the Facebooker API
|
93
|
+
ONE_LINE=1
|
94
|
+
SHORT=2
|
95
|
+
FULL=4
|
96
|
+
|
90
97
|
def initialize
|
91
98
|
@controller = PublisherController.new
|
92
99
|
end
|
@@ -213,11 +220,14 @@ module Facebooker
|
|
213
220
|
attr_accessor :body_general
|
214
221
|
attr_accessor :template_id
|
215
222
|
attr_accessor :template_name
|
216
|
-
|
223
|
+
attr_accessor :story_size
|
217
224
|
def target_ids=(val)
|
218
225
|
@target_ids = val.is_a?(Array) ? val.join(",") : val
|
219
226
|
end
|
220
|
-
|
227
|
+
def data_hash
|
228
|
+
default_data = story_size.nil? ? {} : {:story_size=>story_size}
|
229
|
+
default_data.merge(data||{})
|
230
|
+
end
|
221
231
|
end
|
222
232
|
|
223
233
|
cattr_accessor :ignore_errors
|
@@ -351,7 +361,7 @@ module Facebooker
|
|
351
361
|
when Ref
|
352
362
|
Facebooker::Session.create.server_cache.set_ref_handle(_body.handle,_body.fbml)
|
353
363
|
when UserAction
|
354
|
-
@from.session.publish_user_action(_body.template_id,_body.
|
364
|
+
@from.session.publish_user_action(_body.template_id,_body.data_hash,_body.target_ids,_body.body_general)
|
355
365
|
else
|
356
366
|
raise UnspecifiedBodyType.new("You must specify a valid send_as")
|
357
367
|
end
|
data/test/publisher_test.rb
CHANGED
@@ -118,6 +118,14 @@ class TestPublisher < Facebooker::Rails::Publisher
|
|
118
118
|
from user
|
119
119
|
data :friend=>"Mike"
|
120
120
|
end
|
121
|
+
def user_action_with_story_size(user)
|
122
|
+
send_as :user_action
|
123
|
+
from user
|
124
|
+
story_size ONE_LINE
|
125
|
+
story_size FULL
|
126
|
+
story_size SHORT
|
127
|
+
data :friend=>"Mike"
|
128
|
+
end
|
121
129
|
def user_action_no_data(user)
|
122
130
|
send_as :user_action
|
123
131
|
from user
|
@@ -353,6 +361,19 @@ class PublisherTest < Test::Unit::TestCase
|
|
353
361
|
TestPublisher.deliver_user_action(@from_user)
|
354
362
|
end
|
355
363
|
|
364
|
+
def test_publish_user_action_with_story_size
|
365
|
+
@from_user = Facebooker::User.new
|
366
|
+
@session = Facebooker::Session.new("","")
|
367
|
+
@from_user.stubs(:session).returns(@session)
|
368
|
+
@session.expects(:publish_user_action).with(20309041537,{:friend=>"Mike", :story_size=>2},nil,nil)
|
369
|
+
|
370
|
+
Facebooker::Rails::Publisher::FacebookTemplate.expects(:bundle_id_for_class_and_method).
|
371
|
+
with(TestPublisher, 'user_action_with_story_size').
|
372
|
+
returns(20309041537)
|
373
|
+
TestPublisher.deliver_user_action_with_story_size(@from_user)
|
374
|
+
|
375
|
+
end
|
376
|
+
|
356
377
|
def test_publishing_user_data_no_action_gives_nil_hash
|
357
378
|
@from_user = Facebooker::User.new
|
358
379
|
@session = Facebooker::Session.new("","")
|