clearance 1.8.1 → 1.9.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: 2509c5d9c52e522bf079988f49c43b6e34b66f9b
4
- data.tar.gz: bdda3e9606f883b26fc25bfa17dbcaeda830684e
3
+ metadata.gz: 44710933cf74cc5856e2b54f9635c9ce57a3bccb
4
+ data.tar.gz: 922d68715caba09515eaf38755a4eaacbe84e29a
5
5
  SHA512:
6
- metadata.gz: 67d001dd40baca13d399acb8184a741438ff5af9cd8fd992753469a956a61b4054a54051ff10426efab0b02b689625b0062887f929de9266a4ef3753292e9b12
7
- data.tar.gz: 93709396bcea3b6afa92a3e41216d248cbaf1d2524f88a04d8c00e2c594d18ad920ad6eef736ffc069fdd9db4e3afe8de4cd4d57c141ad08794aed2b74c82bd8
6
+ metadata.gz: 61008d6951aadac829026e458009b7eeeed0aa2fb7fbb814935656ab7e1ccec47bd81bab57430a50ea923d7fa9aee8ef94c418f432782898ec14b10499f1874c
7
+ data.tar.gz: 5bc31612cc5f8203052b0f8a7a6fee0c06da99a54f00890d2fd7f2a52b4746a885c46bc7dd24e675371f6fc689f3f5dfe7611faebfd4af04d310498028481e9e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clearance (1.8.1)
4
+ clearance (1.9.0)
5
5
  bcrypt
6
6
  email_validator (~> 1.4)
7
7
  rails (>= 3.1)
@@ -72,7 +72,7 @@ GEM
72
72
  factory_girl_rails (4.5.0)
73
73
  factory_girl (~> 4.5.0)
74
74
  railties (>= 3.0.0)
75
- globalid (0.3.2)
75
+ globalid (0.3.3)
76
76
  activesupport (>= 4.1.0)
77
77
  hike (1.2.3)
78
78
  i18n (0.7.0)
@@ -85,7 +85,7 @@ GEM
85
85
  mime-types (2.4.3)
86
86
  mini_portile (0.6.2)
87
87
  minitest (5.5.1)
88
- multi_json (1.10.1)
88
+ multi_json (1.11.0)
89
89
  nokogiri (1.6.6.2)
90
90
  mini_portile (~> 0.6.0)
91
91
  pry (0.10.1)
data/NEWS.md CHANGED
@@ -3,6 +3,23 @@
3
3
  The noteworthy changes for each Clearance version are included here. For a
4
4
  complete changelog, see the git history.
5
5
 
6
+ ## [1.9.0] - April 3, 2015
7
+
8
+ ### Added
9
+ - The change password mailer now produces a multipart message which includes a
10
+ text part along with the previously existing HTML part. To override the text
11
+ part, add `change_password.text.erb` alongside your `change_password.html.erb`
12
+ file.
13
+
14
+ ### Fixed
15
+ - Custom `user_model` configured in a Rails initializer will now be reloaded in
16
+ development mode.
17
+ - Change password template now contains "Change my password" link text to
18
+ address an issue linking the URL in some mail clients.
19
+
20
+
21
+ [1.9.0]: https://github.com/thoughtbot/clearance/compare/v1.8.1...v1.9.0
22
+
6
23
  ## [1.8.1] - March 3, 2015
7
24
 
8
25
  ### Security
@@ -13,6 +30,8 @@ complete changelog, see the git history.
13
30
  - All methods included by `Clearance::Controller` are now excluded from
14
31
  `action_methods`.
15
32
 
33
+ [1.8.1]: https://github.com/thoughtbot/clearance/compare/v1.8.0...v1.8.1
34
+
16
35
  ## [1.8.0] - January 23, 2015
17
36
 
18
37
  ### Added
data/README.md CHANGED
@@ -361,17 +361,39 @@ sign_in_as(user)
361
361
  sign_out
