Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow specifying a template id

  • Loading branch information...
commit f454ced77300f79d379965c6851e759c02cfda87 1 parent e6e19a3
@mmangino authored
View
3  lib/facebooker/rails/publisher.rb
@@ -224,6 +224,7 @@ class UserAction
attr_accessor :template_id
attr_accessor :template_name
attr_accessor :story_size
+
def target_ids=(val)
@target_ids = val.is_a?(Array) ? val.join(",") : val
end
@@ -471,7 +472,7 @@ def method_missing(name,*args)
case publisher._body
when UserAction
publisher._body.template_name = method
- publisher._body.template_id = FacebookTemplate.bundle_id_for_class_and_method(self,method)
+ publisher._body.template_id ||= FacebookTemplate.bundle_id_for_class_and_method(self,method)
end
should_send ? publisher.send_message(method) : publisher._body
View
16 test/facebooker/rails/publisher_test.rb
@@ -108,6 +108,13 @@ def user_action(user)
from user
data :friend=>"Mike"
end
+
+ def user_action_with_template_id(user)
+ send_as :user_action
+ from user
+ data :friend=>"Mike"
+ template_id 4
+ end
def user_action_with_story_size(user)
send_as :user_action
from user
@@ -335,6 +342,15 @@ def test_create_user_action
ua = TestPublisher.create_user_action(@from_user)
assert_equal "user_action", ua.template_name
end
+ def test_create_user_action_with_template_id
+ @from_user = Facebooker::User.new
+ @session = Facebooker::Session.new("","")
+ @from_user.stubs(:session).returns(@session)
+ Facebooker::Rails::Publisher::FacebookTemplate.expects(:bundle_id_for_class_and_method).
+ with(TestPublisher,'user_action').never
+ ua = TestPublisher.create_user_action_with_template_id(@from_user)
+ assert_equal 4,ua.template_id
+ end
def test_publisher_user_action
@from_user = Facebooker::User.new
Please sign in to comment.
Something went wrong with that request. Please try again.