devise 1.4.7 → 1.4.8
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +8 -0
- data/lib/devise.rb +2 -5
- data/lib/devise/controllers/url_helpers.rb +10 -4
- data/lib/devise/omniauth/url_helpers.rb +5 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/templates/README +7 -0
- data/test/controllers/internal_helpers_test.rb +1 -1
- data/test/omniauth/url_helpers_test.rb +6 -6
- metadata +2 -27
data/CHANGELOG.rdoc
CHANGED
data/lib/devise.rb
CHANGED
@@ -382,13 +382,10 @@ module Devise
|
|
382
382
|
|
383
383
|
# Include helpers in the given scope to AC and AV.
|
384
384
|
def self.include_helpers(scope)
|
385
|
+
Rails.application.routes.url_helpers.send :include, scope::UrlHelpers
|
386
|
+
|
385
387
|
ActiveSupport.on_load(:action_controller) do
|
386
388
|
include scope::Helpers if defined?(scope::Helpers)
|
387
|
-
include scope::UrlHelpers
|
388
|
-
end
|
389
|
-
|
390
|
-
ActiveSupport.on_load(:action_view) do
|
391
|
-
include scope::UrlHelpers
|
392
389
|
end
|
393
390
|
end
|
394
391
|
|
@@ -24,25 +24,31 @@ module Devise
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def self.generate_helpers!
|
28
|
-
|
29
|
-
|
27
|
+
def self.generate_helpers!(routes=nil)
|
28
|
+
routes ||= begin
|
29
|
+
mappings = Devise.mappings.values.map(&:used_helpers).flatten.uniq
|
30
|
+
Devise::URL_HELPERS.slice(*mappings)
|
31
|
+
end
|
30
32
|
|
31
33
|
routes.each do |module_name, actions|
|
32
34
|
[:path, :url].each do |path_or_url|
|
33
35
|
actions.each do |action|
|
34
36
|
action = action ? "#{action}_" : ""
|
37
|
+
method = "#{action}#{module_name}_#{path_or_url}"
|
35
38
|
|
36
39
|
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
|
37
|
-
def #{
|
40
|
+
def #{method}(resource_or_scope, *args)
|
38
41
|
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
39
42
|
send("#{action}\#{scope}_#{module_name}_#{path_or_url}", *args)
|
40
43
|
end
|
44
|
+
protected :#{method}
|
41
45
|
URL_HELPERS
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
45
49
|
end
|
50
|
+
|
51
|
+
generate_helpers!(Devise::URL_HELPERS)
|
46
52
|
end
|
47
53
|
end
|
48
54
|
end
|
@@ -3,9 +3,10 @@ module Devise
|
|
3
3
|
module UrlHelpers
|
4
4
|
def self.define_helpers(mapping)
|
5
5
|
return unless mapping.omniauthable?
|
6
|
+
method = "#{mapping.name}_omniauth_authorize_path"
|
6
7
|
|
7
8
|
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
|
8
|
-
def #{
|
9
|
+
def #{method}(provider, params = {})
|
9
10
|
if Devise.omniauth_configs[provider.to_sym]
|
10
11
|
script_name = request.env["SCRIPT_NAME"]
|
11
12
|
|
@@ -16,9 +17,12 @@ module Devise
|
|
16
17
|
raise ArgumentError, "Could not find omniauth provider \#{provider.inspect}"
|
17
18
|
end
|
18
19
|
end
|
20
|
+
protected :#{method}
|
19
21
|
URL_HELPERS
|
20
22
|
end
|
21
23
|
|
24
|
+
protected
|
25
|
+
|
22
26
|
def omniauth_authorize_path(resource_or_scope, *args)
|
23
27
|
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
24
28
|
send("#{scope}_omniauth_authorize_path", *args)
|
data/lib/devise/version.rb
CHANGED
@@ -22,4 +22,11 @@ Some setup you must do manually if you haven't yet:
|
|
22
22
|
<p class="notice"><%= notice %></p>
|
23
23
|
<p class="alert"><%= alert %></p>
|
24
24
|
|
25
|
+
4. If you are deploying Rails 3.1 on Heroku, you may want to set:
|
26
|
+
|
27
|
+
config.assets.initialize_on_precompile = false
|
28
|
+
|
29
|
+
On config/application.rb forcing your application to not access the DB
|
30
|
+
or load models when precompiling your assets.
|
31
|
+
|
25
32
|
===============================================================================
|
@@ -35,7 +35,7 @@ class HelpersTest < ActionController::TestCase
|
|
35
35
|
end
|
36
36
|
|
37
37
|
test 'resources methods are not controller actions' do
|
38
|
-
assert @controller.class.action_methods.empty
|
38
|
+
assert @controller.class.action_methods.empty?, "Expected empty, got #{@controller.class.action_methods.inspect}"
|
39
39
|
end
|
40
40
|
|
41
41
|
test 'require no authentication tests current mapping' do
|
@@ -28,31 +28,31 @@ class OmniAuthRoutesTest < ActionController::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
test 'should generate authorization path' do
|
31
|
-
assert_match "/users/auth/facebook", @controller.
|
31
|
+
assert_match "/users/auth/facebook", @controller.send(:omniauth_authorize_path, :user, :facebook)
|
32
32
|
|
33
33
|
assert_raise ArgumentError do
|
34
|
-
@controller.omniauth_authorize_path
|
34
|
+
@controller.send :omniauth_authorize_path, :user, :github
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
test 'should generate authorization path for named open_id omniauth' do
|
39
|
-
assert_match "/users/auth/google", @controller.
|
39
|
+
assert_match "/users/auth/google", @controller.send(:omniauth_authorize_path, :user, :google)
|
40
40
|
end
|
41
41
|
|
42
42
|
test 'should generate authorization path with params' do
|
43
43
|
assert_match "/users/auth/open_id?openid_url=http%3A%2F%2Fyahoo.com",
|
44
|
-
@controller.
|
44
|
+
@controller.send(:omniauth_authorize_path, :user, :open_id, :openid_url => "http://yahoo.com")
|
45
45
|
end
|
46
46
|
|
47
47
|
test 'should not add a "?" if no param was sent' do
|
48
48
|
assert_equal "/users/auth/open_id",
|
49
|
-
@controller.
|
49
|
+
@controller.send(:omniauth_authorize_path, :user, :open_id)
|
50
50
|
end
|
51
51
|
|
52
52
|
test 'should set script name in the path if present' do
|
53
53
|
@request.env['SCRIPT_NAME'] = '/q'
|
54
54
|
|
55
55
|
assert_equal "/q/users/auth/facebook",
|
56
|
-
@controller.
|
56
|
+
@controller.send(:omniauth_authorize_path, :user, :facebook)
|
57
57
|
end
|
58
58
|
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 9
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 1
|
8
|
-
- 4
|
9
|
-
- 7
|
10
|
-
version: 1.4.7
|
5
|
+
version: 1.4.8
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- "Jos\xC3\xA9 Valim"
|
@@ -16,7 +11,7 @@ autorequire:
|
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
13
|
|
19
|
-
date: 2011-
|
14
|
+
date: 2011-10-10 00:00:00 +02:00
|
20
15
|
default_executable:
|
21
16
|
dependencies:
|
22
17
|
- !ruby/object:Gem::Dependency
|
@@ -27,11 +22,6 @@ dependencies:
|
|
27
22
|
requirements:
|
28
23
|
- - ~>
|
29
24
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 17
|
31
|
-
segments:
|
32
|
-
- 1
|
33
|
-
- 0
|
34
|
-
- 3
|
35
25
|
version: 1.0.3
|
36
26
|
type: :runtime
|
37
27
|
version_requirements: *id001
|
@@ -43,11 +33,6 @@ dependencies:
|
|
43
33
|
requirements:
|
44
34
|
- - ~>
|
45
35
|
- !ruby/object:Gem::Version
|
46
|
-
hash: 25
|
47
|
-
segments:
|
48
|
-
- 0
|
49
|
-
- 0
|
50
|
-
- 3
|
51
36
|
version: 0.0.3
|
52
37
|
type: :runtime
|
53
38
|
version_requirements: *id002
|
@@ -59,10 +44,6 @@ dependencies:
|
|
59
44
|
requirements:
|
60
45
|
- - ~>
|
61
46
|
- !ruby/object:Gem::Version
|
62
|
-
hash: 7
|
63
|
-
segments:
|
64
|
-
- 3
|
65
|
-
- 0
|
66
47
|
version: "3.0"
|
67
48
|
type: :runtime
|
68
49
|
version_requirements: *id003
|
@@ -292,18 +273,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
292
273
|
requirements:
|
293
274
|
- - ">="
|
294
275
|
- !ruby/object:Gem::Version
|
295
|
-
hash: 3
|
296
|
-
segments:
|
297
|
-
- 0
|
298
276
|
version: "0"
|
299
277
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
300
278
|
none: false
|
301
279
|
requirements:
|
302
280
|
- - ">="
|
303
281
|
- !ruby/object:Gem::Version
|
304
|
-
hash: 3
|
305
|
-
segments:
|
306
|
-
- 0
|
307
282
|
version: "0"
|
308
283
|
requirements: []
|
309
284
|
|