authlogic_facebook_shim 0.3.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +113 -0
- data/README.rdoc +8 -1
- data/Rakefile +39 -20
- data/authlogic_facebook_shim.gemspec +22 -19
- data/lib/authlogic_facebook_shim/adapters/koala_adapter.rb +12 -9
- data/lib/authlogic_facebook_shim/railtie.rb +19 -0
- data/lib/authlogic_facebook_shim/session/adapter.rb +23 -0
- data/lib/authlogic_facebook_shim/session/config.rb +1 -1
- data/lib/authlogic_facebook_shim/session/facebook.rb +3 -4
- data/lib/authlogic_facebook_shim/session.rb +4 -0
- data/lib/authlogic_facebook_shim/version.rb +3 -0
- data/lib/authlogic_facebook_shim.rb +6 -9
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/{rails_root → dummy}/app/models/user.rb +1 -0
- data/test/{rails_root → dummy}/app/models/user_session.rb +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +49 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +6 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +27 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/{rails_root → dummy}/config/facebook.yml +0 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/config.ru +4 -0
- data/test/{rails_root → dummy}/db/migrate/20101217000008_create_users.rb +0 -0
- data/test/{rails_root → dummy}/db/seeds.rb +0 -0
- data/test/dummy/log/test.log +1386 -0
- data/test/test_helper.rb +20 -20
- data/test/units/adapters/koala_adapter_test.rb +202 -146
- data/test/units/session/config_test.rb +110 -108
- data/test/units/session/facebook_test.rb +175 -156
- metadata +123 -155
- data/VERSION +0 -1
- data/test/rails_root/app/controllers/application_controller.rb +0 -10
- data/test/rails_root/app/helpers/application_helper.rb +0 -3
- data/test/rails_root/config/boot.rb +0 -110
- data/test/rails_root/config/database.yml +0 -10
- data/test/rails_root/config/environment.rb +0 -31
- data/test/rails_root/config/environments/development.rb +0 -0
- data/test/rails_root/config/environments/test.rb +0 -0
- data/test/rails_root/config/initializers/authlogic_facebook_koala.rb +0 -5
- data/test/rails_root/config/initializers/new_rails_defaults.rb +0 -21
- data/test/rails_root/config/initializers/session_store.rb +0 -15
- data/test/rails_root/config/locales/en.yml +0 -5
- data/test/rails_root/config/routes.rb +0 -43
- data/test/rails_root/log/test.log +0 -1137
- data/test/rails_root/script/console +0 -3
- data/test/rails_root/script/dbconsole +0 -3
- data/test/rails_root/script/generate +0 -3
@@ -1,145 +1,147 @@
|
|
1
1
|
require File.expand_path( '../../test_helper.rb', File.dirname(__FILE__) )
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
context "Session::Config" do
|
3
|
+
describe AuthlogicFacebookShim::Session::Config do
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
before do
|
6
|
+
@session_class = Class.new(Authlogic::Session::Base)
|
7
|
+
end
|
10
8
|
|
11
|
-
|
9
|
+
describe "facebook_config_file" do
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
11
|
+
it "should have a default 'facebook.yml'" do
|
12
|
+
@session_class.facebook_config_file.must_equal 'facebook.yml'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have a setter method" do
|
16
|
+
fb_config = 'fbconf.yml'
|
17
|
+
@session_class.facebook_config_file = fb_config
|
18
|
+
@session_class.facebook_config_file.must_equal fb_config
|
23
19
|
end
|
24
20
|
|
25
|
-
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "facebook_app_id" do
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
flexmock(@session_class).should_receive('default_config.app_id').and_return(default_from_config).once
|
30
|
-
assert_equal default_from_config, @session_class.facebook_app_id
|
31
|
-
end
|
25
|
+
it "should default to default_config.app_id" do
|
26
|
+
default_from_config = 'defaultappid'
|
32
27
|
|
33
|
-
|
34
|
-
fb_app_id = '234234234'
|
35
|
-
@session_class.facebook_app_id = fb_app_id
|
36
|
-
assert_equal fb_app_id, @session_class.facebook_app_id
|
37
|
-
end
|
28
|
+
expect @session_class.default_config, 'app_id', :with => [], :return => default_from_config
|
38
29
|
|
30
|
+
@session_class.facebook_app_id.must_equal default_from_config
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have a setter method" do
|
34
|
+
fb_app_id = '234234234'
|
35
|
+
@session_class.facebook_app_id = fb_app_id
|
36
|
+
@session_class.facebook_app_id.must_equal fb_app_id
|
39
37
|
end
|
38
|
+
|
39
|
+
end
|
40
40
|
|
41
|
-
|
41
|
+
describe "facebook_secret_key" do
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
flexmock(@session_class).should_receive('default_config.secret_key').and_return(default_from_config).once
|
46
|
-
assert_equal default_from_config, @session_class.facebook_secret_key
|
47
|
-
end
|
43
|
+
it "should default to default_config.secret_key" do
|
44
|
+
default_from_config = 'defaultsecretkey'
|
48
45
|
|
49
|
-
|
50
|
-
fb_secret = '553246736447566b583138525a716e693950736'
|
51
|
-
@session_class.facebook_secret_key = fb_secret
|
52
|
-
assert_equal fb_secret, @session_class.facebook_secret_key
|
53
|
-
end
|
46
|
+
expect @session_class.default_config, 'secret_key', :with => [], :return => default_from_config
|
54
47
|
|
48
|
+
@session_class.facebook_secret_key.must_equal default_from_config
|
55
49
|
end
|
56
50
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
flexmock(@session_class).should_receive('default_config.api_key').and_return(default_from_config).once
|
62
|
-
assert_equal default_from_config, @session_class.facebook_api_key
|
63
|
-
end
|
64
|
-
|
65
|
-
should "have a setter method" do
|
66
|
-
fb_api_key = '25a366a46366451636933676978776a45585734'
|
67
|
-
@session_class.facebook_api_key = fb_api_key
|
68
|
-
assert_equal fb_api_key, @session_class.facebook_api_key
|
69
|
-
end
|
70
|
-
|
51
|
+
it "should have a setter method" do
|
52
|
+
fb_secret = '553246736447566b583138525a716e693950736'
|
53
|
+
@session_class.facebook_secret_key = fb_secret
|
54
|
+
@session_class.facebook_secret_key.must_equal fb_secret
|
71
55
|
end
|
72
56
|
|
73
|
-
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "facebook_api_key" do
|
74
60
|
|
75
|
-
|
76
|
-
|
77
|
-
end
|
61
|
+
it "should default to default_config.api_key" do
|
62
|
+
default_from_config = 'defaultapikey'
|
78
63
|
|
79
|
-
|
80
|
-
fb_uid_field = 'fb_uid'
|
81
|
-
@session_class.facebook_uid_field = fb_uid_field
|
82
|
-
assert_equal fb_uid_field, @session_class.facebook_uid_field
|
83
|
-
end
|
64
|
+
expect @session_class.default_config, 'api_key', :with => [], :return => default_from_config
|
84
65
|
|
66
|
+
@session_class.facebook_api_key.must_equal default_from_config
|
85
67
|
end
|
86
68
|
|
87
|
-
|
69
|
+
it "should have a setter method" do
|
70
|
+
fb_api_key = '25a366a46366451636933676978776a45585734'
|
71
|
+
@session_class.facebook_api_key = fb_api_key
|
72
|
+
@session_class.facebook_api_key.must_equal fb_api_key
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "facebook_uid_field" do
|
88
78
|
|
89
|
-
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
should "have a setter method" do
|
94
|
-
fb_finder = 'find_by_fb_uid'
|
95
|
-
@session_class.facebook_finder = fb_finder
|
96
|
-
assert_equal fb_finder, @session_class.facebook_finder
|
97
|
-
end
|
98
|
-
|
79
|
+
it "should have a default of :facebook_uid" do
|
80
|
+
@session_class.facebook_uid_field.must_equal :facebook_uid
|
99
81
|
end
|
100
82
|
|
101
|
-
|
83
|
+
it "should have a setter method" do
|
84
|
+
fb_uid_field = 'fb_uid'
|
85
|
+
@session_class.facebook_uid_field = fb_uid_field
|
86
|
+
@session_class.facebook_uid_field.must_equal fb_uid_field
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "facebook_finder" do
|
102
92
|
|
103
|
-
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
should "have a setter method" do
|
108
|
-
fb_auto_reg = true
|
109
|
-
@session_class.facebook_auto_register = fb_auto_reg
|
110
|
-
assert_equal fb_auto_reg, @session_class.facebook_auto_register
|
111
|
-
end
|
112
|
-
|
93
|
+
it 'should default to false' do
|
94
|
+
@session_class.facebook_finder.must_equal false
|
113
95
|
end
|
96
|
+
|
97
|
+
it "should have a setter method" do
|
98
|
+
fb_finder = 'find_by_fb_uid'
|
99
|
+
@session_class.facebook_finder = fb_finder
|
100
|
+
@session_class.facebook_finder.must_equal fb_finder
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "facebook_auto_register" do
|
114
106
|
|
115
|
-
|
107
|
+
it 'should have a default false' do
|
108
|
+
@session_class.facebook_auto_register.must_equal false
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should have a setter method" do
|
112
|
+
fb_auto_reg = true
|
113
|
+
@session_class.facebook_auto_register = fb_auto_reg
|
114
|
+
@session_class.facebook_auto_register.must_equal fb_auto_reg
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
116
118
|
|
117
|
-
|
118
|
-
assert @session_class.respond_to?(:default_config)
|
119
|
-
end
|
120
|
-
|
121
|
-
should "return an OpenStruct" do
|
122
|
-
assert @session_class.default_config.is_a?(OpenStruct)
|
123
|
-
end
|
124
|
-
|
125
|
-
should "return the app_id from the default config file" do
|
126
|
-
assert_equal 'appidfromfile', @session_class.default_config.app_id
|
127
|
-
end
|
128
|
-
|
129
|
-
should "return the api_key from the default config file" do
|
130
|
-
assert_equal 'apikeyfromfile', @session_class.default_config.api_key
|
131
|
-
end
|
132
|
-
|
133
|
-
should "return the secret_key from the default config file" do
|
134
|
-
assert_equal 'secretkeyfromfile', @session_class.default_config.secret_key
|
135
|
-
end
|
119
|
+
describe "default_config" do
|
136
120
|
|
137
|
-
|
138
|
-
|
139
|
-
assert_equal OpenStruct.new({}), @session_class.default_config
|
140
|
-
end
|
121
|
+
it "should be a class method" do
|
122
|
+
@session_class.must_respond_to :default_config
|
141
123
|
end
|
142
124
|
|
125
|
+
it "should return an OpenStruct" do
|
126
|
+
@session_class.default_config.must_be_instance_of OpenStruct
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should return the app_id from the default config file" do
|
130
|
+
@session_class.default_config.app_id.must_equal 'appidfromfile'
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should return the api_key from the default config file" do
|
134
|
+
@session_class.default_config.api_key.must_equal 'apikeyfromfile'
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should return the secret_key from the default config file" do
|
138
|
+
@session_class.default_config.secret_key.must_equal 'secretkeyfromfile'
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should return an empty OpenStruct if the file isn't found" do
|
142
|
+
expect @session_class, :facebook_config_file, :with => [], :return => 'notthere.yml'
|
143
|
+
@session_class.default_config.must_equal OpenStruct.new({})
|
144
|
+
end
|
143
145
|
end
|
144
146
|
|
145
147
|
end
|
@@ -1,218 +1,237 @@
|
|
1
1
|
require File.expand_path( '../../test_helper.rb', File.dirname(__FILE__) )
|
2
|
+
require 'koala'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
describe AuthlogicFacebookShim::Session::Facebook do
|
5
|
+
|
6
|
+
before do
|
7
|
+
activate_authlogic
|
8
|
+
end
|
6
9
|
|
7
|
-
|
10
|
+
describe "setup - for my own sanity" do
|
8
11
|
|
9
|
-
|
10
|
-
@
|
11
|
-
@
|
12
|
+
before do
|
13
|
+
@session = UserSession.new
|
14
|
+
override @session, :controller => controller
|
15
|
+
end
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
@session = flexmock(UserSession.new)
|
16
|
-
@session.should_receive(:controller).and_return(controller).by_default
|
17
|
+
it "should set the controller" do
|
18
|
+
@session.controller.must_equal controller
|
17
19
|
end
|
18
|
-
|
19
|
-
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "config accessors" do
|
24
|
+
|
25
|
+
before do
|
26
|
+
@session = UserSession.new
|
27
|
+
override @session, :controller => controller
|
28
|
+
end
|
29
|
+
|
30
|
+
after do
|
31
|
+
Object.instance_eval do
|
32
|
+
remove_const :User
|
33
|
+
remove_const :UserSession
|
34
|
+
GC.start
|
20
35
|
|
21
|
-
|
22
|
-
|
36
|
+
load(File.join(Rails.root, 'app', 'models', 'user.rb'))
|
37
|
+
load(File.join(Rails.root, 'app', 'models', 'user_session.rb'))
|
23
38
|
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return facebook_app_id" do
|
42
|
+
mockappid = 'mockappid'
|
43
|
+
override UserSession, :facebook_app_id => mockappid
|
44
|
+
@session.send(:facebook_app_id).must_equal mockappid
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should return facebook_api_key" do
|
48
|
+
mockapikey = 'mockapikey'
|
49
|
+
override UserSession, :facebook_api_key => mockapikey
|
24
50
|
|
25
|
-
|
26
|
-
assert_equal @mock_cookies, @session.controller.cookies
|
27
|
-
end
|
28
|
-
|
51
|
+
@session.send(:facebook_api_key).must_equal mockapikey
|
29
52
|
end
|
30
|
-
|
31
|
-
context "config accessors" do
|
32
53
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
54
|
+
it "should return facebook_secret_key" do
|
55
|
+
mocksecret = 'mocksecret'
|
56
|
+
override UserSession, :facebook_secret_key => mocksecret
|
57
|
+
|
58
|
+
@session.send(:facebook_secret_key).must_equal mocksecret
|
59
|
+
end
|
38
60
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
61
|
+
it "should return facebook_uid_field" do
|
62
|
+
mockuidfield = 'mock_uidfield'
|
63
|
+
override UserSession, :facebook_uid_field => mockuidfield
|
64
|
+
|
65
|
+
@session.send(:facebook_uid_field).must_equal mockuidfield
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "facebook_finder" do
|
44
69
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
70
|
+
it "should delegate to the class" do
|
71
|
+
mockfinder = 'mockfinder'
|
72
|
+
override UserSession, :facebook_finder => mockfinder
|
73
|
+
|
74
|
+
@session.send(:facebook_finder).must_equal mockfinder
|
49
75
|
end
|
50
76
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
77
|
+
it "should default if the class returns nil" do
|
78
|
+
override UserSession, :facebook_finder => false
|
79
|
+
override @session, :facebook_uid_field => 'mock_uidfield'
|
80
|
+
|
81
|
+
@session.send(:facebook_finder).must_equal "find_by_mock_uidfield"
|
55
82
|
end
|
56
|
-
|
57
|
-
context "facebook_finder" do
|
58
83
|
|
59
|
-
|
60
|
-
mockfinder = 'mockfinder'
|
61
|
-
flexmock(UserSession).should_receive(:facebook_finder).and_return(mockfinder).once
|
62
|
-
assert_equal mockfinder, @session.send(:facebook_finder)
|
63
|
-
end
|
84
|
+
end
|
64
85
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
86
|
+
it "should return facebook_auto_register?" do
|
87
|
+
override UserSession, :facebook_auto_register => true
|
88
|
+
|
89
|
+
@session.send(:facebook_auto_register?).must_equal true
|
90
|
+
end
|
70
91
|
|
71
|
-
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "validating with facebook" do
|
95
|
+
|
96
|
+
before do
|
97
|
+
@session = UserSession.new
|
98
|
+
override @session, :controller => controller
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "with a valid facebook session" do
|
102
|
+
|
103
|
+
before do
|
104
|
+
@facebook_session = OpenStruct.new(:uid => 'mockuid')
|
72
105
|
|
73
|
-
|
74
|
-
|
75
|
-
assert @session.send(:facebook_auto_register?)
|
106
|
+
override @session, :facebook_session? => true
|
107
|
+
override @session, :facebook_session => @facebook_session
|
76
108
|
end
|
77
109
|
|
78
|
-
|
79
|
-
|
80
|
-
context "validating with facebook" do
|
110
|
+
describe "with an existing facebook uid" do
|
81
111
|
|
82
|
-
|
112
|
+
before do
|
113
|
+
override @session, :facebook_finder => 'finder_method'
|
114
|
+
|
115
|
+
@user = User.create
|
116
|
+
override User, :finder_method => @user
|
83
117
|
|
84
|
-
|
85
|
-
|
86
|
-
|
118
|
+
@session.save
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should return true for logged_in_with_facebook?" do
|
122
|
+
@session.logged_in_with_facebook?.must_equal true
|
87
123
|
end
|
124
|
+
|
125
|
+
it "should set attempted_record" do
|
126
|
+
@session.attempted_record.must_equal @user
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
88
130
|
|
89
|
-
|
131
|
+
describe "without an existing facebook uid" do
|
90
132
|
|
91
|
-
|
92
|
-
|
133
|
+
before do
|
134
|
+
override @session, :facebook_finder => 'finder_method'
|
135
|
+
override User, :finder_method => nil
|
93
136
|
|
94
|
-
|
95
|
-
|
137
|
+
@user = User.new
|
138
|
+
override User, :new => @user
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "and facebook_auto_register? true" do
|
96
142
|
|
143
|
+
before do
|
144
|
+
override @session, :facebook_auto_register? => true
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should build a new user on attempted_record" do
|
148
|
+
override User, :new => @user
|
149
|
+
|
97
150
|
@session.save
|
151
|
+
@session.attempted_record.must_equal @user
|
98
152
|
end
|
99
153
|
|
100
|
-
|
101
|
-
|
154
|
+
it "should attempt to call before_connect on the new user" do
|
155
|
+
expect @user, :before_connect, :with => [@facebook_session], :return => true
|
156
|
+
assert @session.save
|
102
157
|
end
|
103
158
|
|
104
|
-
|
105
|
-
|
159
|
+
it "should save the new user" do
|
160
|
+
expect @user, :save, :with => [:validate => false], :return => true
|
161
|
+
assert @session.save
|
106
162
|
end
|
107
163
|
|
108
164
|
end
|
165
|
+
|
166
|
+
describe "and facebook_auto_register? false" do
|
109
167
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
@session.should_receive(:facebook_finder).and_return('finder_method').by_default
|
114
|
-
flexmock(User).should_receive('finder_method').with('mockuid').and_return(nil).by_default
|
168
|
+
it "should return false for logged_in_with_facebook?" do
|
169
|
+
override @session, :facebook_auto_register? => false
|
170
|
+
@session.save
|
115
171
|
|
116
|
-
@
|
117
|
-
flexmock(User).should_receive(:new).and_return(@user).by_default
|
172
|
+
@session.logged_in_with_facebook?.must_equal false
|
118
173
|
end
|
119
174
|
|
120
|
-
|
175
|
+
it "should not set attempted record" do
|
176
|
+
override @session, :facebook_auto_register? => false
|
121
177
|
|
122
|
-
|
123
|
-
@session.should_receive(:facebook_auto_register?).and_return(true).by_default
|
124
|
-
end
|
125
|
-
|
126
|
-
should "build a new user on attempted_record" do
|
127
|
-
flexmock(User).should_receive(:new).and_return(@user).once
|
128
|
-
@session.save
|
129
|
-
assert_equal @user, @session.attempted_record
|
130
|
-
end
|
131
|
-
|
132
|
-
should "attempt to call before_connect on the new user" do
|
133
|
-
# TODO this is a bit flakey because I can't get flexmock to mock with(@facebook_session)
|
134
|
-
@user.should_receive(:before_connect).with(any).and_return(true).once
|
135
|
-
assert @session.save
|
136
|
-
end
|
137
|
-
|
138
|
-
should "save the new user" do
|
139
|
-
@user.should_receive(:save).with(false).and_return(true).at_least.once
|
140
|
-
assert @session.save
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
context "and facebook_auto_register? false" do
|
146
|
-
|
147
|
-
should "return false for logged_in_with_facebook?" do
|
148
|
-
@session.should_receive(:facebook_auto_register?).and_return(false).once
|
149
|
-
@session.save
|
150
|
-
|
151
|
-
assert_equal false, @session.logged_in_with_facebook?
|
152
|
-
end
|
153
|
-
|
154
|
-
should "not set attempted record" do
|
155
|
-
@session.should_receive(:facebook_auto_register?).and_return(false).once
|
156
|
-
@session.save
|
178
|
+
@session.save
|
157
179
|
|
158
|
-
|
159
|
-
end
|
160
|
-
|
180
|
+
@session.attempted_record.must_be_nil
|
161
181
|
end
|
162
182
|
|
163
183
|
end
|
164
|
-
|
184
|
+
|
165
185
|
end
|
166
186
|
|
167
|
-
|
187
|
+
end
|
168
188
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
end
|
189
|
+
describe "when skip_facebook_authentication is true" do
|
190
|
+
|
191
|
+
it "should not attempt to validate with facebook" do
|
192
|
+
override @session, :skip_facebook_authentication => true
|
193
|
+
override @session, :validate_by_facebook => lambda { raise Override::ExpectationError.new('to not be called', 'called') }
|
175
194
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
end
|
195
|
+
@session.save.must_equal false
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should return false for logged_in_with_facebook?" do
|
199
|
+
override @session, :skip_facebook_authentication => true
|
182
200
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
assert_equal false, @session.save
|
187
|
-
assert_nil @session.attempted_record
|
188
|
-
end
|
201
|
+
@session.save.must_equal false
|
202
|
+
@session.logged_in_with_facebook?.must_be_nil
|
189
203
|
end
|
190
204
|
|
191
|
-
|
205
|
+
it "should not set attempted record" do
|
206
|
+
override @session, :skip_facebook_authentication => true
|
192
207
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
208
|
+
@session.save.must_equal false
|
209
|
+
@session.attempted_record.must_be_nil
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe "when authenticating_with_unauthorized_record? is true" do
|
214
|
+
|
215
|
+
before do
|
216
|
+
override @session, :facebook_session? => true
|
217
|
+
override @session, :authenticating_with_unauthorized_record? => true
|
218
|
+
end
|
199
219
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
assert_equal false, @session.save
|
204
|
-
assert_nil @session.logged_in_with_facebook?
|
205
|
-
end
|
220
|
+
it "should not attempt to validate with facebook" do
|
221
|
+
override @session, :validate_by_facebook => lambda { raise Override::ExpectationError.new('to not be called', 'called') }
|
206
222
|
|
207
|
-
|
208
|
-
|
223
|
+
@session.save.must_equal false
|
224
|
+
end
|
209
225
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
226
|
+
it "should return false for logged_in_with_facebook?" do
|
227
|
+
@session.save.must_equal false
|
228
|
+
@session.logged_in_with_facebook?.must_be_nil
|
214
229
|
end
|
215
230
|
|
231
|
+
it "should not set attempted record" do
|
232
|
+
@session.save.must_equal false
|
233
|
+
@session.attempted_record.must_be_nil
|
234
|
+
end
|
216
235
|
|
217
236
|
end
|
218
237
|
|