taweili-facebooker 1.0.41 → 1.0.45
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/Manifest.txt +5 -0
- data/facebooker.gemspec +4 -4
- data/lib/facebooker/adapters/adapter_base.rb +1 -1
- data/lib/facebooker/models/user.rb +1 -1
- data/lib/facebooker/parser.rb +1 -0
- data/lib/facebooker/rails/controller.rb +5 -6
- data/lib/facebooker/rails/cucumber/world.rb +25 -31
- data/lib/facebooker/rails/helpers/fb_connect.rb +2 -1
- data/lib/facebooker/rails/helpers.rb +14 -4
- data/lib/facebooker/rails/integration_session.rb +1 -1
- data/lib/facebooker/rails/publisher.rb +1 -1
- data/lib/facebooker/service/base_service.rb +18 -0
- data/lib/facebooker/service/curl_service.rb +44 -0
- data/lib/facebooker/service/net_http_service.rb +12 -0
- data/lib/facebooker/service/typhoeus_multi_service.rb +27 -0
- data/lib/facebooker/service/typhoeus_service.rb +17 -0
- data/lib/facebooker/session.rb +22 -9
- data/lib/facebooker/version.rb +1 -1
- data/lib/facebooker.rb +11 -9
- data/test/facebooker/adapters_test.rb +17 -0
- data/test/facebooker/rails/integration_session_test.rb +10 -0
- data/test/facebooker/rails/publisher_test.rb +4 -3
- data/test/facebooker/rails_integration_test.rb +55 -30
- data/test/facebooker/session_test.rb +41 -0
- data/test/rack/facebook_test.rb +21 -9
- metadata +11 -3
data/Manifest.txt
CHANGED
@@ -99,6 +99,11 @@ lib/facebooker/rails/test_helpers.rb
|
|
99
99
|
lib/facebooker/rails/utilities.rb
|
100
100
|
lib/facebooker/server_cache.rb
|
101
101
|
lib/facebooker/service.rb
|
102
|
+
lib/facebooker/service/base_service.rb
|
103
|
+
lib/facebooker/service/curl_service.rb
|
104
|
+
lib/facebooker/service/net_http_service.rb
|
105
|
+
lib/facebooker/service/typhoeus_service.rb
|
106
|
+
lib/facebooker/service/typhoeus_multi_service.rb
|
102
107
|
lib/facebooker/session.rb
|
103
108
|
lib/facebooker/version.rb
|
104
109
|
lib/net/http_multipart_post.rb
|
data/facebooker.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{facebooker}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.45"
|
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"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-24}
|
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
|
@@ -15,14 +15,14 @@ Gem::Specification.new do |s|
|
|
15
15
|
* Well tested}
|
16
16
|
s.email = %q{mmangino@elevatedrails.com}
|
17
17
|
s.extra_rdoc_files = ["Manifest.txt", "CHANGELOG.rdoc", "COPYING.rdoc", "README.rdoc", "TODO.rdoc"]
|
18
|
-
s.files = [".autotest", "CHANGELOG.rdoc", "COPYING.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "TODO.rdoc", "examples/desktop_login.rb", "facebooker.gemspec", "generators/facebook/facebook_generator.rb", "generators/facebook/templates/config/facebooker.yml", "generators/facebook/templates/public/javascripts/facebooker.js", "generators/facebook_controller/USAGE", "generators/facebook_controller/facebook_controller_generator.rb", "generators/facebook_controller/templates/controller.rb", "generators/facebook_controller/templates/functional_test.rb", "generators/facebook_controller/templates/helper.rb", "generators/facebook_controller/templates/view.fbml.erb", "generators/facebook_controller/templates/view.html.erb", "generators/facebook_publisher/facebook_publisher_generator.rb", "generators/facebook_publisher/templates/create_facebook_templates.rb", "generators/facebook_publisher/templates/publisher.rb", "generators/facebook_scaffold/USAGE", "generators/facebook_scaffold/facebook_scaffold_generator.rb", "generators/facebook_scaffold/templates/controller.rb", "generators/facebook_scaffold/templates/facebook_style.css", "generators/facebook_scaffold/templates/functional_test.rb", "generators/facebook_scaffold/templates/helper.rb", "generators/facebook_scaffold/templates/layout.fbml.erb", "generators/facebook_scaffold/templates/layout.html.erb", "generators/facebook_scaffold/templates/style.css", "generators/facebook_scaffold/templates/view_edit.fbml.erb", "generators/facebook_scaffold/templates/view_edit.html.erb", "generators/facebook_scaffold/templates/view_index.fbml.erb", "generators/facebook_scaffold/templates/view_index.html.erb", "generators/facebook_scaffold/templates/view_new.fbml.erb", "generators/facebook_scaffold/templates/view_new.html.erb", "generators/facebook_scaffold/templates/view_show.fbml.erb", "generators/facebook_scaffold/templates/view_show.html.erb", "generators/publisher/publisher_generator.rb", "generators/xd_receiver/templates/xd_receiver.html", "generators/xd_receiver/xd_receiver_generator.rb", "init.rb", "install.rb", "lib/facebooker.rb", "lib/facebooker/adapters/adapter_base.rb", "lib/facebooker/adapters/bebo_adapter.rb", "lib/facebooker/adapters/facebook_adapter.rb", "lib/facebooker/admin.rb", "lib/facebooker/batch_request.rb", "lib/facebooker/data.rb", "lib/facebooker/feed.rb", "lib/facebooker/logging.rb", "lib/facebooker/mobile.rb", "lib/facebooker/mock/service.rb", "lib/facebooker/mock/session.rb", "lib/facebooker/model.rb", "lib/facebooker/models/affiliation.rb", "lib/facebooker/models/album.rb", "lib/facebooker/models/applicationproperties.rb", "lib/facebooker/models/applicationrestrictions.rb", "lib/facebooker/models/cookie.rb", "lib/facebooker/models/education_info.rb", "lib/facebooker/models/event.rb", "lib/facebooker/models/friend_list.rb", "lib/facebooker/models/group.rb", "lib/facebooker/models/info_item.rb", "lib/facebooker/models/info_section.rb", "lib/facebooker/models/location.rb", "lib/facebooker/models/notifications.rb", "lib/facebooker/models/page.rb", "lib/facebooker/models/photo.rb", "lib/facebooker/models/tag.rb", "lib/facebooker/models/user.rb", "lib/facebooker/models/video.rb", "lib/facebooker/models/work_info.rb", "lib/facebooker/parser.rb", "lib/facebooker/rails/backwards_compatible_param_checks.rb", "lib/facebooker/rails/controller.rb", "lib/facebooker/rails/cucumber.rb", "lib/facebooker/rails/cucumber/world.rb", "lib/facebooker/rails/extensions/action_controller.rb", "lib/facebooker/rails/extensions/rack_setup.rb", "lib/facebooker/rails/extensions/routing.rb", "lib/facebooker/rails/facebook_form_builder.rb", "lib/facebooker/rails/facebook_pretty_errors.rb", "lib/facebooker/rails/facebook_request_fix.rb", "lib/facebooker/rails/facebook_request_fix_2-3.rb", "lib/facebooker/rails/facebook_session_handling.rb", "lib/facebooker/rails/facebook_url_helper.rb", "lib/facebooker/rails/facebook_url_rewriting.rb", "lib/facebooker/rails/helpers.rb", "lib/facebooker/rails/helpers/fb_connect.rb", "lib/facebooker/rails/integration_session.rb", "lib/facebooker/rails/profile_publisher_extensions.rb", "lib/facebooker/rails/publisher.rb", "lib/facebooker/rails/routing.rb", "lib/facebooker/rails/test_helpers.rb", "lib/facebooker/rails/utilities.rb", "lib/facebooker/server_cache.rb", "lib/facebooker/service.rb", "lib/facebooker/session.rb", "lib/facebooker/version.rb", "lib/net/http_multipart_post.rb", "lib/rack/facebook.rb", "lib/tasks/facebooker.rake", "lib/tasks/tunnel.rake", "rails/init.rb", "setup.rb", "templates/layout.erb", "test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/page_test.rb", "test/facebooker/models/photo_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/rails/facebook_request_fix_2-3_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/fixtures/multipart_post_body_with_only_parameters.txt", "test/fixtures/multipart_post_body_with_single_file.txt", "test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb", "test/rails_test_helper.rb", "test/test_helper.rb", "test/facebooker/rails/facebook_url_rewriting_test.rb", "test/facebooker/service_test.rb"]
|
18
|
+
s.files = [".autotest", "CHANGELOG.rdoc", "COPYING.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "TODO.rdoc", "examples/desktop_login.rb", "facebooker.gemspec", "generators/facebook/facebook_generator.rb", "generators/facebook/templates/config/facebooker.yml", "generators/facebook/templates/public/javascripts/facebooker.js", "generators/facebook_controller/USAGE", "generators/facebook_controller/facebook_controller_generator.rb", "generators/facebook_controller/templates/controller.rb", "generators/facebook_controller/templates/functional_test.rb", "generators/facebook_controller/templates/helper.rb", "generators/facebook_controller/templates/view.fbml.erb", "generators/facebook_controller/templates/view.html.erb", "generators/facebook_publisher/facebook_publisher_generator.rb", "generators/facebook_publisher/templates/create_facebook_templates.rb", "generators/facebook_publisher/templates/publisher.rb", "generators/facebook_scaffold/USAGE", "generators/facebook_scaffold/facebook_scaffold_generator.rb", "generators/facebook_scaffold/templates/controller.rb", "generators/facebook_scaffold/templates/facebook_style.css", "generators/facebook_scaffold/templates/functional_test.rb", "generators/facebook_scaffold/templates/helper.rb", "generators/facebook_scaffold/templates/layout.fbml.erb", "generators/facebook_scaffold/templates/layout.html.erb", "generators/facebook_scaffold/templates/style.css", "generators/facebook_scaffold/templates/view_edit.fbml.erb", "generators/facebook_scaffold/templates/view_edit.html.erb", "generators/facebook_scaffold/templates/view_index.fbml.erb", "generators/facebook_scaffold/templates/view_index.html.erb", "generators/facebook_scaffold/templates/view_new.fbml.erb", "generators/facebook_scaffold/templates/view_new.html.erb", "generators/facebook_scaffold/templates/view_show.fbml.erb", "generators/facebook_scaffold/templates/view_show.html.erb", "generators/publisher/publisher_generator.rb", "generators/xd_receiver/templates/xd_receiver.html", "generators/xd_receiver/xd_receiver_generator.rb", "init.rb", "install.rb", "lib/facebooker.rb", "lib/facebooker/adapters/adapter_base.rb", "lib/facebooker/adapters/bebo_adapter.rb", "lib/facebooker/adapters/facebook_adapter.rb", "lib/facebooker/admin.rb", "lib/facebooker/batch_request.rb", "lib/facebooker/data.rb", "lib/facebooker/feed.rb", "lib/facebooker/logging.rb", "lib/facebooker/mobile.rb", "lib/facebooker/mock/service.rb", "lib/facebooker/mock/session.rb", "lib/facebooker/model.rb", "lib/facebooker/models/affiliation.rb", "lib/facebooker/models/album.rb", "lib/facebooker/models/applicationproperties.rb", "lib/facebooker/models/applicationrestrictions.rb", "lib/facebooker/models/cookie.rb", "lib/facebooker/models/education_info.rb", "lib/facebooker/models/event.rb", "lib/facebooker/models/friend_list.rb", "lib/facebooker/models/group.rb", "lib/facebooker/models/info_item.rb", "lib/facebooker/models/info_section.rb", "lib/facebooker/models/location.rb", "lib/facebooker/models/notifications.rb", "lib/facebooker/models/page.rb", "lib/facebooker/models/photo.rb", "lib/facebooker/models/tag.rb", "lib/facebooker/models/user.rb", "lib/facebooker/models/video.rb", "lib/facebooker/models/work_info.rb", "lib/facebooker/parser.rb", "lib/facebooker/rails/backwards_compatible_param_checks.rb", "lib/facebooker/rails/controller.rb", "lib/facebooker/rails/cucumber.rb", "lib/facebooker/rails/cucumber/world.rb", "lib/facebooker/rails/extensions/action_controller.rb", "lib/facebooker/rails/extensions/rack_setup.rb", "lib/facebooker/rails/extensions/routing.rb", "lib/facebooker/rails/facebook_form_builder.rb", "lib/facebooker/rails/facebook_pretty_errors.rb", "lib/facebooker/rails/facebook_request_fix.rb", "lib/facebooker/rails/facebook_request_fix_2-3.rb", "lib/facebooker/rails/facebook_session_handling.rb", "lib/facebooker/rails/facebook_url_helper.rb", "lib/facebooker/rails/facebook_url_rewriting.rb", "lib/facebooker/rails/helpers.rb", "lib/facebooker/rails/helpers/fb_connect.rb", "lib/facebooker/rails/integration_session.rb", "lib/facebooker/rails/profile_publisher_extensions.rb", "lib/facebooker/rails/publisher.rb", "lib/facebooker/rails/routing.rb", "lib/facebooker/rails/test_helpers.rb", "lib/facebooker/rails/utilities.rb", "lib/facebooker/server_cache.rb", "lib/facebooker/service.rb", "lib/facebooker/service/base_service.rb", "lib/facebooker/service/curl_service.rb", "lib/facebooker/service/net_http_service.rb", "lib/facebooker/service/typhoeus_service.rb", "lib/facebooker/service/typhoeus_multi_service.rb", "lib/facebooker/session.rb", "lib/facebooker/version.rb", "lib/net/http_multipart_post.rb", "lib/rack/facebook.rb", "lib/tasks/facebooker.rake", "lib/tasks/tunnel.rake", "rails/init.rb", "setup.rb", "templates/layout.erb", "test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/page_test.rb", "test/facebooker/models/photo_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/rails/facebook_request_fix_2-3_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/fixtures/multipart_post_body_with_only_parameters.txt", "test/fixtures/multipart_post_body_with_single_file.txt", "test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb", "test/rails_test_helper.rb", "test/test_helper.rb", "test/facebooker/rails/facebook_url_rewriting_test.rb", "test/facebooker/rails/integration_session_test.rb", "test/facebooker/service_test.rb"]
|
19
19
|
s.homepage = %q{http://facebooker.rubyforge.org}
|
20
20
|
s.rdoc_options = ["--main", "README.rdoc"]
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
s.rubyforge_project = %q{facebooker}
|
23
23
|
s.rubygems_version = %q{1.3.4}
|
24
24
|
s.summary = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]}
|
25
|
-
s.test_files = ["test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/page_test.rb", "test/facebooker/models/photo_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/facebook_request_fix_2-3_test.rb", "test/facebooker/rails/facebook_url_rewriting_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/service_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb"]
|
25
|
+
s.test_files = ["test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/page_test.rb", "test/facebooker/models/photo_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/facebook_request_fix_2-3_test.rb", "test/facebooker/rails/facebook_url_rewriting_test.rb", "test/facebooker/rails/integration_session_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/service_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb"]
|
26
26
|
|
27
27
|
if s.respond_to? :specification_version then
|
28
28
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -10,7 +10,7 @@ module Facebooker
|
|
10
10
|
include Model
|
11
11
|
attr_accessor :message, :time, :status_id
|
12
12
|
end
|
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, :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]
|
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
14
|
STANDARD_FIELDS = [:uid, :first_name, :last_name, :name, :timezone, :birthday, :sex, :affiliations, :locale, :profile_url, :pic_square]
|
15
15
|
populating_attr_accessor(*FIELDS)
|
16
16
|
attr_reader :affiliations
|
data/lib/facebooker/parser.rb
CHANGED
@@ -572,6 +572,7 @@ module Facebooker
|
|
572
572
|
103 => Facebooker::Session::CallOutOfOrder,
|
573
573
|
104 => Facebooker::Session::IncorrectSignature,
|
574
574
|
120 => Facebooker::Session::InvalidAlbumId,
|
575
|
+
200 => Facebooker::Session::PermissionError,
|
575
576
|
250 => Facebooker::Session::ExtendedPermissionRequired,
|
576
577
|
321 => Facebooker::Session::AlbumIsFull,
|
577
578
|
324 => Facebooker::Session::MissingOrInvalidImageFile,
|
@@ -7,7 +7,6 @@ module Facebooker
|
|
7
7
|
include Facebooker::Rails::ProfilePublisherExtensions
|
8
8
|
def self.included(controller)
|
9
9
|
controller.extend(ClassMethods)
|
10
|
-
controller.before_filter :set_adapter
|
11
10
|
controller.before_filter :set_facebook_request_format
|
12
11
|
controller.helper_attr :facebook_session_parameters
|
13
12
|
controller.helper_method :request_comes_from_facebook?
|
@@ -180,7 +179,11 @@ module Facebooker
|
|
180
179
|
end
|
181
180
|
|
182
181
|
def default_after_facebook_login_url
|
183
|
-
|
182
|
+
omit_keys = ["_method", "format"]
|
183
|
+
options = (params||{}).clone
|
184
|
+
options = options.reject{|k,v| k.to_s.match(/^fb_sig/) or omit_keys.include?(k.to_s)}
|
185
|
+
options = options.merge({:only_path => false})
|
186
|
+
url_for(options)
|
184
187
|
end
|
185
188
|
|
186
189
|
def create_new_facebook_session_and_redirect!
|
@@ -329,10 +332,6 @@ module Facebooker
|
|
329
332
|
end
|
330
333
|
end
|
331
334
|
|
332
|
-
def set_adapter
|
333
|
-
Facebooker.load_adapter(params) if(params[:fb_sig_api_key])
|
334
|
-
end
|
335
|
-
|
336
335
|
|
337
336
|
module ClassMethods
|
338
337
|
#
|
@@ -4,43 +4,37 @@ require 'facebooker/rails/integration_session'
|
|
4
4
|
module Facebooker
|
5
5
|
module Rails
|
6
6
|
module Cucumber
|
7
|
-
|
8
|
-
|
9
|
-
session = Facebooker::Rails::IntegrationSession.new
|
7
|
+
def open_session
|
8
|
+
session = Facebooker::Rails::IntegrationSession.new
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
10
|
+
# delegate the fixture accessors back to the test instance
|
11
|
+
extras = Module.new { attr_accessor :delegate, :test_result }
|
12
|
+
if self.class.respond_to?(:fixture_table_names)
|
13
|
+
self.class.fixture_table_names.each do |table_name|
|
14
|
+
name = table_name.tr(".", "_")
|
15
|
+
next unless respond_to?(name)
|
16
|
+
extras.__send__(:define_method, name) { |*args| delegate.send(name, *args) }
|
19
17
|
end
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
# delegate add_assertion to the test case
|
21
|
+
extras.__send__(:define_method, :add_assertion) { test_result.add_assertion }
|
22
|
+
session.extend(extras)
|
23
|
+
session.delegate = self
|
24
|
+
session.test_result = @_result
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
26
|
+
yield session if block_given?
|
27
|
+
session
|
28
|
+
end
|
29
|
+
|
30
|
+
def without_canvas
|
31
|
+
in_canvas = @integration_session.canvas
|
32
|
+
@integration_session.canvas = false
|
33
|
+
yield
|
34
|
+
@integration_session.canvas = in_canvas
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
42
|
-
World
|
43
|
-
w = Facebooker::Rails::Cucumber::World.new
|
44
|
-
w.reset!
|
45
|
-
w
|
46
|
-
end
|
40
|
+
World(Facebooker::Rails::Cucumber)
|
@@ -107,8 +107,9 @@ module Facebooker
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def fb_user_action(action, user_message = nil, prompt = "", callback = nil)
|
110
|
+
defaulted_callback = callback || "null"
|
110
111
|
update_page do |page|
|
111
|
-
page.call("FB.Connect.showFeedDialog",action.template_id,action.data,action.target_ids,action.body_general,nil,page.literal("FB.RequireConnect.promptConnect"),
|
112
|
+
page.call("FB.Connect.showFeedDialog",action.template_id,action.data,action.target_ids,action.body_general,nil,page.literal("FB.RequireConnect.promptConnect"),page.literal(defaulted_callback),prompt,user_message.nil? ? nil : {:value=>user_message})
|
112
113
|
end
|
113
114
|
end
|
114
115
|
|
@@ -187,10 +187,10 @@ module Facebooker
|
|
187
187
|
# <fb:editor-button label="Save Poke"
|
188
188
|
# </fb:editor-buttonset>
|
189
189
|
# </fb:editor>
|
190
|
-
|
190
|
+
def facebook_form_for( record_or_name_or_array,*args, &proc)
|
191
191
|
|
192
|
-
|
193
|
-
|
192
|
+
raise ArgumentError, "Missing block" unless block_given?
|
193
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
194
194
|
|
195
195
|
case record_or_name_or_array
|
196
196
|
when String, Symbol
|
@@ -230,8 +230,18 @@ module Facebooker
|
|
230
230
|
fields_for( object_name,*(args << options), &proc)
|
231
231
|
concat("</fb:editor>",proc.binding)
|
232
232
|
end
|
233
|
-
|
233
|
+
end
|
234
234
|
|
235
|
+
# Render an fb:application-name tag
|
236
|
+
#
|
237
|
+
# This renders the current application name via fbml. See
|
238
|
+
# http://wiki.developers.facebook.com/index.php/Fb:application-name
|
239
|
+
# for a full description.
|
240
|
+
#
|
241
|
+
def fb_application_name(options={})
|
242
|
+
tag "fb:application-name", stringify_vals(options)
|
243
|
+
end
|
244
|
+
|
235
245
|
# Render an fb:name tag for the given user
|
236
246
|
# This renders the name of the user specified. You can use this tag as both subject and object of
|
237
247
|
# a sentence. <em> See </em> http://wiki.developers.facebook.com/index.php/Fb:name for full description.
|
@@ -12,7 +12,7 @@ class Facebooker::Rails::IntegrationSession < ActionController::Integration::Ses
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def reset!
|
15
|
-
self.default_request_params = {:fb_sig_in_canvas => '1'}.with_indifferent_access
|
15
|
+
self.default_request_params = {:fb_sig_in_canvas => '1', :fb_sig_api_key => Facebooker::Session.api_key}.with_indifferent_access
|
16
16
|
self.canvas = true
|
17
17
|
super
|
18
18
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Facebooker::Service::BaseService
|
2
|
+
def parse_results?
|
3
|
+
true
|
4
|
+
end
|
5
|
+
|
6
|
+
def post_params(params)
|
7
|
+
post_params = {}
|
8
|
+
params.each do |k,v|
|
9
|
+
if Array === v || Hash === v
|
10
|
+
post_params[k] = Facebooker.json_encode(v)
|
11
|
+
else
|
12
|
+
post_params[k] = v
|
13
|
+
end
|
14
|
+
end
|
15
|
+
post_params
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'curb'
|
2
|
+
Facebooker.use_curl = true
|
3
|
+
class Facebooker::Service::CurlService < Facebooker::Service::BaseService
|
4
|
+
def post_form(url,params,multipart=false)
|
5
|
+
curl = Curl::Easy.new(url.to_s) do |c|
|
6
|
+
c.multipart_form_post = multipart
|
7
|
+
c.timeout = Facebooker.timeout
|
8
|
+
end
|
9
|
+
curl.http_post(*to_curb_params(params))
|
10
|
+
curl.body_str
|
11
|
+
end
|
12
|
+
|
13
|
+
def post_multipart_form(url,params)
|
14
|
+
post_form(url,params,true)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Net::HTTP::MultipartPostFile
|
18
|
+
def multipart_post_file?(object)
|
19
|
+
object.respond_to?(:content_type) &&
|
20
|
+
object.respond_to?(:data) &&
|
21
|
+
object.respond_to?(:filename)
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_curb_params(params)
|
25
|
+
parray = []
|
26
|
+
params.each_pair do |k,v|
|
27
|
+
if multipart_post_file?(v)
|
28
|
+
# Curl doesn't like blank field names
|
29
|
+
field = Curl::PostField.file((k.blank? ? 'xxx' : k.to_s), nil, File.basename(v.filename))
|
30
|
+
field.content_type = v.content_type
|
31
|
+
field.content = v.data
|
32
|
+
parray << field
|
33
|
+
else
|
34
|
+
parray << Curl::PostField.content(
|
35
|
+
k.to_s,
|
36
|
+
(Array === v || Hash===v) ? Facebooker.json_encode(v) : v.to_s
|
37
|
+
)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
parray
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
class Facebooker::Service::NetHttpService <Facebooker::Service::BaseService
|
3
|
+
def post_form(url,params)
|
4
|
+
Net::HTTP.post_form(url, post_params(params))
|
5
|
+
end
|
6
|
+
|
7
|
+
def post_multipart_form(url,params)
|
8
|
+
Net::HTTP.post_multipart_form(url, params)
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Facebooker::Service::TyphoeusMultiService < Facebooker::Service::TyphoeusService
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
@result_objects = []
|
5
|
+
end
|
6
|
+
|
7
|
+
def parse_results?
|
8
|
+
false
|
9
|
+
end
|
10
|
+
|
11
|
+
#define a method that returns nothing
|
12
|
+
define_remote_method :async_post, :on_success => lambda {|r| puts "."}
|
13
|
+
|
14
|
+
def perform_post(url,params)
|
15
|
+
add_result(self.class.async_post(:base_uri=>url,:params=>params))
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_result(obj)
|
19
|
+
@result_objects << obj
|
20
|
+
end
|
21
|
+
|
22
|
+
def process
|
23
|
+
# we need to access all objects to make sure the proxy has made the request
|
24
|
+
@result_objects.each(&:nil?)
|
25
|
+
@result_objects = []
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'typhoeus'
|
2
|
+
class Facebooker::Service::TyphoeusService < Facebooker::Service::BaseService
|
3
|
+
include Typhoeus
|
4
|
+
def post_form(url,params)
|
5
|
+
perform_post(url.to_s,post_params(params))
|
6
|
+
end
|
7
|
+
|
8
|
+
def perform_post(url,params)
|
9
|
+
self.class.post(url,:params=>post_params)
|
10
|
+
end
|
11
|
+
|
12
|
+
def post_multipart_form(url,params)
|
13
|
+
raise "Multipart not supported on Typhoeus"
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
end
|
data/lib/facebooker/session.rb
CHANGED
@@ -50,6 +50,7 @@ module Facebooker
|
|
50
50
|
class FQLStatementNotIndexable < StandardError; end
|
51
51
|
class FQLFunctionDoesNotExist < StandardError; end
|
52
52
|
class FQLWrongNumberArgumentsPassedToFunction < StandardError; end
|
53
|
+
class PermissionError < StandardError; end
|
53
54
|
class InvalidAlbumId < StandardError; end
|
54
55
|
class AlbumIsFull < StandardError; end
|
55
56
|
class MissingOrInvalidImageFile < StandardError; end
|
@@ -394,14 +395,22 @@ module Facebooker
|
|
394
395
|
# Register a template bundle with Facebook.
|
395
396
|
# returns the template id to use to send using this template
|
396
397
|
def register_template_bundle(one_line_story_templates,short_story_templates=nil,full_story_template=nil, action_links=nil)
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
398
|
+
templates = ensure_array(one_line_story_templates)
|
399
|
+
parameters = {:one_line_story_templates => templates.to_json}
|
400
|
+
|
401
|
+
unless action_links.blank?
|
402
|
+
parameters[:action_links] = action_links.to_json
|
403
|
+
end
|
404
|
+
|
405
|
+
unless short_story_templates.blank?
|
406
|
+
templates = ensure_array(short_story_templates)
|
407
|
+
parameters[:short_story_templates] = templates.to_json
|
408
|
+
end
|
409
|
+
|
410
|
+
unless full_story_template.blank?
|
411
|
+
parameters[:full_story_template] = full_story_template.to_json
|
412
|
+
end
|
413
|
+
|
405
414
|
post("facebook.feed.registerTemplateBundle", parameters, false)
|
406
415
|
end
|
407
416
|
|
@@ -553,7 +562,7 @@ module Facebooker
|
|
553
562
|
end
|
554
563
|
|
555
564
|
def post(method, params = {}, use_session_key = true, &proc)
|
556
|
-
if batch_request?
|
565
|
+
if batch_request? or Facebooker::Logging.skip_api_logging
|
557
566
|
post_without_logging(method, params, use_session_key, &proc)
|
558
567
|
else
|
559
568
|
Logging.log_fb_api(method, params) do
|
@@ -628,6 +637,10 @@ module Facebooker
|
|
628
637
|
end.sort.join
|
629
638
|
Digest::MD5.hexdigest([raw_string, secret_for_method(params[:method])].join)
|
630
639
|
end
|
640
|
+
|
641
|
+
def ensure_array(value)
|
642
|
+
value.is_a?(Array) ? value : [value]
|
643
|
+
end
|
631
644
|
end
|
632
645
|
|
633
646
|
class CanvasSession < Session
|
data/lib/facebooker/version.rb
CHANGED
data/lib/facebooker.rb
CHANGED
@@ -36,14 +36,13 @@ module Facebooker
|
|
36
36
|
class << self
|
37
37
|
|
38
38
|
def load_configuration(facebooker_yaml_file)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
Thread.current[:fb_api_config] = @raw_facebooker_configuration unless Thread.current[:fb_api_config]
|
45
|
-
apply_configuration(@raw_facebooker_configuration)
|
39
|
+
return false unless File.exist?(facebooker_yaml_file)
|
40
|
+
@raw_facebooker_configuration = YAML.load(ERB.new(File.read(facebooker_yaml_file)).result)
|
41
|
+
if defined? RAILS_ENV
|
42
|
+
@raw_facebooker_configuration = @raw_facebooker_configuration[RAILS_ENV]
|
46
43
|
end
|
44
|
+
Thread.current[:fb_api_config] = @raw_facebooker_configuration unless Thread.current[:fb_api_config]
|
45
|
+
apply_configuration(@raw_facebooker_configuration)
|
47
46
|
end
|
48
47
|
|
49
48
|
# Sets the Facebook environment based on a hash of options.
|
@@ -61,7 +60,10 @@ module Facebooker
|
|
61
60
|
ActionController::Base.asset_host = config['callback_url']
|
62
61
|
end
|
63
62
|
Facebooker.timeout = config['timeout']
|
64
|
-
|
63
|
+
|
64
|
+
@facebooker_configuration = config # must be set before adapter loaded
|
65
|
+
load_adapter(:fb_sig_api_key => config['api_key'])
|
66
|
+
facebooker_config
|
65
67
|
end
|
66
68
|
|
67
69
|
def facebooker_config
|
@@ -87,7 +89,7 @@ module Facebooker
|
|
87
89
|
Thread.current[:fb_api_config] = apply_configuration(config)
|
88
90
|
yield
|
89
91
|
ensure
|
90
|
-
Thread.current[:fb_api_config] = old if old
|
92
|
+
Thread.current[:fb_api_config] = old if old && !old.empty?
|
91
93
|
apply_configuration(Thread.current[:fb_api_config])
|
92
94
|
end
|
93
95
|
end
|
@@ -171,4 +171,21 @@ class Facebooker::AdaptersTest < Test::Unit::TestCase
|
|
171
171
|
assert_equal 'my secret key', @secret_in_outer_block
|
172
172
|
end
|
173
173
|
|
174
|
+
def test_adapter_loaded_when_config_applied
|
175
|
+
flexmock( Facebooker ).
|
176
|
+
should_receive( :fetch_config_for ).
|
177
|
+
and_return(
|
178
|
+
{ 'api_key' => 'a_key',
|
179
|
+
'canvas_page_name' => 'default_name' },
|
180
|
+
{ 'api_key' => 'another_key',
|
181
|
+
'canvas_page_name' => 'alternative_name' }
|
182
|
+
)
|
183
|
+
Facebooker.with_application('a_key') do
|
184
|
+
assert_equal 'default_name', Facebooker.current_adapter.facebooker_config['canvas_page_name']
|
185
|
+
Facebooker.with_application('another_key') do
|
186
|
+
assert_equal 'alternative_name', Facebooker.current_adapter.facebooker_config['canvas_page_name']
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
174
191
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../lib/facebooker/rails/integration_session')
|
3
|
+
class Facebooker::Rails::IntegrationSessionTest < Test::Unit::TestCase
|
4
|
+
def test_include_api_key_in_default_request_params
|
5
|
+
ENV['FACEBOOK_API_KEY'] = 'a key'
|
6
|
+
integration_session = Facebooker::Rails::IntegrationSession.new
|
7
|
+
integration_session.reset!
|
8
|
+
assert_equal 'a key', integration_session.default_request_params[ :fb_sig_api_key ]
|
9
|
+
end
|
10
|
+
end
|
@@ -145,6 +145,7 @@ class Facebooker::Rails::Publisher::FacebookTemplateTest < Test::Unit::TestCase
|
|
145
145
|
|
146
146
|
def setup
|
147
147
|
super
|
148
|
+
ENV['FACEBOOK_API_KEY'] = '1234567'
|
148
149
|
@template = mock("facebook template")
|
149
150
|
FacebookTemplate.stubs(:register).returns(@template)
|
150
151
|
FacebookTemplate.clear_cache!
|
@@ -167,13 +168,13 @@ class Facebooker::Rails::Publisher::FacebookTemplateTest < Test::Unit::TestCase
|
|
167
168
|
end
|
168
169
|
|
169
170
|
def test_find_in_db_should_run_find
|
170
|
-
FacebookTemplate.expects(:find_by_template_name).with("TestPublisher::simple_user_action").returns(@template)
|
171
|
+
FacebookTemplate.expects(:find_by_template_name).with("1234567: TestPublisher::simple_user_action").returns(@template)
|
171
172
|
@template.stubs(:template_changed?).returns(false)
|
172
173
|
assert_equal FacebookTemplate.find_in_db(TestPublisher,"simple_user_action"), @template
|
173
174
|
end
|
174
175
|
|
175
176
|
def test_find_in_db_should_register_if_not_found
|
176
|
-
FacebookTemplate.expects(:find_by_template_name).with("TestPublisher::simple_user_action").returns(nil)
|
177
|
+
FacebookTemplate.expects(:find_by_template_name).with("1234567: TestPublisher::simple_user_action").returns(nil)
|
177
178
|
FacebookTemplate.expects(:register).with(TestPublisher,"simple_user_action").returns(@template)
|
178
179
|
FacebookTemplate.find_cached(TestPublisher,"simple_user_action")
|
179
180
|
|
@@ -195,7 +196,7 @@ class Facebooker::Rails::Publisher::FacebookTemplateTest < Test::Unit::TestCase
|
|
195
196
|
end
|
196
197
|
|
197
198
|
def test_find_in_db_should_re_register_if_changed
|
198
|
-
FacebookTemplate.stubs(:find_by_template_name).with("TestPublisher::simple_user_action").returns(@template)
|
199
|
+
FacebookTemplate.stubs(:find_by_template_name).with("1234567: TestPublisher::simple_user_action").returns(@template)
|
199
200
|
FacebookTemplate.stubs(:hashed_content).returns("MY CONTENT")
|
200
201
|
@template.stubs(:template_changed?).returns(true)
|
201
202
|
@template.stubs(:destroy)
|
@@ -160,9 +160,10 @@ class RailsIntegrationTestForFBConnect < Test::Unit::TestCase
|
|
160
160
|
include FBConnectTestHelpers
|
161
161
|
|
162
162
|
def setup
|
163
|
-
|
164
|
-
|
165
|
-
|
163
|
+
Facebooker.apply_configuration({
|
164
|
+
'api_key' => '1234567',
|
165
|
+
'canvas_page_name' => 'facebook_app_name',
|
166
|
+
'secret_key' => '7654321' })
|
166
167
|
@controller = FBConnectController.new
|
167
168
|
@request = ActionController::TestRequest.new
|
168
169
|
@response = ActionController::TestResponse.new
|
@@ -181,9 +182,10 @@ end
|
|
181
182
|
|
182
183
|
class RailsIntegrationTestForNonFacebookControllers < Test::Unit::TestCase
|
183
184
|
def setup
|
184
|
-
|
185
|
-
|
186
|
-
|
185
|
+
Facebooker.apply_configuration({
|
186
|
+
'api_key' => '1234567',
|
187
|
+
'canvas_page_name' => 'facebook_app_name',
|
188
|
+
'secret_key' => '7654321' })
|
187
189
|
@controller = PlainOldRailsController.new
|
188
190
|
@request = ActionController::TestRequest.new
|
189
191
|
@response = ActionController::TestResponse.new
|
@@ -216,8 +218,9 @@ end
|
|
216
218
|
|
217
219
|
class RailsIntegrationTestForExtendedPermissions < Test::Unit::TestCase
|
218
220
|
def setup
|
219
|
-
|
220
|
-
|
221
|
+
Facebooker.apply_configuration({
|
222
|
+
'api_key' => '1234567',
|
223
|
+
'secret_key' => '7654321' })
|
221
224
|
@controller = ControllerWhichRequiresExtendedPermissions.new
|
222
225
|
@request = ActionController::TestRequest.new
|
223
226
|
@response = ActionController::TestResponse.new
|
@@ -255,8 +258,9 @@ end
|
|
255
258
|
|
256
259
|
class RailsIntegrationTestForApplicationInstallation < Test::Unit::TestCase
|
257
260
|
def setup
|
258
|
-
|
259
|
-
|
261
|
+
Facebooker.apply_configuration({
|
262
|
+
'api_key' => '1234567',
|
263
|
+
'secret_key' => '7654321' })
|
260
264
|
@controller = ControllerWhichRequiresApplicationInstallation.new
|
261
265
|
@request = ActionController::TestRequest.new
|
262
266
|
@response = ActionController::TestResponse.new
|
@@ -285,10 +289,12 @@ end
|
|
285
289
|
class RailsIntegrationTest < Test::Unit::TestCase
|
286
290
|
include FBConnectTestHelpers
|
287
291
|
def setup
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
+
Facebooker.apply_configuration({
|
293
|
+
'api_key' => '1234567',
|
294
|
+
'canvas_page_name' => 'root',
|
295
|
+
'secret_key' => '7654321',
|
296
|
+
'set_asset_host_to_callback_url' => true,
|
297
|
+
'callback_url' => "http://root.example.com" })
|
292
298
|
@controller = ControllerWhichRequiresFacebookAuthentication.new
|
293
299
|
@request = ActionController::TestRequest.new
|
294
300
|
@response = ActionController::TestResponse.new
|
@@ -296,10 +302,10 @@ class RailsIntegrationTest < Test::Unit::TestCase
|
|
296
302
|
|
297
303
|
end
|
298
304
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
305
|
+
def test_named_route_includes_new_canvas_path_when_in_new_canvas
|
306
|
+
get :named_route_test, facebook_params("fb_sig_in_new_facebook"=>"1")
|
307
|
+
assert_equal "http://apps.facebook.com/root/comments",@response.body
|
308
|
+
end
|
303
309
|
|
304
310
|
def test_if_controller_requires_facebook_authentication_unauthenticated_requests_will_redirect
|
305
311
|
get :index
|
@@ -476,6 +482,11 @@ class RailsIntegrationTest < Test::Unit::TestCase
|
|
476
482
|
get :link_test,facebook_params(:fb_sig_in_canvas=>0,:canvas=>false)
|
477
483
|
assert !@response.body.match(/root/)
|
478
484
|
end
|
485
|
+
|
486
|
+
def test_default_url_omits_fb_params
|
487
|
+
get :index,facebook_params(:fb_sig_friends=>"overwriteme",:get_param=>"yes")
|
488
|
+
assert_equal "http://apps.facebook.com/root/require_auth?get_param=yes", @controller.send(:default_after_facebook_login_url)
|
489
|
+
end
|
479
490
|
|
480
491
|
def test_url_for_links_to_canvas_if_canvas_is_not_set
|
481
492
|
get :link_test,facebook_params
|
@@ -527,9 +538,10 @@ end
|
|
527
538
|
|
528
539
|
class RailsSignatureTest < Test::Unit::TestCase
|
529
540
|
def setup
|
530
|
-
|
531
|
-
|
532
|
-
|
541
|
+
Facebooker.apply_configuration({
|
542
|
+
'api_key' => '1234567',
|
543
|
+
'canvas_page_name' => 'root',
|
544
|
+
'secret_key' => '7654321' })
|
533
545
|
@controller = ControllerWhichRequiresFacebookAuthentication.new
|
534
546
|
@request = ActionController::TestRequest.new
|
535
547
|
@response = ActionController::TestResponse.new
|
@@ -592,10 +604,10 @@ class RailsHelperTest < Test::Unit::TestCase
|
|
592
604
|
attr_accessor :_erbout
|
593
605
|
|
594
606
|
def setup
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
607
|
+
Facebooker.apply_configuration({
|
608
|
+
'api_key' => '1234567',
|
609
|
+
'canvas_page_name' => 'facebook',
|
610
|
+
'secret_key' => '7654321' })
|
599
611
|
@_erbout = ""
|
600
612
|
@h = HelperClass.new
|
601
613
|
#use an asset path where the canvas path equals the hostname to make sure we handle that case right
|
@@ -687,7 +699,15 @@ class RailsHelperTest < Test::Unit::TestCase
|
|
687
699
|
assert_equal "<fb:add-section-button section=\"info\" />",@h.fb_add_info_section
|
688
700
|
end
|
689
701
|
|
690
|
-
def
|
702
|
+
def test_fb_application_name
|
703
|
+
assert_equal "<fb:application-name />", @h.fb_application_name
|
704
|
+
end
|
705
|
+
|
706
|
+
def test_fb_application_name_with_linked_false
|
707
|
+
assert_equal '<fb:application-name linked="false" />', @h.fb_application_name( :linked => false )
|
708
|
+
end
|
709
|
+
|
710
|
+
def test_fb_name_with_invalid_key_size
|
691
711
|
assert_raises(ArgumentError) {@h.fb_name(1234, :sizee => false)}
|
692
712
|
end
|
693
713
|
|
@@ -1052,7 +1072,11 @@ class RailsHelperTest < Test::Unit::TestCase
|
|
1052
1072
|
def test_fb_logout_link
|
1053
1073
|
assert_equal @h.fb_logout_link("Logout","My URL"),"<a href=\"#\" onclick=\"FB.Connect.logoutAndRedirect("My URL");; return false;\">Logout</a>"
|
1054
1074
|
end
|
1055
|
-
def
|
1075
|
+
def test_fb_user_action_with_literal_callback
|
1076
|
+
action = Facebooker::Rails::Publisher::UserAction.new
|
1077
|
+
assert_equal @h.fb_user_action(action,"message","prompt","function() {alert('hi')}"),"FB.Connect.showFeedDialog(null, null, null, null, null, FB.RequireConnect.promptConnect, function() {alert('hi')}, \"prompt\", {\"value\": \"message\"});"
|
1078
|
+
end
|
1079
|
+
def test_fb_user_action_with_nil_callback
|
1056
1080
|
action = Facebooker::Rails::Publisher::UserAction.new
|
1057
1081
|
assert_equal @h.fb_user_action(action,"message","prompt"),"FB.Connect.showFeedDialog(null, null, null, null, null, FB.RequireConnect.promptConnect, null, \"prompt\", {\"value\": \"message\"});"
|
1058
1082
|
end
|
@@ -1402,9 +1426,10 @@ class RailsRequestFormatTest < Test::Unit::TestCase
|
|
1402
1426
|
end
|
1403
1427
|
|
1404
1428
|
def setup
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1429
|
+
Facebooker.apply_configuration({
|
1430
|
+
'api_key' => '1234567',
|
1431
|
+
'canvas_page_name' => 'facebook_app_name',
|
1432
|
+
'secret_key' => '7654321' })
|
1408
1433
|
@controller = FacebookController.new
|
1409
1434
|
@request = ActionController::TestRequest.new
|
1410
1435
|
@response = ActionController::TestResponse.new
|
@@ -204,6 +204,47 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
204
204
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
205
205
|
assert_equal 17876842716, @session.register_template_bundle("{*actor*} did something",nil,nil,[{:text=>"text",:href=>"href"}])
|
206
206
|
end
|
207
|
+
|
208
|
+
def test_can_register_template_bundle_with_short_story
|
209
|
+
one_line = "{*actor*} did something"
|
210
|
+
short_story = { :title => 'title', :body => 'body' }
|
211
|
+
|
212
|
+
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
213
|
+
@session.expects(:post).with(
|
214
|
+
'facebook.feed.registerTemplateBundle',
|
215
|
+
{:one_line_story_templates => [one_line].to_json, :short_story_templates => [short_story].to_json},
|
216
|
+
false
|
217
|
+
)
|
218
|
+
@session.register_template_bundle(one_line, short_story)
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_can_register_template_bundle_with_short_story_for_several_templates
|
222
|
+
one_line = ["{*actor*} did something", "{*actor*} did something again"]
|
223
|
+
short_story = [{ :title => 'title', :body => 'body' }, { :title => 'title2', :body => 'body2' }]
|
224
|
+
|
225
|
+
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
226
|
+
@session.expects(:post).with(
|
227
|
+
'facebook.feed.registerTemplateBundle',
|
228
|
+
{:one_line_story_templates => one_line.to_json, :short_story_templates => short_story.to_json},
|
229
|
+
false
|
230
|
+
)
|
231
|
+
@session.register_template_bundle(one_line, short_story)
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_can_register_template_bundle_with_full_story_for_several_templates
|
235
|
+
one_line = ["{*actor*} did something", "{*actor*} did something again"]
|
236
|
+
short_story = [{ :title => 'title', :body => 'body' }, { :title => 'title2', :body => 'body2' }]
|
237
|
+
full_story = { :title => 'title', :body => 'body' }
|
238
|
+
|
239
|
+
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
240
|
+
@session.expects(:post).with(
|
241
|
+
'facebook.feed.registerTemplateBundle',
|
242
|
+
{:one_line_story_templates => one_line.to_json, :short_story_templates => short_story.to_json, :full_story_template => full_story.to_json},
|
243
|
+
false
|
244
|
+
)
|
245
|
+
@session.register_template_bundle(one_line, short_story, full_story)
|
246
|
+
end
|
247
|
+
|
207
248
|
def test_can_publish_user_action
|
208
249
|
expect_http_posts_with_responses(publish_user_action_return_xml)
|
209
250
|
@session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
|
data/test/rack/facebook_test.rb
CHANGED
@@ -7,11 +7,20 @@ class Rack::FacebookTest < Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
def setup
|
9
9
|
flexmock(Facebooker).should_receive(:secret_key).and_return('secret')
|
10
|
+
flexmock(Facebooker).should_receive(:load_adapter)
|
10
11
|
@app = lambda do |env|
|
11
12
|
@env = env
|
12
13
|
Rack::Response.new().to_a
|
13
14
|
end
|
14
15
|
@facebook = Rack::Facebook.new(@app)
|
16
|
+
@valid_params = {
|
17
|
+
:fb_sig_user => '1',
|
18
|
+
:fb_sig => 'ignored'
|
19
|
+
}
|
20
|
+
@page = Proc.new {|options|
|
21
|
+
options ||= @valid_params
|
22
|
+
app.post "/", :input => params(options)
|
23
|
+
}
|
15
24
|
end
|
16
25
|
|
17
26
|
def params(p)
|
@@ -28,34 +37,37 @@ class Rack::FacebookTest < Test::Unit::TestCase
|
|
28
37
|
end
|
29
38
|
|
30
39
|
def test_converts_request_method
|
31
|
-
response =
|
32
|
-
:input => params(:fb_sig_request_method => 'GET', :fb_sig => '4d2a700e90b0bcbe54b9e627d2cc1417'))
|
40
|
+
response = @page.call(:fb_sig_request_method => 'GET', :fb_sig => '4d2a700e90b0bcbe54b9e627d2cc1417')
|
33
41
|
assert_equal 200, response.status
|
34
42
|
assert_equal 'GET', @env['REQUEST_METHOD']
|
35
43
|
end
|
36
44
|
|
37
45
|
def test_only_sets_request_method_if_provided
|
38
|
-
response =
|
46
|
+
response = @page.call(:fb_sig_user => '1', :fb_sig => '313dd5caed3d0902d83225ff3ae9a950')
|
39
47
|
assert_equal 200, response.status
|
40
48
|
assert_equal 'POST', @env['REQUEST_METHOD']
|
41
49
|
end
|
42
50
|
|
43
51
|
def test_renders_400_with_invalid_signature
|
44
|
-
response =
|
45
|
-
:input => params(:fb_sig => 'wrong', :fb_sig_user => 1))
|
52
|
+
response = @page.call(:fb_sig => 'wrong', :fb_sig_user => 1)
|
46
53
|
assert_equal 400, response.status
|
47
54
|
end
|
48
55
|
|
49
56
|
def test_skips_with_false_condition
|
50
57
|
@facebook = Rack::Facebook.new(@app) { false }
|
51
|
-
response =
|
58
|
+
response = @page.call({})
|
52
59
|
assert_equal 200, response.status
|
53
60
|
end
|
54
61
|
|
55
|
-
def
|
62
|
+
def test_skips_with_true_condition_without_fb_sig
|
56
63
|
@facebook = Rack::Facebook.new(@app) { true }
|
57
|
-
response =
|
64
|
+
response = @page.call(:fb_sig_user => 'ignored')
|
65
|
+
assert_equal 200, response.status
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_verifies_with_true_condition_with_fb_sig
|
69
|
+
@facebook = Rack::Facebook.new(@app) { true }
|
70
|
+
response = @page.call(:fb_sig => 'wrong', :fb_sig_user => 'ignored')
|
58
71
|
assert_equal 400, response.status
|
59
72
|
end
|
60
|
-
|
61
73
|
end
|
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.
|
4
|
+
version: 1.0.45
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Fowler
|
@@ -13,7 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2009-07-
|
16
|
+
date: 2009-07-24 00:00:00 -07:00
|
17
17
|
default_executable:
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
@@ -150,6 +150,11 @@ files:
|
|
150
150
|
- lib/facebooker/rails/utilities.rb
|
151
151
|
- lib/facebooker/server_cache.rb
|
152
152
|
- lib/facebooker/service.rb
|
153
|
+
- lib/facebooker/service/base_service.rb
|
154
|
+
- lib/facebooker/service/curl_service.rb
|
155
|
+
- lib/facebooker/service/net_http_service.rb
|
156
|
+
- lib/facebooker/service/typhoeus_service.rb
|
157
|
+
- lib/facebooker/service/typhoeus_multi_service.rb
|
153
158
|
- lib/facebooker/session.rb
|
154
159
|
- lib/facebooker/version.rb
|
155
160
|
- lib/net/http_multipart_post.rb
|
@@ -184,9 +189,11 @@ files:
|
|
184
189
|
- test/rails_test_helper.rb
|
185
190
|
- test/test_helper.rb
|
186
191
|
- test/facebooker/rails/facebook_url_rewriting_test.rb
|
192
|
+
- test/facebooker/rails/integration_session_test.rb
|
187
193
|
- test/facebooker/service_test.rb
|
188
194
|
has_rdoc: false
|
189
195
|
homepage: http://facebooker.rubyforge.org
|
196
|
+
licenses:
|
190
197
|
post_install_message:
|
191
198
|
rdoc_options:
|
192
199
|
- --main
|
@@ -208,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
215
|
requirements: []
|
209
216
|
|
210
217
|
rubyforge_project: facebooker
|
211
|
-
rubygems_version: 1.
|
218
|
+
rubygems_version: 1.3.5
|
212
219
|
signing_key:
|
213
220
|
specification_version: 3
|
214
221
|
summary: Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]
|
@@ -226,6 +233,7 @@ test_files:
|
|
226
233
|
- test/facebooker/models/user_test.rb
|
227
234
|
- test/facebooker/rails/facebook_request_fix_2-3_test.rb
|
228
235
|
- test/facebooker/rails/facebook_url_rewriting_test.rb
|
236
|
+
- test/facebooker/rails/integration_session_test.rb
|
229
237
|
- test/facebooker/rails/publisher_test.rb
|
230
238
|
- test/facebooker/rails_integration_test.rb
|
231
239
|
- test/facebooker/server_cache_test.rb
|