fb_rails 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,15 @@ module FbRails
4
4
 
5
5
  class << self
6
6
  def user_class
7
- (user_class_name || 'User').constantize
7
+ @user_class ||= begin
8
+ klass = (user_class_name || 'User').constantize
9
+
10
+ klass.class_eval do
11
+ attr_accessor :access_token
12
+ end unless klass.method_defined?(:access_token)
13
+
14
+ klass
15
+ end
8
16
  end
9
17
  end
10
18
  end
@@ -32,7 +32,9 @@ module FbRails
32
32
 
33
33
  def user
34
34
  if connected?
35
- FbRails::Config.user_class.find_or_initialize_by_fb_uid(uid)
35
+ record = FbRails::Config.user_class.find_or_initialize_by_fb_uid(uid)
36
+ record.access_token = access_token
37
+ record
36
38
  end
37
39
  end
38
40
  memoize :user
data/test/config_test.rb CHANGED
@@ -3,5 +3,6 @@ require 'test_helper'
3
3
  class FbRails::ConfigTest < ActiveSupport::TestCase
4
4
  test 'user_class' do
5
5
  assert_equal User, FbRails::Config.user_class
6
+ assert User.new.respond_to?(:access_token)
6
7
  end
7
8
  end
data/test/connect_test.rb CHANGED
@@ -19,12 +19,20 @@ class FbRails::ConnectTest < ActiveSupport::TestCase
19
19
  end
20
20
 
21
21
  test 'valid cookie' do
22
- fb_connect = FbRails::Connect.new(fb_cookie)
22
+ fb_connect = FbRails::Connect.new(fb_cookie(7, 'abc'))
23
23
 
24
24
  assert fb_connect.connected?
25
- assert_equal 42, fb_connect.uid
26
- assert_equal 'abc', fb_connect.access_token.to_s
25
+ assert_equal 7, fb_connect.uid
26
+ assert_equal 'abc', fb_connect.access_token
27
27
  assert_not_nil fb_connect.user
28
- assert_equal 42, fb_connect.user.fb_uid
28
+ assert_equal 7, fb_connect.uid
29
+ end
30
+
31
+ test 'user' do
32
+ fb_connect = FbRails::Connect.new(fb_cookie(7, 'abc'))
33
+
34
+ user = fb_connect.user
35
+ assert_equal 7, fb_connect.user.fb_uid
36
+ assert_equal 'abc', fb_connect.user.access_token
29
37
  end
30
38
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: fb_rails
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.8.0
5
+ version: 0.9.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matthew Higgins
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-09 00:00:00 -08:00
13
+ date: 2011-02-10 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency