clearance 1.13.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of clearance might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0472155cf20becdae95b0449996f13422cf8fd9f
4
- data.tar.gz: 593e5208e89806394b03e9c0bac1c69f6836434b
3
+ metadata.gz: c1ce84cb7eaf277d03ef97bea09933416876f4c3
4
+ data.tar.gz: 622499f4174f3f22ceae7c50d1a6a586c73190f0
5
5
  SHA512:
6
- metadata.gz: c855e609161a0adc70754a033596de44ffc49ded096b0f1e61bb541c670e1d75e82f518e73f5a0ed53d00d25b4763e12d2f9b494a23802c3428154304665097d
7
- data.tar.gz: b243f157204f0256c3405e62c8e24219c5101e7852c3818d21e057c0405c36d02aa59dbfe4a3d7f27260eb802b2d1f9d5ff306135fbce1f78d6dcefb39d52cbb
6
+ metadata.gz: 374a634825b204e2c41fd78884226ef4684667225b6143170c85f1496eeee37e8494fd64c5bd39fecb972822912d234d3c9967f34e9b9b3a1bf62b1fea3621c9
7
+ data.tar.gz: f1be7061869311f8787b273ad65860c4231975b8e6df2305b0aa15d59c6d332a93b87ec5af88a4af3dfc730b87ab4439b63ffd1a4d74d821067b2f34a9550b1c
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  .bundle
7
7
  db/*.sqlite3
8
8
  gemfiles/*.lock
9
+ gemfiles/vendor/
9
10
  log/*.log
10
11
  pkg
11
12
  tmp/
data/Appraisals CHANGED
@@ -7,14 +7,17 @@ end
7
7
  appraise 'rails40' do
8
8
  gem 'rails', '~> 4.0.13'
9
9
  gem 'test-unit'
10
+ gem 'mime-types', '~> 2.99'
10
11
  end
11
12
 
12
13
  appraise 'rails41' do
13
14
  gem 'rails', '~> 4.1.9'
15
+ gem 'mime-types', '~> 2.99'
14
16
  end
15
17
 
16
18
  appraise 'rails42' do
17
19
  gem 'rails', '~> 4.2.0'
20
+ gem 'mime-types', '~> 2.99'
18
21
  end
19
22
 
20
23
  if RUBY_VERSION >= "2.2.0"
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'appraisal', '~> 1.0'
5
+ gem 'appraisal'
6
6
  gem 'ammeter'
7
7
  gem 'bundler', '~> 1.3'
8
8
  gem 'capybara', '>= 2.6.2'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clearance (1.13.0)
4
+ clearance (1.14.0)
5
5
  bcrypt
6
6
  email_validator (~> 1.4)
7
7
  rails (>= 3.1)
@@ -9,36 +9,36 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actionmailer (4.2.5)
13
- actionpack (= 4.2.5)
14
- actionview (= 4.2.5)
15
- activejob (= 4.2.5)
12
+ actionmailer (4.2.6)
13
+ actionpack (= 4.2.6)
14
+ actionview (= 4.2.6)
15
+ activejob (= 4.2.6)
16
16
  mail (~> 2.5, >= 2.5.4)
17
17
  rails-dom-testing (~> 1.0, >= 1.0.5)
18
- actionpack (4.2.5)
19
- actionview (= 4.2.5)
20
- activesupport (= 4.2.5)
18
+ actionpack (4.2.6)
19
+ actionview (= 4.2.6)
20
+ activesupport (= 4.2.6)
21
21
  rack (~> 1.6)
22
22
  rack-test (~> 0.6.2)
23
23
  rails-dom-testing (~> 1.0, >= 1.0.5)
24
24
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
25
- actionview (4.2.5)
26
- activesupport (= 4.2.5)
25
+ actionview (4.2.6)
26
+ activesupport (= 4.2.6)
27
27
  builder (~> 3.1)
28
28
  erubis (~> 2.7.0)
29
29
  rails-dom-testing (~> 1.0, >= 1.0.5)
30
30
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
31
- activejob (4.2.5)
32
- activesupport (= 4.2.5)
31
+ activejob (4.2.6)
32
+ activesupport (= 4.2.6)
33
33
  globalid (>= 0.3.0)
34
- activemodel (4.2.5)
35
- activesupport (= 4.2.5)
34
+ activemodel (4.2.6)
35
+ activesupport (= 4.2.6)
36
36
  builder (~> 3.1)
37
- activerecord (4.2.5)
38
- activemodel (= 4.2.5)
39
- activesupport (= 4.2.5)
37
+ activerecord (4.2.6)
38
+ activemodel (= 4.2.6)
39
+ activesupport (= 4.2.6)
40
40
  arel (~> 6.0)
41
- activesupport (4.2.5)
41
+ activesupport (4.2.6)
42
42
  i18n (~> 0.7)
43
43
  json (~> 1.7, >= 1.7.7)
44
44
  minitest (~> 5.1)
@@ -49,31 +49,31 @@ GEM
49
49
  activesupport (>= 3.0)
50
50
  railties (>= 3.0)
51
51
  rspec-rails (>= 2.2)
52
- appraisal (1.0.3)
52
+ appraisal (2.1.0)
53
53
  bundler
54
54
  rake
55
55
  thor (>= 0.14.0)
56
56
  arel (6.0.3)
57
- bcrypt (3.1.10)
57
+ bcrypt (3.1.11)
58
58
  builder (3.2.2)
59
- capybara (2.6.2)
59
+ capybara (2.7.0)
60
60
  addressable
61
61
  mime-types (>= 1.16)
62
62
  nokogiri (>= 1.3.3)
63
63
  rack (>= 1.0.0)
64
64
  rack-test (>= 0.5.4)
65
65
  xpath (~> 2.0)
66
- coderay (1.1.0)
66
+ coderay (1.1.1)
67
67
  concurrent-ruby (1.0.1)
68
- database_cleaner (1.5.1)
68
+ database_cleaner (1.5.3)
69
69
  diff-lcs (1.2.5)
70
70
  email_validator (1.6.0)
71
71
  activemodel
72
72
  erubis (2.7.0)
73
- factory_girl (4.5.0)
73
+ factory_girl (4.7.0)
74
74
  activesupport (>= 3.0.0)
75
- factory_girl_rails (4.5.0)
76
- factory_girl (~> 4.5.0)
75
+ factory_girl_rails (4.7.0)
76
+ factory_girl (~> 4.7.0)
77
77
  railties (>= 3.0.0)
78
78
  globalid (0.3.6)
79
79
  activesupport (>= 4.1.0)
@@ -81,13 +81,15 @@ GEM
81
81
  json (1.8.3)
82
82
  loofah (2.0.3)
83
83
  nokogiri (>= 1.5.9)
84
- mail (2.6.3)
85
- mime-types (>= 1.16, < 3)
84
+ mail (2.6.4)
85
+ mime-types (>= 1.16, < 4)
86
86
  method_source (0.8.2)
87
- mime-types (2.99)
87
+ mime-types (3.0)
88
+ mime-types-data (~> 3.2015)
89
+ mime-types-data (3.2016.0221)
88
90
  mini_portile2 (2.0.0)
89
- minitest (5.8.3)
90
- nokogiri (1.6.7.1)
91
+ minitest (5.8.4)
92
+ nokogiri (1.6.7.2)
91
93
  mini_portile2 (~> 2.0.0.rc2)
92
94
  pry (0.10.3)
93
95
  coderay (~> 1.1.0)
@@ -96,16 +98,16 @@ GEM
96
98
  rack (1.6.4)
97
99
  rack-test (0.6.3)
98
100
  rack (>= 1.0)
99
- rails (4.2.5)
100
- actionmailer (= 4.2.5)
101
- actionpack (= 4.2.5)
102
- actionview (= 4.2.5)
103
- activejob (= 4.2.5)
104
- activemodel (= 4.2.5)
105
- activerecord (= 4.2.5)
106
- activesupport (= 4.2.5)
101
+ rails (4.2.6)
102
+ actionmailer (= 4.2.6)
103
+ actionpack (= 4.2.6)
104
+ actionview (= 4.2.6)
105
+ activejob (= 4.2.6)
106
+ activemodel (= 4.2.6)
107
+ activerecord (= 4.2.6)
108
+ activesupport (= 4.2.6)
107
109
  bundler (>= 1.3.0, < 2.0)
108
- railties (= 4.2.5)
110
+ railties (= 4.2.6)
109
111
  sprockets-rails
110
112
  rails-deprecated_sanitizer (1.0.3)
111
113
  activesupport (>= 4.2.0.alpha)
@@ -113,23 +115,23 @@ GEM
113
115
  activesupport (>= 4.2.0.beta, < 5.0)
114
116
  nokogiri (~> 1.6.0)
115
117
  rails-deprecated_sanitizer (>= 1.0.1)
116
- rails-html-sanitizer (1.0.2)
118
+ rails-html-sanitizer (1.0.3)
117
119
  loofah (~> 2.0)
118
- railties (4.2.5)
119
- actionpack (= 4.2.5)
120
- activesupport (= 4.2.5)
120
+ railties (4.2.6)
121
+ actionpack (= 4.2.6)
122
+ activesupport (= 4.2.6)
121
123
  rake (>= 0.8.7)
122
124
  thor (>= 0.18.1, < 2.0)
123
- rake (10.4.2)
124
- rspec-core (3.4.1)
125
+ rake (11.1.2)
126
+ rspec-core (3.4.4)
125
127
  rspec-support (~> 3.4.0)
126
128
  rspec-expectations (3.4.0)
127
129
  diff-lcs (>= 1.2.0, < 2.0)
128
130
  rspec-support (~> 3.4.0)
129
- rspec-mocks (3.4.0)
131
+ rspec-mocks (3.4.1)
130
132
  diff-lcs (>= 1.2.0, < 2.0)
131
133
  rspec-support (~> 3.4.0)
132
- rspec-rails (3.4.0)
134
+ rspec-rails (3.4.2)
133
135
  actionpack (>= 3.0, < 4.3)
134
136
  activesupport (>= 3.0, < 4.3)
135
137
  railties (>= 3.0, < 4.3)
@@ -141,7 +143,7 @@ GEM
141
143
  shoulda-matchers (2.8.0)
142
144
  activesupport (>= 3.0.0)
143
145
  slop (3.6.0)
144
- sprockets (3.5.2)
146
+ sprockets (3.6.0)
145
147
  concurrent-ruby (~> 1.0)
146
148
  rack (> 1, < 3)
147
149
  sprockets-rails (3.0.4)
@@ -151,7 +153,7 @@ GEM
151
153
  sqlite3 (1.3.11)
152
154
  thor (0.19.1)
153
155
  thread_safe (0.3.5)
154
- timecop (0.8.0)
156
+ timecop (0.8.1)
155
157
  tzinfo (1.2.2)
156
158
  thread_safe (~> 0.1)
157
159
  xpath (2.0.0)
@@ -162,7 +164,7 @@ PLATFORMS
162
164
 
163
165
  DEPENDENCIES
164
166
  ammeter
165
- appraisal (~> 1.0)
167
+ appraisal
166
168
  bundler (~> 1.3)
167
169
  capybara (>= 2.6.2)
168
170
  clearance!
data/NEWS.md CHANGED
@@ -3,6 +3,28 @@
3
3
  The noteworthy changes for each Clearance version are included here. For a
4
4
  complete changelog, see the git history for each version via the version links.
5
5
 
6
+ ## [1.14.0] - April 29, 2016
7
+
8
+ ### Added
9
+ - `Clearance::BackDoor` now accepts a block, allowing the user for a test to be
10
+ looked up by a parameter other than `id` if you have overridden `to_param` for
11
+ the `User` model.
12
+
13
+ ### Fixed
14
+ - We now correctly track the dirty state of `User#encrypted_password`, which
15
+ fixes custom validations on `User#password` (e.g. validating password length)
16
+ that were conditional on the password actually changing.
17
+ - The `clearance:install` generator will now generate a `User` model that
18
+ inherits from `ApplicationRecord` if run on a Rails 5 app that doesn't already
19
+ have a `User` model.
20
+
21
+ ### Deprecated
22
+ - `User#password_changing` is deprecated in favor of automatic dirty tracking on
23
+ `encrypted_password` and `password`. If you are calling this in your
24
+ application you should be able to remove it.
25
+
26
+ [1.14.0]: https://github.com/thoughtbot/clearance/compare/v1.13.0...v1.14.0
27
+
6
28
  ## [1.13.0] - March 4, 2016
7
29
 
8
30
  ### Added
data/README.md CHANGED
@@ -337,6 +337,20 @@ Usage:
337
337
  visit root_path(as: user)
338
338
  ```
339
339
 
340
+ Additionally, if `User#to_param` is overridden, you can pass a block in
341
+ order to override the default behavior:
342
+
343
+ ```ruby
344
+ # config/environments/test.rb
345
+ MyRailsApp::Application.configure do
346
+ # ...
347
+ config.middleware.use Clearance::BackDoor do |username|
348
+ Clearance.configuration.user_model.find_by(username: username)
349
+ end
350
+ # ...
351
+ end
352
+ ```
353
+
340
354
  ### Ready Made Feature Specs
341
355
 
342
356
  If you're using RSpec, you can generate feature specs to help prevent
@@ -1,4 +1,4 @@
1
- <%= t(".opening") %></p>
1
+ <%= t(".opening") %>
2
2
 
3
3
  <%= edit_user_password_url(@user, token: @user.confirmation_token.html_safe) %>
4
4
 
@@ -5,7 +5,7 @@ source "https://rubygems.org"
5
5
  gem "appraisal", "~> 1.0"
6
6
  gem "ammeter"
7
7
  gem "bundler", "~> 1.3"
8
- gem "capybara", ">= 2.3"
8
+ gem "capybara", ">= 2.6.2"
9
9
  gem "database_cleaner", "~> 1.0"
10
10
  gem "factory_girl_rails", "~> 4.2"
11
11
  gem "rspec-rails", "~> 3.1"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "~> 1.0"
5
+ gem "appraisal"
6
6
  gem "ammeter"
7
7
  gem "bundler", "~> 1.3"
8
8
  gem "capybara", ">= 2.6.2"
@@ -15,5 +15,6 @@ gem "timecop", "~> 0.6"
15
15
  gem "pry", :require => false
16
16
  gem "rails", "~> 4.0.13"
17
17
  gem "test-unit"
18
+ gem "mime-types", "~> 2.99"
18
19
 
19
20
  gemspec :path => "../"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "~> 1.0"
5
+ gem "appraisal"
6
6
  gem "ammeter"
7
7
  gem "bundler", "~> 1.3"
8
8
  gem "capybara", ">= 2.6.2"
@@ -14,5 +14,6 @@ gem "sqlite3", "~> 1.3"
14
14
  gem "timecop", "~> 0.6"
15
15
  gem "pry", :require => false
16
16
  gem "rails", "~> 4.1.9"
17
+ gem "mime-types", "~> 2.99"
17
18
 
18
19
  gemspec :path => "../"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "~> 1.0"
5
+ gem "appraisal"
6
6
  gem "ammeter"
7
7
  gem "bundler", "~> 1.3"
8
8
  gem "capybara", ">= 2.6.2"
@@ -14,5 +14,6 @@ gem "sqlite3", "~> 1.3"
14
14
  gem "timecop", "~> 0.6"
15
15
  gem "pry", :require => false
16
16
  gem "rails", "~> 4.2.0"
17
+ gem "mime-types", "~> 2.99"
17
18
 
18
19
  gemspec :path => "../"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", "~> 1.0"
5
+ gem "appraisal"
6
6
  gem "ammeter"
7
7
  gem "bundler", "~> 1.3"
8
8
  gem "capybara", ">= 2.6.2"
@@ -1,6 +1,7 @@
1
1
  module Clearance
2
2
  # Middleware which allows signing in by passing as=USER_ID in a query
3
- # parameter.
3
+ # parameter. If `User#to_param` is overriden you may pass a block to
4
+ # override the default user lookup behaviour
4
5
  #
5
6
  # Designed to eliminate time in integration tests wasted by visiting and
6
7
  # submitting the sign in form.
@@ -14,12 +15,24 @@ module Clearance
14
15
  # # ...
15
16
  # end
16
17
  #
18
+ # # or if `User#to_param` is overridden (to `username` for example):
19
+ #
20
+ # # config/environments/test.rb
21
+ # MyRailsApp::Application.configure do
22
+ # # ...
23
+ # config.middleware.use Clearance::BackDoor do |username|
24
+ # User.find_by(username: username)
25
+ # end
26
+ # # ...
27
+ # end
28
+ #
17
29
  # Usage:
18
30
  #
19
31
  # visit new_feedback_path(as: user)
20
32
  class BackDoor
21
- def initialize(app)
33
+ def initialize(app, &block)
22
34
  @app = app
35
+ @block = block
23
36
  end
24
37
 
25
38
  def call(env)
@@ -31,13 +44,22 @@ module Clearance
31
44
 
32
45
  # @api private
33
46
  def sign_in_through_the_back_door(env)
34
- params = Rack::Utils.parse_query(env['QUERY_STRING'])
35
- user_id = params['as']
47
+ params = Rack::Utils.parse_query(env["QUERY_STRING"])
48
+ user_param = params["as"]
36
49
 
37
- if user_id.present?
38
- user = Clearance.configuration.user_model.find(user_id)
50
+ if user_param.present?
51
+ user = find_user(user_param)
39
52
  env[:clearance].sign_in(user)
40
53
  end
41
54
  end
55
+
56
+ # @api private
57
+ def find_user(user_param)
58
+ if @block
59
+ @block.call(user_param)
60
+ else
61
+ Clearance.configuration.user_model.find(user_param)
62
+ end
63
+ end
42
64
  end
43
65
  end
@@ -47,10 +47,7 @@ module Clearance
47
47
  # reset link.
48
48
  #
49
49
  # @!attribute password_changing
50
- # @return [String] Transient (non-persisted) attribute that is set to
51
- # `true` when {#update_password} is called. This value is read by
52
- # {#skip_password_validation?} to determine if password validations need
53
- # to be run.
50
+ # @deprecated Dirty tracking is now handled automatically.
54
51
  #
55
52
  # @!attribute [r] password
56
53
  # @return [String] Transient (non-persisted) attribute that is set when
@@ -103,12 +100,34 @@ module Clearance
103
100
  extend ActiveSupport::Concern
104
101
 
105
102
  included do
106
- attr_accessor :password_changing
107
103
  attr_reader :password
108
104
 
109
105
  include Validations
110
106
  include Callbacks
111
107
  include password_strategy
108
+
109
+ def password=(value)
110
+ encrypted_password_will_change!
111
+ super
112
+ end
113
+
114
+ def password_changing
115
+ warn "#{Kernel.caller.first}: [DEPRECATION] " \
116
+ "The `password_changing` attribute is deprecated. Clearance uses " \
117
+ "the dirty state of the `encrypted_password` field to track this " \
118
+ "automatically."
119
+
120
+ @password_changing
121
+ end
122
+
123
+ def password_changing=(value)
124
+ warn "#{Kernel.caller.first}: [DEPRECATION] " \
125
+ "The `password_changing` attribute is deprecated. Clearance uses " \
126
+ "the dirty state of the `encrypted_password` field to track this " \
127
+ "automatically."
128
+
129
+ @password_changing = value
130
+ end
112
131
  end
113
132
 
114
133
  # @api private
@@ -203,7 +222,6 @@ module Clearance
203
222
  #
204
223
  # @return [Boolean] Was the save successful?
205
224
  def update_password(new_password)
206
- self.password_changing = true
207
225
  self.password = new_password
208
226
 
209
227
  if valid?
@@ -245,7 +263,8 @@ module Clearance
245
263
  #
246
264
  # @return [Boolean]
247
265
  def skip_password_validation?
248
- password_optional? || (encrypted_password.present? && !password_changing)
266
+ password_optional? ||
267
+ (encrypted_password.present? && !encrypted_password_changed?)
249
268
  end
250
269
 
251
270
  # Sets the {#confirmation_token} on the instance to a new value generated by
@@ -259,7 +278,7 @@ module Clearance
259
278
 
260
279
  # Sets the {#remember_token} on the instance to a new value generated by
261
280
  # {Token.new}. The change is not automatically persisted. If you would like
262
- # to generate and sace in a single method call, use
281
+ # to generate and save in a single method call, use
263
282
  # {#reset_remember_token!}.
264
283
  #
265
284
  # @return [String] The new remember token
@@ -1,3 +1,3 @@
1
1
  module Clearance
2
- VERSION = "1.13.0".freeze
2
+ VERSION = "1.14.0".freeze
3
3
  end
@@ -24,10 +24,11 @@ module Clearance
24
24
  inject_into_file(
25
25
  "app/models/user.rb",
26
26
  " include Clearance::User\n\n",
27
- after: "class User < ActiveRecord::Base\n"
27
+ after: "class User < ",
28
28
  )
29
29
  else
30
- copy_file 'user.rb', 'app/models/user.rb'
30
+ @inherit_from = models_inherit_from
31
+ template("user.rb.erb", "app/models/user.rb")
31
32
  end
32
33
  end
33
34
 
@@ -126,6 +127,14 @@ module Clearance
126
127
  "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
127
128
  end
128
129
  end
130
+
131
+ def models_inherit_from
132
+ if Rails.version >= "5.0.0"
133
+ "ApplicationRecord"
134
+ else
135
+ "ActiveRecord::Base"
136
+ end
137
+ end
129
138
  end
130
139
  end
131
140
  end
@@ -0,0 +1,3 @@
1
+ class User < <%= @inherit_from %>
2
+ include Clearance::User
3
+ end
@@ -1,8 +1,8 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Clearance::BackDoor do
4
- it 'signs in as a given user' do
5
- user_id = '123'
4
+ it "signs in as a given user" do
5
+ user_id = "123"
6
6
  user = double("user")
7
7
  allow(User).to receive(:find).with(user_id).and_return(user)
8
8
  env = env_for_user_id(user_id)
@@ -14,7 +14,7 @@ describe Clearance::BackDoor do
14
14
  expect(result).to eq mock_app.call(env)
15
15
  end
16
16
 
17
- it 'delegates directly without a user' do
17
+ it "delegates directly without a user" do
18
18
  env = env_without_user_id
19
19
  back_door = Clearance::BackDoor.new(mock_app)
20
20
 
@@ -24,8 +24,22 @@ describe Clearance::BackDoor do
24
24
  expect(result).to eq mock_app.call(env)
25
25
  end
26
26
 
27
+ it "can set the user via a block" do
28
+ env = env_for_username("foo")
29
+ user = double("user")
30
+ allow(User).to receive(:find_by).with(username: "foo").and_return(user)
31
+ back_door = Clearance::BackDoor.new(mock_app) do |username|
32
+ User.find_by(username: username)
33
+ end
34
+
35
+ result = back_door.call(env)
36
+
37
+ expect(env[:clearance]).to have_received(:sign_in).with(user)
38
+ expect(result).to eq mock_app.call(env)
39
+ end
40
+
27
41
  def env_without_user_id
28
- env_for_user_id('')
42
+ env_for_user_id("")
29
43
  end
30
44
 
31
45
  def env_for_user_id(user_id)
@@ -33,7 +47,12 @@ describe Clearance::BackDoor do
33
47
  Rack::MockRequest.env_for("/?as=#{user_id}").merge(clearance: clearance)
34
48
  end
35
49
 
50
+ def env_for_username(username)
51
+ clearance = double("clearance", sign_in: true)
52
+ Rack::MockRequest.env_for("/?as=#{username}").merge(clearance: clearance)
53
+ end
54
+
36
55
  def mock_app
37
- lambda { |env| [200, {}, ['okay']] }
56
+ lambda { |env| [200, {}, ["okay"]] }
38
57
  end
39
58
  end
@@ -32,12 +32,12 @@ describe Clearance::Session do
32
32
 
33
33
  context "with a custom cookie name" do
34
34
  it "sets a custom cookie name in the header" do
35
- Clearance.configuration.cookie_domain = "custom_token"
35
+ Clearance.configuration.cookie_name = "custom_cookie_name"
36
36
 
37
37
  session.sign_in user
38
38
  session.add_cookie_to_headers(headers)
39
39
 
40
- expect(headers["Set-Cookie"]).to match(/custom_token/)
40
+ expect(headers["Set-Cookie"]).to match(/custom_cookie_name=.+;/)
41
41
  end
42
42
 
43
43
  after { restore_default_config }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clearance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Croak
@@ -25,7 +25,7 @@ authors:
25
25
  autorequire:
26
26
  bindir: bin
27
27
  cert_chain: []
28
- date: 2016-03-05 00:00:00.000000000 Z
28
+ date: 2016-04-29 00:00:00.000000000 Z
29
29
  dependencies:
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bcrypt
@@ -152,7 +152,7 @@ files:
152
152
  - lib/generators/clearance/install/templates/clearance.rb
153
153
  - lib/generators/clearance/install/templates/db/migrate/add_clearance_to_users.rb
154
154
  - lib/generators/clearance/install/templates/db/migrate/create_users.rb
155
- - lib/generators/clearance/install/templates/user.rb
155
+ - lib/generators/clearance/install/templates/user.rb.erb
156
156
  - lib/generators/clearance/routes/routes_generator.rb
157
157
  - lib/generators/clearance/routes/templates/routes.rb
158
158
  - lib/generators/clearance/specs/USAGE
@@ -1,3 +0,0 @@
1
- class User < ActiveRecord::Base
2
- include Clearance::User
3
- end