facebooker 1.0.29 → 1.0.30
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/.autotest +15 -0
- data/Manifest.txt +129 -0
- data/Rakefile +2 -3
- data/examples/desktop_login.rb +14 -0
- data/facebooker.gemspec +43 -0
- data/lib/facebooker.rb +41 -39
- data/lib/facebooker/adapters/adapter_base.rb +3 -2
- data/lib/facebooker/adapters/bebo_adapter.rb +6 -4
- data/lib/facebooker/batch_request.rb +11 -10
- data/lib/facebooker/logging.rb +6 -13
- data/lib/facebooker/mobile.rb +2 -2
- data/lib/facebooker/model.rb +15 -13
- data/lib/facebooker/models/applicationproperties.rb +1 -1
- data/lib/facebooker/models/applicationrestrictions.rb +3 -3
- data/lib/facebooker/models/event.rb +2 -2
- data/lib/facebooker/models/friend_list.rb +2 -2
- data/lib/facebooker/models/group.rb +4 -4
- data/lib/facebooker/models/page.rb +3 -2
- data/lib/facebooker/models/photo.rb +2 -2
- data/lib/facebooker/models/user.rb +13 -5
- data/lib/facebooker/models/work_info.rb +3 -2
- data/lib/facebooker/rails/controller.rb +6 -1
- data/lib/facebooker/rails/facebook_request_fix.rb +12 -8
- data/lib/facebooker/rails/facebook_session_handling.rb +1 -2
- data/lib/facebooker/rails/facebook_url_rewriting.rb +14 -11
- data/lib/facebooker/rails/helpers.rb +4 -3
- data/lib/facebooker/rails/helpers/fb_connect.rb +8 -2
- data/lib/facebooker/rails/publisher.rb +36 -30
- data/lib/facebooker/session.rb +81 -73
- data/lib/facebooker/version.rb +1 -1
- data/test/facebooker/adapters_test.rb +23 -23
- data/test/facebooker/model_test.rb +10 -0
- data/test/facebooker/rails/publisher_test.rb +97 -88
- data/test/facebooker/rails_integration_test.rb +44 -43
- data/test/facebooker/session_test.rb +5 -5
- data/test/rack/facebook_test.rb +2 -3
- data/test/rails_test_helper.rb +14 -0
- data/test/test_helper.rb +5 -4
- metadata +31 -17
data/lib/facebooker/version.rb
CHANGED
@@ -1,46 +1,48 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class Facebooker::
|
3
|
+
class Facebooker::AdaptersTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
5
|
ENV['FACEBOOK_API_KEY'] = '1234567'
|
6
|
-
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
|
7
|
-
|
8
|
-
|
6
|
+
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
|
7
|
+
@current_adapter = Facebooker.current_adapter
|
8
|
+
Facebooker.current_adapter = nil
|
9
|
+
@bebo_api_key = "bebo_api_key"; @bebo_secret_key = "bebo_secret_key"
|
9
10
|
end
|
10
11
|
|
11
12
|
def teardown
|
12
13
|
flexmock_close
|
14
|
+
Facebooker.current_adapter = @current_adapter
|
13
15
|
end
|
14
|
-
|
16
|
+
|
15
17
|
def test_load_default_adapter
|
16
18
|
session = Facebooker::CanvasSession.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
17
19
|
assert_equal(ENV['FACEBOOK_API_KEY'], Facebooker::Session.api_key)
|
18
20
|
assert( Facebooker::FacebookAdapter === Facebooker.current_adapter)
|
19
|
-
|
21
|
+
|
20
22
|
ENV['FACEBOOK_API_KEY'] = nil
|
21
|
-
ENV['FACEBOOK_SECRET_KEY'] = nil
|
22
|
-
Facebooker.current_adapter = nil
|
23
|
+
ENV['FACEBOOK_SECRET_KEY'] = nil
|
24
|
+
Facebooker.current_adapter = nil
|
23
25
|
Facebooker::AdapterBase.stubs(:facebooker_config).returns({"api_key" => "facebook_key", "secret_key" => "facebook_secret" })
|
24
26
|
assert( Facebooker::FacebookAdapter === Facebooker.current_adapter)
|
25
27
|
assert_equal("facebook_key", Facebooker::Session.api_key)
|
26
28
|
end
|
27
|
-
|
29
|
+
|
28
30
|
def test_load_bebo_adapter
|
29
|
-
|
31
|
+
|
30
32
|
load_bebo_adapter
|
31
33
|
assert_equal(@bebo_api_key, Facebooker::Session.api_key)
|
32
34
|
assert_equal(@bebo_secret_key, Facebooker::Session.secret_key)
|
33
35
|
assert(Facebooker::BeboAdapter === Facebooker.current_adapter, " Bebo adapter not loaded correctly.")
|
34
36
|
end
|
35
|
-
|
37
|
+
|
36
38
|
def load_bebo_adapter
|
37
|
-
@bebo_api_key = "bebo_api_key"; @bebo_secret_key = "bebo_secret_key"
|
39
|
+
@bebo_api_key = "bebo_api_key"; @bebo_secret_key = "bebo_secret_key"
|
38
40
|
|
39
41
|
Facebooker::AdapterBase.stubs(:facebooker_config).returns({"bebo_api_key" => @bebo_api_key, "bebo_adapter" => "BeboAdapter", "bebo_secret_key" => @bebo_secret_key, "foo" => "bar"})
|
40
42
|
Facebooker.load_adapter(:config_key_base => "bebo")
|
41
43
|
@session = Facebooker::CanvasSession.create(@bebo_api_key, @bebo_secret_key)
|
42
44
|
end
|
43
|
-
|
45
|
+
|
44
46
|
def test_adapter_details
|
45
47
|
test_load_default_adapter
|
46
48
|
|
@@ -50,7 +52,7 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
50
52
|
assert_equal("http://api.facebook.com", Facebooker.api_server_base_url)
|
51
53
|
assert(Facebooker.is_for?(:facebook))
|
52
54
|
load_bebo_adapter
|
53
|
-
|
55
|
+
|
54
56
|
assert_equal("apps.bebo.com", Facebooker.canvas_server_base)
|
55
57
|
assert_equal("apps.bebo.com", Facebooker.api_server_base)
|
56
58
|
assert_equal("www.bebo.com", Facebooker.www_server_base_url)
|
@@ -58,20 +60,20 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
58
60
|
assert_equal("http://www.bebo.com/SignIn.jsp?ApiKey=bebo_api_key&v=1.0&canvas=true", @session.login_url)
|
59
61
|
assert_equal("http://www.bebo.com/c/apps/add?ApiKey=bebo_api_key&v=1.0", @session.install_url)
|
60
62
|
assert(Facebooker.is_for?(:bebo))
|
61
|
-
|
63
|
+
|
62
64
|
end
|
63
|
-
|
65
|
+
|
64
66
|
def test_adapter_failures
|
65
67
|
Facebooker::AdapterBase.stubs(:facebooker_config).returns({})
|
66
|
-
|
68
|
+
|
67
69
|
assert_raises(Facebooker::AdapterBase::UnableToLoadAdapter){
|
68
70
|
Facebooker.load_adapter(:config_key_base => "bebo")
|
69
71
|
}
|
70
72
|
end
|
71
|
-
|
73
|
+
|
72
74
|
def test_bebo_specific_issues
|
73
75
|
load_bebo_adapter
|
74
|
-
|
76
|
+
|
75
77
|
# @session.send(:service).stubs(:post).returns([{:name => "foo"}])
|
76
78
|
Net::HTTP.stubs(:post_form).returns("<profile_setFBML_response></profile_setFBML_response>")
|
77
79
|
user = Facebooker::User.new(:uid => "123456")
|
@@ -87,10 +89,8 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
87
89
|
Net::HTTP.stubs(:post_form).returns("<feed_publishTemplatizedAction_response>1</feed_publishTemplatizedAction_response>")
|
88
90
|
user.publish_templatized_action(action)
|
89
91
|
end
|
90
|
-
|
92
|
+
|
91
93
|
def test_bebo_process_data
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
94
|
|
95
|
+
end
|
96
96
|
end
|
@@ -12,11 +12,21 @@ class Facebooker::ModelTest < Test::Unit::TestCase
|
|
12
12
|
attr_accessor :name, :job
|
13
13
|
hash_settable_accessor :complex_thing, ComplexThing
|
14
14
|
hash_settable_list_accessor :list_of_complex_things, ComplexThing
|
15
|
+
|
16
|
+
def initialize *args
|
17
|
+
@session = nil
|
18
|
+
super
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
class PopulatingThing
|
18
23
|
include Facebooker::Model
|
19
24
|
populating_attr_accessor :first_name
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@first_name = nil
|
28
|
+
@populated = false
|
29
|
+
end
|
20
30
|
end
|
21
31
|
|
22
32
|
def test_can_instantiate_an_object_with_a_hash
|
@@ -11,32 +11,32 @@ module ModuleHelper
|
|
11
11
|
true
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
::RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
|
16
16
|
|
17
17
|
class TestPublisher < Facebooker::Rails::Publisher
|
18
|
-
|
18
|
+
|
19
19
|
helper :symbol
|
20
20
|
helper ModuleHelper
|
21
|
-
|
21
|
+
|
22
22
|
def action(f)
|
23
23
|
send_as :action
|
24
24
|
from f
|
25
25
|
title "Action Title"
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def templatized_action(f)
|
29
29
|
send_as :templatized_action
|
30
30
|
from f
|
31
31
|
title_template "Templatized Action Title"
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def story(to)
|
35
35
|
send_as :story
|
36
36
|
recipients to
|
37
37
|
title 'Story Title'
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def notification(to,f)
|
41
41
|
send_as :notification
|
42
42
|
recipients to
|
@@ -52,24 +52,24 @@ class TestPublisher < Facebooker::Rails::Publisher
|
|
52
52
|
fbml 'text'
|
53
53
|
text fbml
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def render_notification(to,f)
|
57
57
|
send_as :notification
|
58
58
|
recipients to
|
59
59
|
from f
|
60
60
|
fbml render(:inline=>"<%=module_helper_loaded%>")
|
61
61
|
end
|
62
|
-
|
63
|
-
|
62
|
+
|
63
|
+
|
64
64
|
def profile_update(to,f)
|
65
65
|
send_as :profile
|
66
66
|
recipients to
|
67
67
|
profile "profile"
|
68
68
|
profile_action "profile_action"
|
69
69
|
mobile_profile "mobile_profile"
|
70
|
-
|
70
|
+
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
def profile_update_with_profile_main(to,f)
|
74
74
|
send_as :profile
|
75
75
|
recipients to
|
@@ -79,40 +79,40 @@ class TestPublisher < Facebooker::Rails::Publisher
|
|
79
79
|
mobile_profile "mobile_profile"
|
80
80
|
profile_main "profile_main"
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
def ref_update(user)
|
84
84
|
send_as :ref
|
85
85
|
fbml "fbml"
|
86
86
|
handle "handle"
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
def user_action_template
|
90
90
|
one_line_story_template "{*actor*} did stuff with {*friend*}"
|
91
91
|
short_story_template "{*actor*} has a title {*friend*}", render(:inline=>"This is a test render")
|
92
92
|
full_story_template "{*actor*} did a lot","This is the full body",:img=>{:some_params=>true}
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
def simple_user_action_template
|
96
|
-
one_line_story_template "{*actor*} did stuff with {*friend*}"
|
96
|
+
one_line_story_template "{*actor*} did stuff with {*friend*}"
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
def user_action_with_action_links_template
|
100
100
|
one_line_story_template "{*actor*} did stuff with {*friend*}"
|
101
101
|
short_story_template "{*actor*} has a title {*friend*}", render(:inline=>"This is a test render")
|
102
102
|
full_story_template "{*actor*} did a lot","This is the full body",:img=>{:some_params=>true}
|
103
103
|
action_links action_link("Source","HREF")
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
def user_action(user)
|
107
107
|
send_as :user_action
|
108
108
|
from user
|
109
109
|
data :friend=>"Mike"
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
def user_action_with_template_id(user)
|
113
113
|
send_as :user_action
|
114
114
|
from user
|
115
|
-
data :friend=>"Mike"
|
115
|
+
data :friend=>"Mike"
|
116
116
|
template_id 4
|
117
117
|
end
|
118
118
|
def user_action_with_story_size(user)
|
@@ -127,130 +127,135 @@ class TestPublisher < Facebooker::Rails::Publisher
|
|
127
127
|
send_as :user_action
|
128
128
|
from user
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
def no_send_as(to)
|
132
132
|
recipients to
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
def invalid_send_as(to)
|
136
136
|
send_as :fake
|
137
137
|
recipients to
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
end
|
141
141
|
|
142
142
|
class Facebooker::Rails::Publisher::FacebookTemplateTest < Test::Unit::TestCase
|
143
143
|
FacebookTemplate = Facebooker::Rails::Publisher::FacebookTemplate
|
144
|
-
|
144
|
+
include Facebooker::Rails::TestHelpers
|
145
|
+
|
145
146
|
def setup
|
146
147
|
super
|
147
148
|
@template = mock("facebook template")
|
148
149
|
FacebookTemplate.stubs(:register).returns(@template)
|
149
150
|
FacebookTemplate.clear_cache!
|
150
151
|
end
|
151
|
-
|
152
|
+
|
152
153
|
def test_find_or_register_calls_find_cached
|
153
154
|
FacebookTemplate.expects(:find_cached).with(TestPublisher,"simple_user_action").returns(@template)
|
154
155
|
assert_equal FacebookTemplate.for_class_and_method(TestPublisher,"simple_user_action"),@template
|
155
|
-
end
|
156
|
-
|
156
|
+
end
|
157
|
+
|
157
158
|
def test_find_cached_should_use_cached_if_it_exists
|
158
159
|
FacebookTemplate.cache(TestPublisher,"simple_user_action",@template)
|
159
160
|
assert_equal FacebookTemplate.find_cached(TestPublisher,"simple_user_action"), @template
|
160
|
-
|
161
|
+
|
161
162
|
end
|
162
|
-
|
163
|
+
|
163
164
|
def test_find_cached_should_call_find_in_db_if_not_in_cache
|
164
165
|
FacebookTemplate.expects(:find_in_db).with(TestPublisher,"simple_user_action").returns(@template)
|
165
166
|
assert_equal FacebookTemplate.find_cached(TestPublisher,"simple_user_action"), @template
|
166
167
|
end
|
167
|
-
|
168
|
+
|
168
169
|
def test_find_in_db_should_run_find
|
169
170
|
FacebookTemplate.expects(:find_by_template_name).with("TestPublisher::simple_user_action").returns(@template)
|
170
171
|
@template.stubs(:template_changed?).returns(false)
|
171
172
|
assert_equal FacebookTemplate.find_in_db(TestPublisher,"simple_user_action"), @template
|
172
173
|
end
|
173
|
-
|
174
|
+
|
174
175
|
def test_find_in_db_should_register_if_not_found
|
175
176
|
FacebookTemplate.expects(:find_by_template_name).with("TestPublisher::simple_user_action").returns(nil)
|
176
177
|
FacebookTemplate.expects(:register).with(TestPublisher,"simple_user_action").returns(@template)
|
177
178
|
FacebookTemplate.find_cached(TestPublisher,"simple_user_action")
|
178
|
-
|
179
|
+
|
179
180
|
end
|
180
|
-
|
181
|
+
|
181
182
|
def test_find_in_db_should_check_for_change_if_found
|
182
183
|
FacebookTemplate.stubs(:find_by_template_name).returns(@template)
|
183
184
|
FacebookTemplate.stubs(:hashed_content).returns("MY CONTENT")
|
184
185
|
@template.expects(:template_changed?).with("MY CONTENT").returns(false)
|
185
|
-
FacebookTemplate.find_in_db(TestPublisher,"simple_user_action")
|
186
|
+
FacebookTemplate.find_in_db(TestPublisher,"simple_user_action")
|
186
187
|
end
|
187
|
-
|
188
|
+
|
188
189
|
def test_find_in_db_should_destroy_old_record_if_changed
|
189
190
|
FacebookTemplate.stubs(:find_by_template_name).returns(@template)
|
190
191
|
FacebookTemplate.stubs(:hashed_content).returns("MY CONTENT")
|
191
192
|
@template.stubs(:template_changed?).returns(true)
|
192
193
|
@template.expects(:destroy)
|
193
|
-
FacebookTemplate.find_in_db(TestPublisher,"simple_user_action")
|
194
|
+
FacebookTemplate.find_in_db(TestPublisher,"simple_user_action")
|
194
195
|
end
|
195
|
-
|
196
|
+
|
196
197
|
def test_find_in_db_should_re_register_if_changed
|
197
198
|
FacebookTemplate.stubs(:find_by_template_name).with("TestPublisher::simple_user_action").returns(@template)
|
198
199
|
FacebookTemplate.stubs(:hashed_content).returns("MY CONTENT")
|
199
200
|
@template.stubs(:template_changed?).returns(true)
|
200
201
|
@template.stubs(:destroy)
|
201
202
|
FacebookTemplate.expects(:register).with(TestPublisher,"simple_user_action").returns(@template)
|
202
|
-
FacebookTemplate.find_in_db(TestPublisher,"simple_user_action")
|
203
|
+
FacebookTemplate.find_in_db(TestPublisher,"simple_user_action")
|
203
204
|
end
|
204
205
|
end
|
205
206
|
|
206
207
|
class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
207
208
|
FacebookTemplate = Facebooker::Rails::Publisher::FacebookTemplate
|
208
|
-
|
209
|
+
|
209
210
|
def setup
|
210
211
|
super
|
212
|
+
|
213
|
+
ENV['FACEBOOK_API_KEY'] = '1234567'
|
214
|
+
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
|
215
|
+
|
211
216
|
@user = Facebooker::User.new
|
212
217
|
@user.id=4
|
213
218
|
@session = "session"
|
214
219
|
@user.stubs(:session).returns(@session)
|
215
220
|
end
|
216
|
-
|
221
|
+
|
217
222
|
def teardown
|
218
223
|
super
|
219
224
|
end
|
220
|
-
|
225
|
+
|
221
226
|
def test_create_action
|
222
227
|
action=TestPublisher.create_action(@user)
|
223
228
|
assert_equal Facebooker::Feed::Action,action.class
|
224
229
|
assert_equal "Action Title",action.title
|
225
230
|
end
|
226
|
-
|
231
|
+
|
227
232
|
def test_deliver_action
|
228
233
|
@user.expects(:publish_action)
|
229
234
|
TestPublisher.deliver_action(@user)
|
230
235
|
end
|
231
|
-
|
236
|
+
|
232
237
|
def test_create_story
|
233
238
|
action=TestPublisher.create_story(@user)
|
234
239
|
assert_equal Facebooker::Feed::Story,action.class
|
235
240
|
assert_equal "Story Title",action.title
|
236
241
|
end
|
237
|
-
|
242
|
+
|
238
243
|
def test_deliver_story
|
239
244
|
@user.expects(:publish_story)
|
240
|
-
TestPublisher.deliver_story(@user)
|
245
|
+
TestPublisher.deliver_story(@user)
|
241
246
|
end
|
242
|
-
|
247
|
+
|
243
248
|
def test_create_notification
|
244
249
|
notification=TestPublisher.create_notification(12451752,@user)
|
245
250
|
assert_equal Facebooker::Rails::Publisher::Notification,notification.class
|
246
251
|
assert_equal "Not",notification.fbml
|
247
252
|
end
|
248
|
-
|
253
|
+
|
249
254
|
def test_deliver_notification
|
250
255
|
@session.expects(:send_notification)
|
251
256
|
TestPublisher.deliver_notification("12451752",@user)
|
252
257
|
end
|
253
|
-
|
258
|
+
|
254
259
|
def test_create_email
|
255
260
|
email=TestPublisher.create_email("12451752",@user)
|
256
261
|
assert_equal Facebooker::Rails::Publisher::Email,email.class
|
@@ -258,21 +263,21 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
|
258
263
|
assert_equal "text",email.text
|
259
264
|
assert_equal "text",email.fbml
|
260
265
|
end
|
261
|
-
|
266
|
+
|
262
267
|
def test_deliver_email
|
263
268
|
@session.expects(:send_email)
|
264
269
|
TestPublisher.deliver_email("12451752",@user)
|
265
270
|
end
|
266
|
-
|
271
|
+
|
267
272
|
def test_create_templatized_action
|
268
273
|
ta=TestPublisher.create_templatized_action(@user)
|
269
274
|
assert_equal Facebooker::Feed::TemplatizedAction,ta.class
|
270
275
|
assert_equal "Templatized Action Title",ta.title_template
|
271
|
-
|
276
|
+
|
272
277
|
end
|
273
|
-
|
274
|
-
|
275
|
-
|
278
|
+
|
279
|
+
|
280
|
+
|
276
281
|
def test_deliver_templatized_action
|
277
282
|
@user.expects(:publish_action)
|
278
283
|
TestPublisher.deliver_templatized_action(@user)
|
@@ -292,28 +297,28 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
|
292
297
|
assert_equal "mobile_profile",p.mobile_profile
|
293
298
|
assert_equal "profile_main",p.profile_main
|
294
299
|
end
|
295
|
-
|
296
|
-
|
300
|
+
|
301
|
+
|
297
302
|
def test_deliver_profile
|
298
303
|
Facebooker::User.stubs(:new).returns(@user)
|
299
304
|
@user.expects(:set_profile_fbml).with('profile', 'mobile_profile', 'profile_action',nil)
|
300
|
-
TestPublisher.deliver_profile_update(@user,@user)
|
305
|
+
TestPublisher.deliver_profile_update(@user,@user)
|
301
306
|
end
|
302
|
-
|
307
|
+
|
303
308
|
def test_deliver_profile_with_main
|
304
309
|
Facebooker::User.stubs(:new).returns(@user)
|
305
310
|
@user.expects(:set_profile_fbml).with('profile', 'mobile_profile', 'profile_action','profile_main')
|
306
|
-
TestPublisher.deliver_profile_update_with_profile_main(@user,@user)
|
311
|
+
TestPublisher.deliver_profile_update_with_profile_main(@user,@user)
|
307
312
|
end
|
308
|
-
|
309
|
-
|
313
|
+
|
314
|
+
|
310
315
|
def test_create_ref_update
|
311
316
|
p=TestPublisher.create_ref_update(@user)
|
312
317
|
assert_equal Facebooker::Rails::Publisher::Ref,p.class
|
313
318
|
assert_equal "fbml",p.fbml
|
314
319
|
assert_equal "handle",p.handle
|
315
320
|
end
|
316
|
-
|
321
|
+
|
317
322
|
def test_deliver_ref_update
|
318
323
|
Facebooker::Session.stubs(:create).returns(@session)
|
319
324
|
@server_cache="server_cache"
|
@@ -321,7 +326,7 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
|
321
326
|
@server_cache.expects(:set_ref_handle).with("handle","fbml")
|
322
327
|
TestPublisher.deliver_ref_update(@user)
|
323
328
|
end
|
324
|
-
|
329
|
+
|
325
330
|
def test_register_user_action
|
326
331
|
Facebooker::Rails::Publisher::FacebookTemplate.expects(:register)
|
327
332
|
TestPublisher.register_user_action
|
@@ -331,7 +336,7 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
|
331
336
|
Facebooker::Rails::Publisher::FacebookTemplate.expects(:register)
|
332
337
|
TestPublisher.register_user_action_with_action_links
|
333
338
|
end
|
334
|
-
|
339
|
+
|
335
340
|
def test_create_user_action
|
336
341
|
@from_user = Facebooker::User.new
|
337
342
|
@session = Facebooker::Session.new("","")
|
@@ -351,13 +356,13 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
|
351
356
|
ua = TestPublisher.create_user_action_with_template_id(@from_user)
|
352
357
|
assert_equal 4,ua.template_id
|
353
358
|
end
|
354
|
-
|
359
|
+
|
355
360
|
def test_publisher_user_action
|
356
361
|
@from_user = Facebooker::User.new
|
357
362
|
@session = Facebooker::Session.new("","")
|
358
363
|
@from_user.stubs(:session).returns(@session)
|
359
364
|
@session.expects(:publish_user_action).with(20309041537,{:friend=>"Mike"},nil,nil,nil)
|
360
|
-
|
365
|
+
|
361
366
|
Facebooker::Rails::Publisher::FacebookTemplate.expects(:bundle_id_for_class_and_method).
|
362
367
|
with(TestPublisher, 'user_action').
|
363
368
|
returns(20309041537)
|
@@ -366,26 +371,26 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
|
366
371
|
# Facebooker::Rails::Publisher::FacebookTemplate.expects(:for).returns(pseudo_template)
|
367
372
|
TestPublisher.deliver_user_action(@from_user)
|
368
373
|
end
|
369
|
-
|
374
|
+
|
370
375
|
def test_publish_user_action_with_story_size
|
371
376
|
@from_user = Facebooker::User.new
|
372
377
|
@session = Facebooker::Session.new("","")
|
373
378
|
@from_user.stubs(:session).returns(@session)
|
374
379
|
@session.expects(:publish_user_action).with(20309041537,{:friend=>"Mike"},nil,nil,2)
|
375
|
-
|
380
|
+
|
376
381
|
Facebooker::Rails::Publisher::FacebookTemplate.expects(:bundle_id_for_class_and_method).
|
377
382
|
with(TestPublisher, 'user_action_with_story_size').
|
378
383
|
returns(20309041537)
|
379
384
|
TestPublisher.deliver_user_action_with_story_size(@from_user)
|
380
|
-
|
385
|
+
|
381
386
|
end
|
382
|
-
|
387
|
+
|
383
388
|
def test_publishing_user_data_no_action_gives_nil_hash
|
384
389
|
@from_user = Facebooker::User.new
|
385
390
|
@session = Facebooker::Session.new("","")
|
386
391
|
@from_user.stubs(:session).returns(@session)
|
387
392
|
@session.expects(:publish_user_action).with(20309041537,{},nil,nil,nil)
|
388
|
-
|
393
|
+
|
389
394
|
Facebooker::Rails::Publisher::FacebookTemplate.stubs(:bundle_id_for_class_and_method).returns(20309041537)
|
390
395
|
TestPublisher.deliver_user_action_no_data(@from_user)
|
391
396
|
end
|
@@ -394,14 +399,14 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
|
394
399
|
TestPublisher.deliver_no_send_as(@user)
|
395
400
|
}
|
396
401
|
end
|
397
|
-
|
402
|
+
|
398
403
|
def test_invalid_send_as_raises
|
399
404
|
assert_raises(Facebooker::Rails::Publisher::UnknownBodyType) {
|
400
405
|
TestPublisher.deliver_invalid_send_as(@user)
|
401
406
|
}
|
402
407
|
end
|
403
|
-
|
404
|
-
|
408
|
+
|
409
|
+
|
405
410
|
def test_keeps_class_method_missing
|
406
411
|
assert_raises(NoMethodError) {
|
407
412
|
TestPublisher.fake
|
@@ -412,7 +417,7 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
|
412
417
|
TestPublisher.new.fake
|
413
418
|
}
|
414
419
|
end
|
415
|
-
|
420
|
+
|
416
421
|
def test_image_urls
|
417
422
|
Facebooker.expects(:facebook_path_prefix).returns("/mike")
|
418
423
|
string_image = TestPublisher.new.image('image.png', 'raw_string')
|
@@ -421,7 +426,7 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
|
421
426
|
route_image = TestPublisher.new.image('image.png', {:controller => :pokes, :action => :do, :id => 1})
|
422
427
|
assert_equal('http://apps.facebook.com/mike/pokes/do/1',route_image.href)
|
423
428
|
end
|
424
|
-
|
429
|
+
|
425
430
|
def test_image_to_json_puts_src_first
|
426
431
|
string_image = TestPublisher.new.image('image.png', 'raw_string')
|
427
432
|
assert_equal "{\"src\":\"/images/image.png\", \"href\":\"raw_string\"}",string_image.to_json
|
@@ -429,40 +434,44 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
|
|
429
434
|
def test_action_link
|
430
435
|
assert_equal({:text=>"text", :href=>"href"}, TestPublisher.new.action_link("text","href"))
|
431
436
|
end
|
432
|
-
|
437
|
+
|
433
438
|
def test_default_url_options
|
434
439
|
Facebooker.expects(:facebook_path_prefix).returns("/mike")
|
435
440
|
assert_equal({:host=>"apps.facebook.com/mike"},TestPublisher.default_url_options)
|
436
441
|
end
|
437
|
-
|
442
|
+
|
438
443
|
def test_recipients
|
439
444
|
tp=TestPublisher.new
|
440
445
|
tp.recipients "a"
|
441
446
|
assert_equal("a",tp.recipients)
|
442
447
|
end
|
443
|
-
|
448
|
+
|
444
449
|
def test_symbol_helper
|
445
450
|
assert TestPublisher.new.symbol_helper_loaded
|
446
451
|
end
|
447
452
|
def test_module_helper
|
448
453
|
assert TestPublisher.new.module_helper_loaded
|
449
454
|
end
|
450
|
-
|
455
|
+
|
451
456
|
def test_with_render
|
452
457
|
#normally Rails would do this for us
|
453
|
-
|
454
|
-
ActionController::Base.append_view_path
|
458
|
+
silence_warnings do
|
459
|
+
if ActionController::Base.respond_to?(:append_view_path)
|
460
|
+
ActionController::Base.append_view_path("./test/../../app/views")
|
461
|
+
end
|
462
|
+
notification=TestPublisher.create_render_notification(12451752,@user)
|
463
|
+
assert_equal "true",notification.fbml
|
455
464
|
end
|
456
|
-
notification=TestPublisher.create_render_notification(12451752,@user)
|
457
|
-
assert_equal "true",notification.fbml
|
458
465
|
end
|
459
|
-
|
466
|
+
|
460
467
|
def test_notification_as_announcement
|
461
468
|
#normally Rails would do this for us
|
462
|
-
|
463
|
-
ActionController::Base.append_view_path
|
469
|
+
silence_warnings do
|
470
|
+
if ActionController::Base.respond_to?(:append_view_path)
|
471
|
+
ActionController::Base.append_view_path("./test/../../app/views")
|
472
|
+
end
|
473
|
+
notification=TestPublisher.create_render_notification(12451752,nil)
|
474
|
+
assert_equal "true",notification.fbml
|
464
475
|
end
|
465
|
-
notification=TestPublisher.create_render_notification(12451752,nil)
|
466
|
-
assert_equal "true",notification.fbml
|
467
476
|
end
|
468
477
|
end
|