Skip to content

Commit 6254e8c

Browse files
committedApr 28, 2009
Fixing lots of warnings, making test file run on their own, adding a
.autotest file.
1 parent 40334bd commit 6254e8c

33 files changed

+478
-400
lines changed
 

‎.autotest

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Autotest.add_hook(:initialize) do |at|
2+
at.clear_mappings
3+
at.find_directories = %w(lib test)
4+
5+
at.add_exception("test/test_helper.rb")
6+
at.add_exception("test/rails_test_helper.rb")
7+
8+
at.add_mapping(/^lib\/.*\.rb$/) do |file, _|
9+
at.files_matching(/^test\/.*_test\.rb$/)
10+
end
11+
12+
at.add_mapping(/^test\/.*_test\.rb$/) do |file, _|
13+
file
14+
end
15+
end

‎Rakefile

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- ruby -*-
22
#
33
require 'rubygems'
4-
ENV['RUBY_FLAGS']="-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}"
54
require 'hoe'
65
begin
76
require 'load_multi_rails_rake_tasks'

‎lib/facebooker.rb

+41-39
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
begin
22
unless Object.const_defined?("ActiveSupport") and ActiveSupport.const_defined?("JSON")
3-
require 'json'
3+
require 'json'
44
module Facebooker
55
def self.json_decode(str)
66
JSON.parse(str)
@@ -12,19 +12,25 @@ def self.json_decode(str)
1212
ActiveSupport::JSON.decode(str)
1313
end
1414
end
15-
end
15+
end
1616
rescue
17-
require 'json'
17+
require 'json'
1818
end
1919
require 'zlib'
2020
require 'digest/md5'
2121

2222

2323

