From ad1397187201fb912fc44b7a3438ac4cf2ce0bef Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Fri, 16 Jul 2021 11:14:15 -0500 Subject: [PATCH] Standard RB --- .rubocop.yml | 13 ------ .tool-versions | 2 +- Gemfile | 26 +++++------ Rakefile | 2 +- app/controllers/photos_controller.rb | 4 +- app/helpers/application_helper.rb | 4 +- app/helpers/photos_helper.rb | 2 +- app/mailers/notifier.rb | 4 +- config.ru | 2 +- config/application.rb | 14 +++--- config/boot.rb | 6 +-- config/environment.rb | 2 +- config/environments/development.rb | 3 +- config/environments/production.rb | 17 ++++--- config/environments/test.rb | 2 +- config/initializers/assets.rb | 4 +- config/initializers/dragonfly.rb | 44 +++++++++---------- config/initializers/session_store.rb | 2 +- config/initializers/simple_form.rb | 12 ++--- config/puma.rb | 12 ++--- config/routes.rb | 8 ++-- db/migrate/20101006095457_create_photos.rb | 4 +- .../20101008101157_add_photo_to_category.rb | 4 +- .../20101008103053_add_details_to_photo.rb | 8 ++-- db/migrate/20101008122736_add_sort_orders.rb | 4 +- .../20101008172319_move_to_many_to_many.rb | 2 +- .../20101011133558_create_admin_users.rb | 18 ++++---- db/migrate/20101013165208_photo_showcase.rb | 4 +- .../20101202155552_add_enabled_to_photos.rb | 2 +- .../20101215172105_add_taken_date_to_photo.rb | 2 +- ...20101216180143_add_view_count_to_photos.rb | 2 +- .../20111013085444_add_sessions_table.rb | 2 +- .../20111030163656_remove_admin_users.rb | 16 +++---- ...0111030164012_create_devise_admin_users.rb | 16 +++---- ...0151022110802_remove_devise_admin_users.rb | 16 +++---- script/heap_dump.rb | 6 +-- spec/controllers/contacts_controller_spec.rb | 4 +- spec/controllers/pages_controller_spec.rb | 4 +- spec/controllers/views_controller_spec.rb | 4 +- spec/models/contact_spec.rb | 4 +- spec/spec_helper.rb | 16 +++---- spec/support/ajax.rb | 2 +- 42 files changed, 154 insertions(+), 171 deletions(-) delete mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml deleted file mode 100644 index 087e03e..0000000 --- a/.rubocop.yml +++ /dev/null @@ -1,13 +0,0 @@ -Documentation: - Enabled: false - -AllCops: - Include: - - '**/Rakefile' - - '**/config.ru' - Exclude: - - 'db/**/*' - - 'config/**/*' - - 'script/**/*' - - 'bin/**/*' - - !ruby/regexp /old_and_unused\.rb$/ diff --git a/.tool-versions b/.tool-versions index 1c44dd0..9eb38ed 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -ruby 2.6.6 +ruby 2.7.2 diff --git a/Gemfile b/Gemfile index f403013..84bfb33 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,12 @@ source "http://rubygems.org" -ruby "2.6.6" +ruby "2.7.2" -gem "dotenv-rails", groups: [:development, :test] +gem "dotenv-rails", groups: %i[development test] gem "rails", "~> 5.1" # Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' +# gem "rails", :git => "git://github.com/rails/rails.git" gem "administrate" gem "administrate-field-image" @@ -33,28 +33,28 @@ gem "unf" # put test-only gems in this group so their generators # and rake tasks are available in development mode: group :development do - gem "ruby_parser" - gem "powder" gem "better_errors" gem "binding_of_caller" gem "letter_opener" + gem "powder" + gem "ruby_parser" gem "standardrb" end group :test, :development do - gem "rspec-rails" - gem "rails-controller-testing" - gem "rubocop" gem "pry" + gem "rails-controller-testing" + gem "rspec-rails" + gem "rubocop" end group :test do - gem "factory_bot_rails" - gem "shoulda" - gem "poltergeist" - gem "database_cleaner" - gem "fivemat" gem "capybara-screenshot" + gem "database_cleaner" + gem "factory_bot_rails" + gem "fivemat" + gem "poltergeist" + gem "shoulda" gem "simplecov" end diff --git a/Rakefile b/Rakefile index 51bc076..b40710c 100644 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require File.expand_path("../config/application", __FILE__) DanBarberPhoto::Application.load_tasks diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 104106f..4d971fe 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -18,13 +18,13 @@ class PhotosController < ApplicationController def for_category(category_id) @category = Category.find_by_id(category_id) @photos = @category.photos.enabled.order(taken_at: :desc) - .page(params[:page]) + .page(params[:page]) @page_title = @category.name end def all @photos = Photo.enabled.order(taken_at: :desc) - .page(params[:page]) + .page(params[:page]) @page_title = "All Photos" end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5f644c5..338ba9e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,9 +1,9 @@ module ApplicationHelper def page_title(title) if title.present? - "#{title} - #{APP_CONFIG['page_title']}" + "#{title} - #{APP_CONFIG["page_title"]}" else - APP_CONFIG['page_title'] + APP_CONFIG["page_title"] end end end diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index 7fce6d2..bd2622b 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -1,5 +1,5 @@ module PhotosHelper def link_to_photo(photo) - link_to '', photo.image.url, rel: 'photos', class: 'fancy', data: { id: photo.id } + link_to "", photo.image.url, rel: "photos", class: "fancy", data: {id: photo.id} end end diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 53f097d..ad40afa 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -1,8 +1,8 @@ class Notifier < ActionMailer::Base - default from: 'enquiries@danbarberphoto.com' + default from: "enquiries@danbarberphoto.com" def contact_notification(sender) @sender = sender - mail(to: 'enquiries@danbarberphoto.com', from: sender.email, subject: sender.subject) + mail(to: "enquiries@danbarberphoto.com", from: sender.email, subject: sender.subject) end end diff --git a/config.ru b/config.ru index a2dea3d..a5567d8 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require ::File.expand_path("../config/environment", __FILE__) run DanBarberPhoto::Application diff --git a/config/application.rb b/config/application.rb index 53e5a6d..79b560b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,10 +1,10 @@ -require File.expand_path('../boot', __FILE__) +require File.expand_path("../boot", __FILE__) -require 'rails/all' +require "rails/all" if defined?(Bundler) # If you precompile assets before deploying to production, use this line - Bundler.require *Rails.groups(:assets => %w(development test)) + Bundler.require *Rails.groups(assets: %w[development test]) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end @@ -30,7 +30,7 @@ module DanBarberPhoto # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + config.i18n.load_path += Dir[Rails.root.join("my", "locales", "*.{rb,yml}").to_s] config.i18n.enforce_available_locales = true config.i18n.default_locale = :en @@ -43,10 +43,10 @@ module DanBarberPhoto # Enable the asset pipeline config.assets.enabled = true - config.assets.precompile += %w(favicon.ico fancybox/sprite.png fancybox/loading.gif fancybox/blank.gif fancybox/overlay.png) + config.assets.precompile += %w[favicon.ico fancybox/sprite.png fancybox/loading.gif fancybox/blank.gif fancybox/overlay.png] # Version of your assets, change this if you want to expire all your assets - config.assets.version = '1.0' + config.assets.version = "1.0" # Prefer SASS syntax for stylesheets config.sass.preferred_syntax = :sass @@ -54,7 +54,7 @@ module DanBarberPhoto # Configure factories config.generators do |g| g.test_framework :rspec, fixture: true - g.fixture_replacement :factory_girl, dir: 'spec/factories' + g.fixture_replacement :factory_girl, dir: "spec/factories" end end end diff --git a/config/boot.rb b/config/boot.rb index 4489e58..edf778b 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,6 +1,6 @@ -require 'rubygems' +require "rubygems" # Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) diff --git a/config/environment.rb b/config/environment.rb index 9087dc3..7d17cb3 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the rails application -require File.expand_path('../application', __FILE__) +require File.expand_path("../application", __FILE__) # Initialize the rails application DanBarberPhoto::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 1c57849..2597a08 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -33,6 +33,5 @@ DanBarberPhoto::Application.configure do config.action_mailer.delivery_method = :letter_opener - config.action_mailer.default_url_options = { :host => "danbarberphoto.dev" } - + config.action_mailer.default_url_options = {host: "danbarberphoto.dev"} end diff --git a/config/environments/production.rb b/config/environments/production.rb index 13b7587..94ac5fb 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -49,7 +49,7 @@ DanBarberPhoto::Application.configure do # config.action_controller.asset_host = "http://assets.example.com" # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - config.assets.precompile += %w(administrate/overrides.css) + config.assets.precompile += %w[administrate/overrides.css] # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false @@ -66,15 +66,14 @@ DanBarberPhoto::Application.configure do # Settings for Sendgrid Free on Heroku ActionMailer::Base.smtp_settings = { - :address => 'smtp.sendgrid.net', - :port => '587', - :authentication => :plain, - :user_name => ENV['SENDGRID_USERNAME'], - :password => ENV['SENDGRID_PASSWORD'], - :domain => 'heroku.com' + address: "smtp.sendgrid.net", + port: "587", + authentication: :plain, + user_name: ENV["SENDGRID_USERNAME"], + password: ENV["SENDGRID_PASSWORD"], + domain: "heroku.com", } ActionMailer::Base.delivery_method = :smtp - config.action_mailer.default_url_options = { :host => "danbarberphoto.com" } - + config.action_mailer.default_url_options = {host: "danbarberphoto.com"} end diff --git a/config/environments/test.rb b/config/environments/test.rb index b105500..9d3e754 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -24,7 +24,7 @@ DanBarberPhoto::Application.configure do config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 0874f2c..36e5b84 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,11 +1,11 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' +Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -Rails.application.config.assets.precompile += %w( administrate/overrides.css ) +Rails.application.config.assets.precompile += %w[administrate/overrides.css] diff --git a/config/initializers/dragonfly.rb b/config/initializers/dragonfly.rb index 4f3c0dd..9d18b46 100644 --- a/config/initializers/dragonfly.rb +++ b/config/initializers/dragonfly.rb @@ -1,4 +1,4 @@ -require 'dragonfly' +require "dragonfly" # Configure Dragonfly.app.configure do @@ -9,35 +9,35 @@ Dragonfly.app.configure do url_format "/media/:job/:name" - if Rails.env.in?(%w(development production)) + if Rails.env.in?(%w[development production]) datastore :s3, - bucket_name: ENV['AWS_BUCKET'], - access_key_id: ENV['AWS_KEY'], - secret_access_key: ENV['AWS_SECRET'], - region: 'eu-west-1' + bucket_name: ENV["AWS_BUCKET"], + access_key_id: ENV["AWS_KEY"], + secret_access_key: ENV["AWS_SECRET"], + region: "eu-west-1" else datastore :file, - root_path: Rails.root.join('public/system/dragonfly', Rails.env), - server_root: Rails.root.join('public') + root_path: Rails.root.join("public/system/dragonfly", Rails.env), + server_root: Rails.root.join("public") end - processor :preview do |content| content.process! :thumb, '600x600' end + processor :preview do |content| content.process! :thumb, "600x600" end - processor :admin do |content| content.process! :thumb, '140x140#' end + processor :admin do |content| content.process! :thumb, "140x140#" end - processor :size17 do |content| content.process! :thumb, '476x476#' end - processor :size11 do |content| content.process! :thumb, '308x308#' end - processor :size8 do |content| content.process! :thumb, '224x224#' end - processor :size5 do |content| content.process! :thumb, '140x140#' end - processor :size3 do |content| content.process! :thumb, '84x84#' end - processor :size2 do |content| content.process! :thumb, '56x56#' end + processor :size17 do |content| content.process! :thumb, "476x476#" end + processor :size11 do |content| content.process! :thumb, "308x308#" end + processor :size8 do |content| content.process! :thumb, "224x224#" end + processor :size5 do |content| content.process! :thumb, "140x140#" end + processor :size3 do |content| content.process! :thumb, "84x84#" end + processor :size2 do |content| content.process! :thumb, "56x56#" end - processor :size17x2 do |content| content.process! :thumb, '952x952#' end - processor :size11x2 do |content| content.process! :thumb, '616x616#' end - processor :size8x2 do |content| content.process! :thumb, '448x448#' end - processor :size5x2 do |content| content.process! :thumb, '280x280#' end - processor :size3x2 do |content| content.process! :thumb, '168x168#' end - processor :size2x2 do |content| content.process! :thumb, '112x112#' end + processor :size17x2 do |content| content.process! :thumb, "952x952#" end + processor :size11x2 do |content| content.process! :thumb, "616x616#" end + processor :size8x2 do |content| content.process! :thumb, "448x448#" end + processor :size5x2 do |content| content.process! :thumb, "280x280#" end + processor :size3x2 do |content| content.process! :thumb, "168x168#" end + processor :size2x2 do |content| content.process! :thumb, "112x112#" end end # Logger diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 2eaad7f..5ad1bba 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,6 +1,6 @@ # Be sure to restart your server when you modify this file. -DanBarberPhoto::Application.config.session_store :cookie_store, key: '_danbarberphoto_session' +DanBarberPhoto::Application.config.session_store :cookie_store, key: "_danbarberphoto_session" # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index 6986de9..8b9a495 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -6,7 +6,7 @@ SimpleForm.setup do |config| # stack. The options given below are used to wrap the # whole input. config.wrappers :default, class: :input, - hint_class: :field_with_hint, error_class: :field_with_errors do |b| + hint_class: :field_with_hint, error_class: :field_with_errors do |b| ## Extensions enabled by default # Any of these extensions can be disabled for a # given input by passing: `f.input EXTENSION_NAME => false`. @@ -41,8 +41,8 @@ SimpleForm.setup do |config| ## Inputs b.use :label_input - b.use :hint, wrap_with: { tag: :span, class: :hint } - b.use :error, wrap_with: { tag: :span, class: :error } + b.use :hint, wrap_with: {tag: :span, class: :hint} + b.use :error, wrap_with: {tag: :span, class: :error} end # The default wrapper to be used by the FormBuilder. @@ -55,7 +55,7 @@ SimpleForm.setup do |config| config.boolean_style = :nested # Default class for buttons - config.button_class = 'btn' + config.button_class = "btn" # Method used to tidy up errors. Specify any Rails Array method. # :first lists the first message for each field. @@ -66,7 +66,7 @@ SimpleForm.setup do |config| config.error_notification_tag = :div # CSS class to add for error notification helper. - config.error_notification_class = 'alert alert-error' + config.error_notification_class = "alert alert-error" # ID to add for error notification helper. # config.error_notification_id = nil @@ -95,7 +95,7 @@ SimpleForm.setup do |config| # config.label_text = lambda { |label, required| "#{required} #{label}" } # You can define the class to use on all labels. Default is nil. - config.label_class = 'control-label' + config.label_class = "control-label" # You can define the class to use on all forms. Default is simple_form. # config.form_class = :simple_form diff --git a/config/puma.rb b/config/puma.rb index 2e49738..1e1c1a0 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,18 +1,18 @@ -workers Integer(ENV['PUMA_WORKERS'] || 3) -threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16) +workers Integer(ENV["PUMA_WORKERS"] || 3) +threads Integer(ENV["MIN_THREADS"] || 1), Integer(ENV["MAX_THREADS"] || 16) preload_app! rackup DefaultRackup -port ENV['PORT'] || 3000 -environment ENV['RACK_ENV'] || 'development' +port ENV["PORT"] || 3000 +environment ENV["RACK_ENV"] || "development" on_worker_boot do # worker specific setup ActiveSupport.on_load(:active_record) do config = ActiveRecord::Base.configurations[Rails.env] || - Rails.application.config.database_configuration[Rails.env] - config['pool'] = ENV['MAX_THREADS'] || 16 + Rails.application.config.database_configuration[Rails.env] + config["pool"] = ENV["MAX_THREADS"] || 16 ActiveRecord::Base.establish_connection(config) end end diff --git a/config/routes.rb b/config/routes.rb index 064bf9c..96913f9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ -require 'oath/constraints/signed_in' -require 'oath/constraints/signed_out' +require "oath/constraints/signed_in" +require "oath/constraints/signed_out" DanBarberPhoto::Application.routes.draw do namespace :admin do @@ -32,6 +32,6 @@ DanBarberPhoto::Application.routes.draw do resources :contacts, only: [:new, :create] - get '/:name' => 'pages#show', as: :page - root to: 'home#index' + get "/:name" => "pages#show", :as => :page + root to: "home#index" end diff --git a/db/migrate/20101006095457_create_photos.rb b/db/migrate/20101006095457_create_photos.rb index f1b02ac..da140d0 100644 --- a/db/migrate/20101006095457_create_photos.rb +++ b/db/migrate/20101006095457_create_photos.rb @@ -2,9 +2,9 @@ class CreatePhotos < ActiveRecord::Migration def self.up create_table :photos do |t| t.integer :category_id - + t.string :flickr_url - + t.string :photo_file_name t.string :photo_content_type t.integer :photo_file_size diff --git a/db/migrate/20101008101157_add_photo_to_category.rb b/db/migrate/20101008101157_add_photo_to_category.rb index 0bbb3cc..832daa4 100644 --- a/db/migrate/20101008101157_add_photo_to_category.rb +++ b/db/migrate/20101008101157_add_photo_to_category.rb @@ -1,9 +1,9 @@ class AddPhotoToCategory < ActiveRecord::Migration def self.up - add_column :categories, :photo_id, :integer + add_column :categories, :photo_id, :integer end def self.down - remove_column :categories, :photo_id + remove_column :categories, :photo_id end end diff --git a/db/migrate/20101008103053_add_details_to_photo.rb b/db/migrate/20101008103053_add_details_to_photo.rb index d68bba0..f8e44b1 100644 --- a/db/migrate/20101008103053_add_details_to_photo.rb +++ b/db/migrate/20101008103053_add_details_to_photo.rb @@ -1,11 +1,11 @@ class AddDetailsToPhoto < ActiveRecord::Migration def self.up - add_column :photos, :title, :string - add_column :photos, :description, :text + add_column :photos, :title, :string + add_column :photos, :description, :text end def self.down - remove_column :photos, :title - remove_column :photos, :description + remove_column :photos, :title + remove_column :photos, :description end end diff --git a/db/migrate/20101008122736_add_sort_orders.rb b/db/migrate/20101008122736_add_sort_orders.rb index 7b5325f..bab57e1 100644 --- a/db/migrate/20101008122736_add_sort_orders.rb +++ b/db/migrate/20101008122736_add_sort_orders.rb @@ -5,7 +5,7 @@ class AddSortOrders < ActiveRecord::Migration end def self.down - remove_column :photos, :sort - remove_column :categories, :sort + remove_column :photos, :sort + remove_column :categories, :sort end end diff --git a/db/migrate/20101008172319_move_to_many_to_many.rb b/db/migrate/20101008172319_move_to_many_to_many.rb index c255951..465649f 100644 --- a/db/migrate/20101008172319_move_to_many_to_many.rb +++ b/db/migrate/20101008172319_move_to_many_to_many.rb @@ -1,7 +1,7 @@ class MoveToManyToMany < ActiveRecord::Migration def self.up remove_column :photos, :category_id - create_table :categories_photos, :id => false do |t| + create_table :categories_photos, id: false do |t| t.integer :category_id t.integer :photo_id end diff --git a/db/migrate/20101011133558_create_admin_users.rb b/db/migrate/20101011133558_create_admin_users.rb index d269e1a..dc885ec 100644 --- a/db/migrate/20101011133558_create_admin_users.rb +++ b/db/migrate/20101011133558_create_admin_users.rb @@ -1,15 +1,14 @@ class CreateAdminUsers < ActiveRecord::Migration - def self.up create_table :admin_users do |t| - t.string :first_name, :default => "", :null => false - t.string :last_name, :default => "", :null => false - t.string :role, :null => false - t.string :email, :null => false - t.boolean :status, :default => false - t.string :token, :null => false - t.string :salt, :null => false - t.string :crypted_password, :null => false + t.string :first_name, default: "", null: false + t.string :last_name, default: "", null: false + t.string :role, null: false + t.string :email, null: false + t.boolean :status, default: false + t.string :token, null: false + t.string :salt, null: false + t.string :crypted_password, null: false t.string :preferences t.timestamps end @@ -18,5 +17,4 @@ class CreateAdminUsers < ActiveRecord::Migration def self.down drop_table :admin_users end - end diff --git a/db/migrate/20101013165208_photo_showcase.rb b/db/migrate/20101013165208_photo_showcase.rb index 501fb67..62ebf30 100644 --- a/db/migrate/20101013165208_photo_showcase.rb +++ b/db/migrate/20101013165208_photo_showcase.rb @@ -1,9 +1,9 @@ class PhotoShowcase < ActiveRecord::Migration def self.up - add_column :photos, :featured, :boolean, :default => false + add_column :photos, :featured, :boolean, default: false end def self.down - remove_column :photos, :featured + remove_column :photos, :featured end end diff --git a/db/migrate/20101202155552_add_enabled_to_photos.rb b/db/migrate/20101202155552_add_enabled_to_photos.rb index 8355e14..86b09e5 100644 --- a/db/migrate/20101202155552_add_enabled_to_photos.rb +++ b/db/migrate/20101202155552_add_enabled_to_photos.rb @@ -1,6 +1,6 @@ class AddEnabledToPhotos < ActiveRecord::Migration def self.up - add_column :photos, :enabled, :boolean, :default => true + add_column :photos, :enabled, :boolean, default: true end def self.down diff --git a/db/migrate/20101215172105_add_taken_date_to_photo.rb b/db/migrate/20101215172105_add_taken_date_to_photo.rb index 603d2cd..265132a 100644 --- a/db/migrate/20101215172105_add_taken_date_to_photo.rb +++ b/db/migrate/20101215172105_add_taken_date_to_photo.rb @@ -1,6 +1,6 @@ class AddTakenDateToPhoto < ActiveRecord::Migration def self.up - add_column :photos, :taken_at, :datetime + add_column :photos, :taken_at, :datetime end def self.down diff --git a/db/migrate/20101216180143_add_view_count_to_photos.rb b/db/migrate/20101216180143_add_view_count_to_photos.rb index 4ef78f2..5320637 100644 --- a/db/migrate/20101216180143_add_view_count_to_photos.rb +++ b/db/migrate/20101216180143_add_view_count_to_photos.rb @@ -1,6 +1,6 @@ class AddViewCountToPhotos < ActiveRecord::Migration def self.up - add_column :photos, :views, :integer, :default => 0 + add_column :photos, :views, :integer, default: 0 end def self.down diff --git a/db/migrate/20111013085444_add_sessions_table.rb b/db/migrate/20111013085444_add_sessions_table.rb index fd942cc..37d1a63 100644 --- a/db/migrate/20111013085444_add_sessions_table.rb +++ b/db/migrate/20111013085444_add_sessions_table.rb @@ -1,7 +1,7 @@ class AddSessionsTable < ActiveRecord::Migration def up create_table :sessions do |t| - t.string :session_id, :null => false + t.string :session_id, null: false t.text :data t.timestamps end diff --git a/db/migrate/20111030163656_remove_admin_users.rb b/db/migrate/20111030163656_remove_admin_users.rb index 0b31c69..5f3be82 100644 --- a/db/migrate/20111030163656_remove_admin_users.rb +++ b/db/migrate/20111030163656_remove_admin_users.rb @@ -5,14 +5,14 @@ class RemoveAdminUsers < ActiveRecord::Migration def self.down create_table :admin_users do |t| - t.string :first_name, :default => "", :null => false - t.string :last_name, :default => "", :null => false - t.string :role, :null => false - t.string :email, :null => false - t.boolean :status, :default => false - t.string :token, :null => false - t.string :salt, :null => false - t.string :crypted_password, :null => false + t.string :first_name, default: "", null: false + t.string :last_name, default: "", null: false + t.string :role, null: false + t.string :email, null: false + t.boolean :status, default: false + t.string :token, null: false + t.string :salt, null: false + t.string :crypted_password, null: false t.string :preferences t.timestamps end diff --git a/db/migrate/20111030164012_create_devise_admin_users.rb b/db/migrate/20111030164012_create_devise_admin_users.rb index bb694f4..d833bb9 100644 --- a/db/migrate/20111030164012_create_devise_admin_users.rb +++ b/db/migrate/20111030164012_create_devise_admin_users.rb @@ -2,8 +2,8 @@ class CreateDeviseAdminUsers < ActiveRecord::Migration def up create_table(:admin_users) do |t| # Database authenticatable - t.string :email, :null => false, :default => "" - t.string :encrypted_password, :null => false, :default => "" + t.string :email, null: false, default: "" + t.string :encrypted_password, null: false, default: "" # Recoverable t.string :reset_password_token @@ -13,7 +13,7 @@ class CreateDeviseAdminUsers < ActiveRecord::Migration t.datetime :remember_created_at # Trackable - t.integer :sign_in_count, :default => 0 + t.integer :sign_in_count, default: 0 t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -26,17 +26,17 @@ class CreateDeviseAdminUsers < ActiveRecord::Migration t.string :unconfirmed_email # Only if using reconfirmable # Lockable - t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts + t.integer :failed_attempts, default: 0 # Only if lock strategy is :failed_attempts t.string :unlock_token # Only if unlock strategy is :email or :both t.datetime :locked_at t.timestamps end - add_index :admin_users, :email, :unique => true - add_index :admin_users, :reset_password_token, :unique => true - add_index :admin_users, :confirmation_token, :unique => true - add_index :admin_users, :unlock_token, :unique => true + add_index :admin_users, :email, unique: true + add_index :admin_users, :reset_password_token, unique: true + add_index :admin_users, :confirmation_token, unique: true + add_index :admin_users, :unlock_token, unique: true # add_index :admin_users, :authentication_token, :unique => true end diff --git a/db/migrate/20151022110802_remove_devise_admin_users.rb b/db/migrate/20151022110802_remove_devise_admin_users.rb index 5da29d5..5c392e0 100644 --- a/db/migrate/20151022110802_remove_devise_admin_users.rb +++ b/db/migrate/20151022110802_remove_devise_admin_users.rb @@ -6,8 +6,8 @@ class RemoveDeviseAdminUsers < ActiveRecord::Migration def down create_table(:admin_users) do |t| # Database authenticatable - t.string :email, :null => false, :default => "" - t.string :encrypted_password, :null => false, :default => "" + t.string :email, null: false, default: "" + t.string :encrypted_password, null: false, default: "" # Recoverable t.string :reset_password_token @@ -17,7 +17,7 @@ class RemoveDeviseAdminUsers < ActiveRecord::Migration t.datetime :remember_created_at # Trackable - t.integer :sign_in_count, :default => 0 + t.integer :sign_in_count, default: 0 t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -30,16 +30,16 @@ class RemoveDeviseAdminUsers < ActiveRecord::Migration t.string :unconfirmed_email # Only if using reconfirmable # Lockable - t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts + t.integer :failed_attempts, default: 0 # Only if lock strategy is :failed_attempts t.string :unlock_token # Only if unlock strategy is :email or :both t.datetime :locked_at t.timestamps end - add_index :admin_users, :email, :unique => true - add_index :admin_users, :reset_password_token, :unique => true - add_index :admin_users, :confirmation_token, :unique => true - add_index :admin_users, :unlock_token, :unique => true + add_index :admin_users, :email, unique: true + add_index :admin_users, :reset_password_token, unique: true + add_index :admin_users, :confirmation_token, unique: true + add_index :admin_users, :unlock_token, unique: true end end diff --git a/script/heap_dump.rb b/script/heap_dump.rb index 8d8a16b..2f27b2e 100644 --- a/script/heap_dump.rb +++ b/script/heap_dump.rb @@ -1,6 +1,6 @@ -Thread.new do +Thread.new { require "objspace" ObjectSpace.trace_object_allocations_start - GC.start() + GC.start ObjectSpace.dump_all(output: File.open("heap.json", "w")) -end.join +}.join diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index 5e09217..8b43802 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -21,7 +21,7 @@ describe ContactsController, type: :controller do valid_contact = double(valid?: true) allow(Contact).to receive(:new).and_return(valid_contact) allow(Notifier).to receive(:contact_notification).and_return(double(deliver: true)) - post :create, params: { contact: contact_params } + post :create, params: {contact: contact_params} expect(Notifier).to have_received(:contact_notification).with(valid_contact) expect(flash[:notice]).to eql(I18n.t("contact.thanks")) @@ -30,7 +30,7 @@ describe ContactsController, type: :controller do it "re-renders the form if params are missing" do allow(Contact).to receive(:new).and_return(double(valid?: false)) - post :create, params: { contact: {} } + post :create, params: {contact: {}} expect(flash[:alert]).to eql(I18n.t("contact.invalid")) expect(response).to render_template(:new) end diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index 1e2c2de..19b2b36 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -5,12 +5,12 @@ describe PagesController, type: :controller do let(:test_page) { create(:page) } it "renders a page" do - get :show, params: { name: test_page.name } + get :show, params: {name: test_page.name} expect(response).to render_template(:show) end it "renders 404 for a non existant page" do - get :show, params: { name: "not-a-page" } + get :show, params: {name: "not-a-page"} expect(response.status).to eql(404) end end diff --git a/spec/controllers/views_controller_spec.rb b/spec/controllers/views_controller_spec.rb index fd129af..e0bb822 100644 --- a/spec/controllers/views_controller_spec.rb +++ b/spec/controllers/views_controller_spec.rb @@ -6,12 +6,12 @@ RSpec.describe ViewsController, type: :controller do it "logs a photo view" do expect_any_instance_of(Photo).to receive(:log_view).once - post :create, params: { photo_id: photo.id } + post :create, params: {photo_id: photo.id} expect(response).to be_successful end it "responds with not_found if the photo is not present" do - post :create, params: { photo_id: 999 } + post :create, params: {photo_id: 999} expect(response.status).to eql(404) end end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 9132346..e261113 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -5,8 +5,8 @@ describe Contact do it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:message) } - it { is_expected.to allow_value('test@test.com').for(:email) } - it { is_expected.not_to allow_value('test@test').for(:email) } + it { is_expected.to allow_value("test@test.com").for(:email) } + it { is_expected.not_to allow_value("test@test").for(:email) } let(:contact) { build(:contact) } end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 71dabae..60fcd8f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,12 +1,12 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' -ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../config/environment', __FILE__) -require 'rspec/rails' -require 'capybara/rspec' -require 'capybara/poltergeist' +ENV["RAILS_ENV"] ||= "test" +require File.expand_path("../../config/environment", __FILE__) +require "rspec/rails" +require "capybara/rspec" +require "capybara/poltergeist" # For code coverage -require 'simplecov' +require "simplecov" SimpleCov.start # Use Poltergeist @@ -14,7 +14,7 @@ Capybara.javascript_driver = :poltergeist # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. -Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } +Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } RSpec.configure do |config| # ## Mock Framework @@ -46,7 +46,7 @@ RSpec.configure do |config| # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 - config.order = 'random' + config.order = "random" config.before(:suite) do DatabaseCleaner.clean_with(:truncation) diff --git a/spec/support/ajax.rb b/spec/support/ajax.rb index 87c0816..338c7f9 100644 --- a/spec/support/ajax.rb +++ b/spec/support/ajax.rb @@ -2,7 +2,7 @@ module Ajax def wait_for_ajax Timeout.timeout(Capybara.default_max_wait_time) do loop do - active = page.evaluate_script('jQuery.active') + active = page.evaluate_script("jQuery.active") break if active == 0 end end