tenderlove-facebooker 1.0.16.20090319151701

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/CHANGELOG.rdoc +17 -0
  2. data/COPYING.rdoc +19 -0
  3. data/Manifest.txt +123 -0
  4. data/README.rdoc +103 -0
  5. data/Rakefile +86 -0
  6. data/TODO.rdoc +4 -0
  7. data/examples/desktop_login.rb +14 -0
  8. data/facebooker.gemspec +38 -0
  9. data/generators/facebook/facebook_generator.rb +14 -0
  10. data/generators/facebook/templates/config/facebooker.yml +46 -0
  11. data/generators/facebook/templates/public/javascripts/facebooker.js +99 -0
  12. data/generators/facebook_controller/USAGE +33 -0
  13. data/generators/facebook_controller/facebook_controller_generator.rb +40 -0
  14. data/generators/facebook_controller/templates/controller.rb +7 -0
  15. data/generators/facebook_controller/templates/functional_test.rb +11 -0
  16. data/generators/facebook_controller/templates/helper.rb +2 -0
  17. data/generators/facebook_controller/templates/view.fbml.erb +2 -0
  18. data/generators/facebook_controller/templates/view.html.erb +2 -0
  19. data/generators/facebook_publisher/facebook_publisher_generator.rb +14 -0
  20. data/generators/facebook_publisher/templates/create_facebook_templates.rb +15 -0
  21. data/generators/facebook_publisher/templates/publisher.rb +3 -0
  22. data/generators/facebook_scaffold/USAGE +27 -0
  23. data/generators/facebook_scaffold/facebook_scaffold_generator.rb +118 -0
  24. data/generators/facebook_scaffold/templates/controller.rb +93 -0
  25. data/generators/facebook_scaffold/templates/facebook_style.css +2579 -0
  26. data/generators/facebook_scaffold/templates/functional_test.rb +89 -0
  27. data/generators/facebook_scaffold/templates/helper.rb +2 -0
  28. data/generators/facebook_scaffold/templates/layout.fbml.erb +6 -0
  29. data/generators/facebook_scaffold/templates/layout.html.erb +17 -0
  30. data/generators/facebook_scaffold/templates/style.css +74 -0
  31. data/generators/facebook_scaffold/templates/view_edit.fbml.erb +13 -0
  32. data/generators/facebook_scaffold/templates/view_edit.html.erb +18 -0
  33. data/generators/facebook_scaffold/templates/view_index.fbml.erb +24 -0
  34. data/generators/facebook_scaffold/templates/view_index.html.erb +24 -0
  35. data/generators/facebook_scaffold/templates/view_new.fbml.erb +12 -0
  36. data/generators/facebook_scaffold/templates/view_new.html.erb +17 -0
  37. data/generators/facebook_scaffold/templates/view_show.fbml.erb +10 -0
  38. data/generators/facebook_scaffold/templates/view_show.html.erb +10 -0
  39. data/generators/publisher/publisher_generator.rb +14 -0
  40. data/generators/xd_receiver/templates/xd_receiver.html +10 -0
  41. data/generators/xd_receiver/xd_receiver_generator.rb +9 -0
  42. data/init.rb +72 -0
  43. data/install.rb +12 -0
  44. data/lib/facebooker/adapters/adapter_base.rb +87 -0
  45. data/lib/facebooker/adapters/bebo_adapter.rb +75 -0
  46. data/lib/facebooker/adapters/facebook_adapter.rb +52 -0
  47. data/lib/facebooker/admin.rb +42 -0
  48. data/lib/facebooker/batch_request.rb +44 -0
  49. data/lib/facebooker/data.rb +57 -0
  50. data/lib/facebooker/feed.rb +78 -0
  51. data/lib/facebooker/logging.rb +51 -0
  52. data/lib/facebooker/mobile.rb +20 -0
  53. data/lib/facebooker/mock/service.rb +50 -0
  54. data/lib/facebooker/mock/session.rb +18 -0
  55. data/lib/facebooker/model.rb +135 -0
  56. data/lib/facebooker/models/affiliation.rb +10 -0
  57. data/lib/facebooker/models/album.rb +11 -0
  58. data/lib/facebooker/models/applicationproperties.rb +39 -0
  59. data/lib/facebooker/models/applicationrestrictions.rb +10 -0
  60. data/lib/facebooker/models/cookie.rb +10 -0
  61. data/lib/facebooker/models/education_info.rb +11 -0
  62. data/lib/facebooker/models/event.rb +28 -0
  63. data/lib/facebooker/models/friend_list.rb +16 -0
  64. data/lib/facebooker/models/group.rb +36 -0
  65. data/lib/facebooker/models/info_item.rb +10 -0
  66. data/lib/facebooker/models/info_section.rb +10 -0
  67. data/lib/facebooker/models/location.rb +8 -0
  68. data/lib/facebooker/models/notifications.rb +17 -0
  69. data/lib/facebooker/models/page.rb +27 -0
  70. data/lib/facebooker/models/photo.rb +12 -0
  71. data/lib/facebooker/models/tag.rb +12 -0
  72. data/lib/facebooker/models/user.rb +426 -0
  73. data/lib/facebooker/models/video.rb +9 -0
  74. data/lib/facebooker/models/work_info.rb +9 -0
  75. data/lib/facebooker/parser.rb +589 -0
  76. data/lib/facebooker/rails/controller.rb +304 -0
  77. data/lib/facebooker/rails/cucumber/world.rb +46 -0
  78. data/lib/facebooker/rails/cucumber.rb +28 -0
  79. data/lib/facebooker/rails/facebook_form_builder.rb +112 -0
  80. data/lib/facebooker/rails/facebook_pretty_errors.rb +22 -0
  81. data/lib/facebooker/rails/facebook_request_fix.rb +24 -0
  82. data/lib/facebooker/rails/facebook_session_handling.rb +69 -0
  83. data/lib/facebooker/rails/facebook_url_helper.rb +192 -0
  84. data/lib/facebooker/rails/facebook_url_rewriting.rb +39 -0
  85. data/lib/facebooker/rails/helpers/fb_connect.rb +89 -0
  86. data/lib/facebooker/rails/helpers.rb +762 -0
  87. data/lib/facebooker/rails/integration_session.rb +38 -0
  88. data/lib/facebooker/rails/profile_publisher_extensions.rb +42 -0
  89. data/lib/facebooker/rails/publisher.rb +526 -0
  90. data/lib/facebooker/rails/routing.rb +49 -0
  91. data/lib/facebooker/rails/test_helpers.rb +68 -0
  92. data/lib/facebooker/rails/utilities.rb +22 -0
  93. data/lib/facebooker/server_cache.rb +24 -0
  94. data/lib/facebooker/service.rb +94 -0
  95. data/lib/facebooker/session.rb +584 -0
  96. data/lib/facebooker/version.rb +9 -0
  97. data/lib/facebooker.rb +174 -0
  98. data/lib/net/http_multipart_post.rb +123 -0
  99. data/lib/tasks/facebooker.rake +18 -0
  100. data/lib/tasks/tunnel.rake +46 -0
  101. data/rails/init.rb +1 -0
  102. data/setup.rb +1585 -0
  103. data/templates/layout.erb +24 -0
  104. data/test/facebooker/adapters_test.rb +96 -0
  105. data/test/facebooker/admin_test.rb +102 -0
  106. data/test/facebooker/batch_request_test.rb +83 -0
  107. data/test/facebooker/data_test.rb +86 -0
  108. data/test/facebooker/logging_test.rb +43 -0
  109. data/test/facebooker/mobile_test.rb +45 -0
  110. data/test/facebooker/model_test.rb +123 -0
  111. data/test/facebooker/models/event_test.rb +15 -0
  112. data/test/facebooker/models/user_test.rb +295 -0
  113. data/test/facebooker/rails/publisher_test.rb +452 -0
  114. data/test/facebooker/rails_integration_test.rb +1312 -0
  115. data/test/facebooker/server_cache_test.rb +44 -0
  116. data/test/facebooker/session_test.rb +614 -0
  117. data/test/facebooker_test.rb +925 -0
  118. data/test/fixtures/multipart_post_body_with_only_parameters.txt +33 -0
  119. data/test/fixtures/multipart_post_body_with_single_file.txt +38 -0
  120. data/test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt +38 -0
  121. data/test/net/http_multipart_post_test.rb +52 -0
  122. data/test/rails_test_helper.rb +11 -0
  123. data/test/test_helper.rb +66 -0
  124. metadata +217 -0
