taweili-facebooker 1.0.47 → 1.0.50

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/Rakefile CHANGED
@@ -23,26 +23,30 @@ HOE = Hoe.spec('facebooker') do
23
23
  self.readme_file = 'README.rdoc'
24
24
  self.history_file = 'CHANGELOG.rdoc'
25
25
  self.remote_rdoc_dir = '' # Release to root
26
- self.test_globs = 'test/**/*_test.rb'
26
+ self.test_globs = ['test/**/*_test.rb']
27
27
  extra_deps << ['json', '>= 1.0.0']
28
28
  self.extra_rdoc_files = FileList['*.rdoc']
29
29
  end
30
30
 
31
- require 'rcov/rcovtask'
31
+ begin
32
+ require 'rcov/rcovtask'
32
33
 
33
- namespace :test do
34
- namespace :coverage do
35
- desc "Delete aggregate coverage data."
36
- task(:clean) { rm_f "coverage.data" }
37
- end
38
- desc 'Aggregate code coverage for unit, functional and integration tests'
39
- Rcov::RcovTask.new(:coverage) do |t|
40
- t.libs << "test"
41
- t.test_files = FileList["test/**/*_test.rb"]
42
- t.output_dir = "coverage/"
43
- t.verbose = true
44
- t.rcov_opts = ['--exclude', 'test,/usr/lib/ruby,/Library/Ruby,/System/Library', '--sort', 'coverage']
34
+ namespace :test do
35
+ namespace :coverage do
36
+ desc "Delete aggregate coverage data."
37
+ task(:clean) { rm_f "coverage.data" }
38
+ end
39
+ desc 'Aggregate code coverage for unit, functional and integration tests'
40
+ Rcov::RcovTask.new(:coverage) do |t|
41
+ t.libs << "test"
42
+ t.test_files = FileList["test/**/*_test.rb"]
43
+ t.output_dir = "coverage/"
44
+ t.verbose = true
45
+ t.rcov_opts = ['--exclude', 'test,/usr/lib/ruby,/Library/Ruby,/System/Library', '--sort', 'coverage']
46
+ end
45
47
  end
48
+ rescue LoadError
49
+ $stderr.puts "Install the rcov gem to enable test coverage analysis"
46
50
  end
47
51
 
48
52
  namespace :gem do
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{facebooker}
5
- s.version = "1.0.47"
5
+ s.version = "1.0.50"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chad Fowler", "Patrick Ewing", "Mike Mangino", "Shane Vitarana", "Corey Innis", "Mike Mangino"]
9
- s.date = %q{2009-08-14}
9
+ s.date = %q{2009-09-08}
10
10
  s.description = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]. Its goals are:
11
11
 
12
12
  * Idiomatic Ruby
@@ -164,7 +164,7 @@ module Facebooker
164
164
  @timeout
165
165
  end
166
166
 
167
- [:api_key,:secret_key, :www_server_base_url,:login_url_base,:install_url_base,:api_rest_path,:api_server_base,:api_server_base_url,:canvas_server_base, :video_server_base].each do |delegated_method|
167
+ [:api_key,:secret_key, :www_server_base_url,:login_url_base,:install_url_base,:permission_url_base,:connect_permission_url_base,:api_rest_path,:api_server_base,:api_server_base_url,:canvas_server_base, :video_server_base].each do |delegated_method|
168
168
  define_method(delegated_method){ return current_adapter.send(delegated_method)}
169
169
  end
170
170
 
@@ -44,6 +44,14 @@ module Facebooker
44
44
  def install_url_base
45
45
  "http://#{www_server_base_url}/install.php?api_key=#{api_key}&v=1.0"
46
46
  end
47
+
48
+ def connect_permission_url_base
49
+ "http://#{www_server_base_url}/connect/prompt_permissions.php?api_key=#{api_key}&v=1.0"
50
+ end
51
+
52
+ def permission_url_base
53
+ "http://#{www_server_base_url}/authorize.php?api_key=#{api_key}&v=1.0"
54
+ end
47
55
 
48
56
  end
49
57
 
@@ -8,7 +8,7 @@ module Facebooker
8
8
  attr_accessor :position, :gid, :uid
9
9
  end
10
10
  include Model
