Skip to content
Browse files

Update Hash Syntax

* Update to ruby 1.9+ hash syntax
  • Loading branch information...
1 parent 1e27ada commit 9f61654371eee99123a15a3f22a3c842e34578ef @richrines richrines committed Feb 28, 2014
Showing with 128 additions and 128 deletions.
  1. +13 −13 app/controllers/clearance/passwords_controller.rb
  2. +4 −4 app/controllers/clearance/sessions_controller.rb
  3. +4 −4 app/controllers/clearance/users_controller.rb
  4. +4 −4 app/mailers/clearance_mailer.rb
  5. +5 −5 db/migrate/20110111224543_create_clearance_users.rb
  6. +10 −10 db/schema.rb
  7. +8 −8 features/step_definitions/configuration_steps.rb
  8. +1 −1 features/step_definitions/gem_file_steps.rb
  9. +1 −1 lib/clearance/password_strategies/bcrypt.rb
  10. +5 −5 lib/clearance/session.rb
  11. +1 −1 lib/clearance/testing/app/controllers/application_controller.rb
  12. +1 −1 lib/clearance/testing/application.rb
  13. +1 −1 lib/clearance/testing/config/routes.rb
  14. +2 −2 lib/clearance/user.rb
  15. +8 −8 lib/generators/clearance/install/install_generator.rb
  16. +5 −5 lib/generators/clearance/install/templates/db/migrate/create_users.rb
  17. +2 −2 lib/generators/clearance/specs/templates/features/clearance/visitor_signs_in_spec.rb
  18. +3 −3 lib/generators/clearance/specs/templates/features/clearance/visitor_updates_password_spec.rb
  19. +1 −1 lib/generators/clearance/specs/templates/support/features.rb
  20. +6 −6 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb
  21. +2 −2 spec/clearance/constraints/signed_in_spec.rb
  22. +1 −1 spec/clearance/rack_session_spec.rb
  23. +1 −1 spec/controllers/flashes_controller_spec.rb
  24. +5 −5 spec/controllers/forgeries_controller_spec.rb
  25. +16 −16 spec/controllers/passwords_controller_spec.rb
  26. +2 −2 spec/controllers/sessions_controller_spec.rb
  27. +4 −4 spec/controllers/users_controller_spec.rb
  28. +2 −2 spec/models/bcrypt_migration_from_sha1_spec.rb
  29. +4 −4 spec/models/bcrypt_spec.rb
  30. +5 −5 spec/models/user_spec.rb
  31. +1 −1 spec/support/request_with_remember_token.rb
