clearance 1.3.0 → 1.4.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: bd3a11e206f30f451d54a86f708384fa70347724
4
- data.tar.gz: e5b0a43cb7152178ca45351686e151bc1a01dd69
3
+ metadata.gz: 5b85f77997240efd1427372cbc15a24e658acffd
4
+ data.tar.gz: 5ca6fb26641354dbc90fb1415cc9b8a1a00c0f3e
5
5
  SHA512:
6
- metadata.gz: 72f6f66e1473b220645672aa7fa324544f71217e298f05e85f545e898ba92eb1f7c2e056ed518c136aa5d2dbeda3ad313e72de3bb91f19cc21f929df2487860a
7
- data.tar.gz: de1749e0f05fa69744648c32c6358c0adf4a14da4c9c9dabeec723d847c2cd7321c590d8a1c7f1154106e09d7e113d85bbb97acda2e23142ce61ba2a12b49576
6
+ metadata.gz: 98db9d506f81c47c7c4ca09a11d7e5bef8265460becde5e73959c342629b43f2d019a047d12cece15b8ffc31ba10ca20a0f15f5026ec4ccc41b7c056384afc6b
7
+ data.tar.gz: 6ef805fc817c6aedc195042aa15b473f16ed3b195fa180762e1365e7fd32dad57d957b8432617ef98fbbb72907d57584ad497e23a9bd948816d40f54f9667a22
data/.hound.yml ADDED
@@ -0,0 +1,2 @@
1
+ StringLiterals:
2
+ EnforcedStyle: single_quotes
data/.travis.yml CHANGED
@@ -4,18 +4,20 @@ language:
4
4
  rvm:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
- - 2.1.0
8
-
9
- before_install:
10
- - "sudo apt-get install ca-certificates"
11
- - "gem update --system"
7
+ - 2.1.1
12
8
 
13
9
  install:
14
10
  - "travis_retry bundle install"
11
+ - "bundle exec appraisal generate"
12
+ - "travis_retry bundle exec appraisal install"
15
13
 
16
14
  before_script:
17
15
  - "bundle exec rake db:migrate"
18
16
 
17
+ script:
18
+ - "bundle exec appraisal rake"
19
+
19
20
  branches:
20
21
  only:
21
22
  - master
23
+ - 2.0
data/Appraisals CHANGED
@@ -9,13 +9,13 @@ end
9
9
 
10
10
  appraise 'rails4.0' do
11
11
  gem 'jbuilder', '~> 1.2'
12
- gem 'rails', '~> 4.0.3'
12
+ gem 'rails', '~> 4.0.4'
13
13
  gem 'sdoc'
14
14
  end
15
15
 
16
16
  appraise 'rails4.1' do
17
17
  gem 'jbuilder', '~> 2.0'
18
- gem 'rails', '~> 4.1.0.rc1'
18
+ gem 'rails', '~> 4.1.0'
19
19
  gem 'sdoc'
20
20
  gem 'spring'
21
21
  end
data/CONTRIBUTING.md CHANGED
@@ -1,12 +1,12 @@
1
1
  We love pull requests. Here's a quick guide:
2
2
 
3
- 1. Fork the repo.
3
+ 1. Fork the repo and `bundle install`
4
4
 
5
5
  2. Set up Appraisal, which helps us test against multiple Rails versions:
6
- `rake appraisal:install`.
6
+ `bundle exec appraisal install`
7
7
 
8
8
  3. Run the tests. We only take pull requests with passing tests, and it's great
9
- to know that you have a clean slate: `rake`
9
+ to know that you have a clean slate: `bundle exec appraisal rake`
10
10
 
11
11
  4. Add a test for your change. Only refactoring and documentation changes
12
12
  require no new tests. If you are adding functionality or fixing a
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'appraisal', '~> 0.5'
5
+ gem 'appraisal', '~> 1.0'
6
6
  gem 'aruba', '~> 0.5'
7
7
  gem 'bourne', '~> 1.4'
8
8
  gem 'bundler', '~> 1.3'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clearance (1.3.0)
4
+ clearance (1.4.0)
5
5
  bcrypt
6
6
  email_validator (~> 1.4)
7
7
  rails (>= 3.1)
@@ -33,9 +33,10 @@ GEM
33
33
  multi_json (~> 1.3)
34
34
  thread_safe (~> 0.1)
35
35
  tzinfo (~> 0.3.37)
36
- appraisal (0.5.2)
36
+ appraisal (1.0.0)
37
37
  bundler
38
38
  rake
39
+ thor (>= 0.14.0)
39
40
  arel (4.0.1)
40
41
  aruba (0.5.4)
41
42
  childprocess (>= 0.3.6)
@@ -111,7 +112,7 @@ GEM
111
112
  activesupport (= 4.0.2)
112
113
  rake (>= 0.8.7)
113
114
  thor (>= 0.18.1, < 2.0)
114
- rake (10.1.1)
115
+ rake (10.2.2)
115
116
  rspec-core (2.14.7)
116
117
  rspec-expectations (2.14.4)
117
118
  diff-lcs (>= 1.1.3, < 2.0)
@@ -159,7 +160,7 @@ PLATFORMS
159
160
  ruby
160
161
 
161
162
  DEPENDENCIES
162
- appraisal (~> 0.5)
163
+ appraisal (~> 1.0)
163
164
  aruba (~> 0.5)
164
165
  bourne (~> 1.4)
165
166
  bundler (~> 1.3)