11
- attr_accessor :pic, :pic_small, :pic_big, :name, :creator, :recent_news, :update_time, :group_subtype, :group_type, :website, :office, :description, :venue, :nid
11
+ attr_accessor :pic, :pic_small, :pic_big, :name, :creator, :recent_news, :update_time, :group_subtype, :group_type, :website, :office, :description, :venue, :nid, :privacy
12
12
 
13
13
  id_is :gid
14
14
 
@@ -11,7 +11,7 @@ module Facebooker
11
11
  attr_accessor :message, :time, :status_id
12
12
  end
13
13
  FIELDS = [:status, :political, :pic_small, :name, :quotes, :is_app_user, :tv, :profile_update_time, :meeting_sex, :hs_info, :timezone, :relationship_status, :hometown_location, :about_me, :wall_count, :significant_other_id, :pic_big, :music, :work_history, :sex, :religion, :notes_count, :activities, :pic_square, :movies, :has_added_app, :education_history, :birthday, :birthday_date, :first_name, :meeting_for, :last_name, :interests, :current_location, :pic, :books, :affiliations, :locale, :profile_url, :proxied_email, :email_hashes, :allowed_restrictions, :pic_with_logo, :pic_big_with_logo, :pic_small_with_logo, :pic_square_with_logo]
14
- STANDARD_FIELDS = [:uid, :first_name, :last_name, :name, :timezone, :birthday, :sex, :affiliations, :locale, :profile_url, :pic_square]
14
+ STANDARD_FIELDS = [:uid, :first_name, :last_name, :name, :timezone, :birthday, :sex, :affiliations, :locale, :profile_url, :proxied_email]
15
15
  populating_attr_accessor(*FIELDS)
16
16
  attr_reader :affiliations
17
17
  populating_hash_settable_accessor :current_location, Location
@@ -63,7 +63,17 @@ module Facebooker
63
63
  @events[params.to_s] ||= @session.post('facebook.events.get', {:uid => self.id}.merge(params)).map do |event|
64
64
  Event.from_hash(event)
65
65
  end
66
- end
66
+ end
67
+
68
+ # Rsvp to an event with the eid and rsvp_status which can be 'attending', 'unsure', or 'declined'.
69
+ # http://wiki.developers.facebook.com/index.php/Events.rsvp
70
+ # E.g:
71
+ # @user.rsvp_event('100321123', 'attending')
72
+ # # => Returns true if all went well
73
+ def rsvp_event(eid, rsvp_status, options = {})
74
+ result = @session.post('facebook.events.rsvp', options.merge(:eid => eid, :rsvp_status => rsvp_status))
75
+ result == '1' ? true : false
76
+ end
67
77
 
68
78
  #
69
79
  # Set the list of friends, given an array of User objects. If the list has been retrieved previously, will not set
@@ -127,21 +137,25 @@ module Facebooker
127
137
  # :text => 'my website',
128
138
  # :href => 'http://tenderlovemaking.com/'
129
139
  # ])
130
- def publish_to target, options = {}
131
-
132
- attachment = options[:attachment]
133
- links = options[:action_links]
134
- @session.post('facebook.stream.publish',
135
- { :uid => self.id,
136
- :target_id => target.id,
137
- :message => options[:message],
138
- :attachment => attachment && Facebooker.json_encode(attachment),
139
- :action_links => links && Facebooker.json_encode(links) },
140
- false
141
- )
140
+ def publish_to(target, options = {})
141
+ @session.post('facebook.stream.publish', prepare_publish_to_options(target, options), false)
142
+ end
143
+
144
+ # Prepares options for the stream.publish
145
+ def prepare_publish_to_options(target, options)
146
+ opts = {:uid => self.id,
147
+ :target_id => target.id,
148
+ :message => options[:message]}
149
+
150
+ if(attachment = options[:attachment] && Facebooker.json_encode(options[:attachment]))
151
+ opts[:attachment] = attachment
152
+ end
153
+ if (links = options[:action_links] && Facebooker.json_encode(options[:action_links]))
154
+ opts[:action_links] = links
155
+ end
156
+ opts
142
157
  end
143
158
 
144
-
145
159
  ###
146
160
  # Publish a comment on a post
147
161
  #
@@ -211,12 +211,12 @@ module Facebooker
211
211
  element('stream_publish_response', data).content.strip
212
212
  end
213
213
  end
214
-
214
+
215
215
  class StreamAddComment < Parser#:nodoc:
216
216
  def self.process(data)
217
217
  element('stream_addComment_response', data).content.strip
218
218
  end
219
- end
219
+ end
220
220
 
221
221
  class RegisterTemplateBundle < Parser#:nodoc:
222
222
  def self.process(data)
@@ -461,12 +461,18 @@ module Facebooker
461
461
  end
462
462
  end
463
463
 
464
+ class EventsRsvp < Parser#:nodoc:
465
+ def self.process(data)
466
+ element('events_rsvp_response', data).content.strip
467
+ end
468
+ end
469
+
464
470
  class EventsRsvp < Parser#:nodoc:
465
471
  def self.process(data)
466
472
  element('events_rsvp_response', data).text_value
467
473
  end
468
474
  end
469
-
475
+
470
476
  class EventsGet < Parser#:nodoc:
471
477
  def self.process(data)
472
478
  array_of_hashes(element('events_get_response', data), 'event')
@@ -563,10 +569,10 @@ module Facebooker
563
569
 
564
570
  class Errors < Parser#:nodoc:
565
571
  EXCEPTIONS = {
566
- 1 => Facebooker::Session::UnknownError,
567
- 2 => Facebooker::Session::ServiceUnavailable,
568
- 4 => Facebooker::Session::MaxRequestsDepleted,
569
- 5 => Facebooker::Session::HostNotAllowed,
572
+ 1 => Facebooker::Session::UnknownError,
573
+ 2 => Facebooker::Session::ServiceUnavailable,
574
+ 4 => Facebooker::Session::MaxRequestsDepleted,
575
+ 5 => Facebooker::Session::HostNotAllowed,
570
576
  100 => Facebooker::Session::MissingOrInvalidParameter,
571
577
  101 => Facebooker::Session::InvalidAPIKey,
572
578
  102 => Facebooker::Session::SessionExpired,
@@ -667,8 +673,10 @@ module Facebooker
667
673
  'facebook.photos.addTag' => AddTags,
668
674
  'facebook.photos.upload' => UploadPhoto,
669
675
  'facebook.stream.publish' => StreamPublish,
670
- 'facebook.stream.addComment' => StreamAddComment,
676
+ 'facebook.stream.addComment' => StreamAddComment,
671
677
  'facebook.events.get' => EventsGet,
678
+ 'facebook.events.rsvp' => EventsRsvp,
679
+ 'facebook.groups.get' => GroupsGet,
672
680
  'facebook.events.getMembers' => EventMembersGet,
673
681
  'facebook.events.rsvp' => EventsRsvp,
674
682
  'facebook.groups.get' => GroupsGet,
@@ -451,10 +451,10 @@ module Facebooker
451
451
  def facebook_messages
452
452
  message=""
453
453
  unless flash[:notice].blank?
454
- message += fb_success(flash[:notice])
454
+ message += fb_success(*flash[:notice])
455
455
  end
456
456
  unless flash[:error].blank?
457
- message += fb_error(flash[:error])
457
+ message += fb_error(*flash[:error])
458
458
  end
459
459
  message
460
460
  end
@@ -33,9 +33,9 @@ module Facebooker
33
33
  end
34
34
 
35
35
  if request.ssl?
36
- init_string = "FB.Facebook.init('#{Facebooker.api_key}','/xd_receiver_ssl.html', #{options[:app_settings]});"
36
+ init_string = "FB.init('#{Facebooker.api_key}','/xd_receiver_ssl.html', #{options[:app_settings]});"
37
37
  else
38
- init_string = "FB.Facebook.init('#{Facebooker.api_key}','/xd_receiver.html', #{options[:app_settings]});"
38
+ init_string = "FB.init('#{Facebooker.api_key}','/xd_receiver.html', #{options[:app_settings]});"
39
39
  end
40
40
  unless required_features.blank?
41
41
  init_string = <<-FBML
@@ -4,7 +4,7 @@ module Facebooker
4
4
  #
5
5
  # To use, create a subclass and define methods
6
6
  # Each method should start by calling send_as to specify the type of message
7
- # Valid options are :email and :notification, :user_action, :profile, :ref
7
+ # Valid options are :email and :notification, :user_action, :profile, :ref, :publish_stream
8
8
  #
9
9
  #
10
10
  # Below is an example of each type
@@ -78,6 +78,16 @@ module Facebooker
78
78
  # handle "a_ref_handle"
79
79
  # end
80
80
  #
81
+ # # Publish a post into the stream on the user's Wall and News Feed.
82
+ # def publish_stream(user_with_session_to_use, user_to_update, params)
83
+ # send_as :publish_stream
84
+ # from user_with_session_to_use
85
+ # target user_to_update
86
+ # attachment params[:attachment]
87
+ # message params[:message]
88
+ # action_links params[:action_links]
89
+ # end
90
+ #
81
91
  #
82
92
  # To send a message, use ActionMailer like semantics
83
93
  # TestPublisher.deliver_action(@user)
@@ -254,6 +264,13 @@ module Facebooker
254
264
  end
255
265
  end
256
266
 
267
+ class PublishStream
268
+ attr_accessor :target
269
+ attr_accessor :attachment
270
+ attr_accessor :action_links
271
+ attr_accessor :message
272
+ end
273
+
257
274
  cattr_accessor :ignore_errors
258
275
  attr_accessor :_body
259
276
 
@@ -292,6 +309,8 @@ module Facebooker
292
309
  Ref.new
293
310
  when :user_action
294
311
  UserAction.new
312
+ when :publish_stream
313
+ PublishStream.new
295
314
  else
296
315
  raise UnknownBodyType.new("Unknown type to publish")
297
316
  end
@@ -403,6 +422,8 @@ module Facebooker
403
422
  Facebooker::Session.create.server_cache.set_ref_handle(_body.handle,_body.fbml)
404
423
  when UserAction
405
424
  @from.session.publish_user_action(_body.template_id,_body.data_hash,_body.target_ids,_body.body_general,_body.story_size)
425
+ when PublishStream
426
+ @from.publish_to(_body.target, {:attachment => _body.attachment, :action_links => @action_links, :message => _body.message })
406
427
  else
407
428
  raise UnspecifiedBodyType.new("You must specify a valid send_as")
408
429
  end
@@ -493,6 +514,15 @@ module Facebooker
493
514
  end
494
515
  end
495
516
 
517
+ def unregister_inactive_templates
518
+ session = Facebooker::Session.create
519
+ active_template_ids = FacebookTemplate.all.map(&:bundle_id)
520
+ all_template_ids = session.active_template_bundles.map {|t| t["template_bundle_id"]}
521
+ (all_template_ids - active_template_ids).each do |template_bundle_id|
522
+ session.deactivate_template_bundle_by_id(template_bundle_id)
523
+ end
524
+ end
525
+
496
526
  def method_missing(name,*args)
497
527
  should_send = false
498
528
  method = ''
@@ -526,7 +556,7 @@ module Facebooker
526
556
  args.each do |arg|
527
557
  case arg
528
558
  when Symbol,String
529
- add_template_helper("#{arg.to_s.classify}Helper".constantize)
559
+ add_template_helper("#{arg.to_s.camelcase}Helper".constantize)
530
560
  when Module
531
561
  add_template_helper(arg)
532
562
  end
@@ -122,7 +122,16 @@ module Facebooker
122
122
  # * sms
123
123
  def permission_url(permission,options={})
124
124
  options = default_login_url_options.merge(options)
125
- "http://#{Facebooker.www_server_base_url}/authorize.php?api_key=#{@api_key}&v=1.0&ext_perm=#{permission}#{install_url_optional_parameters(options)}"
125
+ options = add_next_parameters(options)
126
+ options << "&ext_perm=#{permission}"
127
+ "#{Facebooker.permission_url_base}#{options.join}"
128
+ end
129
+
130
+ def connect_permission_url(permission,options={})
131
+ options = default_login_url_options.merge(options)
132
+ options = add_next_parameters(options)
133
+ options << "&ext_perm=#{permission}"
134
+ "#{Facebooker.connect_permission_url_base}#{options.join}"
126
135
  end
127
136
 
128
137
  def install_url_optional_parameters(options)
@@ -145,6 +154,8 @@ module Facebooker
145
154
  optional_parameters << "&skipcookie=true" if options[:skip_cookie]
146
155
  optional_parameters << "&hide_checkbox=true" if options[:hide_checkbox]
147
156
  optional_parameters << "&canvas=true" if options[:canvas]
157
+ optional_parameters << "&fbconnect=true" if options[:fbconnect]
158
+ optional_parameters << "&req_perms=#{options[:req_perms]}" if options[:req_perms]
148
159
  optional_parameters.join
149
160
  end
150
161
 
@@ -269,6 +280,23 @@ module Facebooker
269
280
  end
270
281
  end
271
282
 
283
+ # Creates an event with the event_info hash and an optional Net::HTTP::MultipartPostFile for the event picture
284
+ # Returns the eid of the newly created event
285
+ # http://wiki.developers.facebook.com/index.php/Events.create
286
+ def create_event(event_info, multipart_post_file = nil)
287
+ post_file('facebook.events.create', :event_info => event_info.to_json, nil => multipart_post_file)
288
+ end
289
+
290
+ # Cancel an event
291
+ # http://wiki.developers.facebook.com/index.php/Events.cancel
292
+ # E.g:
293
+ # @session.cancel_event('100321123', :cancel_message => "It's raining...")
294
+ # # => Returns true if all went well
295
+ def cancel_event(eid, options = {})
296
+ result = post('facebook.events.cancel', options.merge(:eid => eid))
297
+ result == '1' ? true : false
298
+ end
299
+
272
300
  def event_members(eid)
273
301
  @members = post('facebook.events.getMembers', :eid => eid) do |response|
274
302
  response.map do |attendee_hash|
@@ -347,7 +375,9 @@ module Facebooker
347
375
  if [subj_id, pids, aid].all? {|arg| arg.nil?}
348
376
  raise ArgumentError, "Can't get a photo without a picture, album or subject ID"
349
377
  end
350
- @photos = post('facebook.photos.get', :subj_id => subj_id, :pids => pids, :aid => aid ) do |response|
378
+ # We have to normalize params orherwise FB complain about signature
379
+ params = {:pids => pids, :subj_id => subj_id, :aid => aid}.delete_if { |k,v| v.nil? }
380
+ @photos = post('facebook.photos.get', params ) do |response|
351
381
  response.map do |hash|
352
382
  Photo.from_hash(hash)
353
383
  end
@@ -422,6 +452,10 @@ module Facebooker
422
452
  post("facebook.feed.deactivateTemplateBundleByID", {:template_bundle_id => template_bundle_id.to_s}, false)
423
453
  end
424
454
 
455
+ def active_template_bundles
456
+ post("facebook.feed.getRegisteredTemplateBundles",{},false)
457
+ end
458
+
425
459
  ##
426
460
  # publish a previously rendered template bundle
427
461
  # see http://wiki.developers.facebook.com/index.php/Feed.publishUserAction
@@ -2,7 +2,7 @@ module Facebooker #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 47
5
+ TINY = 50
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -130,6 +130,14 @@ class Facebooker::UserTest < Test::Unit::TestCase
130
130
  assert_equal "2357384227378429949", photos.first.aid
131
131
  end
132
132
 
133
+ def test_prepare_publish_to_options_pass_only_neccessary_parameters
134
+ options = @user.prepare_publish_to_options(@user, {:message => 'Hey there', :action_links => [:text => 'Link', :href => 'http://example.com']})
135
+ assert_equal(options[:uid], @user.uid)
136
+ assert_equal(options[:target_id], @user.id)
137
+ assert_equal(options[:message], 'Hey there')
138
+ assert_nil(options[:attachment])
139
+ assert_equal(options[:action_links], [:text => 'Link', :href => 'http://example.com'].to_json )
140
+ end
133
141
  def test_publish_to
134
142
  @user = Facebooker::User.new(548871286, @session)
135
143
  expect_http_posts_with_responses(example_profile_publish_to_get_xml)
@@ -254,6 +262,12 @@ class Facebooker::UserTest < Test::Unit::TestCase
254
262
  assert_equal "http://www.facebook.com/profile.php?id=8055", @user.profile_url
255
263
  end
256
264
 
265
+ def test_can_rsvp_to_event
266
+ expect_http_posts_with_responses(example_events_rsvp_xml)
267
+ result = @user.rsvp_event(1000, 'attending')
268
+ assert result
269
+ end
270
+
257
271
  private
258
272
  def example_profile_photos_get_xml
259
273
  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
@@ -363,4 +377,13 @@ class Facebooker::UserTest < Test::Unit::TestCase
363
377
  <stream_addComment_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">703826862_78463536863</stream_addComment_response>
364
378
  eoxml
365
379
  end
380
+
381
+ def example_events_rsvp_xml
382
+ <<-E
383
+ <?xml version="1.0" encoding="UTF-8"?>
384
+ <events_rsvp_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
385
+ xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1
386
+ </events_rsvp_response>
387
+ E
388
+ end
366
389
  end
@@ -137,6 +137,23 @@ class TestPublisher < Facebooker::Rails::Publisher
137
137
  recipients to
138
138
  end
139
139
 
140
+ def publish_post_to_own_stream(user)
141
+ send_as :publish_stream
142
+ from user
143
+ target user
144
+ attachment({:name => "Facebooker", :href => "http://www.exampple.com"})
145
+ message "Posting post to own stream"
146
+ action_links([{:text => "Action Link", :href => "http://www.example.com/action_link"}])
147
+ end
148
+
149
+ def publish_post_to_friends_stream(from, to)
150
+ send_as :publish_stream
151
+ from from
152
+ target to
153
+ attachment({:name => "Facebooker", :href => "http://www.exampple.com"})
154
+ message "Posting post to friends stream"
155
+ action_links([{:text => "Action Link", :href => "http://www.example.com/action_link"}])
156
+ end
140
157
  end
141
158
 
142
159
  class Facebooker::Rails::Publisher::FacebookTemplateTest < Test::Unit::TestCase
@@ -413,6 +430,20 @@ class Facebooker::Rails::Publisher::PublisherTest < Test::Unit::TestCase
413
430
  }