2424
module Facebooker
25-
25+
26+
@facebooker_configuration = {}
27+
@current_adapter = nil
28+
@set_asset_host_to_callback_url = nil
29+
@path_prefix = nil
30+
@use_curl = false
31+
2632
class << self
27-
33+
2834
def load_configuration(facebooker_yaml_file)
2935
if File.exist?(facebooker_yaml_file)
3036
if defined? RAILS_ENV
@@ -35,7 +41,7 @@ def load_configuration(facebooker_yaml_file)
3541
apply_configuration(config)
3642
end
3743
end
38-
44+
3945
# Sets the Facebook environment based on a hash of options.
4046
# By default the hash passed in is loaded from facebooker.yml, but it can also be passed in
4147
# manually every request to run multiple Facebook apps off one Rails app.
@@ -53,70 +59,66 @@ def apply_configuration(config)
5359
Facebooker.timeout = config['timeout']
5460
@facebooker_configuration = config
5561
end
56-
62+
5763
def facebooker_config
58-
@facebooker_configuration || {} # to prevent pretty_errors error if the config hasn't been set yet
59-
end
60-
61-
def current_adapter=(adapter_class)
62-
@current_adapter = adapter_class
64+
@facebooker_configuration
6365
end
64-
66+
67+
# TODO: This should be converted to attr_accessor, but we need to
68+
# get all the require statements at the top of the file to work.
69+
70+
# Set the current adapter
71+
attr_writer :current_adapter
72+
73+
# Get the current adapter
6574
def current_adapter
6675
@current_adapter || Facebooker::AdapterBase.default_adapter
6776
end
68-
77+
6978
def load_adapter(params)
7079
self.current_adapter = Facebooker::AdapterBase.load_adapter(params)
7180
end
72-
81+
7382
def facebook_path_prefix=(path)
7483
current_adapter.facebook_path_prefix = path
7584
end
76-
85+
7786
# Default is canvas_page_name in yml file
7887
def facebook_path_prefix
7988
current_adapter.facebook_path_prefix
8089
end
81-
90+
8291
def is_for?(application_container)
8392
current_adapter.is_for?(application_container)
8493
end
85-
94+
8695
def set_asset_host_to_callback_url=(val)
8796
@set_asset_host_to_callback_url=val
8897
end
89-
98+
9099
def set_asset_host_to_callback_url
91-
@set_asset_host_to_callback_url.nil? ? true : @set_asset_host_to_callback_url
92-
end
93-
94-
def use_curl=(val)
95-
@use_curl=val
96-
end
97-
98-
def use_curl?
99-
@use_curl
100+
@set_asset_host_to_callback_url || true
100101
end
101-
102+
103+
attr_accessor :use_curl
104+
alias :use_curl? :use_curl
105+
102106
def timeout=(val)
103107
@timeout = val.to_i
104108
end
105-
109+
106110
def timeout
107111
@timeout
108112
end
109-
113+
110114
[: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|
111115
define_method(delegated_method){ return current_adapter.send(delegated_method)}
112116
end
113-
114-
115-
def path_prefix
116-
@path_prefix
117-
end
118-
119-
117+
118+
119+
attr_reader :path_prefix
120+
121+
120122
# Set the asset path to the canvas path for just this one request
121123
# by definition, we will make this a canvas request
122124
def with_asset_path_for_canvas
@@ -130,7 +132,7 @@ def with_asset_path_for_canvas
130132
ActionController::Base.asset_host = original_asset_host
131133
end
132134
end
133-
135+
134136
# If this request is_canvas_request
135137
# then use the application name as the url root
136138
def request_for_canvas(is_canvas_request)

‎lib/facebooker/adapters/adapter_base.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def self.facebooker_config
3737
def self.load_adapter(params)
3838

3939
config_key_base = params[:config_key_base] # This allows for loading of a aspecific adapter
40-
config_key_base += "_" unless config_key_base.blank?
40+
config_key_base += "_" if config_key_base && config_key_base.length > 0
4141

4242
unless api_key = (params[:fb_sig_api_key] || facebooker_config["#{config_key_base}api_key"])
4343
raise Facebooker::AdapterBase::UnableToLoadAdapter
@@ -52,7 +52,7 @@ def self.load_adapter(params)
5252

5353
key_base = key.match(/(.*)[_]?api_key/)[1]
5454

55-
adapter_class_name = if key_base.blank?
55+
adapter_class_name = if !key_base || key_base.length == 0
5656
"FacebookAdapter"
5757
else
5858
facebooker_config[key_base + "adapter"]

‎lib/facebooker/adapters/bebo_adapter.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ def api_server_base
1212
def api_rest_path
1313
"/restserver.php"
1414
end
15-
15+
1616
def is_for?(application_context)
1717
application_context == :bebo
1818
end
19-
19+
2020
def www_server_base_url
2121
"www.bebo.com"
2222
end
2323

24-
24+
2525
def login_url_base
2626
"http://#{www_server_base_url}/SignIn.jsp?ApiKey=#{api_key}&v=1.0"
2727
end
@@ -33,7 +33,6 @@ def install_url_base
3333
end
3434

3535
# Things that don't actually work as expected in BEBO
36-
Facebooker::PublishTemplatizedAction
3736
module Facebooker
3837
class User
3938
def set_profile_fbml_with_bebo_adapter(profile_fbml, mobile_fbml, profile_action_fbml, profile_main = nil)
@@ -49,6 +48,9 @@ def set_profile_fbml_with_bebo_adapter(profile_fbml, mobile_fbml, profile_action
4948
private
5049

5150
BEBO_FIELDS = FIELDS - [:meeting_sex, :wall_count, :meeting_for]
51+
52+
remove_method :collect
53+
5254
def collect(fields)
5355
if(Facebooker.is_for?(:bebo) )
5456
BEBO_FIELDS.reject{|field_name| !fields.empty? && !fields.include?(field_name)}.join(',')

‎lib/facebooker/batch_request.rb

+11-10
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,33 @@ class BatchRequest
55
attr_reader :method
66
class UnexecutedRequest < StandardError; end
77
def initialize(params,proc)
8-
@method=params[:method]
9-
@uri=params.map{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join("&")
10-
@proc=proc
8+
@exception = nil
9+
@result = nil
10+
@method = params[:method]
11+
@uri = params.map{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join("&")
12+
@proc = proc
1113
end
12-
14+
1315
def result=(result_object)
1416
@result = @proc.nil? ? result_object : @proc.call(result_object)
1517
end
16-
18+
1719
def exception_raised=(ex)
1820
@exception=ex
1921
end
20-
22+
2123
def exception_raised?
2224
@exception.nil? ? false : raise(@exception)
2325
end
2426

2527
def respond_to?(name)
2628
super || @result.respond_to?(name)
2729
end
28-
30+
2931
def ===(other)
3032
other === @result
3133
end
32-
33-
34+
3435
def method_missing(name,*args,&proc)
3536
if @exception
3637
raise @exception
@@ -41,4 +42,4 @@ def method_missing(name,*args,&proc)
4142
end
4243
end
4344
end
44-
end
45+
end

‎lib/facebooker/logging.rb

+6-13
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,9 @@ def self.logger
99
end
1010

1111
module Logging
12-
13-
def self.skip_api_logging=(val)
14-
@skip_api_logging=val
15-
end
16-
17-
def self.skip_api_logging
18-
@skip_api_logging
19-
end
20-
21-
12+
@skip_api_logging = nil
13+
class << self; attr_accessor :skip_api_logging; end
14+
2215
def self.log_fb_api(method, params)
2316
message = method # might customize later
2417
dump = format_fb_params(params)
@@ -36,16 +29,16 @@ def self.log_fb_api(method, params)
3629
log_info(message, exception)
3730
raise
3831
end
39-
32+
4033
def self.format_fb_params(params)
4134
params.map { |key,value| "#{key} = #{value}" }.join(', ')
4235
end
43-
36+
4437
def self.log_info(message, dump, seconds = 0)
4538
return unless Facebooker.logger
4639
log_message = "#{message} (#{seconds}) #{dump}"
4740
Facebooker.logger.info(log_message)
4841
end
4942

5043
end
51-
end
44+
end

‎lib/facebooker/mobile.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ class Mobile
33
def initialize(session)
44
@session = session
55
end
6-
6+
77
# Used to determine whether the user identified by "uid" has enabled SMS for this application.
88
def can_send(user)
99
@session.post('facebook.sms.canSend', :uid => User.cast_to_facebook_id(user))
1010
end
11-
11+
1212
# Send the given message to the user.
1313
# See http://wiki.developers.facebook.com/index.php/Mobile
1414
def send(user, message)

‎lib/facebooker/model.rb

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Facebooker
22
##
3-
# helper methods primarily supporting the management of Ruby objects which are populatable via Hashes.
3+
# helper methods primarily supporting the management of Ruby objects which are populatable via Hashes.
44
# Since most Facebook API calls accept and return hashes of data (as XML), the Model module allows us to
55
# directly populate a model's attributes given a Hash with matching key names.
66
module Model
@@ -19,15 +19,15 @@ def from_hash(hash)
1919
yield instance if block_given?
2020
instance
2121
end
22-
22+
2323
##
24-
# Create a standard attr_writer and a populating_attr_reader
24+
# Create a standard attr_writer and a populating_attr_reader
2525
def populating_attr_accessor(*symbols)
26-
attr_writer *symbols
27-
populating_attr_reader *symbols
26+
attr_writer(*symbols)
27+
populating_attr_reader(*symbols)
2828
end
2929

30-
##
30+
##
3131
# Create a reader that will attempt to populate the model if it has not already been populated
3232
def populating_attr_reader(*symbols)
3333
symbols.each do |symbol|
@@ -59,27 +59,29 @@ def hash_settable_accessor(symbol, klass)
5959
def hash_settable_writer(symbol, klass)
6060
define_method("#{symbol}=") do |value|
6161
instance_variable_set("@#{symbol}", value.kind_of?(Hash) ? klass.from_hash(value) : value)
62-
end
62+
end
6363
end
6464

6565
#
6666
# Declares an attribute named ::symbol:: which can be set with either a list of instances of ::klass::
67-
# or a list of Hashes which will be used to populate a new instance of ::klass::.
67+
# or a list of Hashes which will be used to populate a new instance of ::klass::.
6868
def hash_settable_list_accessor(symbol, klass)
6969
attr_reader symbol
7070
hash_settable_list_writer(symbol, klass)
7171
end
72-
72+
7373
def hash_settable_list_writer(symbol, klass)
7474
define_method("#{symbol}=") do |list|
7575
instance_variable_set("@#{symbol}", list.map do |item|
7676
item.kind_of?(Hash) ? klass.from_hash(item) : item
7777
end)
7878
end
79-
end
79+
end
8080

8181
def id_is(attribute)
82-
class_eval <<-EOS
82+
(file, line) = caller.first.split(':')
83+
84+
class_eval(<<-EOS, file, line.to_i)
8385
def #{attribute}=(value)
8486
@#{attribute} = value.to_i
8587
end
@@ -90,7 +92,7 @@ def #{attribute}=(value)
9092
EOS
9193
end
9294
end
93-
95+
9496
##
9597
# Centralized, error-checked place for a model to get the session to which it is bound.
9698
# Any Facebook API queries require a Session instance.
@@ -113,7 +115,7 @@ def populate
113115
end
114116

115117
def populated?
116-
!@populated.nil?
118+
@populated
117119
end
118120

119121
##

‎lib/facebooker/models/applicationproperties.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ApplicationProperties
3333
:private_install, :installable, :privacy_url, :help_url, :see_all_url, :tos_url,
3434
:dev_mode, :preload_fql, :icon_url, :canvas_name, :logo_url, :connect_logo_url ]
3535

36-
attr_accessor *FIELDS
36+
attr_accessor(*FIELDS)
3737

3838
end
3939
end

‎lib/facebooker/models/applicationrestrictions.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module Facebooker
33
class ApplicationRestrictions
44
include Model
55
FIELDS = [ :age, :location, :age_distribution, :type ]
6-
7-
attr_accessor *FIELDS
8-
6+
7+
attr_accessor(*FIELDS)
8+
99
end
1010
end

‎lib/facebooker/models/event.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def event
2121
end
2222

2323
include Model
24-
attr_accessor :eid, :pic, :pic_small, :pic_big, :name, :creator, :update_time, :description, :tagline, :venue, :host, :event_type, :nid, :location, :end_time, :start_time, :event_subtype
24+
attr_accessor :pic, :pic_small, :pic_big, :name, :creator, :update_time, :description, :tagline, :venue, :host, :event_type, :nid, :location, :end_time, :start_time, :event_subtype
2525

2626
id_is :eid
2727
end
28-
end
28+
end

‎lib/facebooker/models/friend_list.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module Facebooker
44
# A simple representation of a friend list.
55
class FriendList
66
include Model
7-
attr_accessor :flid, :name
8-
7+
attr_accessor :name
8+
99
id_is :flid
1010

1111
# We need this to be an integer, so do the conversion

‎lib/facebooker/models/group.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ class Membership
88
attr_accessor :position, :gid, :uid
99
end
1010
include Model
11-
attr_accessor :pic, :pic_small, :pic_big, :name, :creator, :recent_news, :gid, :update_time, :group_subtype, :group_type, :website, :office, :description, :venue, :nid
12-
11+
attr_accessor :pic, :pic_small, :pic_big, :name, :creator, :recent_news, :update_time, :group_subtype, :group_type, :website, :office, :description, :venue, :nid
12+
1313
id_is :gid
14-
14+
1515
##
1616
# Get the full list of members as populated User objects. First time fetches group members via Facebook API call.
1717
# Subsequent calls return cached values.
@@ -33,4 +33,4 @@ def memberships
3333
end
3434
end
3535
end
36-
end
36+
end

‎lib/facebooker/models/page.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Page
55
class Genre
66
include Model
77
FIELDS = [ :dance, :party, :relax, :talk, :think, :workout, :sing, :intimate, :raunchy, :headphones ]
8-
attr_accessor *FIELDS
8+
attr_accessor(*FIELDS)
99

1010
def initialize(*args)
1111
super
@@ -18,7 +18,8 @@ def initialize(*args)
1818
end
1919

2020
include Model
21-
attr_accessor :page_id, :name, :pic_small, :pic_big, :pic_square, :pic_large, :type, :type, :website, :location, :hours, :band_members, :bio, :hometown, :genre, :record_label, :influences, :has_added_app, :founded, :company_overview, :mission, :products, :release_date, :starring, :written_by, :directed_by, :produced_by, :studio, :awards, :plot_outline, :network, :season, :schedule
21+
attr_accessor :page_id, :name, :pic_small, :pic_big, :pic_square, :pic_large, :type, :type, :website, :location, :hours, :band_members, :bio, :hometown, :record_label, :influences, :has_added_app, :founded, :company_overview, :mission, :products, :release_date, :starring, :written_by, :directed_by, :produced_by, :studio, :awards, :plot_outline, :network, :season, :schedule
22+
attr_reader :genre
2223

2324
def genre=(value)
2425
@genre = value.kind_of?(Hash) ? Genre.from_hash(value) : value

‎lib/facebooker/models/photo.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
module Facebooker
33
class Photo
44
include Model
5-
attr_accessor :pid, :aid, :owner, :title,
5+
attr_accessor :aid, :owner, :title,
66
:link, :caption, :created,
77
:src, :src_big, :src_small,
88
:story_fbid
99

1010
id_is :pid
1111
end
12-
end
12+
end

‎lib/facebooker/models/user.rb

+13-6
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,30 @@ class Status
1010
include Model
1111
attr_accessor :message, :time, :status_id
1212
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, :uid, :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 = [: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]
1414
STANDARD_FIELDS = [:uid, :first_name, :last_name, :name, :timezone, :birthday, :sex, :affiliations, :locale, :profile_url, :pic_square]
15-
populating_attr_accessor *FIELDS
15+
populating_attr_accessor(*FIELDS)
1616
attr_reader :affiliations
1717
populating_hash_settable_accessor :current_location, Location
1818
populating_hash_settable_accessor :hometown_location, Location
1919
populating_hash_settable_accessor :hs_info, EducationInfo::HighschoolInfo
20-
populating_hash_settable_accessor :status, Status
2120
populating_hash_settable_list_accessor :affiliations, Affiliation
2221
populating_hash_settable_list_accessor :education_history, EducationInfo
2322
populating_hash_settable_list_accessor :work_history, WorkInfo
24-
23+
24+
populating_attr_reader :status
25+
2526
# Can pass in these two forms:
2627
# id, session, (optional) attribute_hash
2728
# attribute_hash
2829
def initialize(*args)
29-
@friends = nil
30+
@friends = nil
31+
@current_location = nil
32+
@pic = nil
33+
@hometown_location = nil
34+
@populated = false
35+
@session = nil
36+
@id = nil
3037
if (args.first.kind_of?(String) || args.first.kind_of?(Integer)) && args.size==1
3138
self.uid = args.shift
3239
@session = Session.current
@@ -36,7 +43,7 @@ def initialize(*args)
3643
end
3744
if args.last.kind_of?(Hash)
3845
populate_from_hash!(args.pop)
39-
end
46+
end
4047
end
4148

4249
id_is :uid

‎lib/facebooker/models/work_info.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module Facebooker
22
class WorkInfo
33
include Model
4-
attr_accessor :end_date, :start_date, :company_name, :description, :position, :location
4+
attr_accessor :end_date, :start_date, :company_name, :description, :position
5+
attr_reader :location
56
def location=(location)
67
@location = location.kind_of?(Hash) ? Location.from_hash(location) : location
78
end
89
end
9-
end
10+
end

‎lib/facebooker/rails/controller.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ def self.included(controller)
1212
controller.helper_method :request_comes_from_facebook?
1313
end
1414

15-
15+
def initialize *args
16+
@facebook_session = nil
17+
@installation_required = nil
18+
super
19+
end
20+
1621
def facebook_session
1722
@facebook_session
1823
end

‎lib/facebooker/rails/facebook_request_fix.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ def request_method_with_facebooker
88
end
99
request_method_without_facebooker
1010
end
11-
11+
1212
if new.methods.include?("request_method")
13-
alias_method_chain :request_method, :facebooker
13+
alias_method_chain :request_method, :facebooker
1414
end
15-
15+
1616
def xml_http_request_with_facebooker?
1717
parameters["fb_sig_is_mockajax"] == "1" ||
1818
parameters["fb_sig_is_ajax"] == "1" ||
1919
xml_http_request_without_facebooker?
2020
end
2121
alias_method_chain :xml_http_request?, :facebooker
2222
# we have to re-alias xhr? since it was pointing to the old method
23-
alias xhr? :xml_http_request?
24-
23+
unless defined? :xhr?
24+
alias xhr? :xml_http_request?
25+
end
26+
2527
end
26-
end
28+
end

‎lib/facebooker/rails/facebook_session_handling.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def initialize(cgi, session_options = {})
2424

2525
class CGI
2626
class Session
27-
private
2827
alias :initialize_aliased_by_facebooker :initialize
2928
attr_reader :request, :initialization_options
3029

@@ -66,4 +65,4 @@ def create_new_id
6665
@session_id || create_new_id_aliased_by_facebooker
6766
end
6867
end
69-
end
68+
end

‎lib/facebooker/rails/facebook_url_rewriting.rb

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
11
module ::ActionController
22
if Rails.version < '2.3'
3-
class AbstractRequest
3+
class AbstractRequest
44
def relative_url_root
55
Facebooker.path_prefix
6-
end
6+
end
77
end
88
else
9-
class Request
9+
class Request
1010
def relative_url_root
1111
Facebooker.path_prefix
12-
end
12+
end
1313
end
1414
end
15-
15+
1616
class Base
17-
def self.relative_url_root
18-
Facebooker.path_prefix
17+
class << self
18+
alias :old_relative_url_root :relative_url_root
19+
def relative_url_root
20+
Facebooker.path_prefix
21+
end
1922
end
20-
end
21-
23+
end
24+
2225
class UrlRewriter
2326
RESERVED_OPTIONS << :canvas
2427
def link_to_new_canvas?
25-
@request.parameters["fb_sig_in_new_facebook"] == "1"
28+
@request.parameters["fb_sig_in_new_facebook"] == "1"
2629
end
2730
def link_to_canvas?(params, options)
2831
option_override = options[:canvas]
2932
return false if option_override == false # important to check for false. nil should use default behavior
3033
option_override || (can_safely_access_request_parameters? && (@request.parameters["fb_sig_in_canvas"] == "1" || @request.parameters[:fb_sig_in_canvas] == "1" ))
3134
end
32-
35+
3336
#rails blindly tries to merge things that may be nil into the parameters. Make sure this won't break
3437
def can_safely_access_request_parameters?
3538
@request.request_parameters

‎lib/facebooker/rails/helpers.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
require 'action_pack'
2+
23
module Facebooker
34
module Rails
4-
5+
56
# Facebook specific helpers for creating FBML
67
#
78
# All helpers that take a user as a parameter will get the Facebook UID from the facebook_id attribute if it exists.
89
# It will use to_s if the facebook_id attribute is not present.
910
#
1011
module Helpers
11-
12+
1213
include Facebooker::Rails::Helpers::FbConnect
13-
14+
1415
# Create an fb:dialog
1516
# id must be a unique name e.g. "my_dialog"
1617
# cancel_button is true or false

‎lib/facebooker/rails/publisher.rb

+36-30
Original file line numberDiff line numberDiff line change
@@ -88,31 +88,32 @@ module Rails
8888
#
8989
# Publisher makes many helpers available, including the linking and asset helpers
9090
class Publisher
91-
91+
9292
#story sizes from the Facebooker API
9393
ONE_LINE=1
9494
SHORT=2
9595
FULL=4
96-
96+
9797
def initialize
98-
@controller = PublisherController.new
98+
@from = nil
99+
@full_story_template = nil
100+
@recipients = nil
101+
@controller = PublisherController.new
99102
end
100-
103+
101104
# use facebook options everywhere
102105
def request_comes_from_facebook?
103106
true
104107
end
105-
108+
106109
class FacebookTemplate < ::ActiveRecord::Base
107-
108-
109110
cattr_accessor :template_cache
110111
self.template_cache = {}
111-
112+
112113
def self.inspect(*args)
113114
"FacebookTemplate"
114115
end
115-
116+
116117
def template_changed?(hash)
117118
if respond_to?(:content_hash)
118119
content_hash != hash
@@ -180,20 +181,21 @@ def hashed_content(klass, method)
180181
(publisher.full_story_template and publisher.full_story_template.to_a.sort_by{|e| e[0].to_s})
181182
].to_json
182183
end
183-
184+
184185
def template_name(klass,method)
185186
"#{klass.name}::#{method}"
186187
end
187188
end
188189
end
189-
190+
190191
class_inheritable_accessor :master_helper_module
191-
attr_accessor :one_line_story_templates, :short_story_templates, :action_links
192-
192+
attr_accessor :one_line_story_templates, :short_story_templates
193+
attr_writer :action_links
194+
193195
cattr_accessor :skip_registry
194196
self.skip_registry = false
195-
196-
197+
198+
197199
class InvalidSender < StandardError; end
198200
class UnknownBodyType < StandardError; end
199201
class UnspecifiedBodyType < StandardError; end
@@ -219,20 +221,21 @@ class Ref
219221
end
220222
class UserAction
221223
attr_accessor :data
222-
attr_accessor :target_ids
224+
attr_reader :target_ids
223225
attr_accessor :body_general
224226
attr_accessor :template_id
225227
attr_accessor :template_name
226228
attr_accessor :story_size
227-
229+
228230
def target_ids=(val)
229231
@target_ids = val.is_a?(Array) ? val.join(",") : val
230232
end
233+
231234
def data_hash
232235
data||{}
233236
end
234237
end
235-
238+
236239
cattr_accessor :ignore_errors
237240
attr_accessor :_body
238241

@@ -288,12 +291,12 @@ def one_line_story_template(str)
288291
@one_line_story_templates ||= []
289292
@one_line_story_templates << str
290293
end
291-
294+
292295
def short_story_template(title,body,params={})
293296
@short_story_templates ||= []
294297
@short_story_templates << params.merge(:template_title=>title, :template_body=>body)
295298
end
296-
299+
297300
def action_links(*links)
298301
if links.blank?
299302
@action_links
@@ -493,38 +496,41 @@ def helper(*args)
493496
args.each do |arg|
494497
case arg
495498
when Symbol,String
496-
add_template_helper("#{arg.to_s.classify}Helper".constantize)
499+
add_template_helper("#{arg.to_s.classify}Helper".constantize)
497500
when Module
498501
add_template_helper(arg)
499502
end
500503
end
501504
end
502-
505+
503506
def add_template_helper(helper_module) #:nodoc:
504507
master_helper_module.send :include,helper_module
505508
include master_helper_module
506509
end
507510

508-
511+
509512
def inherited(child)
510-
super
513+
super
511514
child.master_helper_module=Module.new
512515
child.master_helper_module.__send__(:include,self.master_helper_module)
513516
child.send(:include, child.master_helper_module)
514517
FacebookTemplate.clear_cache!
515518
end
516-
519+
517520
end
518521
class PublisherController
519522
include Facebooker::Rails::Publisher.master_helper_module
520523
include ActionController::UrlWriter
521-
522-
def self.default_url_options(*args)
523-
Facebooker::Rails::Publisher.default_url_options(*args)
524+
525+
class << self
526+
alias :old_default_url_options :default_url_options
527+
def default_url_options(*args)
528+
Facebooker::Rails::Publisher.default_url_options(*args)
529+
end
524530
end
525-
531+
526532
end
527-
533+
528534
end
529535
end
530536
end

‎lib/facebooker/session.rb

+81-75
Large diffs are not rendered by default.

‎test/facebooker/adapters_test.rb

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
22

3-
class Facebooker::SessionTest < Test::Unit::TestCase
3+
class Facebooker::AdaptersTest < Test::Unit::TestCase
44
def setup
55
ENV['FACEBOOK_API_KEY'] = '1234567'
6-
ENV['FACEBOOK_SECRET_KEY'] = '7654321'
7-
Facebooker.current_adapter = nil
8-
@bebo_api_key = "bebo_api_key"; @bebo_secret_key = "bebo_secret_key"
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"
910
end
1011

1112
def teardown
1213
flexmock_close
14+
Facebooker.current_adapter = @current_adapter
1315
end
14-
16+
1517
def test_load_default_adapter
1618
session = Facebooker::CanvasSession.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
1719
assert_equal(ENV['FACEBOOK_API_KEY'], Facebooker::Session.api_key)
1820
assert( Facebooker::FacebookAdapter === Facebooker.current_adapter)
19-
21+
2022
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
2325
Facebooker::AdapterBase.stubs(:facebooker_config).returns({"api_key" => "facebook_key", "secret_key" => "facebook_secret" })
2426
assert( Facebooker::FacebookAdapter === Facebooker.current_adapter)
2527
assert_equal("facebook_key", Facebooker::Session.api_key)
2628
end
27-
29+
2830
def test_load_bebo_adapter
29-
31+
3032
load_bebo_adapter
3133
assert_equal(@bebo_api_key, Facebooker::Session.api_key)
3234
assert_equal(@bebo_secret_key, Facebooker::Session.secret_key)
3335
assert(Facebooker::BeboAdapter === Facebooker.current_adapter, " Bebo adapter not loaded correctly.")
3436
end
35-
37+
3638
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"
3840

3941
Facebooker::AdapterBase.stubs(:facebooker_config).returns({"bebo_api_key" => @bebo_api_key, "bebo_adapter" => "BeboAdapter", "bebo_secret_key" => @bebo_secret_key, "foo" => "bar"})
4042
Facebooker.load_adapter(:config_key_base => "bebo")
4143
@session = Facebooker::CanvasSession.create(@bebo_api_key, @bebo_secret_key)
4244
end
43-
45+
4446
def test_adapter_details
4547
test_load_default_adapter
4648

@@ -50,28 +52,28 @@ def test_adapter_details
5052
assert_equal("http://api.facebook.com", Facebooker.api_server_base_url)
5153
assert(Facebooker.is_for?(:facebook))
5254
load_bebo_adapter
53-
55+
5456
assert_equal("apps.bebo.com", Facebooker.canvas_server_base)
5557
assert_equal("apps.bebo.com", Facebooker.api_server_base)
5658
assert_equal("www.bebo.com", Facebooker.www_server_base_url)
5759
assert_equal("http://apps.bebo.com", Facebooker.api_server_base_url)
5860
assert_equal("http://www.bebo.com/SignIn.jsp?ApiKey=bebo_api_key&v=1.0&canvas=true", @session.login_url)
5961
assert_equal("http://www.bebo.com/c/apps/add?ApiKey=bebo_api_key&v=1.0", @session.install_url)
6062
assert(Facebooker.is_for?(:bebo))
61-
63+
6264
end
63-
65+
6466
def test_adapter_failures
6567
Facebooker::AdapterBase.stubs(:facebooker_config).returns({})
66-
68+
6769
assert_raises(Facebooker::AdapterBase::UnableToLoadAdapter){
6870
Facebooker.load_adapter(:config_key_base => "bebo")
6971
}
7072
end
71-
73+
7274
def test_bebo_specific_issues
7375
load_bebo_adapter
74-
76+
7577
# @session.send(:service).stubs(:post).returns([{:name => "foo"}])
7678
Net::HTTP.stubs(:post_form).returns("<profile_setFBML_response></profile_setFBML_response>")
7779
user = Facebooker::User.new(:uid => "123456")
@@ -87,10 +89,8 @@ def test_bebo_specific_issues
8789
Net::HTTP.stubs(:post_form).returns("<feed_publishTemplatizedAction_response>1</feed_publishTemplatizedAction_response>")
8890
user.publish_templatized_action(action)
8991
end
90-
92+
9193
def test_bebo_process_data
92-
93-
end
94-
9594

95+
end
9696
end

‎test/facebooker/model_test.rb

+10
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,21 @@ class Thing
1212
attr_accessor :name, :job
1313
hash_settable_accessor :complex_thing, ComplexThing
1414
hash_settable_list_accessor :list_of_complex_things, ComplexThing
15+
16+
def initialize *args
17+
@session = nil
18+
super
19+
end
1520
end
1621

1722
class PopulatingThing
1823
include Facebooker::Model
1924
populating_attr_accessor :first_name
25+
26+
def initialize
27+
@first_name = nil
28+
@populated = false
29+
end
2030
end
2131

2232
def test_can_instantiate_an_object_with_a_hash

‎test/facebooker/rails/publisher_test.rb

+97-88
Large diffs are not rendered by default.

‎test/facebooker/rails_integration_test.rb

+42-43
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
require File.expand_path(File.dirname(__FILE__) + '/../rails_test_helper')
22

3-
ActionController::Routing::Routes.draw do |map|
4-
map.connect '', :controller=>"facebook",:conditions=>{:canvas=>true}
5-
map.connect '', :controller=>"plain_old_rails"
6-
map.resources :comments, :controller=>"plain_old_rails"
7-
map.connect 'require_auth/:action', :controller => "controller_which_requires_facebook_authentication"
8-
map.connect 'require_install/:action', :controller => "controller_which_requires_application_installation"
9-
map.connect ':controller/:action/:id', :controller => "plain_old_rails"
10-
end
11-
123
module FBConnectTestHelpers
134
def setup_fb_connect_cookies(params=cookie_hash_for_auth)
14-
params.each {|k,v| @request.cookies[ENV['FACEBOOK_API_KEY']+k] = CGI::Cookie.new(ENV['FACEBOOK_API_KEY']+k,v)}
5+
params.each {|k,v| @request.cookies[ENV['FACEBOOK_API_KEY']+k] = CGI::Cookie.new(ENV['FACEBOOK_API_KEY']+k,v)}
156
end
167

178
def expired_cookie_hash_for_auth
@@ -193,7 +184,7 @@ def setup
193184

194185
def test_url_for_links_to_callback_if_canvas_is_false_and_in_canvas
195186
get :link_test
196-
assert_match /test.host/,@response.body
187+
assert_match(/test.host/, @response.body)
197188
end
198189

199190
def test_named_route_doesnt_include_canvas_path_when_not_in_canvas
@@ -444,33 +435,33 @@ def test_redirect_to_renders_javascript_redirect_if_request_is_for_a_facebook_if
444435
assert_match "http-equiv", @response.body
445436
assert_match "http://www.facebook.com/login.php?api_key=1234567&v=1.0".to_json, @response.body
446437
assert_match "http://www.facebook.com/login.php?api_key=1234567&amp;v=1.0", @response.body
447-
end
448-
438+
end
439+
449440
def test_url_for_links_to_canvas_if_canvas_is_true_and_not_in_canvas
450441
get :link_test, facebook_params(:fb_sig_in_canvas=>0,:canvas=>true)
451-
assert_match /apps.facebook.com/,@response.body
442+
assert_match(/apps.facebook.com/, @response.body)
452443
end
453-
444+
454445
def test_includes_relative_url_root_when_linked_to_canvas
455446
get :link_test,facebook_params(:fb_sig_in_canvas=>0,:canvas=>true)
456-
assert_match /root/,@response.body
447+
assert_match(/root/,@response.body)
457448
end
458449

459450
def test_url_for_links_to_callback_if_canvas_is_false_and_in_canvas
460451
get :link_test,facebook_params(:fb_sig_in_canvas=>0,:canvas=>false)
461-
assert_match /test.host/,@response.body
452+
assert_match(/test.host/,@response.body)
462453
end
463454

464455
def test_url_for_doesnt_include_url_root_when_not_linked_to_canvas
465456
get :link_test,facebook_params(:fb_sig_in_canvas=>0,:canvas=>false)
466457
assert !@response.body.match(/root/)
467458
end
468-
459+
469460
def test_url_for_links_to_canvas_if_canvas_is_not_set
470461
get :link_test,facebook_params
471-
assert_match /apps.facebook.com/,@response.body
462+
assert_match(/apps.facebook.com/,@response.body)
472463
end
473-
464+
474465
def test_image_tag
475466
get :image_test, facebook_params
476467
assert_equal "<img alt=\"Image\" src=\"http://root.example.com/images/image.png\" />",@response.body
@@ -660,35 +651,35 @@ def test_fb_add_info_section
660651
assert_equal "<fb:add-section-button section=\"info\" />",@h.fb_add_info_section
661652
end
662653

663-
def test_fb_name_with_invalid_key
654+
def test_fb_name_with_invalid_key_sizee
664655
assert_raises(ArgumentError) {@h.fb_name(1234, :sizee => false)}
665656
end
666657

667658
def test_fb_name
668659
assert_equal "<fb:name uid=\"1234\"></fb:name>",@h.fb_name("1234")
669660
end
670-
661+
671662
def test_fb_name_with_transformed_key
672663
assert_equal "<fb:name uid=\"1234\" useyou=\"true\"></fb:name>", @h.fb_name(1234, :use_you => true)
673664
end
674-
665+
675666
def test_fb_name_with_user_responding_to_facebook_id
676667
user = flexmock("user", :facebook_id => "5678")
677668
assert_equal "<fb:name uid=\"5678\"></fb:name>", @h.fb_name(user)
678669
end
679-
680-
def test_fb_name_with_invalid_key
670+
671+
def test_fb_name_with_invalid_key_linkd
681672
assert_raises(ArgumentError) {@h.fb_name(1234, :linkd => false)}
682673
end
683-
674+
684675
def test_fb_tabs
685676
assert_equal "<fb:tabs></fb:tabs>", @h.fb_tabs{}
686677
end
687-
678+
688679
def test_fb_tab_item
689680
assert_equal "<fb:tab-item href=\"http://www.google.com\" title=\"Google\" />", @h.fb_tab_item("Google", "http://www.google.com")
690681
end
691-
682+
692683
def test_fb_tab_item_raises_exception_for_invalid_option
693684
assert_raises(ArgumentError) {@h.fb_tab_item("Google", "http://www.google.com", :alignn => :right)}
694685
end
@@ -708,10 +699,6 @@ def test_fb_multi_friend_selector_with_options
708699
assert_equal "<fb:multi-friend-selector actiontext=\"This is a message\" exclude_ids=\"1,2\" max=\"20\" showborder=\"false\" />", @h.fb_multi_friend_selector("This is a message",:exclude_ids=>"1,2")
709700
end
710701

711-
def test_fb_comments
712-
assert_equal "<fb:comments candelete=\"false\" canpost=\"true\" numposts=\"7\" showform=\"true\" xid=\"a:1\" />", @h.fb_comments("a:1",true,false,7,:showform=>true)
713-
end
714-
715702
def test_fb_title
716703
assert_equal "<fb:title>This is the canvas page window title</fb:title>", @h.fb_title("This is the canvas page window title")
717704
end
@@ -919,9 +906,15 @@ def test_fb_help
919906
def test_fb_create_button
920907
assert_equal "<fb:create-button href=\"/growingpets/invite\">Invite Friends</fb:create-button>", @h.fb_create_button('Invite Friends', '/growingpets/invite')
921908
end
922-
def test_fb_comments
923-
assert_equal "<fb:comments candelete=\"false\" canpost=\"true\" numposts=\"4\" optional=\"false\" xid=\"xxx\"></fb:comments>", @h.fb_comments("xxx",true,false,4,:optional=>false)
909+
910+
def test_fb_comments_a_1
911+
assert_equal "<fb:comments candelete=\"false\" canpost=\"true\" numposts=\"7\" showform=\"true\" xid=\"a:1\"></fb:comments>", @h.fb_comments("a:1",true,false,7,:showform=>true)
924912
end
913+
914+
def test_fb_comments_xxx
915+
assert_equal "<fb:comments candelete=\"false\" canpost=\"true\" numposts=\"4\" optional=\"false\" xid=\"xxx\"></fb:comments>", @h.fb_comments("xxx",true,false,4,:optional=>false)
916+
end
917+
925918
def test_fb_comments_with_title
926919
assert_equal "<fb:comments candelete=\"false\" canpost=\"true\" numposts=\"4\" optional=\"false\" xid=\"xxx\"><fb:title>TITLE</fb:title></fb:comments>", @h.fb_comments("xxx",true,false,4,:optional=>false, :title => "TITLE")
927920
end
@@ -1003,13 +996,15 @@ def test_fb_user_action
1003996
action = Facebooker::Rails::Publisher::UserAction.new
1004997
assert_equal @h.fb_user_action(action,"message","prompt"),"FB.Connect.showFeedDialog(null, null, null, null, null, FB.RequireConnect.promptConnect, null, \"prompt\", \"message\");"
1005998
end
1006-
1007-
999+
1000+
10081001
def test_fb_connect_javascript_tag
1009-
assert_equal "<script src=\"http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php\" type=\"text/javascript\"></script>",
1010-
@h.fb_connect_javascript_tag
1002+
silence_warnings do
1003+
assert_equal "<script src=\"http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php\" type=\"text/javascript\"></script>",
1004+
@h.fb_connect_javascript_tag
1005+
end
10111006
end
1012-
1007+
10131008
def test_fb_container
10141009
@h.expects(:capture).returns("Inner Stuff")
10151010
@h.fb_container(:condition=>"somejs") do
@@ -1157,19 +1152,23 @@ def test_pretty_errors_disabled_success
11571152
post :pass, facebook_params
11581153
assert_response 200
11591154
end
1160-
1155+
11611156
def test_pretty_errors_disabled_error
11621157
Facebooker.apply_configuration('api_key'=>"1234", 'secret_key'=>"34278",'canvas_page_name'=>'mike','pretty_errors'=>false)
1163-
post :fail, facebook_params
1158+
silence_warnings do
1159+
post :fail, facebook_params
1160+
end
11641161
assert_response :error
11651162
end
1166-
1163+
11671164
def test_pretty_errors_enabled_success
11681165
post :pass, facebook_params
11691166
assert_response 200
11701167
end
11711168
def test_pretty_errors_enabled_error
1172-
post :fail, facebook_params
1169+
silence_warnings do
1170+
post :fail, facebook_params
1171+
end
11731172
assert_response 200
11741173
end
11751174
end

‎test/facebooker/session_test.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ def setup
1414

1515
def teardown
1616
Facebooker::Session.configuration_file_path = nil
17-
super
17+
super
1818
end
19-
19+
2020
def test_install_url_escapes_optional_next_parameter
2121
session = Facebooker::CanvasSession.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
2222
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"))
2323
end
24-
24+
2525
def test_can_get_api_and_secret_key_from_environment
2626
assert_equal('1234567', Facebooker::Session.api_key)
27-
assert_equal('7654321', Facebooker::Session.secret_key)
27+
assert_equal('7654321', Facebooker::Session.secret_key)
2828
end
29-
29+
3030
def test_if_keys_are_not_available_via_environment_then_they_are_gotten_from_a_file
3131
ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'] = nil
3232
flexmock(File).should_receive(:read).with(File.expand_path("~/.facebookerrc")).once.and_return('{:api => "foo"}')

‎test/rack/facebook_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.dirname(__FILE__) + '/../test_helper.rb'
1+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
22
require 'rack/facebook'
33
require 'rack/lint'
44
require 'rack/mock'

‎test/rails_test_helper.rb

+14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
require File.expand_path(File.dirname(__FILE__) + '/test_helper')
22

3+
tmp = $-w
4+
$-w = nil
35
require 'action_controller'
46
require 'action_controller/test_process'
57
require 'active_record'
8+
$-w = tmp
69
gem 'rails'
710
require 'initializer'
811
require File.dirname(__FILE__)+'/../init'
@@ -11,3 +14,14 @@
1114
require 'facebooker/rails/helpers'
1215
require 'facebooker/rails/publisher'
1316
require 'facebooker/rails/facebook_form_builder'
17+
18+
ActionController::Routing::Routes.draw do |map|
19+
map.connect '', :controller=>"facebook",:conditions=>{:canvas=>true}
20+
map.connect '', :controller=>"plain_old_rails"
21+
map.resources :comments, :controller=>"plain_old_rails"
22+
map.connect 'require_auth/:action', :controller => "controller_which_requires_facebook_authentication"
23+
map.connect 'require_install/:action', :controller => "controller_which_requires_application_installation"
24+
silence_warnings do
25+
map.connect ':controller/:action/:id', :controller => "plain_old_rails"
26+
end
27+
end

‎test/test_helper.rb

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'test/unit'
22
require 'rubygems'
3+
34
begin
45
require 'multi_rails_init'
56
rescue LoadError
@@ -24,16 +25,16 @@
2425

2526
class Test::Unit::TestCase
2627
include Facebooker::Rails::TestHelpers
27-
28+
2829
private
29-
30+
3031
def expect_http_posts_with_responses(*responses_xml)
3132
mock_http = establish_session
3233
responses_xml.each do |xml_string|
3334
mock_http.should_receive(:post_form).and_return(xml_string).once.ordered(:posts)
34-
end
35+
end
3536
end
36-
37+
3738
def establish_session(session = @session)
3839
mock = flexmock(Net::HTTP).should_receive(:post_form).and_return(example_auth_token_xml).once.ordered(:posts)
3940
mock.should_receive(:post_form).and_return(example_get_session_xml).once.ordered(:posts)

0 commit comments

Comments
 (0)
Please sign in to comment.