View
26 app/controllers/clearance/passwords_controller.rb
@@ -1,25 +1,25 @@
require 'active_support/deprecation'
class Clearance::PasswordsController < ApplicationController
- skip_before_filter :authorize, :only => [:create, :edit, :new, :update]
- before_filter :forbid_missing_token, :only => [:edit, :update]
- before_filter :forbid_non_existent_user, :only => [:edit, :update]
+ skip_before_filter :authorize, only: [:create, :edit, :new, :update]
+ before_filter :forbid_missing_token, only: [:edit, :update]
+ before_filter :forbid_non_existent_user, only: [:edit, :update]
def create
if user = find_user_for_create
user.forgot_password!
deliver_email(user)
end
- render :template => 'passwords/create'
+ render template: 'passwords/create'
end
def edit
@user = find_user_for_edit
- render :template => 'passwords/edit'
+ render template: 'passwords/edit'
end
def new
- render :template => 'passwords/new'
+ render template: 'passwords/new'
end
def update
@@ -30,7 +30,7 @@ def update
redirect_to url_after_update
else
flash_failure_after_update
- render :template => 'passwords/edit'
+ render template: 'passwords/edit'
end
end
@@ -71,27 +71,27 @@ def find_user_for_update
def flash_failure_when_forbidden
flash.now[:notice] = translate(:forbidden,
- :scope => [:clearance, :controllers, :passwords],
- :default => t('flashes.failure_when_forbidden'))
+ scope: [:clearance, :controllers, :passwords],
+ default: t('flashes.failure_when_forbidden'))
end
def flash_failure_after_update
flash.now[:notice] = translate(:blank_password,
- :scope => [:clearance, :controllers, :passwords],
- :default => t('flashes.failure_after_update'))
+ scope: [:clearance, :controllers, :passwords],
+ default: t('flashes.failure_after_update'))
end
def forbid_missing_token
if params[:token].to_s.blank?
flash_failure_when_forbidden
- render :template => 'passwords/new'
+ render template: 'passwords/new'
end
end
def forbid_non_existent_user
unless find_user_by_id_and_confirmation_token
flash_failure_when_forbidden
- render :template => 'passwords/new'
+ render template: 'passwords/new'
end
end
View
8 app/controllers/clearance/sessions_controller.rb
@@ -1,6 +1,6 @@
class Clearance::SessionsController < ApplicationController
- skip_before_filter :authorize, :only => [:create, :new, :destroy]
- protect_from_forgery :except => :create
+ skip_before_filter :authorize, only: [:create, :new, :destroy]
+ protect_from_forgery except: :create
def create
@user = authenticate(params)
@@ -10,7 +10,7 @@ def create
redirect_back_or url_after_create
else
flash.now.notice = status.failure_message
- render :template => 'sessions/new', :status => :unauthorized
+ render template: 'sessions/new', status: :unauthorized
end
end
end
@@ -21,7 +21,7 @@ def destroy
end
def new
- render :template => 'sessions/new'
+ render template: 'sessions/new'
end
private
View
8 app/controllers/clearance/users_controller.rb
@@ -1,10 +1,10 @@
class Clearance::UsersController < ApplicationController
- skip_before_filter :authorize, :only => [:create, :new]
- before_filter :avoid_sign_in, :only => [:create, :new], :if => :signed_in?
+ skip_before_filter :authorize, only: [:create, :new]
+ before_filter :avoid_sign_in, only: [:create, :new], if: :signed_in?
def new
@user = user_from_params
- render :template => 'users/new'
+ render template: 'users/new'
end
def create
@@ -14,7 +14,7 @@ def create
sign_in @user
redirect_back_or url_after_create
else
- render :template => 'users/new'
+ render template: 'users/new'
end
end
View
8 app/mailers/clearance_mailer.rb
@@ -1,9 +1,9 @@
class ClearanceMailer < ActionMailer::Base
def change_password(user)
@user = user
- mail :from => Clearance.configuration.mailer_sender, :to => @user.email,
- :subject => I18n.t(:change_password,
- :scope => [:clearance, :models, :clearance_mailer],
- :default => 'Change your password')
+ mail from: Clearance.configuration.mailer_sender, to: @user.email,
+ subject: I18n.t(:change_password,
+ scope: [:clearance, :models, :clearance_mailer],
+ default: 'Change your password')
end
end
View
10 db/migrate/20110111224543_create_clearance_users.rb
@@ -1,11 +1,11 @@
class CreateClearanceUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
- t.timestamps :null => false
- t.string :email, :null => false
- t.string :encrypted_password, :limit => 128, :null => false
- t.string :confirmation_token, :limit => 128
- t.string :remember_token, :limit => 128, :null => false
+ t.timestamps null: false
+ t.string :email, null: false
+ t.string :encrypted_password, limit: 128, null: false
+ t.string :confirmation_token, limit: 128
+ t.string :remember_token, limit: 128, null: false
end
add_index :users, :email
View
20 db/schema.rb
@@ -11,18 +11,18 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110111224543) do
+ActiveRecord::Schema.define(version: 20110111224543) do
- create_table "users", :force => true do |t|
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "email", :null => false
- t.string "encrypted_password", :limit => 128, :null => false
- t.string "confirmation_token", :limit => 128
- t.string "remember_token", :limit => 128, :null => false
+ create_table "users", force: true do |t|
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "email", null: false
+ t.string "encrypted_password", limit: 128, null: false
+ t.string "confirmation_token", limit: 128
+ t.string "remember_token", limit: 128, null: false
end
- add_index "users", ["email"], :name => "index_users_on_email"
- add_index "users", ["remember_token"], :name => "index_users_on_remember_token"
+ add_index "users", ["email"], name: "index_users_on_email"
+ add_index "users", ["remember_token"], name: "index_users_on_remember_token"
end
View
16 features/step_definitions/configuration_steps.rb
@@ -31,7 +31,7 @@
end
When /^I configure ActionMailer to use "([^"]+)" as a host$/ do |host|
- mailer_config = "config.action_mailer.default_url_options = { :host => '#{host}' }"
+ mailer_config = "config.action_mailer.default_url_options = { host: '#{host}' }"
path = 'config/application.rb'
in_current_dir do
@@ -42,7 +42,7 @@
end
When /^I configure a root route$/ do
- route = "root :to => 'home#show'"
+ route = "root to: 'home#show'"
path = 'config/routes.rb'
in_current_dir do
@@ -54,7 +54,7 @@
write_file('app/controllers/home_controller.rb', <<-CONTROLLER)
class HomeController < ApplicationController
def show
- render :text => '', :layout => 'application'
+ render text: '', layout: 'application'
end
end
CONTROLLER
@@ -114,11 +114,11 @@ def self.down
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
- t.timestamps :null => false
- t.string :email, :null => false
- t.string :encrypted_password, :limit => 128, :null => false
- t.string :confirmation_token, :limit => 128
- t.string :remember_token, :limit => 128, :null => false
+ t.timestamps null: false
+ t.string :email, null: false
+ t.string :encrypted_password, limit: 128, null: false
+ t.string :confirmation_token, limit: 128
+ t.string :remember_token, limit: 128, null: false
end
add_index :users, :email
View
2 features/step_definitions/gem_file_steps.rb
@@ -3,7 +3,7 @@
end
When /^I add the "([^"]*)" gem from this project$/ do |gem_name|
- append_to_file('Gemfile', %{\ngem "#{gem_name}", :path => "../../.."\n})
+ append_to_file('Gemfile', %{\ngem "#{gem_name}", path: "../../.."\n})
end
When /^I remove the "([^"]*)" gem from this project$/ do |gem_name|
View
2 lib/clearance/password_strategies/bcrypt.rb
@@ -20,7 +20,7 @@ def password=(new_password)
private
def encrypt(password)
- ::BCrypt::Password.create(password, :cost => cost)
+ ::BCrypt::Password.create(password, cost: cost)
end
def cost
View
10 lib/clearance/session.rb
@@ -98,11 +98,11 @@ def initialize_sign_in_guard_stack
def cookie_value
value = {
- :expires => remember_token_expires,
- :httponly => Clearance.configuration.httponly,
- :path => Clearance.configuration.cookie_path,
- :secure => Clearance.configuration.secure_cookie,
- :value => remember_token
+ expires: remember_token_expires,
+ httponly: Clearance.configuration.httponly,
+ path: Clearance.configuration.cookie_path,
+ secure: Clearance.configuration.secure_cookie,
+ value: remember_token
}
if Clearance.configuration.cookie_domain.present?
View
2 lib/clearance/testing/app/controllers/application_controller.rb
@@ -2,6 +2,6 @@ class ApplicationController < ActionController::Base
include Clearance::Controller
def show
- render :text => '', :layout => 'application'
+ render text: '', layout: 'application'
end
end
View
2 lib/clearance/testing/application.rb
@@ -14,7 +14,7 @@ class Application < Rails::Application
config.action_controller.allow_forgery_protection = false
config.action_controller.perform_caching = false
config.action_dispatch.show_exceptions = false
- config.action_mailer.default_url_options = { :host => 'localhost' }
+ config.action_mailer.default_url_options = { host: 'localhost' }
config.action_mailer.delivery_method = :test
config.active_support.deprecation = :stderr
config.assets.enabled = true
View
2 lib/clearance/testing/config/routes.rb
@@ -1,3 +1,3 @@
Rails.application.routes.draw do
- root :to => "application#show"
+ root to: "application#show"
end
View
4 lib/clearance/user.rb
@@ -63,12 +63,12 @@ module Callbacks
def forgot_password!
generate_confirmation_token
- save :validate => false
+ save validate: false
end
def reset_remember_token!
generate_remember_token
- save :validate => false
+ save validate: false
end
def update_password(new_password)
View
16 lib/generators/clearance/install/install_generator.rb
@@ -48,8 +48,8 @@ def display_readme_in_terminal
def create_add_columns_migration
if migration_needed?
config = {
- :new_columns => new_columns,
- :new_indexes => new_indexes
+ new_columns: new_columns,
+ new_indexes: new_indexes
}
copy_migration('add_clearance_to_users.rb', config)
@@ -82,17 +82,17 @@ def migration_needed?
def new_columns
@new_columns ||= {
- :email => 't.string :email',
- :encrypted_password => 't.string :encrypted_password, :limit => 128',
- :confirmation_token => 't.string :confirmation_token, :limit => 128',
- :remember_token => 't.string :remember_token, :limit => 128'
+ email: 't.string :email',
+ encrypted_password: 't.string :encrypted_password, limit: 128',
+ confirmation_token: 't.string :confirmation_token, limit: 128',
+ remember_token: 't.string :remember_token, limit: 128'
}.reject { |column| existing_users_columns.include?(column.to_s) }
end
def new_indexes
@new_indexes ||= {
- :index_users_on_email => 'add_index :users, :email',
- :index_users_on_remember_token => 'add_index :users, :remember_token'
+ index_users_on_email: 'add_index :users, :email',
+ index_users_on_remember_token: 'add_index :users, :remember_token'
}.reject { |index| existing_users_indexes.include?(index.to_s) }
end
View
10 lib/generators/clearance/install/templates/db/migrate/create_users.rb
@@ -1,11 +1,11 @@
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
- t.timestamps :null => false
- t.string :email, :null => false
- t.string :encrypted_password, :limit => 128, :null => false
- t.string :confirmation_token, :limit => 128
- t.string :remember_token, :limit => 128, :null => false
+ t.timestamps null: false
+ t.string :email, null: false
+ t.string :encrypted_password, limit: 128, null: false
+ t.string :confirmation_token, limit: 128
+ t.string :remember_token, limit: 128, null: false
end
add_index :users, :email
View
4 lib/generators/clearance/specs/templates/features/clearance/visitor_signs_in_spec.rb
@@ -33,12 +33,12 @@
private
def create_user(email, password)
- create(:user, :email => email, :password => password)
+ create(:user, email: email, password: password)
end
def page_should_display_sign_in_error
page.body.should include(
- I18n.t('flashes.failure_after_create', :sign_up_path => sign_up_path)
+ I18n.t('flashes.failure_after_create', sign_up_path: sign_up_path)
)
end
end
View
6 lib/generators/clearance/specs/templates/features/clearance/visitor_updates_password_spec.rb
@@ -35,13 +35,13 @@ def update_password(user, password)
def visit_password_reset_page_for(user)
visit edit_user_password_path(
- :user_id => user,
- :token => user.confirmation_token
+ user_id: user,
+ token: user.confirmation_token
)
end
def change_password_to(password)
- fill_in 'password_reset_password', :with => password
+ fill_in 'password_reset_password', with: password
click_button I18n.t('helpers.submit.password_reset.submit')
end
end
View
2 lib/generators/clearance/specs/templates/support/features.rb
@@ -1,5 +1,5 @@
Dir[Rails.root.join('spec/support/features/*.rb')].each { |f| require f }
RSpec.configure do |config|
- config.include Features::ClearanceHelpers, :type => :feature
+ config.include Features::ClearanceHelpers, type: :feature
end
View
12 lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb
@@ -2,21 +2,21 @@ module Features
module ClearanceHelpers
def sign_up_with(email, password)
visit sign_up_path
- fill_in 'user_email', :with => email
- fill_in 'user_password', :with => password
+ fill_in 'user_email', with: email
+ fill_in 'user_password', with: password
click_button I18n.t('helpers.submit.user.create')
end
def sign_in_with(email, password)
visit sign_in_path
- fill_in 'session_email', :with => email
- fill_in 'session_password', :with => password
+ fill_in 'session_email', with: email
+ fill_in 'session_password', with: password
click_button I18n.t('helpers.submit.session.submit')
end
def signed_in_user
password = 'password'
- user = create(:user, :password => password)
+ user = create(:user, password: password)
sign_in_with user.email, password
user
end
@@ -42,7 +42,7 @@ def user_with_reset_password
def reset_password_for(email)
visit new_password_path
- fill_in 'password_email', :with => email
+ fill_in 'password_email', with: email
click_button I18n.t('helpers.submit.password.submit')
end
end
View
4 spec/clearance/constraints/signed_in_spec.rb
@@ -14,7 +14,7 @@
end
it 'yields a signed-in user to a provided block' do
- user = create(:user, :email => 'before@example.com')
+ user = create(:user, email: 'before@example.com')
signed_in_constraint = Clearance::Constraints::SignedIn.new do |user|
user.update_attribute :email, 'after@example.com'
@@ -25,7 +25,7 @@
end
it 'does not yield a user if they are not signed in' do
- user = create(:user, :email => 'before@example.com')
+ user = create(:user, email: 'before@example.com')
signed_in_constraint = Clearance::Constraints::SignedIn.new do |user|
user.update_attribute :email, 'after@example.com'
View
2 spec/clearance/rack_session_spec.rb
@@ -4,7 +4,7 @@
it 'injects a clearance session into the environment' do
expected_session = 'the session'
expected_session.stubs :add_cookie_to_headers
- Clearance::Session.stubs :new => expected_session
+ Clearance::Session.stubs new: expected_session
headers = { 'X-Roaring-Lobster' => 'Red' }
app = Rack::Builder.new do
View
2 spec/controllers/flashes_controller_spec.rb
@@ -9,7 +9,7 @@ def set_flash
end
def view_flash
- render :text => "<html><body>#{flash[:notice]}</body></html>"
+ render text: "<html><body>#{flash[:notice]}</body></html>"
end
end
View
10 spec/controllers/forgeries_controller_spec.rb
@@ -10,7 +10,7 @@ class ForgeriesController < ActionController::Base
self.allow_forgery_protection = true
def create
- redirect_to :action => 'index'
+ redirect_to action: 'index'
end
end
@@ -19,7 +19,7 @@ def create
before do
Rails.application.routes.draw do
resources :forgeries
- get '/sign_in' => 'clearance/sessions#new', :as => 'sign_in'
+ get '/sign_in' => 'clearance/sessions#new', as: 'sign_in'
end
@user = create(:user)
@@ -33,12 +33,12 @@ def create
end
it 'succeeds with authentic token' do
- post :create, :authenticity_token => 'golden-ticket'
- subject.should redirect_to(:action => 'index')
+ post :create, authenticity_token: 'golden-ticket'
+ subject.should redirect_to(action: 'index')
end
it 'fails with invalid token' do
- post :create, :authenticity_token => 'hax0r'
+ post :create, authenticity_token: 'hax0r'
subject.should deny_access
end
View
32 spec/controllers/passwords_controller_spec.rb
@@ -7,7 +7,7 @@
end
describe 'on GET to #new' do
- before { get :new, :user_id => @user.to_param }
+ before { get :new, user_id: @user.to_param }
it { should respond_with(:success) }
it { should render_template(:new) }
@@ -17,7 +17,7 @@
describe 'with correct email address' do
before do
ActionMailer::Base.deliveries.clear
- post :create, :password => { :email => @user.email }
+ post :create, password: { email: @user.email }
end
it 'should generate a token for the change your password email' do
@@ -35,7 +35,7 @@
describe 'with correct email address capitalized differently' do
before do
ActionMailer::Base.deliveries.clear
- post :create, :password => { :email => @user.email.upcase }
+ post :create, password: { email: @user.email.upcase }
end
it 'should generate a token for the change your password email' do
@@ -57,7 +57,7 @@
ActionMailer::Base.deliveries.clear
@user.reload.confirmation_token.should == @user.confirmation_token
- post :create, :password => { :email => email }
+ post :create, password: { email: email }
end
it 'should not generate a token for the change your password email' do
@@ -81,8 +81,8 @@
describe 'on GET to #edit with correct id and token' do
before do
- get :edit, :user_id => @user.to_param,
- :token => @user.confirmation_token
+ get :edit, user_id: @user.to_param,
+ token: @user.confirmation_token
end
it 'should find the user' do
@@ -95,7 +95,7 @@
describe 'on GET to #edit with correct id but blank token' do
before do
- get :edit, :user_id => @user.to_param, :token => ''
+ get :edit, user_id: @user.to_param, token: ''
end
it { should set_the_flash.to(/double check the URL/i).now }
@@ -104,7 +104,7 @@
describe 'on GET to #edit with correct id but no token' do
before do
- get :edit, :user_id => @user.to_param
+ get :edit, user_id: @user.to_param
end
it { should set_the_flash.to(/double check the URL/i).now }
@@ -116,8 +116,8 @@
@new_password = 'new_password'
@old_encrypted_password = @user.encrypted_password
- put :update, :user_id => @user, :token => @user.confirmation_token,
- :password_reset => { :password => @new_password }
+ put :update, user_id: @user, token: @user.confirmation_token,
+ password_reset: { password: @new_password }
@user.reload
end
@@ -138,8 +138,8 @@
describe 'on PUT to #update with blank password' do
before do
- put :update, :user_id => @user.to_param, :token => @user.confirmation_token,
- :password_reset => { :password => '' }
+ put :update, user_id: @user.to_param, token: @user.confirmation_token,
+ password_reset: { password: '' }
@user.reload
end
@@ -162,10 +162,10 @@
describe 'on PUT to #update with an empty token after the user sets a password' do
before do
- put :update, :user_id => @user.to_param, :token => @user.confirmation_token,
- :password_reset => { :password => 'good password' }
- put :update, :user_id => @user.to_param, :token => [nil],
- :password_reset => { :password => 'new password' }
+ put :update, user_id: @user.to_param, token: @user.confirmation_token,
+ password_reset: { password: 'good password' }
+ put :update, user_id: @user.to_param, token: [nil],
+ password_reset: { password: 'new password' }
end
it { should set_the_flash.to(/double check the URL/i).now }
View
4 spec/controllers/sessions_controller_spec.rb
@@ -26,7 +26,7 @@
before do
@user = create(:user)
@user.update_attribute :remember_token, 'old-token'
- post :create, :session => { :email => @user.email, :password => @user.password }
+ post :create, session: { email: @user.email, password: @user.password }
end
it { should redirect_to_url_after_create }
@@ -45,7 +45,7 @@
@user = create(:user)
@return_url = '/url_in_the_session'
@request.session[:return_to] = @return_url
- post :create, :session => { :email => @user.email, :password => @user.password }
+ post :create, session: { email: @user.email, password: @user.password }
end
it 'redirects to the return URL' do
View
8 spec/controllers/users_controller_spec.rb
@@ -15,7 +15,7 @@
describe 'on GET to #new with email' do
before do
@email = 'a@example.com'
- get :new, :user => { :email => @email }
+ get :new, user: { email: @email }
end
it 'should set assigned user email' do
@@ -27,7 +27,7 @@
before do
user_attributes = FactoryGirl.attributes_for(:user)
@old_user_count = User.count
- post :create, :user => user_attributes
+ post :create, user: user_attributes
end
it 'assigns a user' do
@@ -47,7 +47,7 @@
@old_user_count = User.count
@return_url = '/url_in_the_session'
@request.session[:return_to] = @return_url
- post :create, :user => user_attributes
+ post :create, user: user_attributes
end
it 'assigns a user' do
@@ -77,7 +77,7 @@
end
describe 'POST to create' do
- before { post :create, :user => {} }
+ before { post :create, user: {} }
it 'redirects to the home page' do
should redirect_to(Clearance.configuration.redirect_url)
View
4 spec/models/bcrypt_migration_from_sha1_spec.rb
@@ -15,7 +15,7 @@
before do
subject.salt = salt
subject.encrypted_password = Digest::SHA1.hexdigest("--#{salt}--#{password}--")
- BCrypt::Password.stubs :create => encrypted_password
+ BCrypt::Password.stubs create: encrypted_password
subject.password = password
end
@@ -41,7 +41,7 @@
before do
subject.salt = salt
subject.encrypted_password = sha1_hash
- subject.stubs :save => true
+ subject.stubs save: true
end
it 'is authenticated' do
View
8 spec/models/bcrypt_spec.rb
@@ -10,7 +10,7 @@
let(:encrypted_password) { stub('encrypted password') }
before do
- BCrypt::Password.stubs :create => encrypted_password
+ BCrypt::Password.stubs create: encrypted_password
end
it 'encrypts the password into encrypted_password' do
@@ -20,13 +20,13 @@
end
it 'encrypts with BCrypt using default cost in non test environments' do
- Rails.stubs :env => ActiveSupport::StringInquirer.new("production")
+ Rails.stubs env: ActiveSupport::StringInquirer.new("production")
subject.password = password
BCrypt::Password.should have_received(:create).with(
password,
- :cost => ::BCrypt::Engine::DEFAULT_COST
+ cost: ::BCrypt::Engine::DEFAULT_COST
)
end
@@ -35,7 +35,7 @@
BCrypt::Password.should have_received(:create).with(
password,
- :cost => ::BCrypt::Engine::MIN_COST
+ cost: ::BCrypt::Engine::MIN_COST
)
end
end
View
10 spec/models/user_spec.rb
@@ -18,7 +18,7 @@
it { should_not allow_value('foo;@example.com').for(:email) }
it 'stores email in down case and removes whitespace' do
- user = create(:user, :email => 'Jo hn.Do e @exa mp le.c om')
+ user = create(:user, email: 'Jo hn.Do e @exa mp le.c om')
user.email.should == 'john.doe@example.com'
end
end
@@ -84,10 +84,10 @@
end
it 'does not generate same remember token for users with same password at same time' do
- Time.stubs :now => Time.now
+ Time.stubs now: Time.now
password = 'secret'
- first_user = create(:user, :password => password)
- second_user = create(:user, :password => password)
+ first_user = create(:user, password: password)
+ second_user = create(:user, password: password)
second_user.remember_token.should_not == first_user.remember_token
end
@@ -158,7 +158,7 @@ def email_optional?
describe 'user factory' do
it 'should create a valid user with just an overridden password' do
- build(:user, :password => 'test').should be_valid
+ build(:user, password: 'test').should be_valid
end
end
View
2 spec/support/request_with_remember_token.rb
@@ -5,7 +5,7 @@ def request_with_remember_token(remember_token)
Clearance::Session::REMEMBER_TOKEN_COOKIE => remember_token
}
}
- env = { :clearance => Clearance::Session.new(cookies) }
+ env = { clearance: Clearance::Session.new(cookies) }
Rack::Request.new env
end

0 comments on commit 9f61654

Please sign in to comment.
Something went wrong with that request. Please try again.