djanowski-facebooker 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/facebooker/models/user.rb +8 -3
- data/lib/facebooker/rails/publisher.rb +5 -0
- data/test/publisher_test.rb +1 -1
- data/test/user_test.rb +10 -4
- metadata +1 -1
@@ -42,13 +42,18 @@ module Facebooker
|
|
42
42
|
# Returns a user's events, params correspond to API call parameters (except UID):
|
43
43
|
# http://wiki.developers.facebook.com/index.php/Events.get
|
44
44
|
# E.g:
|
45
|
-
# @user.events(:start_time => Time.now
|
45
|
+
# @user.events(:start_time => Time.now, :end_time => 1.month.from_now)
|
46
46
|
# # => Returns events betwen now and a month from now
|
47
47
|
def events(params={})
|
48
|
-
@events ||=
|
48
|
+
@events ||= {}
|
49
|
+
[:start_time,:end_time].compact.each do |key|
|
50
|
+
params[key] = params[key].to_i
|
51
|
+
end
|
52
|
+
# puts @events[params.to_s].nil?
|
53
|
+
@events[params.to_s] ||= @session.post('facebook.events.get', {:uid => self.id}.merge(params)).map do |event|
|
49
54
|
Event.from_hash(event)
|
50
55
|
end
|
51
|
-
end
|
56
|
+
end
|
52
57
|
|
53
58
|
#
|
54
59
|
# Set the list of friends, given an array of User objects. If the list has been retrieved previously, will not set
|
@@ -404,6 +404,11 @@ module Facebooker
|
|
404
404
|
def protect_against_forgery?
|
405
405
|
@paf ||= ActionController::Base.new.send(:protect_against_forgery?)
|
406
406
|
end
|
407
|
+
|
408
|
+
# url_for calls in publishers tend to want full paths
|
409
|
+
def url_for(options = {})
|
410
|
+
super(options.kind_of?(Hash) ? {:only_path => false}.update(options) : options)
|
411
|
+
end
|
407
412
|
end
|
408
413
|
ActionController::Routing::Routes.named_routes.install(self.master_helper_module)
|
409
414
|
include self.master_helper_module
|
data/test/publisher_test.rb
CHANGED
@@ -391,7 +391,7 @@ class PublisherTest < Test::Unit::TestCase
|
|
391
391
|
assert_equal({:src => '/images/image.png', :href => 'raw_string' },
|
392
392
|
TestPublisher.new.image('image.png', 'raw_string'))
|
393
393
|
assert_equal({:src => '/images/image.png', :href => 'http://apps.facebook.com/mike/pokes/do/1' },
|
394
|
-
TestPublisher.new.image('image.png', {:
|
394
|
+
TestPublisher.new.image('image.png', {:controller => :pokes, :action => :do, :id => 1}))
|
395
395
|
end
|
396
396
|
|
397
397
|
def test_action_link
|
data/test/user_test.rb
CHANGED
@@ -129,12 +129,18 @@ class UserTest < Test::Unit::TestCase
|
|
129
129
|
events = @user.events
|
130
130
|
assert_equal "29511517904", events.first.eid
|
131
131
|
end
|
132
|
-
|
133
|
-
def
|
134
|
-
@user.
|
135
|
-
@
|
132
|
+
|
133
|
+
def test_events_caching_honors_params
|
134
|
+
@user = Facebooker::User.new(9507801, @session)
|
135
|
+
@session.expects(:post).returns([{:eid=>1}])
|
136
|
+
assert_equal 1,@user.events.first.eid
|
137
|
+
@session.expects(:post).returns([{:eid=>2}])
|
138
|
+
assert_equal 2,@user.events(:start_time=>1.day.ago).first.eid
|
139
|
+
@session.expects(:post).never
|
140
|
+
assert_equal 1,@user.events.first.eid
|
136
141
|
end
|
137
142
|
|
143
|
+
|
138
144
|
def test_to_s
|
139
145
|
assert_equal("1234",@user.to_s)
|
140
146
|
end
|