@@ -0,0 +1,452 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../rails_test_helper')
2
+
3
+ module SymbolHelper
4
+ def symbol_helper_loaded
5
+ true
6
+ end
7
+ end
8
+
9
+ module ModuleHelper
10
+ def module_helper_loaded
11
+ true
12
+ end
13
+ end
14
+
15
+ ::RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
16
+
17
+ class TestPublisher < Facebooker::Rails::Publisher
18
+
19
+ helper :symbol
20
+ helper ModuleHelper
21
+
22
+ def action(f)
23
+ send_as :action
24
+ from f
25
+ title "Action Title"
26
+ end
27
+
28
+ def templatized_action(f)
29
+ send_as :templatized_action
30
+ from f
31
+ title_template "Templatized Action Title"
32
+ end
33
+
34
+ def story(to)
35
+ send_as :story
36
+ recipients to
37
+ title 'Story Title'
38
+ end
39
+
40
+ def notification(to,f)
41
+ send_as :notification
42
+ recipients to
43
+ from f
44
+ fbml "Not"
45
+ end
46
+
47
+ def email(to,f)
48
+ send_as :email
49
+ recipients to
50
+ from f
51
+ title "Email"
52
+ fbml 'text'
53
+ text fbml
54
+ end
55
+
56
+ def render_notification(to,f)
57
+ send_as :notification
58
+ recipients to
59
+ from f
60
+ fbml render(:inline=>"<%=module_helper_loaded%>")
61
+ end
62
+
63
+
64
+ def profile_update(to,f)
65
+ send_as :profile
66
+ recipients to
67
+ profile "profile"
68
+ profile_action "profile_action"
69
+ mobile_profile "mobile_profile"
70
+
71
+ end
72
+
73
+ def profile_update_with_profile_main(to,f)
74
+ send_as :profile
75
+ recipients to
76
+ from f
77
+ profile "profile"
78
+ profile_action "profile_action"
79
+ mobile_profile "mobile_profile"
80
+ profile_main "profile_main"
81
+ end
82
+
83
+ def ref_update(user)
84
+ send_as :ref
85
+ fbml "fbml"
86
+ handle "handle"
87
+ end
88
+
89
+ def user_action_template
90
+ one_line_story_template "{*actor*} did stuff with {*friend*}"
91
+ short_story_template "{*actor*} has a title {*friend*}", render(:inline=>"This is a test render")
92
+ full_story_template "{*actor*} did a lot","This is the full body",:img=>{:some_params=>true}
93
+ end
94
+
95
+ def simple_user_action_template
96
+ one_line_story_template "{*actor*} did stuff with {*friend*}"
97
+ end
98
+
99
+ def user_action_with_action_links_template
100
+ one_line_story_template "{*actor*} did stuff with {*friend*}"
101
+ short_story_template "{*actor*} has a title {*friend*}", render(:inline=>"This is a test render")
102
+ full_story_template "{*actor*} did a lot","This is the full body",:img=>{:some_params=>true}
103
+ action_links action_link("Source","HREF")
104
+ end
105
+
106
+ def user_action(user)
107
+ send_as :user_action
108
+ from user
109
+ data :friend=>"Mike"
110
+ end
111
+ def user_action_with_story_size(user)
112
+ send_as :user_action
113
+ from user
114
+ story_size ONE_LINE
115
+ story_size FULL
116
+ story_size SHORT
117
+ data :friend=>"Mike"
118
+ end
119
+ def user_action_no_data(user)
120
+ send_as :user_action
121
+ from user
122
+ end
123
+
124
+ def no_send_as(to)
125
+ recipients to
126
+ end
127
+
128
+ def invalid_send_as(to)
129
+ send_as :fake
130
+ recipients to
131
+ end
132
+
133
+ end
134
+
135
+ class Facebooker::Rails::Publisher::FacebookTemplateTest < Test::Unit::TestCase
136
+ FacebookTemplate = Facebooker::Rails::Publisher::FacebookTemplate
137
+
138
+ def setup
139
+ super
140
+ @template = mock("facebook template")
141
+ FacebookTemplate.stubs(:register).returns(@template)
142
+ FacebookTemplate.clear_cache!
143
+ end
144
+
145
+ def test_find_or_register_calls_find_cached
146
+ FacebookTemplate.expects(:find_cached).with(TestPublisher,"simple_user_action").returns(@template)
147
+ assert_equal FacebookTemplate.for_class_and_method(TestPublisher,"simple_user_action"),@template
148
+ end
149
+
150
+ def test_find_cached_should_use_cached_if_it_exists
151
+ FacebookTemplate.cache(TestPublisher,"simple_user_action",@template)
152
+ assert_equal FacebookTemplate.find_cached(TestPublisher,"simple_user_action"), @template
153
+
154
+ end
155
+
156
+ def test_find_cached_should_call_find_in_db_if_not_in_cache
157
+ FacebookTemplate.expects(:find_in_db).with(TestPublisher,"simple_user_action").returns(@template)
158
+ assert_equal FacebookTemplate.find_cached(TestPublisher,"simple_user_action"), @template
159
+ end
160
+
161
+ def test_find_in_db_should_run_find
162
+ FacebookTemplate.expects(:find_by_template_name).with("TestPublisher::simple_user_action").returns(@template)
163
+ @template.stubs(:template_changed?).returns(false)
164
+ assert_equal FacebookTemplate.find_in_db(TestPublisher,"simple_user_action"), @template
165
+ end
166
+
167
+ def test_find_in_db_should_register_if_not_found
168
+ FacebookTemplate.expects(:find_by_template_name).with("TestPublisher::simple_user_action").returns(nil)
169
+ FacebookTemplate.expects(:register).with(TestPublisher,"simple_user_action").returns(@template)
170
+ FacebookTemplate.find_cached(TestPublisher,"simple_user_action")
171
+
172
+ end
173
+
174
+ def test_find_in_db_should_check_for_change_if_found
175
+ FacebookTemplate.stubs(:find_by_template_name).returns(@template)
176
+ FacebookTemplate.stubs(:hashed_content).returns("MY CONTENT")
177
+ @template.expects(:template_changed?).with("MY CONTENT").returns(false)
178
+ FacebookTemplate.find_in_db(TestPublisher,"simple_user_action")
179
+ end
180
+
181
+ def test_find_in_db_should_destroy_old_record_if_changed
182
+ FacebookTemplate.stubs(:find_by_template_name).returns(@template)
183
+ FacebookTemplate.stubs(:hashed_content).returns("MY CONTENT")
184
+ @template.stubs(:template_changed?).returns(true)
185
+ @template.expects(:destroy)
186
+ FacebookTemplate.find_in_db(TestPublisher,"simple_user_action")
187
+ end
188
+
189
+ def test_find_in_db_should_re_register_if_changed
190
+ FacebookTemplate.stubs(:find_by_template_name).with("TestPublisher::simple_user_action").returns(@template)
191
+ FacebookTemplate.stubs(:hashed_content).returns("MY CONTENT")
192
+ @template.stubs(:template_changed?).returns(true)
193
+ @template.stubs(:destroy)
194
+ FacebookTemplate.expects(:register).with(TestPublisher,"simple_user_action").returns(@template)
195
+ FacebookTemplate.find_in_db(TestPublisher,"simple_user_action")
196
+ end
197
+ end
198
+
199
+ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
200
+ FacebookTemplate = Facebooker::Rails::Publisher::FacebookTemplate
201
+
202
+ def setup
203
+ super
204
+ @user = Facebooker::User.new
205
+ @user.id=4
206
+ @session = "session"
207
+ @user.stubs(:session).returns(@session)
208
+ end
209
+
210
+ def teardown
211
+ super
212
+ end
213
+
214
+ def test_create_action
215
+ action=TestPublisher.create_action(@user)
216
+ assert_equal Facebooker::Feed::Action,action.class
217
+ assert_equal "Action Title",action.title
218
+ end
219
+
220
+ def test_deliver_action
221
+ @user.expects(:publish_action)
222
+ TestPublisher.deliver_action(@user)
223
+ end
224
+
225
+ def test_create_story
226
+ action=TestPublisher.create_story(@user)
227
+ assert_equal Facebooker::Feed::Story,action.class
228
+ assert_equal "Story Title",action.title
229
+ end
230
+
231
+ def test_deliver_story
232
+ @user.expects(:publish_story)
233
+ TestPublisher.deliver_story(@user)
234
+ end
235
+
236
+ def test_create_notification
237
+ notification=TestPublisher.create_notification(12451752,@user)
238
+ assert_equal Facebooker::Rails::Publisher::Notification,notification.class
239
+ assert_equal "Not",notification.fbml
240
+ end
241
+
242
+ def test_deliver_notification
243
+ @session.expects(:send_notification)
244
+ TestPublisher.deliver_notification("12451752",@user)
245
+ end
246
+
247
+ def test_create_email
248
+ email=TestPublisher.create_email("12451752",@user)
249
+ assert_equal Facebooker::Rails::Publisher::Email,email.class
250
+ assert_equal "Email",email.title
251
+ assert_equal "text",email.text
252
+ assert_equal "text",email.fbml
253
+ end
254
+
255
+ def test_deliver_email
256
+ @session.expects(:send_email)
257
+ TestPublisher.deliver_email("12451752",@user)
258
+ end
259
+
260
+ def test_create_templatized_action
261
+ ta=TestPublisher.create_templatized_action(@user)
262
+ assert_equal Facebooker::Feed::TemplatizedAction,ta.class
263
+ assert_equal "Templatized Action Title",ta.title_template
264
+
265
+ end
266
+
267
+
268
+
269
+ def test_deliver_templatized_action
270
+ @user.expects(:publish_action)
271
+ TestPublisher.deliver_templatized_action(@user)
272
+ end
273
+ def test_create_profile_update
274
+ p=TestPublisher.create_profile_update(@user,@user)
275
+ assert_equal Facebooker::Rails::Publisher::Profile,p.class
276
+ assert_equal "profile",p.profile
277
+ assert_equal "profile_action",p.profile_action
278
+ assert_equal "mobile_profile",p.mobile_profile
279
+ end
280
+ def test_create_profile_update_with_profile_main
281
+ p=TestPublisher.create_profile_update_with_profile_main(@user,@user)
282
+ assert_equal Facebooker::Rails::Publisher::Profile,p.class
283
+ assert_equal "profile",p.profile
284
+ assert_equal "profile_action",p.profile_action
285
+ assert_equal "mobile_profile",p.mobile_profile
286
+ assert_equal "profile_main",p.profile_main
287
+ end
288
+
289
+
290
+ def test_deliver_profile
291
+ Facebooker::User.stubs(:new).returns(@user)
292
+ @user.expects(:set_profile_fbml).with('profile', 'mobile_profile', 'profile_action',nil)
293
+ TestPublisher.deliver_profile_update(@user,@user)
294
+ end
295
+
296
+ def test_deliver_profile_with_main
297
+ Facebooker::User.stubs(:new).returns(@user)
298
+ @user.expects(:set_profile_fbml).with('profile', 'mobile_profile', 'profile_action','profile_main')
299
+ TestPublisher.deliver_profile_update_with_profile_main(@user,@user)
300
+ end
301
+
302
+
303
+ def test_create_ref_update
304
+ p=TestPublisher.create_ref_update(@user)
305
+ assert_equal Facebooker::Rails::Publisher::Ref,p.class
306
+ assert_equal "fbml",p.fbml
307
+ assert_equal "handle",p.handle
308
+ end
309
+
310
+ def test_deliver_ref_update
311
+ Facebooker::Session.stubs(:create).returns(@session)
312
+ @server_cache="server_cache"
313
+ @session.expects(:server_cache).returns(@server_cache)
314
+ @server_cache.expects(:set_ref_handle).with("handle","fbml")
315
+ TestPublisher.deliver_ref_update(@user)
316
+ end
317
+
318
+ def test_register_user_action
319
+ Facebooker::Rails::Publisher::FacebookTemplate.expects(:register)
320
+ TestPublisher.register_user_action
321
+ end
322
+ def test_register_user_action_with_action_links
323
+ ActionController::Base.append_view_path("./test/../../app/views")
324
+ Facebooker::Rails::Publisher::FacebookTemplate.expects(:register)
325
+ TestPublisher.register_user_action_with_action_links
326
+ end
327
+
328
+ def test_create_user_action
329
+ @from_user = Facebooker::User.new
330
+ @session = Facebooker::Session.new("","")
331
+ @from_user.stubs(:session).returns(@session)
332
+ Facebooker::Rails::Publisher::FacebookTemplate.expects(:bundle_id_for_class_and_method).
333
+ with(TestPublisher,'user_action').
334
+ returns(20309041537)
335
+ ua = TestPublisher.create_user_action(@from_user)
336
+ assert_equal "user_action", ua.template_name
337
+ end
338
+
339
+ def test_publisher_user_action
340
+ @from_user = Facebooker::User.new
341
+ @session = Facebooker::Session.new("","")
342
+ @from_user.stubs(:session).returns(@session)
343
+ @session.expects(:publish_user_action).with(20309041537,{:friend=>"Mike"},nil,nil)
344
+
345
+ Facebooker::Rails::Publisher::FacebookTemplate.expects(:bundle_id_for_class_and_method).
346
+ with(TestPublisher, 'user_action').
347
+ returns(20309041537)
348
+ # pseudo_template = Struct.new(:bundle_id, :content_hash).new(20309041537, '')
349
+ # pseudo_template.expects(:matches_content?).returns(true)
350
+ # Facebooker::Rails::Publisher::FacebookTemplate.expects(:for).returns(pseudo_template)
351
+ TestPublisher.deliver_user_action(@from_user)
352
+ end
353
+
354
+ def test_publish_user_action_with_story_size
355
+ @from_user = Facebooker::User.new
356
+ @session = Facebooker::Session.new("","")
357
+ @from_user.stubs(:session).returns(@session)
358
+ @session.expects(:publish_user_action).with(20309041537,{:friend=>"Mike", :story_size=>2},nil,nil)
359
+
360
+ Facebooker::Rails::Publisher::FacebookTemplate.expects(:bundle_id_for_class_and_method).
361
+ with(TestPublisher, 'user_action_with_story_size').
362
+ returns(20309041537)
363
+ TestPublisher.deliver_user_action_with_story_size(@from_user)
364
+
365
+ end
366
+
367
+ def test_publishing_user_data_no_action_gives_nil_hash
368
+ @from_user = Facebooker::User.new
369
+ @session = Facebooker::Session.new("","")
370
+ @from_user.stubs(:session).returns(@session)
371
+ @session.expects(:publish_user_action).with(20309041537,{},nil,nil)
372
+
373
+ Facebooker::Rails::Publisher::FacebookTemplate.stubs(:bundle_id_for_class_and_method).returns(20309041537)
374
+ TestPublisher.deliver_user_action_no_data(@from_user)
375
+ end
376
+ def test_no_sends_as_raises
377
+ assert_raises(Facebooker::Rails::Publisher::UnspecifiedBodyType) {
378
+ TestPublisher.deliver_no_send_as(@user)
379
+ }
380
+ end
381
+
382
+ def test_invalid_send_as_raises
383
+ assert_raises(Facebooker::Rails::Publisher::UnknownBodyType) {
384
+ TestPublisher.deliver_invalid_send_as(@user)
385
+ }
386
+ end
387
+
388
+
389
+ def test_keeps_class_method_missing
390
+ assert_raises(NoMethodError) {
391
+ TestPublisher.fake
392
+ }
393
+ end
394
+ def test_keeps_instance_method_missing
395
+ assert_raises(NoMethodError) {
396
+ TestPublisher.new.fake
397
+ }
398
+ end
399
+
400
+ def test_image_urls
401
+ Facebooker.expects(:facebook_path_prefix).returns("/mike")
402
+ string_image = TestPublisher.new.image('image.png', 'raw_string')
403
+ assert_equal('/images/image.png',string_image.src)
404
+ assert_equal('raw_string',string_image.href)
405
+ route_image = TestPublisher.new.image('image.png', {:controller => :pokes, :action => :do, :id => 1})
406
+ assert_equal('http://apps.facebook.com/mike/pokes/do/1',route_image.href)
407
+ end
408
+
409
+ def test_image_to_json_puts_src_first
410
+ string_image = TestPublisher.new.image('image.png', 'raw_string')
411
+ assert_equal "{\"src\":\"/images/image.png\", \"href\":\"raw_string\"}",string_image.to_json
412
+ end
413
+ def test_action_link
414
+ assert_equal({:text=>"text", :href=>"href"}, TestPublisher.new.action_link("text","href"))
415
+ end
416
+
417
+ def test_default_url_options
418
+ Facebooker.expects(:facebook_path_prefix).returns("/mike")
419
+ assert_equal({:host=>"apps.facebook.com/mike"},TestPublisher.default_url_options)
420
+ end
421
+
422
+ def test_recipients
423
+ tp=TestPublisher.new
424
+ tp.recipients "a"
425
+ assert_equal("a",tp.recipients)
426
+ end
427
+
428
+ def test_symbol_helper
429
+ assert TestPublisher.new.symbol_helper_loaded
430
+ end
431
+ def test_module_helper
432
+ assert TestPublisher.new.module_helper_loaded
433
+ end
434
+
435
+ def test_with_render
436
+ #normally Rails would do this for us
437
+ if ActionController::Base.respond_to?(:append_view_path)
438
+ ActionController::Base.append_view_path("./test/../../app/views")
439
+ end
440
+ notification=TestPublisher.create_render_notification(12451752,@user)
441
+ assert_equal "true",notification.fbml
442
+ end
443
+
444
+ def test_notification_as_announcement
445
+ #normally Rails would do this for us
446
+ if ActionController::Base.respond_to?(:append_view_path)
447
+ ActionController::Base.append_view_path("./test/../../app/views")
448
+ end
449
+ notification=TestPublisher.create_render_notification(12451752,nil)
450
+ assert_equal "true",notification.fbml
451
+ end
452
+ end