authlogic_facebook_koala 0.3.0 → 0.3.2
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/README.md +4 -0
- data/authlogic_facebook_koala.gemspec +25 -22
- metadata +31 -165
- data/LICENSE +0 -20
- data/README.rdoc +0 -76
- data/Rakefile +0 -39
- data/VERSION +0 -1
- data/init.rb +0 -1
- data/lib/authlogic_facebook_koala.rb +0 -17
- data/lib/authlogic_facebook_koala/acts_as_authentic.rb +0 -20
- data/lib/authlogic_facebook_koala/adapter.rb +0 -35
- data/lib/authlogic_facebook_koala/config.rb +0 -80
- data/lib/authlogic_facebook_koala/helper.rb +0 -4
- data/lib/authlogic_facebook_koala/session.rb +0 -68
- data/rails/init.rb +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/app/models/user.rb +0 -7
- data/test/rails_root/app/models/user_session.rb +0 -7
- 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/facebook.yml +0 -7
- 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/db/migrate/20101217000008_create_users.rb +0 -37
- data/test/rails_root/db/seeds.rb +0 -7
- data/test/rails_root/script/console +0 -3
- data/test/rails_root/script/dbconsole +0 -3
- data/test/rails_root/script/generate +0 -3
- data/test/test_helper.rb +0 -43
- data/test/units/adapter_test.rb +0 -182
- data/test/units/config_test.rb +0 -145
- data/test/units/session_test.rb +0 -221
data/test/units/session_test.rb
DELETED
@@ -1,221 +0,0 @@
|
|
1
|
-
require File.expand_path( '../test_helper.rb', File.dirname(__FILE__) )
|
2
|
-
|
3
|
-
class SessionTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup :activate_authlogic
|
6
|
-
|
7
|
-
context "Session" do
|
8
|
-
|
9
|
-
setup do
|
10
|
-
@mock_cookies = MockCookieJar.new
|
11
|
-
@mock_cookies['fbs_mockappid'] = {:value => 'access_token=mockaccesstoken&expires=0&secret=mocksecret&session_key=mocksessionkey&sig=cbd80b97f124bf392f76e2ee61168990&uid=mockuid'}
|
12
|
-
|
13
|
-
flexmock(controller).should_receive(:cookies).and_return(@mock_cookies).by_default
|
14
|
-
|
15
|
-
@session = flexmock(UserSession.new)
|
16
|
-
@session.should_receive(:controller).and_return(controller).by_default
|
17
|
-
end
|
18
|
-
|
19
|
-
context "setup - for my own sanity" do
|
20
|
-
|
21
|
-
should "set the controller" do
|
22
|
-
assert_equal controller, @session.controller
|
23
|
-
end
|
24
|
-
|
25
|
-
should "set the cookies" do
|
26
|
-
assert_equal @mock_cookies, @session.controller.cookies
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
context "config accessors" do
|
32
|
-
|
33
|
-
should "return facebook_app_id" do
|
34
|
-
mockappid = 'mockappid'
|
35
|
-
flexmock(UserSession).should_receive(:facebook_app_id).and_return(mockappid).once
|
36
|
-
assert_equal mockappid, @session.send(:facebook_app_id)
|
37
|
-
end
|
38
|
-
|
39
|
-
should "return facebook_api_key" do
|
40
|
-
mockapikey = 'mockapikey'
|
41
|
-
flexmock(UserSession).should_receive(:facebook_api_key).and_return(mockapikey).once
|
42
|
-
assert_equal mockapikey, @session.send(:facebook_api_key)
|
43
|
-
end
|
44
|
-
|
45
|
-
should "return facebook_secret_key" do
|
46
|
-
mocksecret = 'mocksecret'
|
47
|
-
flexmock(UserSession).should_receive(:facebook_secret_key).and_return(mocksecret).once
|
48
|
-
assert_equal mocksecret, @session.send(:facebook_secret_key)
|
49
|
-
end
|
50
|
-
|
51
|
-
should "return facebook_uid_field" do
|
52
|
-
mockuidfield = 'mockuidfield'
|
53
|
-
flexmock(UserSession).should_receive(:facebook_uid_field).and_return(mockuidfield).once
|
54
|
-
assert_equal mockuidfield, @session.send(:facebook_uid_field)
|
55
|
-
end
|
56
|
-
|
57
|
-
context "facebook_finder" do
|
58
|
-
|
59
|
-
should "delegate to the class" do
|
60
|
-
mockfinder = 'mockfinder'
|
61
|
-
flexmock(UserSession).should_receive(:facebook_finder).and_return(mockfinder).once
|
62
|
-
assert_equal mockfinder, @session.send(:facebook_finder)
|
63
|
-
end
|
64
|
-
|
65
|
-
should "default if the class returns nil" do
|
66
|
-
flexmock(UserSession).should_receive(:facebook_finder).and_return(nil).once
|
67
|
-
@session.should_receive(:facebook_uid_field).and_return('mockuidfield').once
|
68
|
-
assert_equal "find_by_mockuidfield", @session.send(:facebook_finder)
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
should "return facebook_auto_register?" do
|
74
|
-
flexmock(UserSession).should_receive(:facebook_auto_register).and_return(true).once
|
75
|
-
assert @session.send(:facebook_auto_register?)
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
context "validating with facebook" do
|
81
|
-
|
82
|
-
context "with a valid facebook session" do
|
83
|
-
|
84
|
-
setup do
|
85
|
-
@facebook_session = flexmock('facebook session', :uid => 'mockuid')
|
86
|
-
@session.should_receive(:facebook_session).and_return(@facebook_session).by_default
|
87
|
-
end
|
88
|
-
|
89
|
-
context "with an existing facebook uid" do
|
90
|
-
|
91
|
-
setup do
|
92
|
-
@session.should_receive(:facebook_finder).and_return('finder_method').by_default
|
93
|
-
|
94
|
-
@user = User.create
|
95
|
-
flexmock(User).should_receive('finder_method').with('mockuid').and_return(@user).by_default
|
96
|
-
|
97
|
-
@session.save
|
98
|
-
end
|
99
|
-
|
100
|
-
should "return true for logged_in_with_facebook?" do
|
101
|
-
assert @session.logged_in_with_facebook?
|
102
|
-
end
|
103
|
-
|
104
|
-
should "set attempted_record" do
|
105
|
-
assert_equal @user, @session.attempted_record
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
context "without an existing facebook uid" do
|
111
|
-
|
112
|
-
setup do
|
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
|
115
|
-
|
116
|
-
@user = flexmock(User.new)
|
117
|
-
flexmock(User).should_receive(:new).and_return(@user).by_default
|
118
|
-
end
|
119
|
-
|
120
|
-
context "and facebook_auto_register? true" do
|
121
|
-
|
122
|
-
setup do
|
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
|
157
|
-
|
158
|
-
assert_nil @session.attempted_record
|
159
|
-
end
|
160
|
-
|
161
|
-
end
|
162
|
-
|
163
|
-
end
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
context "when skip_facebook_authentication is true" do
|
168
|
-
|
169
|
-
should "not attempt to validate with facebook" do
|
170
|
-
@session.should_receive(:skip_facebook_authentication).and_return(true).once
|
171
|
-
@session.should_receive(:validate_by_facebook).never
|
172
|
-
|
173
|
-
assert_equal false, @session.save
|
174
|
-
end
|
175
|
-
|
176
|
-
should "return false for logged_in_with_facebook?" do
|
177
|
-
@session.should_receive(:skip_facebook_authentication).and_return(true).once
|
178
|
-
|
179
|
-
assert_equal false, @session.save
|
180
|
-
assert_nil @session.logged_in_with_facebook?
|
181
|
-
end
|
182
|
-
|
183
|
-
should "not set attempted record" do
|
184
|
-
@session.should_receive(:skip_facebook_authentication).and_return(true).once
|
185
|
-
|
186
|
-
assert_equal false, @session.save
|
187
|
-
assert_nil @session.attempted_record
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
context "when authenticating_with_unauthorized_record? is false" do
|
192
|
-
|
193
|
-
should "not attempt to validate with facebook" do
|
194
|
-
@session.should_receive(:authenticating_with_unauthorized_record?).and_return(false).at_least.once
|
195
|
-
@session.should_receive(:validate_by_facebook).never
|
196
|
-
|
197
|
-
assert_equal false, @session.save
|
198
|
-
end
|
199
|
-
|
200
|
-
should "return false for logged_in_with_facebook?" do
|
201
|
-
@session.should_receive(:authenticating_with_unauthorized_record?).and_return(true).at_least.once
|
202
|
-
|
203
|
-
assert_equal false, @session.save
|
204
|
-
assert_nil @session.logged_in_with_facebook?
|
205
|
-
end
|
206
|
-
|
207
|
-
should "not set attempted record" do
|
208
|
-
@session.should_receive(:authenticating_with_unauthorized_record?).and_return(true).at_least.once
|
209
|
-
|
210
|
-
assert_equal false, @session.save
|
211
|
-
assert_nil @session.attempted_record
|
212
|
-
end
|
213
|
-
|
214
|
-
end
|
215
|
-
|
216
|
-
|
217
|
-
end
|
218
|
-
|
219
|
-
end
|
220
|
-
|
221
|
-
end
|