devise 0.8.1 → 0.8.2

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.

@@ -1,3 +1,13 @@
1
+ == 0.8.2
2
+
3
+ * enhancements
4
+ * Allow Devise.mailer_sender to be a proc (by github/grimen)
5
+
6
+ * bug fix
7
+ * Fix bug with passenger, update is required to anyone deploying on passenger (by github/dvdpalm)
8
+
9
+ == 0.8.1
10
+
1
11
  * enhancements
2
12
  * Move salt to encryptors
3
13
 
@@ -19,7 +19,7 @@ class DeviseMailer < ::ActionMailer::Base
19
19
  raise "Invalid devise resource #{record}" unless mapping
20
20
 
21
21
  subject translate(mapping, key)
22
- from Devise.mailer_sender
22
+ from mailer_sender(mapping)
23
23
  recipients record.email
24
24
  sent_on Time.now
25
25
  content_type 'text/html'
@@ -38,6 +38,14 @@ class DeviseMailer < ::ActionMailer::Base
38
38
  end
39
39
  end
40
40
 
41
+ def mailer_sender(mapping)
42
+ if Devise.mailer_sender.is_a?(Proc)
43
+ Devise.mailer_sender.call(mapping.name)
44
+ else
45
+ Devise.mailer_sender
46
+ end
47
+ end
48
+
41
49
  # Setup subject namespaced by model. It means you're able to setup your
42
50
  # messages using specific resource scope, or provide a default one.
43
51
  # Example (i18n locale file):
@@ -1,5 +1,5 @@
1
1
  # After each sign in, update sign in time, sign in count and sign in IP.
2
- Warden::Manager.after_set_user :event => [:authentication, :set_user] do |record, warden, options|
2
+ Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
3
3
  scope = options[:scope]
4
4
  if Devise.mappings[scope].try(:trackable?) && warden.authenticated?(scope)
5
5
  old_current, new_current = record.current_sign_in_at, Time.now
@@ -92,9 +92,9 @@ module Devise
92
92
  self.path_prefix.count("/")
93
93
  end
94
94
 
95
- # Returns the raw path using path_prefix and as.
95
+ # Returns the raw path using the current relative_url_root, path_prefix and as.
96
96
  def raw_path
97
- path_prefix + as.to_s
97
+ ActionController::Base.relative_url_root.to_s + path_prefix + as.to_s
98
98
  end
99
99
 
100
100
  # Returns the parsed path. If you need meta information in your path_prefix,
@@ -1,3 +1,3 @@
1
1
  module Devise
2
- VERSION = "0.8.1".freeze
2
+ VERSION = "0.8.2".freeze
3
3
  end
@@ -62,4 +62,10 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
62
62
  assert_equal user.email, mail.body
63
63
  end
64
64
  end
65
+
66
+ test 'mailer sender accepts a proc' do
67
+ swap Devise, :mailer_sender => lambda { "another@example.com" } do
68
+ assert_equal ['another@example.com'], mail.from
69
+ end
70
+ end
65
71
  end
@@ -59,4 +59,10 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
59
59
  reset_url_regexp = %r{<a href=\"http://#{host}/users/password/edit\?reset_password_token=#{user.reset_password_token}">}
60
60
  assert_match reset_url_regexp, mail.body
61
61
  end
62
+
63
+ test 'mailer sender accepts a proc' do
64
+ swap Devise, :mailer_sender => lambda { "another@example.com" } do
65
+ assert_equal ['another@example.com'], mail.from
66
+ end
67
+ end
62
68
  end
@@ -86,7 +86,7 @@ class MappingTest < ActiveSupport::TestCase
86
86
  mapping = Devise.mappings[:manager]
87
87
  assert_equal '/:locale/', mapping.path_prefix
88
88
  end
89
-
89
+
90
90
  test 'retrieve as from the proper position' do
91
91
  assert_equal 1, Devise.mappings[:user].as_position
92
92
  assert_equal 2, Devise.mappings[:manager].as_position
@@ -96,6 +96,18 @@ class MappingTest < ActiveSupport::TestCase
96
96
  assert_equal '/users', Devise.mappings[:user].raw_path
97
97
  assert_equal '/:locale/accounts', Devise.mappings[:manager].raw_path
98
98
  end
99
+
100
+ test 'raw path adds in the relative_url_root' do
101
+ swap ActionController::Base, :relative_url_root => '/abc' do
102
+ assert_equal '/abc/users', Devise.mappings[:user].raw_path
103
+ end
104
+ end
105
+
106
+ test 'raw path deals with a nil relative_url_root' do
107
+ swap ActionController::Base, :relative_url_root => nil do
108
+ assert_equal '/users', Devise.mappings[:user].raw_path
109
+ end
110
+ end
99
111
 
100
112
  test 'parsed path is returned' do
101
113
  begin
@@ -106,7 +118,13 @@ class MappingTest < ActiveSupport::TestCase
106
118
  Devise.default_url_options {{ }}
107
119
  end
108
120
  end
109
-
121
+
122
+ test 'parsed path deals with non-standard relative_url_roots' do
123
+ swap ActionController::Base, :relative_url_root => "/abc" do
124
+ assert_equal '/abc/users', Devise.mappings[:user].parsed_path
125
+ end
126
+ end
127
+
110
128
  test 'should have default route options' do
111
129
  assert_equal({}, Devise.mappings[:user].route_options)
112
130
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jos\xC3\xA9 Valim"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-01-08 00:00:00 +01:00
13
+ date: 2010-01-13 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency