Permalink
Browse files

Update Hash Syntax

* Update to ruby 1.9+ hash syntax
  • Loading branch information...
1 parent 1e27ada commit 9f61654371eee99123a15a3f22a3c842e34578ef @richrines richrines committed Mar 1, 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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|
@@ -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
@@ -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?
@@ -2,6 +2,6 @@ class ApplicationController < ActionController::Base
include Clearance::Controller
def show
- render :text => '', :layout => 'application'
+ render text: '', layout: 'application'
end
end
@@ -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
@@ -1,3 +1,3 @@
Rails.application.routes.draw do
- root :to => "application#show"
+ root to: "application#show"
end
View
@@ -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)
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Oops, something went wrong.

0 comments on commit 9f61654

Please sign in to comment.