362
362
  ```
363
363
 
364
- ## Credits
364
+ ## Contributing
365
365
 
366
- ![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
366
+ Please see [CONTRIBUTING.md].
367
+ Thank you, [contributors]!
367
368
 
368
- Clearance is maintained by [thoughtbot, inc](http://thoughtbot.com/community)
369
- and [contributors](https://github.com/thoughtbot/clearance/contributors) like
370
- you. Thank you!
369
+ [CONTRIBUTING.md]: /CONTRIBUTING.md
370
+ [contributors]: https://github.com/thoughtbot/clearance/graphs/contributors
371
+
372
+ ## Need Help?
373
+
374
+ We offer 1-on-1 coaching. We can help you set up Clearance, write authentication
375
+ and authorization extensions for your application, and work out a permission and
376
+ role model which works for you. [Get in touch][coaching].
371
377
 
372
378
  ## License
373
379
 
374
380
  Clearance is copyright © 2009 thoughtbot. It is free software, and may be
375
- redistributed under the terms specified in the `LICENSE` file.
381
+ redistributed under the terms specified in the [`LICENSE`] file.
382
+
383
+ [`LICENSE`]: /LICENSE
384
+
385
+ ## About thoughtbot
376
386
 
387
+ ![thoughtbot](https://thoughtbot.com/logo.png)
388
+
389
+ Clearance is maintained and funded by thoughtbot, inc.
377
390
  The names and logos for thoughtbot are trademarks of thoughtbot, inc.
391
+
392
+ We love open source software!
393
+ See [our other projects][community],
394
+ [hire us][hire] to design, develop, and grow your product,
395
+ or get in touch about [1-on-1 coaching][coaching].
396
+
397
+ [community]: https://thoughtbot.com/community?utm_source=github
398
+ [hire]: https://thoughtbot.com/hire-us?utm_source=github
399
+ [coaching]: http://coaching.thoughtbot.com/rails/?utm_source=github
@@ -1,5 +1,8 @@
1
- <%= t(".opening") %>
1
+ <p><%= t(".opening") %></p>
2
2
 
3
- <%= edit_user_password_url(@user, token: @user.confirmation_token.html_safe) %>
3
+ <p>
4
+ <%= link_to t(".link_text", default: "Change my password"),
5
+ edit_user_password_url(@user, token: @user.confirmation_token.html_safe) %>
6
+ </p>
4
7
 
5
- <%= raw t(".closing") %>
8
+ <p><%= raw t(".closing") %></p>
@@ -0,0 +1,5 @@
1
+ <%= t(".opening") %></p>
2
+
3
+ <%= edit_user_password_url(@user, token: @user.confirmation_token.html_safe) %>
4
+
5
+ <%= raw t(".closing") %>
@@ -4,6 +4,7 @@ en:
4
4
  change_password:
5
5
  closing: If you didn't request this, ignore this email. Your password has
6
6
  not been changed.
7
+ link_text: Change my password
7
8
  opening: "Someone, hopefully you, requested we send you a link to change
8
9
  your password:"
9
10
  flashes:
@@ -1,6 +1,6 @@
1
1
  class CreateClearanceUsers < ActiveRecord::Migration
2
2
  def self.up
3
- create_table :users do |t|
3
+ create_table :users do |t|
4
4
  t.timestamps null: false
5
5
  t.string :email, null: false
6
6
  t.string :encrypted_password, limit: 128, null: false
@@ -9,7 +9,7 @@ gem "capybara", ">= 2.3"
9
9
  gem "database_cleaner", "~> 1.0"
10
10
  gem "factory_girl_rails", "~> 4.2"
11
11
  gem "rspec-rails", "~> 3.1"
12
- gem "shoulda-matchers", "~> 2.4"
12
+ gem "shoulda-matchers", "~> 2.8"
13
13
  gem "sqlite3", "~> 1.3"
14
14
  gem "timecop", "~> 0.6"
15
15
  gem "pry", :require => false
@@ -133,6 +133,17 @@ module Clearance
133
133
  def routes_enabled?
134
134
  @routes
135
135
  end
136
+
137
+ # Reloads the clearance user model class.
138
+ # This is called from the Clearance engine to reload the configured
139
+ # user class during each request while in development mode, but only once
140
+ # in production.
141
+ # @private
142
+ def reload_user_model
143
+ if @user_model.present?
144
+ @user_model = @user_model.to_s.constantize
145
+ end
146
+ end
136
147
  end
137
148
 
138
149
  # @return [Clearance::Configuration] Clearance's current configuration
@@ -1,12 +1,19 @@
1
- require 'clearance'
2
- require 'rails'
1
+ require "clearance"
2
+ require "rails"
3
3
 
4
4
  module Clearance
5
5
  class Engine < Rails::Engine
6
- initializer 'clearance.filter' do |app|
6
+ initializer "clearance.filter" do |app|
7
7
  app.config.filter_parameters += [:password, :token]
8
8
  end
9
9
 
10
- config.app_middleware.insert_after ActionDispatch::ParamsParser, Clearance::RackSession
10
+ config.app_middleware.insert_after(
11
+ ActionDispatch::ParamsParser,
12
+ Clearance::RackSession
13
+ )
14
+
15
+ config.to_prepare do
16
+ Clearance.configuration.reload_user_model
17
+ end
11
18
  end
12
19
  end
@@ -1,3 +1,3 @@
1
1
  module Clearance
2
- VERSION = "1.8.1"
2
+ VERSION = "1.9.0"
3
3
  end
@@ -47,7 +47,8 @@ feature "Visitor resets password" do
47
47
  message = ActionMailer::Base.deliveries.any? do |email|
48
48
  email.to == [recipient] &&
49
49
  email.subject =~ /#{subject}/i &&
50
- email.body =~ /#{body}/
50
+ email.html_part.body =~ /#{body}/
51
+ email.text_part.body =~ /#{body}/
51
52
  end
52
53
 
53
54
  expect(message).to be
@@ -162,4 +162,19 @@ describe Clearance::Configuration do
162
162
  expect(Clearance.configuration.routes_enabled?).to be false
163
163
  end
164
164
  end
165
+
166
+ describe "#reload_user_model" do
167
+ it "returns the user model class if one has already been configured" do
168
+ ConfiguredUser = Class.new
169
+ Clearance.configure { |config| config.user_model = ConfiguredUser }
170
+
171
+ expect(Clearance.configuration.reload_user_model).to eq ConfiguredUser
172
+ end
173
+
174
+ it "returns nil if the user_model has not been configured" do
175
+ Clearance.configuration = Clearance::Configuration.new
176
+
177
+ expect(Clearance.configuration.reload_user_model).to be_nil
178
+ end
179
+ end
165
180
  end
@@ -6,18 +6,19 @@ describe Clearance::Generators::ViewsGenerator, :generator do
6
6
  run_generator
7
7
 
8
8
  views = %w(
9
- clearance_mailer/change_password
10
- layouts/application
11
- passwords/create
12
- passwords/edit
13
- passwords/new
14
- sessions/_form
15
- sessions/new
16
- users/_form
17
- users/new
9
+ clearance_mailer/change_password.html.erb
10
+ clearance_mailer/change_password.text.erb
11
+ layouts/application.html.erb
12
+ passwords/create.html.erb
13
+ passwords/edit.html.erb
14
+ passwords/new.html.erb
15
+ sessions/_form.html.erb
16
+ sessions/new.html.erb
17
+ users/_form.html.erb
18
+ users/new.html.erb
18
19
  )
19
20
 
20
- view_files = views.map { |view| file("app/views/#{view}.html.erb") }
21
+ view_files = views.map { |view| file("app/views/#{view}") }
21
22
 
22
23
  view_files.each do |each|
23
24
  expect(each).to exist
@@ -19,18 +19,6 @@ describe ClearanceMailer do
19
19
  expect(email.to.first).to eq(user.email)
20
20
  end
21
21
 
22
- it "contains a link to edit the password" do
23
- user = create(:user)
24
- user.forgot_password!
25
- host = ActionMailer::Base.default_url_options[:host]
26
- link = "http://#{host}/users/#{user.id}/password/edit" \
27
- "?token=#{user.confirmation_token}"
28
-
29
- email = ClearanceMailer.change_password(user)
30
-
31
- expect(email.body.to_s).to include(link)
32
- end
33
-
34
22
  it "sets its subject" do
35
23
  user = create(:user)
36
24
  user.forgot_password!
@@ -40,25 +28,31 @@ describe ClearanceMailer do
40
28
  expect(email.subject).to include("Change your password")
41
29
  end
42
30
 
43
- it "contains opening text in the body" do
31
+ it "has html and plain text parts" do
44
32
  user = create(:user)
45
33
  user.forgot_password!
46
34
 
47
35
  email = ClearanceMailer.change_password(user)
48
36
 
49
- expect(email.body).to include(
50
- I18n.t("clearance_mailer.change_password.opening")
51
- )
37
+ expect(email.body.parts.length).to eq 2
38
+ expect(email.text_part).to be_present
39
+ expect(email.html_part).to be_present
52
40
  end
53
41
 
54
- it "contains closing text in the body" do
42
+ it "contains a link to edit the password" do
55
43
  user = create(:user)
56
44
  user.forgot_password!
45
+ host = ActionMailer::Base.default_url_options[:host]
46
+ link = "http://#{host}/users/#{user.id}/password/edit" \
47
+ "?token=#{user.confirmation_token}"
57
48
 
58
49
  email = ClearanceMailer.change_password(user)
59
50
 
60
- expect(email.body.raw_source).to include(
61
- I18n.t("clearance_mailer.change_password.closing")
51
+ expect(email.text_part.body).to include(link)
52
+ expect(email.html_part.body).to include(link)
53
+ expect(email.html_part.body).to have_css(
54
+ "a",
55
+ text: I18n.t("clearance_mailer.change_password.link_text")
62
56
  )
63
57
  end
64
58
  end
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.8.1
4
+ version: 1.9.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: 2015-03-03 00:00:00.000000000 Z
28
+ date: 2015-04-03 00:00:00.000000000 Z
29
29
  dependencies:
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bcrypt
@@ -94,6 +94,7 @@ files:
94
94
  - app/controllers/clearance/users_controller.rb
95
95
  - app/mailers/clearance_mailer.rb
96
96
  - app/views/clearance_mailer/change_password.html.erb
97
+ - app/views/clearance_mailer/change_password.text.erb
97
98
  - app/views/layouts/application.html.erb
98
99
  - app/views/passwords/create.html.erb
99
100
  - app/views/passwords/edit.html.erb
@@ -174,7 +175,6 @@ files:
174
175
  - spec/clearance/back_door_spec.rb
175
176
  - spec/clearance/constraints/signed_in_spec.rb
176
177
  - spec/clearance/constraints/signed_out_spec.rb
177
- - spec/clearance/contoller_spec.rb
178
178
  - spec/clearance/controller_spec.rb
179
179
  - spec/clearance/default_sign_in_guard_spec.rb
180
180
  - spec/clearance/rack_session_spec.rb
@@ -1,11 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Clearance::Controller", type: :controller do
4
- controller(ActionController::Base) do
5
- include Clearance::Controller
6
- end
7
-
8
- it "does not expose any action_methods" do
9
- expect(controller.action_methods).to be_empty
10
- end
11
- end