data/NEWS.md CHANGED
@@ -1,5 +1,16 @@
1
1
  Thank you to all the [contributors](https://github.com/thoughtbot/clearance/graphs/contributors)!
2
2
 
3
+ New for 1.4.0 (July 18, 2014)
4
+ * The sign out link in the default application layout has been replaced with a
5
+ semantically correct sign out button. This also removes an unnecessary
6
+ JavaScript dependency.
7
+ * Clearance now uses `original_fullpath` when redirecting to a saved URL after
8
+ login. This should improve the behavior in mounted engines.
9
+ * `user_params` method was added to `Clearance::UsersController` which provides
10
+ a convenient place to override the parameters used when creating users.
11
+ * Controllers now inherit from `Clearance::BaseController` to allow for easily
12
+ adding behavior to all of them.
13
+
3
14
  New for 1.3.0 (March 14, 2014)
4
15
  * Installing Clearance with an existing User model will now create a migration
5
16
  that includes adding remember tokens to all existing user records.
data/README.md CHANGED
@@ -3,7 +3,6 @@ Clearance
3
3
 
4
4
  [![Build Status](https://secure.travis-ci.org/thoughtbot/clearance.png)](http://travis-ci.org/thoughtbot/clearance?branch=master)
5
5
  [![Code Climate](https://codeclimate.com/github/thoughtbot/clearance.png)](https://codeclimate.com/github/thoughtbot/clearance)
6
- [![Dependency Status](https://gemnasium.com/thoughtbot/clearance.png)](https://gemnasium.com/thoughtbot/clearance)
7
6
 
8
7
  Rails authentication with email & password.
9
8
 
@@ -80,7 +79,7 @@ helpers. For example:
80
79
  ```haml
81
80
  - if signed_in?
82
81
  = current_user.email
83
- = link_to 'Sign out', sign_out_path, method: :delete
82
+ = button_to 'Sign out', sign_out_path, method: :delete
84
83
  - else
85
84
  = link_to 'Sign in', sign_in_path
86
85
  ```
@@ -174,6 +173,8 @@ class SessionsController < Clearance::SessionsController
174
173
  class UsersController < Clearance::UsersController
175
174
  ```
176
175
 
176
+ Don't forget to override routes to your new controllers!
177
+
177
178
  Then, override public methods:
178
179
 
179
180
  passwords#create
@@ -204,6 +205,7 @@ Or, override private methods:
204
205
  users#flash_failure_after_create
205
206
  users#url_after_create
206
207
  users#user_from_params
208
+ users#user_params
207
209
 
208
210
  All of these controller methods redirect to `'/'` by default:
209
211
 
data/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
-
3
2
  require 'rubygems'
4
3
  require 'bundler/setup'
5
4
  require 'bundler/gem_tasks'
@@ -7,22 +6,19 @@ require 'bundler/gem_tasks'
7
6
  require 'rake'
8
7
  require 'cucumber/rake/task'
9
8
  require 'rspec/core/rake_task'
10
- require 'appraisal'
11
-
12
9
  require 'clearance/testing/application'
13
- Clearance::Testing::Application.load_tasks
14
10
 
15
11
  desc 'Default'
16
12
  task :default => [:all]
17
13
 
18
- desc 'Test the engine under all supported Rails versions'
19
- task :all => ['appraisal:install'] do |t|
20
- exec 'rake appraisal spec cucumber'
21
- end
14
+ desc 'Run the specs and cucumber featrues'
15
+ task :all => [:spec, :cucumber]
22
16
 
23
- RSpec::Core::RakeTask.new(:spec)
17
+ Clearance::Testing::Application.load_tasks
24
18
 
25
19
  Cucumber::Rake::Task.new(:cucumber) do |t|
26
20
  t.fork = false
27
21
  t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
28
22
  end
23
+
24
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,2 @@
1
+ class Clearance::BaseController < ApplicationController
2
+ end
@@ -1,6 +1,6 @@
1
1
  require 'active_support/deprecation'
2
2
 
3
- class Clearance::PasswordsController < ApplicationController
3
+ class Clearance::PasswordsController < Clearance::BaseController
4
4
  skip_before_filter :authorize, only: [:create, :edit, :new, :update]
5
5
  before_filter :forbid_missing_token, only: [:edit, :update]
6
6
  before_filter :forbid_non_existent_user, only: [:edit, :update]
@@ -1,4 +1,4 @@
1
- class Clearance::SessionsController < ApplicationController
1
+ class Clearance::SessionsController < Clearance::BaseController
2
2
  skip_before_filter :authorize, only: [:create, :new, :destroy]
3
3
  protect_from_forgery except: :create
4
4
 
@@ -1,4 +1,4 @@
1
- class Clearance::UsersController < ApplicationController
1
+ class Clearance::UsersController < Clearance::BaseController
2
2
  skip_before_filter :authorize, only: [:create, :new]
3
3
  before_filter :avoid_sign_in, only: [:create, :new], if: :signed_in?
4
4
 
@@ -29,7 +29,6 @@ class Clearance::UsersController < ApplicationController
29
29
  end
30
30
 
31
31
  def user_from_params
32
- user_params = params[:user] || Hash.new
33
32
  email = user_params.delete(:email)
34
33
  password = user_params.delete(:password)
35
34
 
@@ -38,4 +37,8 @@ class Clearance::UsersController < ApplicationController
38
37
  user.password = password
39
38
  end
40
39
  end
40
+
41
+ def user_params
42
+ params[:user] || Hash.new
43
+ end
41
44
  end
@@ -5,17 +5,17 @@
5
5
  <%= csrf_meta_tag %>
6
6
  </head>
7
7
  <body>
8
- <div id='header'>
8
+ <div id="header">
9
9
  <% if signed_in? -%>
10
- <%= link_to t('.sign_out'), sign_out_path, :method => :delete %>
10
+ <%= button_to t('.sign_out'), sign_out_path, :method => :delete %>
11
11
  <% else -%>
12
12
  <%= link_to t('.sign_in'), sign_in_path %>
13
13
  <% end -%>
14
14
  </div>
15
15
 
16
- <div id='flash'>
16
+ <div id="flash">
17
17
  <% flash.each do |key, value| -%>
18
- <div id='flash_<%= key %>'><%=h value %></div>
18
+ <div id="flash_<%= key %>"><%=h value %></div>
19
19
  <% end %>
20
20
  </div>
21
21
 
@@ -1,4 +1,4 @@
1
- <div id='clearance' class='password-reset'>
1
+ <div id="clearance" class="password-reset">
2
2
  <h2><%= t '.title' %></h2>
3
3
 
4
4
  <p><%= t '.description' %></p>
@@ -6,12 +6,12 @@
6
6
  <%= form_for :password_reset,
7
7
  :url => user_password_path(@user, :token => @user.confirmation_token),
8
8
  :html => { :method => :put } do |form| %>
9
- <div class='password-field'>
9
+ <div class="password-field">
10
10
  <%= form.label :password %>
11
11
  <%= form.password_field :password %>
12
12
  </div>
13
13
 
14
- <div class='submit-field'>
14
+ <div class="submit-field">
15
15
  <%= form.submit %>
16
16
  </div>
17
17
  <% end %>
@@ -1,15 +1,15 @@
1
- <div id='clearance' class='password-reset'>
1
+ <div id="clearance" class="password-reset">
2
2
  <h2><%= t '.title' %></h2>
3
3
 
4
4
  <p><%= t '.description' %></p>
5
5
 
6
6
  <%= form_for :password, :url => passwords_path do |form| %>
7
- <div class='text-field'>
7
+ <div class="text-field">
8
8
  <%= form.label :email %>
9
9
  <%= form.text_field :email, :type => 'email' %>
10
10
  </div>
11
11
 
12
- <div class='submit-field'>
12
+ <div class="submit-field">
13
13
  <%= form.submit %>
14
14
  </div>
15
15
  <% end %>
@@ -1,19 +1,19 @@
1
1
  <%= form_for :session, :url => session_path do |form| %>
2
- <div class='text-field'>
2
+ <div class="text-field">
3
3
  <%= form.label :email %>
4
4
  <%= form.text_field :email, :type => 'email' %>
5
5
  </div>
6
6
 
7
- <div class='password-field'>
7
+ <div class="password-field">
8
8
  <%= form.label :password %>
9
9
  <%= form.password_field :password %>
10
10
  </div>
11
11
 
12
- <div class='submit-field'>
12
+ <div class="submit-field">
13
13
  <%= form.submit %>
14
14
  </div>
15
15
 
16
- <div class='other-links'>
16
+ <div class="other-links">
17
17
  <% if Clearance.configuration.allow_sign_up? %>
18
18
  <%= link_to t('.sign_up'), sign_up_path %>
19
19
  <% end %>
@@ -1,4 +1,4 @@
1
- <div id='clearance' class='sign-in'>
1
+ <div id="clearance" class="sign-in">
2
2
  <h2><%= t '.title' %></h2>
3
3
 
4
4
  <%= render :partial => '/sessions/form' %>
@@ -1,9 +1,9 @@
1
- <div class='text-field'>
1
+ <div class="text-field">
2
2
  <%= form.label :email %>
3
3
  <%= form.text_field :email, :type => 'email' %>
4
4
  </div>
5
5
 
6
- <div class='password-field'>
6
+ <div class="password-field">
7
7
  <%= form.label :password %>
8
8
  <%= form.password_field :password %>
9
9
  </div>
@@ -1,14 +1,14 @@
1
- <div id='clearance' class='sign-up'>
1
+ <div id="clearance" class="sign-up">
2
2
  <h2><%= t('.title') %></h2>
3
3
 
4
4
  <%= form_for @user do |form| %>
5
5
  <%= render :partial => '/users/form', :object => form %>
6
6
 
7
- <div class='submit-field'>
7
+ <div class="submit-field">
8
8
  <%= form.submit %>
9
9
  </div>
10
10
 
11
- <div class='other-links'>
11
+ <div class="other-links">
12
12
  <%= link_to t('.sign_in'), sign_in_path %>
13
13
  </div>
14
14
  <% end %>
@@ -41,7 +41,7 @@ module Clearance
41
41
 
42
42
  def store_location
43
43
  if request.get?
44
- session[:return_to] = request.fullpath
44
+ session[:return_to] = request.original_fullpath
45
45
  end
46
46
  end
47
47
 
@@ -4,7 +4,6 @@ module Clearance
4
4
  autoload :BCryptMigrationFromSHA1,
5
5
  'clearance/password_strategies/bcrypt_migration_from_sha1'
6
6
  autoload :Blowfish, 'clearance/password_strategies/blowfish'
7
- autoload :Fake, 'clearance/password_strategies/fake'
8
7
  autoload :SHA1, 'clearance/password_strategies/sha1'
9
8
  end
10
9
  end
@@ -20,6 +20,7 @@ module Clearance
20
20
 
21
21
  def sign_in_as(user)
22
22
  @controller.sign_in user
23
+ user
23
24
  end
24
25
 
25
26
  def sign_out
@@ -1,3 +1,3 @@
1
1
  module Clearance
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -6,7 +6,7 @@ Next steps:
6
6
  1. Configure the mailer to create full URLs in emails:
7
7
 
8
8
  # config/environments/{development,test}.rb
9
- config.action_mailer.default_url_options = { :host => 'localhost:3000' }
9
+ config.action_mailer.default_url_options = { host: 'localhost:3000' }
10
10
 
11
11
  In production it should be your app's domain name.
12
12
 
@@ -14,7 +14,7 @@ Next steps:
14
14
 
15
15
  <% if signed_in? %>
16
16
  Signed in as: <%= current_user.email %>
17
- <%= link_to 'Sign out', sign_out_path, :method => :delete %>
17
+ <%= button_to 'Sign out', sign_out_path, method: :delete %>
18
18
  <% else %>
19
19
  <%= link_to 'Sign in', sign_in_path %>
20
20
  <% end %>
@@ -23,11 +23,11 @@ module Features
23
23
 
24
24
  def user_should_be_signed_in
25
25
  visit root_path
26
- page.should have_content I18n.t('layouts.application.sign_out')
26
+ page.should have_button I18n.t('layouts.application.sign_out')
27
27
  end
28
28
 
29
29
  def sign_out
30
- click_link I18n.t('layouts.application.sign_out')
30
+ click_button I18n.t('layouts.application.sign_out')
31
31
  end
32
32
 
33
33
  def user_should_be_signed_out
@@ -24,4 +24,14 @@ describe Clearance::Testing::Helpers do
24
24
  expect(FactoryGirl).to have_received(:create).with(:my_user_model)
25
25
  end
26
26
  end
27
+
28
+ describe '#sign_in_as' do
29
+ it 'returns the user if signed in successfully' do
30
+ user = build(:user)
31
+
32
+ returned_user = TestClass.new.sign_in_as user
33
+
34
+ expect(returned_user).to eq user
35
+ end
36
+ end
27
37
  end
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Clearance::PasswordsController do
4
+ it { should be_a Clearance::BaseController }
5
+
4
6
  describe 'a signed up user' do
5
7
  before do
6
8
  @user = create(:user)
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Clearance::SessionsController do
4
+ it { should be_a Clearance::BaseController }
5
+
4
6
  describe 'on GET to /sessions/new' do
5
7
  before { get :new }
6
8
 
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Clearance::UsersController do
4
+ it { should be_a Clearance::BaseController }
5
+
4
6
  describe 'when signed out' do
5
7
  before { sign_out }
6
8
 
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.3.0
4
+ version: 1.4.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: 2014-03-14 00:00:00.000000000 Z
28
+ date: 2014-07-18 00:00:00.000000000 Z
29
29
  dependencies:
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bcrypt
@@ -78,6 +78,7 @@ extra_rdoc_files:
78
78
  - README.md
79
79
  files:
80
80
  - ".gitignore"
81
+ - ".hound.yml"
81
82
  - ".rspec"
82
83
  - ".travis.yml"
83
84
  - Appraisals
@@ -88,6 +89,7 @@ files:
88
89
  - NEWS.md
89
90
  - README.md
90
91
  - Rakefile
92
+ - app/controllers/clearance/base_controller.rb
91
93
  - app/controllers/clearance/passwords_controller.rb
92
94
  - app/controllers/clearance/sessions_controller.rb
93
95
  - app/controllers/clearance/users_controller.rb
@@ -220,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
222
  version: '0'
221
223
  requirements: []
222
224
  rubyforge_project:
223
- rubygems_version: 2.2.0
225
+ rubygems_version: 2.2.2
224
226
  signing_key:
225
227
  specification_version: 4
226
228
  summary: Rails authentication & authorization with email & password.