From 782b53e288272c730e115e972de5e999c51ebe4e Mon Sep 17 00:00:00 2001 From: Grant Blakeman Date: Mon, 15 Dec 2014 13:23:00 -0700 Subject: [PATCH] update syntax --- Rakefile | 2 +- app/controllers/lockup/lockup_controller.rb | 6 +++--- app/views/lockup/lockup/unlock.html.erb | 10 +++++----- config/routes.rb | 2 +- lib/lockup.rb | 6 +++--- lib/lockup/engine.rb | 2 +- spec/dummy/app/controllers/application_controller.rb | 2 +- spec/dummy/app/models/post.rb | 6 +++--- spec/dummy/app/views/layouts/application.html.erb | 4 ++-- spec/dummy/config/routes.rb | 6 +++--- spec/features/access_restricted_spec.rb | 2 +- spec/spec_helper.rb | 4 ++-- 12 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Rakefile b/Rakefile index 3900d62..44846bb 100644 --- a/Rakefile +++ b/Rakefile @@ -18,4 +18,4 @@ require 'rspec/core/rake_task' desc "Run all specs in spec directory (excluding plugin specs)" RSpec::Core::RakeTask.new -task :default => :spec \ No newline at end of file +task default: :spec diff --git a/app/controllers/lockup/lockup_controller.rb b/app/controllers/lockup/lockup_controller.rb index bb59cfc..67c0bba 100644 --- a/app/controllers/lockup/lockup_controller.rb +++ b/app/controllers/lockup/lockup_controller.rb @@ -13,7 +13,7 @@ def unlock run_redirect end else - render :nothing => true + render nothing: true end elsif request.post? if params[:lockup].present? && params[:lockup].respond_to?(:'[]') @@ -26,7 +26,7 @@ def unlock @wrong = true end else - render :nothing => true + render nothing: true end end end @@ -34,7 +34,7 @@ def unlock private def set_cookie - cookies[:lockup] = { :value => @codeword.to_s.downcase, :expires => (Time.now + 5.years) } + cookies[:lockup] = { value: @codeword.to_s.downcase, expires: (Time.now + 5.years) } end def run_redirect diff --git a/app/views/lockup/lockup/unlock.html.erb b/app/views/lockup/lockup/unlock.html.erb index f151bef..de8fccf 100644 --- a/app/views/lockup/lockup/unlock.html.erb +++ b/app/views/lockup/lockup/unlock.html.erb @@ -6,11 +6,11 @@ <% end %> -<%= form_for :lockup, :url => { :action => 'unlock' } do |form| %> +<%= form_for :lockup, url: { action: 'unlock' } do |form| %> <% unless @wrong == true %> -

<%= form.password_field "codeword", :placeholder => "code word" %>

+

<%= form.password_field "codeword", placeholder: "code word" %>

<% else %> -

<%= form.password_field "codeword", :value => @codeword, :class => 'nope' %>

+

<%= form.password_field "codeword", value: @codeword, class: 'nope' %>