414
431
  end
415
432
 
433
+ def test_publish_post_to_own_stream
434
+ @user = Facebooker::User.new
435
+ @user.expects(:publish_to).with(@user, has_entry(:attachment=>instance_of(Hash)))
436
+
437
+ TestPublisher.deliver_publish_post_to_own_stream(@user)
438
+ end
439
+
440
+ def test_publish_post_to_friends_stream
441
+ @from_user = Facebooker::User.new
442
+ @to_user = Facebooker::User.new
443
+ @from_user.expects(:publish_to).with(@to_user, has_entry(:action_links=>instance_of(Array)))
444
+
445
+ TestPublisher.deliver_publish_post_to_friends_stream(@from_user, @to_user)
446
+ end
416
447
 
417
448
  def test_keeps_class_method_missing
418
449
  assert_raises(NoMethodError) {
@@ -22,6 +22,33 @@ class Facebooker::SessionTest < Test::Unit::TestCase
22
22
  assert_equal("http://www.facebook.com/install.php?api_key=1234567&v=1.0&next=next_url%3Fa%3D1%26b%3D2", session.install_url(:next => "next_url?a=1&b=2"))
23
23
  end
24
24
 
25
+ def test_permission_url_returns_correct_url_and_parameters
26
+ fb_url = "http://www.facebook.com/connect/prompt_permissions.php?api_key=#{ENV['FACEBOOK_API_KEY']}&v=1.0&next=next_url&ext_perm=publish_stream,email"
27
+ url = Facebooker::Session.new(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY']).connect_permission_url('publish_stream,email', {:next => 'next_url'})
28
+ assert_equal url, fb_url
29
+ end
30
+
31
+ def test_login_url_skips_all_parameters_when_not_passed_or_false
32
+ session = Facebooker::Session.new(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
33
+ url = session.login_url({:fbconnect => false})
34
+ expected_url = Facebooker.login_url_base
35
+ assert_equal url, expected_url
36
+ end
37
+
38
+ def test_login_url_adds_all_parameters_when_passed
39
+ login_options = {:skipcookie => true,
40
+ :hide_checkbox => true,
41
+ :canvas => true,
42
+ :fbconnect => true,
43
+ :req_perms => 'publish_stream',
44
+ :next => 'http://example.com'}
45
+
46
+ session = Facebooker::Session.new(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
47
+ url = session.login_url(login_options)
48
+ expected_url = "#{Facebooker.login_url_base}&next=#{CGI.escape(login_options[:next])}&hide_checkbox=true&canvas=true&fbconnect=true&req_perms=publish_stream"
49
+ assert_equal url, expected_url
50
+ end
51
+
25
52
  def test_can_get_api_and_secret_key_from_environment
26
53
  assert_equal('1234567', Facebooker::Session.api_key)
27
54
  assert_equal('7654321', Facebooker::Session.secret_key)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taweili-facebooker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.47
4
+ version: 1.0.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Fowler
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2009-08-14 00:00:00 -07:00
17
+ date: 2009-09-08 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency