Skip to content

Commit dcb9b3c

Browse files
authored
Merge pull request #21 from RadiusNetworks/reloading-user
Use `::User` for the `user_class` in the auth module
2 parents d4542cf + faed08b commit dcb9b3c

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

lib/kracken/config.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Kracken
22
class Config
3-
attr_accessor :app_id, :app_secret
4-
attr_writer :provider_url, :user_class
3+
attr_accessor :app_id, :app_secret, :user_class
4+
attr_writer :provider_url
55

66
def initialize
77
@user_class = nil
@@ -12,7 +12,7 @@ def provider_url
1212
end
1313

1414
def user_class
15-
@user_class || ::User
15+
::User
1616
end
1717
end
1818
end

spec/kracken/controllers/token_authenticatable_spec.rb

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,13 @@ def authenticate_or_request_with_http_token(realm = nil)
125125
end
126126

127127
it "lazy loads the current user" do
128-
begin
129-
# Ensure we cannot lookup a user - doing so would raise an error
130-
org_user_class = Kracken.config.user_class
131-
user_class = double("AnyUserClass")
132-
Kracken.config.user_class = user_class
133-
134-
# Action under test
135-
a_controller.authenticate_user_with_token!
128+
# Action under test
129+
a_controller.authenticate_user_with_token!
136130

137-
# Make sure we perform the lookup as expected now
138-
expect(user_class).to receive(:find).with(:any_id).and_return(:user)
131+
# Make sure we perform the lookup as expected now
132+
expect(::User).to receive(:find).with(:any_id).and_return(:user)
139133

140-
expect(a_controller.current_user).to be :user
141-
ensure
142-
Kracken.config.user_class = org_user_class
143-
end
134+
expect(a_controller.current_user).to be :user
144135
end
145136
end
146137

0 commit comments

Comments
 (0)