<% end %> <% if ENV["LOCKUP_HINT"].present? || ((Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && Rails.application.secrets.lockup_hint.present?) %> @@ -19,9 +19,9 @@ <% end %> <% if params[:return_to].present? %> - <%= form.hidden_field "return_to", :value => params[:return_to] %> + <%= form.hidden_field "return_to", value: params[:return_to] %> <% elsif @return_to.present? %> - <%= form.hidden_field "return_to", :value => @return_to %> + <%= form.hidden_field "return_to", value: @return_to %> <% end %>

<%= button_tag "Go" %>

diff --git a/config/routes.rb b/config/routes.rb index b1b9fa4..90f4a53 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ Lockup::Engine.routes.draw do - get 'unlock' => 'lockup#unlock', :as => 'unlock' + get 'unlock' => 'lockup#unlock', as: 'unlock' post 'unlock' => 'lockup#unlock' end diff --git a/lib/lockup.rb b/lib/lockup.rb index 7981ec5..874e478 100644 --- a/lib/lockup.rb +++ b/lib/lockup.rb @@ -4,7 +4,7 @@ module Lockup extend ActiveSupport::Concern included do - before_filter :check_for_lockup, :except => ["unlock"] + before_filter :check_for_lockup, except: ["unlock"] end private @@ -15,10 +15,10 @@ def check_for_lockup if cookies[:lockup] == ENV["LOCKUP_CODEWORD"].to_s.downcase || ((Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1) && cookies[:lockup] == Rails.application.secrets.lockup_codeword.to_s.downcase) return else - redirect_to lockup.unlock_path(:return_to => request.fullpath.split('?lockup_codeword')[0], :lockup_codeword => params[:lockup_codeword]) + redirect_to lockup.unlock_path(return_to: request.fullpath.split('?lockup_codeword')[0], lockup_codeword: params[:lockup_codeword]) end else - redirect_to lockup.unlock_path(:return_to => request.fullpath.split('?lockup_codeword')[0], :lockup_codeword => params[:lockup_codeword]) + redirect_to lockup.unlock_path(return_to: request.fullpath.split('?lockup_codeword')[0], lockup_codeword: params[:lockup_codeword]) end end end diff --git a/lib/lockup/engine.rb b/lib/lockup/engine.rb index 7afc68e..7814bd0 100644 --- a/lib/lockup/engine.rb +++ b/lib/lockup/engine.rb @@ -3,7 +3,7 @@ class Engine < ::Rails::Engine isolate_namespace Lockup config.generators do |g| - g.test_framework :rspec, :fixture => false + g.test_framework :rspec, fixture: false g.assets false g.helper false end diff --git a/spec/dummy/app/controllers/application_controller.rb b/spec/dummy/app/controllers/application_controller.rb index e2f9409..a61cd9d 100644 --- a/spec/dummy/app/controllers/application_controller.rb +++ b/spec/dummy/app/controllers/application_controller.rb @@ -4,6 +4,6 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception def render_404 - render :file => Rails.root.join('public', '404.html'), :status => 404 + render file: Rails.root.join('public', '404.html'), status: 404 end end diff --git a/spec/dummy/app/models/post.rb b/spec/dummy/app/models/post.rb index 774264f..5b645b9 100644 --- a/spec/dummy/app/models/post.rb +++ b/spec/dummy/app/models/post.rb @@ -4,8 +4,8 @@ class Post attr_accessor :id, :title, :body POSTS = [ - {:id => 1, :title => 'Title One', :body => 'Body One'}, - {:id => 2, :title => 'Title Two', :body => 'Body Two'} + {id: 1, title: 'Title One', body: 'Body One'}, + {id: 2, title: 'Title Two', body: 'Body Two'} ] def self.all @@ -20,4 +20,4 @@ def to_param id end -end \ No newline at end of file +end diff --git a/spec/dummy/app/views/layouts/application.html.erb b/spec/dummy/app/views/layouts/application.html.erb index 670d187..f7c312d 100644 --- a/spec/dummy/app/views/layouts/application.html.erb +++ b/spec/dummy/app/views/layouts/application.html.erb @@ -2,8 +2,8 @@ Dummy - <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> - <%= javascript_include_tag "application", "data-turbolinks-track" => true %> + <%= stylesheet_link_tag "application", media: "all", data: {turbolinks_track: true} %> + <%= javascript_include_tag "application", data: {turbolinks_track: true} %> <%= csrf_meta_tags %> diff --git a/spec/dummy/config/routes.rb b/spec/dummy/config/routes.rb index 671355d..5b76c3c 100644 --- a/spec/dummy/config/routes.rb +++ b/spec/dummy/config/routes.rb @@ -1,10 +1,10 @@ Rails.application.routes.draw do - mount Lockup::Engine, :at => '/lockup', :as => 'lockup' + mount Lockup::Engine, at: '/lockup', as: 'lockup' - resources :posts, :only => [:index, :show] + resources :posts, only: [:index, :show] # this makes tests fail with endless redirect loop b/c it is before lockup routes # catch all route b/c Rails `rescue_from` doesn't catch ActionController::RoutingError - match '*path', :via => :all, :to => 'application#render_404' + match '*path', via: :all, to: 'application#render_404' end diff --git a/spec/features/access_restricted_spec.rb b/spec/features/access_restricted_spec.rb index 04e29c1..6ae9d0a 100644 --- a/spec/features/access_restricted_spec.rb +++ b/spec/features/access_restricted_spec.rb @@ -4,7 +4,7 @@ describe "Accessing a page in the application" do def enter_code_word(code_word) - fill_in 'code word', :with => code_word + fill_in 'code word', with: code_word click_on 'Go' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 738850e..a939968 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,5 +12,5 @@ config.mock_with :rspec config.infer_base_class_for_anonymous_controllers = false config.order = "random" - config.include UserAgentHelper, :type => :feature -end \ No newline at end of file + config.include UserAgentHelper, type: :feature +end