diff --git a/.rubocop.yml b/.rubocop.yml index 9faa2644..304b0859 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,6 @@ +inherit_gem: + rubocop-basic: rubocop.yml + require: - rubocop-capybara - rubocop-factory_bot @@ -7,7 +10,6 @@ require: AllCops: TargetRubyVersion: 3.4.1 - NewCops: enable Exclude: - Gemfile.lock - db/schema.rb @@ -18,12 +20,6 @@ AllCops: - tmp/**/* - vendor/**/* -Layout/AccessModifierIndentation: - EnforcedStyle: outdent - -Layout/ParameterAlignment: - EnforcedStyle: with_fixed_indentation - Layout/EmptyLinesAroundBlockBody: Enabled: false @@ -66,12 +62,6 @@ Style/ClassAndModuleChildren: Style/EmptyCaseCondition: Enabled: false -Style/TrailingCommaInArrayLiteral: - EnforcedStyleForMultiline: consistent_comma - -Style/TrailingCommaInHashLiteral: - EnforcedStyleForMultiline: consistent_comma - Style/ExpandPathArguments: Enabled: false diff --git a/Brewfile b/Brewfile index 88fd8701..5ee675f0 100644 --- a/Brewfile +++ b/Brewfile @@ -1,2 +1,2 @@ -brew 'rbenv' -brew 'vips' +brew "rbenv" +brew "vips" diff --git a/Gemfile b/Gemfile index b40dca1d..908bc0da 100644 --- a/Gemfile +++ b/Gemfile @@ -1,57 +1,58 @@ -source 'https://rubygems.org' +source "https://rubygems.org" -ruby '3.4.1' +ruby "3.4.1" -gem 'rails' +gem "rails" -gem 'pg' -gem 'puma' +gem "pg" +gem "puma" -gem 'bootsnap', require: false -gem 'thruster', require: false +gem "bootsnap", require: false +gem "thruster", require: false -gem 'bcrypt' -gem 'erroneous' -gem 'foreman' -gem 'hiredis' -gem 'http' -gem 'kaminari' -gem 'progress' -gem 'propshaft' -gem 'redcarpet' -gem 'redis' -gem 'rouge' +gem "bcrypt" +gem "erroneous" +gem "foreman" +gem "hiredis" +gem "http" +gem "kaminari" +gem "progress" +gem "propshaft" +gem "redcarpet" +gem "redis" +gem "rouge" -gem 'image_processing' +gem "image_processing" -gem 'aws-sdk-s3', require: false -gem 'cloudflare-ips' +gem "aws-sdk-s3", require: false +gem "cloudflare-ips" -gem 'cssbundling-rails' -gem 'jsbundling-rails' -gem 'sentry-rails' -gem 'stimulus-rails' +gem "cssbundling-rails" +gem "jsbundling-rails" +gem "sentry-rails" +gem "stimulus-rails" -gem 'debug', group: %i[development test] +gem "debug", group: %i[development test] group :development do - gem 'brakeman' - gem 'listen' - gem 'rubocop' - gem 'rubocop-capybara' - gem 'rubocop-factory_bot' - gem 'rubocop-rails' - gem 'rubocop-rspec' - gem 'rubocop-rspec_rails' - gem 'web-console' + gem "brakeman" + gem "listen" + gem "rubocop" + gem "rubocop-basic" + gem "rubocop-capybara" + gem "rubocop-factory_bot" + gem "rubocop-rails" + gem "rubocop-rspec" + gem "rubocop-rspec_rails" + gem "web-console" end group :test do - gem 'capybara' - gem 'factory_bot_rails' - gem 'rspec_junit_formatter' - gem 'rspec-rails' - gem 'selenium-webdriver' - gem 'shoulda-matchers' - gem 'simplecov', require: false + gem "capybara" + gem "factory_bot_rails" + gem "rspec_junit_formatter" + gem "rspec-rails" + gem "selenium-webdriver" + gem "shoulda-matchers" + gem "simplecov", require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 4f8034d0..0aa7b6a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -332,6 +332,7 @@ GEM unicode-display_width (>= 2.4.0, < 4.0) rubocop-ast (1.37.0) parser (>= 3.3.1.0) + rubocop-basic (0.2.0) rubocop-capybara (2.21.0) rubocop (~> 1.41) rubocop-factory_bot (2.26.1) @@ -444,6 +445,7 @@ DEPENDENCIES rspec-rails rspec_junit_formatter rubocop + rubocop-basic rubocop-capybara rubocop-factory_bot rubocop-rails diff --git a/Rakefile b/Rakefile index e85f9139..9a5ea738 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,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_relative 'config/application' +require_relative "config/application" Rails.application.load_tasks diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 3363ef1f..52698ec6 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,3 +1,3 @@ class AdminController < ApplicationController - layout 'admin/application' + layout "admin/application" end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8e1724b3..ab41e47a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -37,7 +37,7 @@ def authenticate!(role:) return if authenticated? && user.role.eql?(role) store - redirect_to new_admin_session_path, alert: 'You must be authenticated.' + redirect_to new_admin_session_path, alert: "You must be authenticated." end def store diff --git a/app/controllers/auths_controller.rb b/app/controllers/auths_controller.rb index 4f8e86d1..3894aa35 100644 --- a/app/controllers/auths_controller.rb +++ b/app/controllers/auths_controller.rb @@ -1,7 +1,7 @@ class AuthsController < ApplicationController # POST /auth def create - user = GlobalID::Locator.locate_signed(params[:token], for: 'auth') + user = GlobalID::Locator.locate_signed(params[:token], for: "auth") authenticate(user) head :ok end diff --git a/app/controllers/concerns/robots.rb b/app/controllers/concerns/robots.rb index 507d9bc0..f45c9b0c 100644 --- a/app/controllers/concerns/robots.rb +++ b/app/controllers/concerns/robots.rb @@ -1,11 +1,11 @@ module Robots extend ActiveSupport::Concern - def robots(value = 'all') - response.headers['X-Robots-Tag'] = value + def robots(value = "all") + response.headers["X-Robots-Tag"] = value end def norobot - robots('noindex,nofollow') + robots("noindex,nofollow") end end diff --git a/app/controllers/sitemaps_controller.rb b/app/controllers/sitemaps_controller.rb index 94ab485b..2494979e 100644 --- a/app/controllers/sitemaps_controller.rb +++ b/app/controllers/sitemaps_controller.rb @@ -1,5 +1,5 @@ class SitemapsController < ApplicationController - layout 'sitemap' + layout "sitemap" # GET /sitemap def show diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 75362194..cc73ad88 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -5,16 +5,16 @@ def active?(*mode) def prose(&) tag.div(class: [ - 'prose', - 'prose-slate', - 'prose-a:text-indigo-600', - 'prose-pre:bg-slate-50', - 'prose-pre:text-slate-800', - 'prose-pre:text-base', - 'prose-pre:p-4', - 'max-w-none', - 'min-w-none', - ].join(' '), &) + "prose", + "prose-slate", + "prose-a:text-indigo-600", + "prose-pre:bg-slate-50", + "prose-pre:text-slate-800", + "prose-pre:text-base", + "prose-pre:p-4", + "max-w-none", + "min-w-none", + ].join(" "), &) end def markdown(text) @@ -25,7 +25,7 @@ def markdown(text) end def viewport - 'width=device-width,initial-scale=1.0' + "width=device-width,initial-scale=1.0" end def filters(filters = {}) @@ -40,13 +40,13 @@ def filters(filters = {}) def ld { - '@context': 'http://schema.org', - '@type': 'WebSite', - 'url': root_url, - 'potentialAction': { - '@type': 'SearchAction', - 'target': "#{search_url}?query={query}", - 'query-input': 'required name=query', + "@context": "http://schema.org", + "@type": "WebSite", + "url": root_url, + "potentialAction": { + "@type": "SearchAction", + "target": "#{search_url}?query={query}", + "query-input": "required name=query", }, } end @@ -54,27 +54,27 @@ def ld # @return [Array] def header_nav [ - ['Home', root_path], - ['About', about_path], - ['Contact', contact_path], - ['Projects', projects_path], - ['Portfolio', portfolio_path], - ['Search', search_path], + ["Home", root_path], + ["About", about_path], + ["Contact", contact_path], + ["Projects", projects_path], + ["Portfolio", portfolio_path], + ["Search", search_path], ] end # @return [Array] def footer_nav [ - ['GitHub', github_url], - ['Twitter', twitter_url], - ['Facebook', facebook_url], - ['Linkedin', linkedin_url], - ['Dribbble', dribbble_url], - ['Stack', stackoverflow_url], - ['Vimeo', vimeo_url], - ['Status', status_url], - ['Feed', feed_url(:atom)], + ["GitHub", github_url], + ["Twitter", twitter_url], + ["Facebook", facebook_url], + ["Linkedin", linkedin_url], + ["Dribbble", dribbble_url], + ["Stack", stackoverflow_url], + ["Vimeo", vimeo_url], + ["Status", status_url], + ["Feed", feed_url(:atom)], ] end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index d8bd387b..47cdc622 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,3 +1,3 @@ class ApplicationMailer < ActionMailer::Base - layout 'mailer' + layout "mailer" end diff --git a/app/models/concerns/approvable.rb b/app/models/concerns/approvable.rb index 8d6ea61e..7d324999 100644 --- a/app/models/concerns/approvable.rb +++ b/app/models/concerns/approvable.rb @@ -2,8 +2,8 @@ module Approvable extend ActiveSupport::Concern module Status - ACTIVE = 'active'.freeze - PENDING = 'pending'.freeze + ACTIVE = "active".freeze + PENDING = "pending".freeze end STATUSES = [ diff --git a/app/models/concerns/redcarpet/render/advanced.rb b/app/models/concerns/redcarpet/render/advanced.rb index df26268a..d186e402 100644 --- a/app/models/concerns/redcarpet/render/advanced.rb +++ b/app/models/concerns/redcarpet/render/advanced.rb @@ -1,5 +1,5 @@ -require 'rouge' -require 'rouge/plugins/redcarpet' +require "rouge" +require "rouge/plugins/redcarpet" class Redcarpet::Render::Advanced < Redcarpet::Render::HTML include Rouge::Plugins::Redcarpet @@ -17,10 +17,10 @@ def internalize(link) file = Attachment.find(attributes[:id]).file case attributes[:variant] - when 'original' then file - when 'small' then file.variant(resize: '480x480') - when 'large' then file.variant(resize: '960x960') - when 'square' then file.variant(thumbnail: '120x120') + when "original" then file + when "small" then file.variant(resize: "480x480") + when "large" then file.variant(resize: "960x960") + when "square" then file.variant(thumbnail: "120x120") end end diff --git a/app/models/concerns/searchable.rb b/app/models/concerns/searchable.rb index 2bf88366..cd4c6554 100644 --- a/app/models/concerns/searchable.rb +++ b/app/models/concerns/searchable.rb @@ -10,7 +10,7 @@ module Searchable class Tokenizer include Singleton - LANGUAGE = 'english'.freeze + LANGUAGE = "english".freeze SEPARATOR = /\W+/ def generate(query, fields, sanitizer) @@ -23,7 +23,7 @@ def searchables(fields, conjunction = " || ' ' || ") tsvector(fields.map { |field| "coalesce(#{field}, '')" }.join(conjunction)) end - def tokens(query, sanitizer, conjunction = ' && ') + def tokens(query, sanitizer, conjunction = " && ") query.split(SEPARATOR).map { |term| tsquery(term, sanitizer) }.join(conjunction) end diff --git a/app/models/concerns/taggable.rb b/app/models/concerns/taggable.rb index 8aab5272..39902870 100644 --- a/app/models/concerns/taggable.rb +++ b/app/models/concerns/taggable.rb @@ -10,11 +10,11 @@ module Taggable end def keywords - tags.join(',') + tags.join(",") end def taggables - tags.join(' ') + tags.join(" ") end def taggables=(value) diff --git a/app/models/page.rb b/app/models/page.rb index 2bcd04e8..a8293ac1 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -13,7 +13,7 @@ class Page < ApplicationRecord before_validation :defaults! - scope :ordered, -> { order('id DESC') } + scope :ordered, -> { order("id DESC") } scope :optimized, -> { includes(:user) } scope :canonical, -> { where(canonical_url: nil) } diff --git a/app/models/portfolio.rb b/app/models/portfolio.rb index 948f8817..4589b65f 100644 --- a/app/models/portfolio.rb +++ b/app/models/portfolio.rb @@ -3,22 +3,22 @@ class Portfolio attr_reader :summary def self.all - @all ||= YAML.load_file(Rails.root.join('config/portfolio.yml')).map { |config| new(config) } + @all ||= YAML.load_file(Rails.root.join("config/portfolio.yml")).map { |config| new(config) } end def initialize(config) - @slug = config['slug'] - @name = config['name'] - @summary = config['summary'] - @images = config['images'] - @videos = config['videos'] + @slug = config["slug"] + @name = config["name"] + @summary = config["summary"] + @images = config["images"] + @videos = config["videos"] end def images return unless @images - size = @images['size'] - files = @images['files'] + size = @images["size"] + files = @images["files"] files.each do |file| yield({ size:, @@ -31,7 +31,7 @@ def images def videos return unless @videos - urls = @videos['urls'] + urls = @videos["urls"] urls.each do |url| yield({ url: }) end diff --git a/app/models/post.rb b/app/models/post.rb index 9c62ddc7..9d8867de 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -5,7 +5,7 @@ class Post < ApplicationRecord include Attachable module Formats - SEGMENT = '%Y-%m-%d'.freeze + SEGMENT = "%Y-%m-%d".freeze end belongs_to :user @@ -20,7 +20,7 @@ module Formats scope :canonical, -> { where(canonical_url: nil) } - scope :ordered, -> { order('id DESC') } + scope :ordered, -> { order("id DESC") } scope :optimized, -> { includes(:user) } def date diff --git a/app/models/project.rb b/app/models/project.rb index a337abcc..1ea8a0c6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -5,8 +5,8 @@ class Project attr_reader :url def self.all - @all ||= YAML.load_file(Rails.root.join('config/projects.yml')).map do |config| - Project.new(config['name'], config['icon'], config['description'], config['url']) + @all ||= YAML.load_file(Rails.root.join("config/projects.yml")).map do |config| + Project.new(config["name"], config["icon"], config["description"], config["url"]) end end diff --git a/app/models/session.rb b/app/models/session.rb index 96fc46bf..00b6e902 100644 --- a/app/models/session.rb +++ b/app/models/session.rb @@ -1,14 +1,14 @@ class Session include ActiveModel::Model - INVALID_EMAIL_OR_PASSWORD_MESSAGE = 'the email and password entered did not match our records'.freeze + INVALID_EMAIL_OR_PASSWORD_MESSAGE = "the email and password entered did not match our records".freeze private_constant :INVALID_EMAIL_OR_PASSWORD_MESSAGE attr_accessor :email attr_accessor :password validates :email, presence: true - validates :email, format: { with: Validation::EMAIL, message: 'must be an email' }, if: -> { email.present? } + validates :email, format: { with: Validation::EMAIL, message: "must be an email" }, if: -> { email.present? } validates :password, presence: true validate do diff --git a/app/models/user.rb b/app/models/user.rb index 3425869d..dc7d1ad8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,7 @@ class User < ApplicationRecord module Role - ADMIN = 'admin'.freeze - GUEST = 'guest'.freeze + ADMIN = "admin".freeze + GUEST = "guest".freeze end ROLES = [ @@ -15,7 +15,7 @@ module Role has_many :pages, dependent: :nullify validates :name, presence: true - validates :email, presence: true, uniqueness: true, format: { with: Validation::EMAIL, message: 'should be an email' } + validates :email, presence: true, uniqueness: true, format: { with: Validation::EMAIL, message: "should be an email" } validates :password, length: { in: 4..64 }, presence: true, unless: ->(user) { user.password_digest.present? } validates :role, inclusion: { in: ROLES } diff --git a/app/views/feeds/show.atom.builder b/app/views/feeds/show.atom.builder index f0369ee8..d4df5799 100644 --- a/app/views/feeds/show.atom.builder +++ b/app/views/feeds/show.atom.builder @@ -1,5 +1,5 @@ atom_feed do |feed| - feed.title 'Kevin Sylvestre' + feed.title "Kevin Sylvestre" feed.updated @posts.maximum(:updated_at) || @posts.maximum(:created_at) cache @posts do @@ -7,7 +7,7 @@ atom_feed do |feed| cache post do feed.entry post, url: post_url(segment: post.segment, slug: post.slug) do |entry| entry.title post.title - entry.content post.summary, type: 'html' + entry.content post.summary, type: "html" if post.user entry.author do |author| author.name post.user.name diff --git a/app/views/feeds/show.rss.builder b/app/views/feeds/show.rss.builder index 8a11099e..91999266 100644 --- a/app/views/feeds/show.rss.builder +++ b/app/views/feeds/show.rss.builder @@ -1,8 +1,8 @@ -xml.instruct! :xml, version: '1.0' -xml.rss version: '2.0' do +xml.instruct! :xml, version: "1.0" +xml.rss version: "2.0" do xml.channel do - xml.title 'Kevin Sylvestre' - xml.description 'A Ruby and iOS developer and designer.' + xml.title "Kevin Sylvestre" + xml.description "A Ruby and iOS developer and designer." xml.link root_url cache @posts do diff --git a/config.ru b/config.ru index ad1fbf29..4a3c09a6 100644 --- a/config.ru +++ b/config.ru @@ -1,6 +1,6 @@ # This file is used by Rack-based servers to start the application. -require_relative 'config/environment' +require_relative "config/environment" run Rails.application Rails.application.load_server diff --git a/config/application.rb b/config/application.rb index 01fb0c87..bf2dee2a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,6 +1,6 @@ -require_relative 'boot' +require_relative "boot" -require 'rails/all' +require "rails/all" Bundler.require(*Rails.groups) @@ -17,16 +17,16 @@ class Application < Rails::Application g.stylesheets false g.javascripts false g.test_framework :rspec, fixture: true, views: false - g.fixture_replacement :factory_bot, dir: 'spec/factories' + g.fixture_replacement :factory_bot, dir: "spec/factories" end - if ENV.include?('HOST') - config.action_mailer.asset_host = ENV['HOST'] - config.action_controller.asset_host = ENV['HOST'] + if ENV.include?("HOST") + config.action_mailer.asset_host = ENV["HOST"] + config.action_controller.asset_host = ENV["HOST"] end config.action_mailer.default_url_options ||= {} - config.action_mailer.default_url_options[:host] = ENV.fetch('HOST', 'https://ksylvest.com') + config.action_mailer.default_url_options[:host] = ENV.fetch("HOST", "https://ksylvest.com") config.autoload_lib(ignore: %w[assets tasks]) end diff --git a/config/boot.rb b/config/boot.rb index b9e460ce..988a5ddc 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,4 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) -require 'bundler/setup' # Set up gems listed in the Gemfile. -require 'bootsnap/setup' # Speed up boot time by caching expensive operations. +require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/environment.rb b/config/environment.rb index 426333bb..cac53157 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require_relative 'application' +require_relative "application" # Initialize the Rails application. Rails.application.initialize! diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 986cb482..2a84d194 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -1,6 +1,6 @@ Sentry.init do |config| if Rails.env.production? config.dsn = Rails.application.credentials.sentry_dsn - config.traces_sample_rate = Float(ENV['SENTRY_TRACE_SAMPLE_RATE']) if ENV['SENTRY_TRACE_SAMPLE_RATE'] + config.traces_sample_rate = Float(ENV["SENTRY_TRACE_SAMPLE_RATE"]) if ENV["SENTRY_TRACE_SAMPLE_RATE"] end end diff --git a/config/puma.rb b/config/puma.rb index f7042668..b3036276 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,5 +1,5 @@ -workers Integer(ENV.fetch('PUMA_WORKERS', 0)) -threads Integer(ENV.fetch('PUMA_MIN_THREADS', 4)), Integer(ENV.fetch('PUMA_MAX_THREADS', 4)) +workers Integer(ENV.fetch("PUMA_WORKERS", 0)) +threads Integer(ENV.fetch("PUMA_MIN_THREADS", 4)), Integer(ENV.fetch("PUMA_MAX_THREADS", 4)) -port ENV.fetch('PORT', 3000) -environment ENV.fetch('RAILS_ENV', 'development') +port ENV.fetch("PORT", 3000) +environment ENV.fetch("RAILS_ENV", "development") diff --git a/config/routes.rb b/config/routes.rb index dd3e72dd..bbaca571 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,18 +1,18 @@ Rails.application.routes.draw do - default_url_options(Rails.env.production? ? { host: 'ksylvest.com' } : {}) + default_url_options(Rails.env.production? ? { host: "ksylvest.com" } : {}) - get 'up', to: 'rails/health#show' + get "up", to: "rails/health#show" - root to: 'posts#index' + root to: "posts#index" - get '404', to: 'errors#missing', as: :missing - get '422', to: 'errors#unprocessable', as: :unprocessable - get '500', to: 'errors#exception', as: :exception + get "404", to: "errors#missing", as: :missing + get "422", to: "errors#unprocessable", as: :unprocessable + get "500", to: "errors#exception", as: :exception - get 'about', to: 'main#about', as: :about - get 'contact', to: 'main#contact', as: :contact - get 'projects', to: 'main#projects', as: :projects - get 'portfolio', to: 'main#portfolio', as: :portfolio + get "about", to: "main#about", as: :about + get "contact", to: "main#contact", as: :contact + get "projects", to: "main#projects", as: :projects + get "portfolio", to: "main#portfolio", as: :portfolio resource :feed, only: :show resource :archive, only: :show @@ -20,7 +20,7 @@ resource :search, only: %i[show] - get 'admin', to: 'admin/dashboard#index', as: :admin + get "admin", to: "admin/dashboard#index", as: :admin resource :auth, only: %i[create destroy] @@ -32,44 +32,44 @@ resources :pages, only: %i[index new edit update create destroy] end - get '(tagged/:tag)/(page/:page)', to: 'posts#index', as: :posts + get "(tagged/:tag)/(page/:page)", to: "posts#index", as: :posts - get 'posts/:segment/:slug', to: 'posts#show', as: :post - get 'pages/:slug', to: 'pages#show', as: :page + get "posts/:segment/:slug", to: "posts#show", as: :post + get "pages/:slug", to: "pages#show", as: :page direct :status do - 'https://status.ksylvest.com' + "https://status.ksylvest.com" end direct :github do - 'https://github.com/ksylvest' + "https://github.com/ksylvest" end direct :twitter do - 'https://x.com/ksylvest' + "https://x.com/ksylvest" end direct :facebook do - 'https://facebook.com/ksylvest' + "https://facebook.com/ksylvest" end direct :dribbble do - 'https://dribbble.com/ksylvest' + "https://dribbble.com/ksylvest" end direct :linkedin do - 'https://www.linkedin.com/in/ksylvest' + "https://www.linkedin.com/in/ksylvest" end direct :vimeo do - 'https://vimeo.com/ksylvest' + "https://vimeo.com/ksylvest" end direct :stackoverflow do - 'https://stackoverflow.com/users/259900/kevin-sylvestre?rel=author' + "https://stackoverflow.com/users/259900/kevin-sylvestre?rel=author" end %w[wp-login.php].each do |path| - get path, to: redirect('/') + get path, to: redirect("/") end end diff --git a/db/seeds.rb b/db/seeds.rb index 85975a3b..a5aca36a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,5 +1,5 @@ -user = User.find_or_initialize_by(email: 'kevin@ksylvest.com') -user.name = 'Kevin Sylvestre' -user.password = 'secret' -user.role = 'admin' +user = User.find_or_initialize_by(email: "kevin@ksylvest.com") +user.name = "Kevin Sylvestre" +user.password = "secret" +user.role = "admin" user.save! diff --git a/lib/tasks/favicon.rake b/lib/tasks/favicon.rake index 2cf3d73c..a5c4c38d 100644 --- a/lib/tasks/favicon.rake +++ b/lib/tasks/favicon.rake @@ -1,8 +1,8 @@ namespace :favicon do - desc 'generate a favicon' + desc "generate a favicon" task generate: :environment do - `sketchtool export artboards #{Rails.root.join('doc/favicon.sketch')} --output=#{Rails.root.join('tmp')}` - `convert #{Rails.root.join('tmp/favicon-*.png')} #{Rails.root.join('app/assets/images?favicon.ico')}` - `rm #{Rails.root.join('tmp/favicon-*')}` + `sketchtool export artboards #{Rails.root.join("doc/favicon.sketch")} --output=#{Rails.root.join("tmp")}` + `convert #{Rails.root.join("tmp/favicon-*.png")} #{Rails.root.join("app/assets/images?favicon.ico")}` + `rm #{Rails.root.join("tmp/favicon-*")}` end end diff --git a/spec/controllers/admin/attachments_controller_spec.rb b/spec/controllers/admin/attachments_controller_spec.rb index 2e7aad21..1b74de63 100644 --- a/spec/controllers/admin/attachments_controller_spec.rb +++ b/spec/controllers/admin/attachments_controller_spec.rb @@ -1,37 +1,37 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Admin::AttachmentsController, type: :request do let!(:attachment) { create(:attachment) } - let(:user) { create(:user, role: 'admin') } - let(:invalid_attributes) { { file: fixture_file_upload('spec/fixtures/attachment'), name: '' } } - let(:valid_attributes) { { file: fixture_file_upload('spec/fixtures/attachment'), name: 'Ruby...' } } + let(:user) { create(:user, role: "admin") } + let(:invalid_attributes) { { file: fixture_file_upload("spec/fixtures/attachment"), name: "" } } + let(:valid_attributes) { { file: fixture_file_upload("spec/fixtures/attachment"), name: "Ruby..." } } before { authenticate(user) } - describe 'GET #index' do - it 'is successful' do + describe "GET #index" do + it "is successful" do get admin_attachments_path expect(response).to have_http_status(:ok) end end - describe 'GET #new' do - it 'is successful' do + describe "GET #new" do + it "is successful" do get new_admin_attachment_path expect(response).to have_http_status(:ok) end end - describe 'GET #edit' do - it 'is successful' do + describe "GET #edit" do + it "is successful" do get edit_admin_attachment_path(attachment) expect(response).to have_http_status(:ok) end end - describe 'POST #create' do - describe 'with valid params' do - it 'saves' do + describe "POST #create" do + describe "with valid params" do + it "saves" do expect { post admin_attachments_path, params: { attachment: valid_attributes } expect(response).to redirect_to(admin_attachments_path) @@ -39,8 +39,8 @@ end end - describe 'with invalid params' do - it 'does not save' do + describe "with invalid params" do + it "does not save" do expect { post admin_attachments_path, params: { attachment: invalid_attributes } expect(response).to have_http_status(:unprocessable_content) @@ -49,9 +49,9 @@ end end - describe 'PATCH #update' do - describe 'with valid params' do - it 'saves' do + describe "PATCH #update" do + describe "with valid params" do + it "saves" do expect { patch admin_attachment_path(attachment), params: { attachment: valid_attributes } expect(response).to redirect_to(admin_attachments_path) @@ -59,8 +59,8 @@ end end - describe 'with invalid params' do - it 'does not save' do + describe "with invalid params" do + it "does not save" do expect { patch admin_attachment_path(attachment), params: { attachment: invalid_attributes } expect(response).to have_http_status(:unprocessable_content) @@ -69,8 +69,8 @@ end end - describe 'DELETE #destroy' do - it 'destroys' do + describe "DELETE #destroy" do + it "destroys" do expect { delete admin_attachment_path(attachment) expect(response).to redirect_to(admin_attachments_path) diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb index 6a7e1f9b..4a4ca3a9 100644 --- a/spec/controllers/admin/dashboard_controller_spec.rb +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -1,12 +1,12 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Admin::DashboardController, type: :request do - let(:user) { create(:user, role: 'admin') } + let(:user) { create(:user, role: "admin") } before { authenticate(user) } - describe 'GET #index' do - it 'is successful' do + describe "GET #index" do + it "is successful" do get admin_path expect(response).to have_http_status(:ok) end diff --git a/spec/controllers/admin/pages_controller_spec.rb b/spec/controllers/admin/pages_controller_spec.rb index 52c08a9b..04aa6fc3 100644 --- a/spec/controllers/admin/pages_controller_spec.rb +++ b/spec/controllers/admin/pages_controller_spec.rb @@ -1,37 +1,37 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Admin::PagesController, type: :request do let!(:entry) { create(:page, user:) } - let(:user) { create(:user, role: 'admin') } - let(:valid_attributes) { { title: 'Sorbet', summary: 'Sorbet', body: 'Sorbet...' } } - let(:invalid_attributes) { { title: '', body: '' } } + let(:user) { create(:user, role: "admin") } + let(:valid_attributes) { { title: "Sorbet", summary: "Sorbet", body: "Sorbet..." } } + let(:invalid_attributes) { { title: "", body: "" } } before { authenticate(user) } - describe 'GET #index' do - it 'is successful' do + describe "GET #index" do + it "is successful" do get admin_pages_path expect(response).to have_http_status(:ok) end end - describe 'GET #new' do - it 'is successful' do + describe "GET #new" do + it "is successful" do get new_admin_page_path expect(response).to have_http_status(:ok) end end - describe 'GET #edit' do - it 'is successful' do + describe "GET #edit" do + it "is successful" do get edit_admin_page_path(entry) expect(response).to have_http_status(:ok) end end - describe 'POST #create' do - context 'with valid params' do - it 'saves' do + describe "POST #create" do + context "with valid params" do + it "saves" do expect { post admin_pages_path, params: { page: valid_attributes } expect(response).to redirect_to(admin_pages_path) @@ -39,8 +39,8 @@ end end - context 'with invalid params' do - it 'does not' do + context "with invalid params" do + it "does not" do expect { post admin_pages_path, params: { page: invalid_attributes } expect(response).to have_http_status(:unprocessable_content) @@ -49,9 +49,9 @@ end end - describe 'PATCH #update' do - context 'with valid params' do - it 'saves' do + describe "PATCH #update" do + context "with valid params" do + it "saves" do expect { patch admin_page_path(entry), params: { page: valid_attributes } expect(response).to redirect_to(admin_pages_path) @@ -59,8 +59,8 @@ end end - context 'with invalid params' do - it 'does not save' do + context "with invalid params" do + it "does not save" do expect { patch admin_page_path(entry), params: { page: invalid_attributes } expect(response).to have_http_status(:unprocessable_content) @@ -69,8 +69,8 @@ end end - describe 'DELETE #destroy' do - it 'destroys' do + describe "DELETE #destroy" do + it "destroys" do expect { delete admin_page_path(entry) expect(response).to redirect_to(admin_pages_path) diff --git a/spec/controllers/admin/posts_controller_spec.rb b/spec/controllers/admin/posts_controller_spec.rb index bab41327..d1c50a29 100644 --- a/spec/controllers/admin/posts_controller_spec.rb +++ b/spec/controllers/admin/posts_controller_spec.rb @@ -1,37 +1,37 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Admin::PostsController, type: :request do let!(:entry) { create(:post, user:) } - let(:user) { create(:user, role: 'admin') } - let(:valid_attributes) { { title: 'Sorbet', summary: 'Sorbet', body: 'Sorbet...' } } - let(:invalid_attributes) { { title: '', body: '' } } + let(:user) { create(:user, role: "admin") } + let(:valid_attributes) { { title: "Sorbet", summary: "Sorbet", body: "Sorbet..." } } + let(:invalid_attributes) { { title: "", body: "" } } before { authenticate(user) } - describe 'GET #index' do - it 'is successful' do + describe "GET #index" do + it "is successful" do get admin_posts_path expect(response).to have_http_status(:ok) end end - describe 'GET #new' do - it 'is successful' do + describe "GET #new" do + it "is successful" do get new_admin_post_path expect(response).to have_http_status(:ok) end end - describe 'GET #edit' do - it 'assigns the requested post as @post' do + describe "GET #edit" do + it "assigns the requested post as @post" do get edit_admin_post_path(entry) expect(response).to have_http_status(:ok) end end - describe 'POST #create' do - context 'with valid params' do - it 'saves a post' do + describe "POST #create" do + context "with valid params" do + it "saves a post" do expect { post admin_posts_path, params: { post: valid_attributes } expect(response).to redirect_to(admin_posts_path) @@ -39,8 +39,8 @@ end end - context 'with invalid params' do - it 'does not save a post' do + context "with invalid params" do + it "does not save a post" do expect { post admin_posts_path, params: { post: invalid_attributes } expect(response).to have_http_status(:unprocessable_content) @@ -49,9 +49,9 @@ end end - describe 'PATCH #update' do - context 'with valid params' do - it 'saves the post' do + describe "PATCH #update" do + context "with valid params" do + it "saves the post" do expect { patch admin_post_path(entry), params: { post: valid_attributes } expect(response).to redirect_to(admin_posts_path) @@ -59,8 +59,8 @@ end end - context 'with invalid params' do - it 'does not save the page' do + context "with invalid params" do + it "does not save the page" do expect { patch admin_post_path(entry), params: { post: invalid_attributes } expect(response).to have_http_status(:unprocessable_content) @@ -69,8 +69,8 @@ end end - describe 'DELETE #destroy' do - it 'destroys' do + describe "DELETE #destroy" do + it "destroys" do expect { delete admin_post_path(entry) expect(response).to redirect_to(admin_posts_path) diff --git a/spec/controllers/admin/sessions_controller_spec.rb b/spec/controllers/admin/sessions_controller_spec.rb index 96d9d63b..3cfad0f6 100644 --- a/spec/controllers/admin/sessions_controller_spec.rb +++ b/spec/controllers/admin/sessions_controller_spec.rb @@ -1,33 +1,33 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Admin::SessionsController, type: :request do - let(:user) { create(:user, role: 'admin') } + let(:user) { create(:user, role: "admin") } - describe 'GET #new' do - it 'is successful' do + describe "GET #new" do + it "is successful" do get new_admin_session_url expect(response).to have_http_status(:ok) end end - describe 'POST #create' do - context 'with valid parameters' do - it 'authenticates' do + describe "POST #create" do + context "with valid parameters" do + it "authenticates" do post admin_session_url, params: { session: { email: user.email, password: user.password } } expect(response).to redirect_to(admin_path) end end - context 'with invalid parameters' do - it 'does not authenticate' do + context "with invalid parameters" do + it "does not authenticate" do post admin_session_url, params: { session: { email: user.password, password: user.email } } expect(response).to have_http_status(:unprocessable_content) end end end - describe 'DELETE #destroy' do - it 'deauthenticates' do + describe "DELETE #destroy" do + it "deauthenticates" do authenticate user delete admin_session_url expect(response).to be_redirect diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index da0f7871..7cf8ba6a 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -1,20 +1,20 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Admin::UsersController, type: :request do let(:user) { create(:user, role: User::Role::ADMIN) } before { authenticate(user) } - describe 'GET #edit' do - it 'is successful' do + describe "GET #edit" do + it "is successful" do get edit_admin_user_path expect(response).to have_http_status(:ok) end end - describe 'PATCH #update' do - context 'with valid parameters' do - it 'saves the user' do + describe "PATCH #update" do + context "with valid parameters" do + it "saves the user" do expect { patch admin_user_path, params: { user: { name: user.name.reverse } } expect(response).to redirect_to(admin_path) @@ -22,10 +22,10 @@ end end - context 'with invalid parameters' do - it 'does not save the user' do + context "with invalid parameters" do + it "does not save the user" do expect { - patch admin_user_path, params: { user: { name: '' } } + patch admin_user_path, params: { user: { name: "" } } expect(response).to have_http_status(:unprocessable_content) }.not_to change { user.reload.name } end diff --git a/spec/controllers/archives_controller_spec.rb b/spec/controllers/archives_controller_spec.rb index c924a968..e6db5bfd 100644 --- a/spec/controllers/archives_controller_spec.rb +++ b/spec/controllers/archives_controller_spec.rb @@ -1,8 +1,8 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe ArchivesController, type: :request do - describe 'GET #show' do - it 'is successful' do + describe "GET #show" do + it "is successful" do get archive_path expect(response).to have_http_status(:ok) end diff --git a/spec/controllers/auths_controller_spec.rb b/spec/controllers/auths_controller_spec.rb index 7c2b307e..bfa9e68a 100644 --- a/spec/controllers/auths_controller_spec.rb +++ b/spec/controllers/auths_controller_spec.rb @@ -1,17 +1,17 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe AuthsController, type: :request do let(:user) { create(:user) } - describe 'POST #create' do - it 'is successful' do + describe "POST #create" do + it "is successful" do authenticate(user) expect(response).to have_http_status(:ok) end end - describe 'DELETE #destroy' do - it 'is successful' do + describe "DELETE #destroy" do + it "is successful" do deauthenticate expect(response).to have_http_status(:ok) end diff --git a/spec/controllers/errors_controller_spec.rb b/spec/controllers/errors_controller_spec.rb index 42e7ac0b..4a208cea 100644 --- a/spec/controllers/errors_controller_spec.rb +++ b/spec/controllers/errors_controller_spec.rb @@ -1,22 +1,22 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe ErrorsController, type: :request do - describe 'GET #missing' do - it 'renders the correct status code' do + describe "GET #missing" do + it "renders the correct status code" do get missing_path expect(response).to have_http_status(:not_found) end end - describe 'GET #unprocessable' do - it 'renders the correct status code' do + describe "GET #unprocessable" do + it "renders the correct status code" do get unprocessable_path expect(response).to have_http_status(:unprocessable_content) end end - describe 'GET #exception' do - it 'renders the correct status code' do + describe "GET #exception" do + it "renders the correct status code" do get exception_path expect(response).to have_http_status(:internal_server_error) end diff --git a/spec/controllers/feeds_controller_spec.rb b/spec/controllers/feeds_controller_spec.rb index 65655c1a..41c17a3e 100644 --- a/spec/controllers/feeds_controller_spec.rb +++ b/spec/controllers/feeds_controller_spec.rb @@ -1,8 +1,8 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe FeedsController, type: :request do - describe 'GET #show' do - it 'is successful' do + describe "GET #show" do + it "is successful" do get feed_path(format: :atom) expect(response).to have_http_status(:ok) end diff --git a/spec/controllers/main_controller_spec.rb b/spec/controllers/main_controller_spec.rb index dd617d11..cddfff62 100644 --- a/spec/controllers/main_controller_spec.rb +++ b/spec/controllers/main_controller_spec.rb @@ -1,29 +1,29 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe MainController, type: :request do - describe 'GET #about' do - it 'is successful' do + describe "GET #about" do + it "is successful" do get about_path expect(response).to have_http_status(:ok) end end - describe 'GET #contact' do - it 'is successful' do + describe "GET #contact" do + it "is successful" do get contact_path expect(response).to have_http_status(:ok) end end - describe 'GET #projects' do - it 'is successful' do + describe "GET #projects" do + it "is successful" do get projects_path expect(response).to have_http_status(:ok) end end - describe 'GET #portfolio' do - it 'is successful' do + describe "GET #portfolio" do + it "is successful" do get portfolio_path expect(response).to have_http_status(:ok) end diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index fa18da68..d246bf27 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -1,10 +1,10 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe PagesController, type: :request do let(:page) { create(:page) } - describe 'GET #show' do - it 'is successful' do + describe "GET #show" do + it "is successful" do get page_path(slug: page.slug) expect(response).to have_http_status(:ok) end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index d0a0c976..05d10e35 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -1,36 +1,36 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe PostsController, type: :request do let(:post) { create(:post) } - describe 'GET #index' do - it 'is succcesful' do + describe "GET #index" do + it "is succcesful" do get posts_path expect(response).to have_http_status(:ok) end end - describe 'GET #show' do - it 'is successful' do + describe "GET #show" do + it "is successful" do get post_path(segment: post.segment, slug: post.slug) expect(response).to have_http_status(:ok) end - context 'with an active post' do + context "with an active post" do let(:post) { create(:post, status: Approvable::Status::ACTIVE) } - it 'allows indexing of valid posts' do + it "allows indexing of valid posts" do get post_path(segment: post.segment, slug: post.slug) - expect(response.headers['X-Robots-Tag']).to be_nil + expect(response.headers["X-Robots-Tag"]).to be_nil end end - context 'with an inactive post' do + context "with an inactive post" do let(:post) { create(:post, status: Approvable::Status::PENDING) } - it 'disallows indexing of invalid posts' do + it "disallows indexing of invalid posts" do get post_path(segment: post.segment, slug: post.slug) - expect(response.headers['X-Robots-Tag']).to(eql('noindex,nofollow')) + expect(response.headers["X-Robots-Tag"]).to(eql("noindex,nofollow")) end end end diff --git a/spec/controllers/sitemaps_controller_spec.rb b/spec/controllers/sitemaps_controller_spec.rb index b304cded..99cb9dd1 100644 --- a/spec/controllers/sitemaps_controller_spec.rb +++ b/spec/controllers/sitemaps_controller_spec.rb @@ -1,8 +1,8 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe SitemapsController, type: :request do - describe 'GET #show' do - it 'is successful' do + describe "GET #show" do + it "is successful" do get sitemap_path(:xml) expect(response).to have_http_status(:ok) end diff --git a/spec/factories/attachments.rb b/spec/factories/attachments.rb index a7228f6f..9c1ff2a5 100644 --- a/spec/factories/attachments.rb +++ b/spec/factories/attachments.rb @@ -1,26 +1,26 @@ FactoryBot.define do factory :attachment do - name { 'Attachment' } - file { Rack::Test::UploadedFile.new(Rails.root.join('spec/fixtures', fixture)) } + name { "Attachment" } + file { Rack::Test::UploadedFile.new(Rails.root.join("spec/fixtures", fixture)) } transient do - fixture { 'attachment' } + fixture { "attachment" } end trait :audio do - fixture { 'audio.wav' } + fixture { "audio.wav" } end trait :image do - fixture { 'image.png' } + fixture { "image.png" } end trait :video do - fixture { 'video.mov' } + fixture { "video.mov" } end trait :other do - fixture { 'other' } + fixture { "other" } end end end diff --git a/spec/factories/pages.rb b/spec/factories/pages.rb index 4a285efc..ad8cdc3f 100644 --- a/spec/factories/pages.rb +++ b/spec/factories/pages.rb @@ -2,8 +2,8 @@ factory :page do user status { Approvable::Status::ACTIVE } - title { 'Ruby' } - summary { 'An overview of ruby.' } - body { 'Ruby is an interpreted programming language.' } + title { "Ruby" } + summary { "An overview of ruby." } + body { "Ruby is an interpreted programming language." } end end diff --git a/spec/factories/posts.rb b/spec/factories/posts.rb index 4c9f5a64..ad273adf 100644 --- a/spec/factories/posts.rb +++ b/spec/factories/posts.rb @@ -2,8 +2,8 @@ factory :post do user status { Approvable::Status::ACTIVE } - title { 'Rails' } - summary { 'An overview of rails.' } - body { 'Rails is a web application framework.' } + title { "Rails" } + summary { "An overview of rails." } + body { "Rails is a web application framework." } end end diff --git a/spec/factories/sessions.rb b/spec/factories/sessions.rb index 3fbd7f3d..ec910e0b 100644 --- a/spec/factories/sessions.rb +++ b/spec/factories/sessions.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory :session do sequence(:email) { |index| "#{index}@test.host" } - password { 'secret' } + password { "secret" } end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 5e381130..aff2c345 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :user do - name { 'Kevin Sylvestre' } + name { "Kevin Sylvestre" } sequence(:email) { |index| "#{index}@test.host" } - password { 'secret' } + password { "secret" } end end diff --git a/spec/features/compression_spec.rb b/spec/features/compression_spec.rb index cc359c0a..0e212fa9 100644 --- a/spec/features/compression_spec.rb +++ b/spec/features/compression_spec.rb @@ -1,19 +1,19 @@ -require 'spec_helper' +require "spec_helper" -RSpec.describe 'compression', type: :request do - describe 'a request with gzip or deflate' do +RSpec.describe "compression", type: :request do + describe "a request with gzip or deflate" do %w[gzip deflate,gzip gzip,deflate].each do |http_accept_encoding| it "sets a content encoding for '#{http_accept_encoding}'" do - get root_path, headers: { 'HTTP_ACCEPT_ENCODING' => http_accept_encoding } - expect(response.headers['Content-Encoding']).to be_present + get root_path, headers: { "HTTP_ACCEPT_ENCODING" => http_accept_encoding } + expect(response.headers["Content-Encoding"]).to be_present end end end - describe 'a request without gzip or deflate' do - it 'does not set a content encoding for no accept content encoding' do + describe "a request without gzip or deflate" do + it "does not set a content encoding for no accept content encoding" do get root_path - expect(response.headers['Content-Encoding']).to be_blank + expect(response.headers["Content-Encoding"]).to be_blank end end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 738ae14c..c28b1c7c 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,18 +1,18 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe ApplicationHelper do - describe '#markdown' do + describe "#markdown" do subject(:markdown) { helper.markdown(text) } - context 'with text' do - let(:text) { 'Example' } + context "with text" do + let(:text) { "Example" } - it 'converts to markdown' do - expect(markdown).to match('

Example

') + it "converts to markdown" do + expect(markdown).to match("

Example

") end end - context 'with code' do + context "with code" do let(:text) do <<~MARKDOWN ```language @@ -21,10 +21,10 @@ MARKDOWN end - it 'highlights code' do + it "highlights code" do expect(markdown).to match('
')
-        expect(markdown).to match('hello')
-        expect(markdown).to match('
') + expect(markdown).to match("hello") + expect(markdown).to match("") end end @@ -33,26 +33,26 @@ let(:text) { "![Image](attachment:#{attachment.id}:#{variant})" } let(:attachment) { create(:attachment, :image) } - it 'generates an image' do + it "generates an image" do expect(markdown).to match('Image') end end end end - describe '#filters' do - it 'returns nothing unless a page is specified' do + describe "#filters" do + it "returns nothing unless a page is specified" do expect(helper.filters({})).to be_blank end - it 'returns something if a page is specified' do - expect(helper.filters(page: 2, tag: 'Ruby')).to be_present + it "returns something if a page is specified" do + expect(helper.filters(page: 2, tag: "Ruby")).to be_present end end %w[github twitter facebook dribbble linkedin vimeo stackoverflow].each do |service| describe "##{service}_url" do - it 'returns a valid URL' do + it "returns a valid URL" do expect(helper.send("#{service}_url")).to match(Validation::URL) end end diff --git a/spec/models/attaching_spec.rb b/spec/models/attaching_spec.rb index fa673166..5ca8506d 100644 --- a/spec/models/attaching_spec.rb +++ b/spec/models/attaching_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Attaching do it { is_expected.to belong_to(:attachment) } diff --git a/spec/models/attachment_spec.rb b/spec/models/attachment_spec.rb index 4e6587b1..cb7b68cf 100644 --- a/spec/models/attachment_spec.rb +++ b/spec/models/attachment_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Attachment do it { is_expected.to validate_presence_of(:name) } diff --git a/spec/models/page_spec.rb b/spec/models/page_spec.rb index c3b5ceea..f1464305 100644 --- a/spec/models/page_spec.rb +++ b/spec/models/page_spec.rb @@ -1,12 +1,12 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Page do subject { build(:page) } - it_behaves_like 'approvable' - it_behaves_like 'attachable' - it_behaves_like 'searchable' - it_behaves_like 'taggable' + it_behaves_like "approvable" + it_behaves_like "attachable" + it_behaves_like "searchable" + it_behaves_like "taggable" it { is_expected.to belong_to(:user) } @@ -14,17 +14,17 @@ it { is_expected.to validate_presence_of(:summary) } it { is_expected.to validate_presence_of(:body) } - it { is_expected.to allow_value('ruby-on-rails').for(:slug) } - it { is_expected.not_to allow_value('Ruby on Rails').for(:slug) } + it { is_expected.to allow_value("ruby-on-rails").for(:slug) } + it { is_expected.not_to allow_value("Ruby on Rails").for(:slug) } - it { is_expected.to allow_value('2013-12-31').for(:slug) } - it { is_expected.not_to allow_value('2013 12 31').for(:slug) } + it { is_expected.to allow_value("2013-12-31").for(:slug) } + it { is_expected.not_to allow_value("2013 12 31").for(:slug) } - describe '.search' do - subject(:search) { Page.search('Potato') } + describe ".search" do + subject(:search) { Page.search("Potato") } - let!(:match) { create(:page, title: 'Potato') } - let!(:miss) { create(:page, title: 'Tomato') } + let!(:match) { create(:page, title: "Potato") } + let!(:miss) { create(:page, title: "Tomato") } it 'includes a page about "Potato" when searching for "Potato"' do expect(search).to include(match) diff --git a/spec/models/portfolio_spec.rb b/spec/models/portfolio_spec.rb index 2e2f8139..81a4d4f7 100644 --- a/spec/models/portfolio_spec.rb +++ b/spec/models/portfolio_spec.rb @@ -1,8 +1,8 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Portfolio do - describe '.all' do - it 'returns an array of projects' do + describe ".all" do + it "returns an array of projects" do expect(Portfolio.all).to be_a(Array) end end diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 4ac4f9d5..e062bcbf 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -1,12 +1,12 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Post do subject { build(:post) } - it_behaves_like 'approvable' - it_behaves_like 'attachable' - it_behaves_like 'searchable' - it_behaves_like 'taggable' + it_behaves_like "approvable" + it_behaves_like "attachable" + it_behaves_like "searchable" + it_behaves_like "taggable" it { is_expected.to belong_to(:user) } @@ -14,14 +14,14 @@ it { is_expected.to validate_presence_of(:summary) } it { is_expected.to validate_presence_of(:body) } - it { is_expected.to allow_value('ruby-on-rails').for(:slug) } - it { is_expected.not_to allow_value('Ruby on Rails').for(:slug) } + it { is_expected.to allow_value("ruby-on-rails").for(:slug) } + it { is_expected.not_to allow_value("Ruby on Rails").for(:slug) } - describe '.search' do - subject(:search) { Post.search('Ruby') } + describe ".search" do + subject(:search) { Post.search("Ruby") } - let!(:match) { create(:post, title: 'Ruby') } - let!(:miss) { create(:post, title: 'Python') } + let!(:match) { create(:post, title: "Ruby") } + let!(:miss) { create(:post, title: "Python") } it 'includes a post about "Ruby" when searching for "Ruby"' do expect(search).to include(match) diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 0d07cf64..381a2103 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1,8 +1,8 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Project do - describe '.all' do - it 'returns an array of projects' do + describe ".all" do + it "returns an array of projects" do expect(Project.all).to be_a(Array) end end diff --git a/spec/models/search_spec.rb b/spec/models/search_spec.rb index 8cfba089..9690ba32 100644 --- a/spec/models/search_spec.rb +++ b/spec/models/search_spec.rb @@ -1,20 +1,20 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Search do subject(:search) { Search.new(query) } let!(:page) { create(:page, title: query) } let!(:post) { create(:post, title: query) } - let(:query) { 'Ruby' } + let(:query) { "Ruby" } - describe '#pages' do - it 'searches pages' do + describe "#pages" do + it "searches pages" do expect(search.pages).to include(page) end end - describe '#posts' do - it 'searches posts' do + describe "#posts" do + it "searches posts" do expect(search.posts).to include(post) end end diff --git a/spec/models/session_spec.rb b/spec/models/session_spec.rb index a2401102..50def8ea 100644 --- a/spec/models/session_spec.rb +++ b/spec/models/session_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Session do let(:user) { create(:user) } @@ -6,18 +6,18 @@ it { is_expected.to validate_presence_of(:email) } it { is_expected.to validate_presence_of(:password) } - it { is_expected.not_to allow_value('kevin').for(:email) } - it { is_expected.not_to allow_value('@host.com').for(:email) } - it { is_expected.to allow_value('kevin@host.com').for(:email) } + it { is_expected.not_to allow_value("kevin").for(:email) } + it { is_expected.not_to allow_value("@host.com").for(:email) } + it { is_expected.to allow_value("kevin@host.com").for(:email) } - describe '#authenticate' do - it 'returns a user if authed' do + describe "#authenticate" do + it "returns a user if authed" do session = Session.new(email: user.email, password: user.password) expect(session.authenticate).to eq(user) expect(session.errors).to be_blank end - it 'returns a nil if not authed' do + it "returns a nil if not authed" do session = Session.new(email: user.email, password: user.password.reverse) expect(session.authenticate).to be_nil expect(session.errors).to be_present diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index bce1d89a..e8d9ee0e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe User do subject { build(:user) } @@ -8,8 +8,8 @@ it { is_expected.to validate_uniqueness_of :email } - it { is_expected.not_to allow_value('kevin').for(:email) } - it { is_expected.not_to allow_value('@host.com').for(:email) } - it { is_expected.not_to allow_value('kevin@host').for(:email) } - it { is_expected.to allow_value('kevin@host.com').for(:email) } + it { is_expected.not_to allow_value("kevin").for(:email) } + it { is_expected.not_to allow_value("@host.com").for(:email) } + it { is_expected.not_to allow_value("kevin@host").for(:email) } + it { is_expected.to allow_value("kevin@host.com").for(:email) } end diff --git a/spec/models/validation_spec.rb b/spec/models/validation_spec.rb index 15e27d81..e7695979 100644 --- a/spec/models/validation_spec.rb +++ b/spec/models/validation_spec.rb @@ -1,18 +1,18 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe Validation do - it 'validates urls' do - expect(Validation::URL).to match('https://ksylvest.com') - expect(Validation::URL).not_to match('ksylvest.com') + it "validates urls" do + expect(Validation::URL).to match("https://ksylvest.com") + expect(Validation::URL).not_to match("ksylvest.com") end - it 'validates emails' do - expect(Validation::EMAIL).to match('kevin@ksylvest.com') - expect(Validation::EMAIL).not_to match('kevin') + it "validates emails" do + expect(Validation::EMAIL).to match("kevin@ksylvest.com") + expect(Validation::EMAIL).not_to match("kevin") end - it 'validates permalinks' do - expect(Validation::PERMALINK).to match('2014-12-31-something') - expect(Validation::PERMALINK).not_to match('2014 12 31 something') + it "validates permalinks" do + expect(Validation::PERMALINK).to match("2014-12-31-something") + expect(Validation::PERMALINK).not_to match("2014 12 31 something") end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index adf9c6c6..9272a82a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,12 +1,12 @@ -require 'simplecov' -SimpleCov.start 'rails' +require "simplecov" +SimpleCov.start "rails" -ENV['RAILS_ENV'] ||= 'test' +ENV["RAILS_ENV"] ||= "test" -require File.expand_path('../../config/environment', __FILE__) -require 'rspec/rails' +require File.expand_path("../../config/environment", __FILE__) +require "rspec/rails" -Rails.root.glob('spec/support/**/*.rb').each { |file| require file } +Rails.root.glob("spec/support/**/*.rb").each { |file| require file } ActiveJob::Base.queue_adapter = :test diff --git a/spec/support/auth.rb b/spec/support/auth.rb index b76e05ab..47fc13aa 100644 --- a/spec/support/auth.rb +++ b/spec/support/auth.rb @@ -1,7 +1,7 @@ module Auth module Helpers def authenticate(user) - post(auth_path, params: { token: user.to_signed_global_id(for: 'auth') }) + post(auth_path, params: { token: user.to_signed_global_id(for: "auth") }) end def deauthenticate diff --git a/spec/support/concerns/approvable.rb b/spec/support/concerns/approvable.rb index ae5e4094..5618fa5e 100644 --- a/spec/support/concerns/approvable.rb +++ b/spec/support/concerns/approvable.rb @@ -1,14 +1,14 @@ -require 'spec_helper' +require "spec_helper" -shared_examples_for 'approvable' do - describe 'active?' do +shared_examples_for "approvable" do + describe "active?" do it 'is active if the status is "active"' do subject.status = Approvable::Status::ACTIVE expect(subject).to be_active end end - describe 'pending?' do + describe "pending?" do it 'is pending if the status is "pending"' do subject.status = Approvable::Status::PENDING expect(subject).to be_pending diff --git a/spec/support/concerns/attachable.rb b/spec/support/concerns/attachable.rb index ee74d638..da2d2836 100644 --- a/spec/support/concerns/attachable.rb +++ b/spec/support/concerns/attachable.rb @@ -1,8 +1,8 @@ -require 'spec_helper' +require "spec_helper" -shared_examples_for 'attachable' do - describe '#attachments' do - it 'attaches using a the link syntax provided by markdown' do +shared_examples_for "attachable" do + describe "#attachments" do + it "attaches using a the link syntax provided by markdown" do attachment = create(:attachment) subject.summary = "![attachment](attachment:#{attachment.id}:original)" subject.attach! diff --git a/spec/support/concerns/searchable.rb b/spec/support/concerns/searchable.rb index d8ab469f..4ac413f8 100644 --- a/spec/support/concerns/searchable.rb +++ b/spec/support/concerns/searchable.rb @@ -1,12 +1,12 @@ -require 'spec_helper' +require "spec_helper" -shared_examples_for 'searchable' do - describe '.search' do +shared_examples_for "searchable" do + describe ".search" do subject(:search) { described_class.search(query) } - let(:query) { 'Technology' } + let(:query) { "Technology" } - it 'searches' do + it "searches" do expect { search }.not_to raise_error end end diff --git a/spec/support/concerns/taggable.rb b/spec/support/concerns/taggable.rb index 067de3e3..0f835041 100644 --- a/spec/support/concerns/taggable.rb +++ b/spec/support/concerns/taggable.rb @@ -1,17 +1,17 @@ -require 'spec_helper' +require "spec_helper" -shared_examples_for 'taggable' do - describe '#taggables=' do - it 'splits a value into tags' do - subject.taggables = 'ruby rack' +shared_examples_for "taggable" do + describe "#taggables=" do + it "splits a value into tags" do + subject.taggables = "ruby rack" expect(subject.tags).to eql(%w[ruby rack]) end end - describe '#taggables' do - it 'joins tags into a value' do + describe "#taggables" do + it "joins tags into a value" do subject.tags = %w[ruby rack] - expect(subject.taggables).to eq('ruby rack') + expect(subject.taggables).to eq("ruby rack") end end end diff --git a/spec/system/admin_spec.rb b/spec/system/admin_spec.rb index da76f52d..3bb937cc 100644 --- a/spec/system/admin_spec.rb +++ b/spec/system/admin_spec.rb @@ -1,27 +1,27 @@ -require 'spec_helper' +require "spec_helper" -RSpec.describe 'Admin' do +RSpec.describe "Admin" do let(:user) { create(:user, role: :admin) } - it 'lets a user authenticate with valid credentials' do + it "lets a user authenticate with valid credentials" do visit admin_path - within('form') do - fill_in('Email', with: user.email) - fill_in('Password', with: user.password) - click_on('Login') + within("form") do + fill_in("Email", with: user.email) + fill_in("Password", with: user.password) + click_on("Login") end - expect(page).to have_text('Account') - expect(page).to have_text('Logout') + expect(page).to have_text("Account") + expect(page).to have_text("Logout") end - it 'prohibits a user authentication with invalid credentials' do + it "prohibits a user authentication with invalid credentials" do visit admin_path - within('form') do - fill_in('Email', with: '') - fill_in('Password', with: '') - click_on('Login') + within("form") do + fill_in("Email", with: "") + fill_in("Password", with: "") + click_on("Login") end - expect(page).to have_no_text('Account') - expect(page).to have_no_text('Logout') + expect(page).to have_no_text("Account") + expect(page).to have_no_text("Logout") end end diff --git a/spec/system/errors_spec.rb b/spec/system/errors_spec.rb index 2aad002a..42ee685a 100644 --- a/spec/system/errors_spec.rb +++ b/spec/system/errors_spec.rb @@ -1,27 +1,27 @@ -require 'spec_helper' +require "spec_helper" -RSpec.describe 'Errors' do - it 'renders a page for missing' do +RSpec.describe "Errors" do + it "renders a page for missing" do visit missing_path - expect(page).to have_text('The page you were looking for does not exist.') - expect(page).to have_text('You may have mistyped the address or the page may have moved.') - expect(page).to have_text('If you continue to experience problems please contact us at info@ksylvest.com.') + expect(page).to have_text("The page you were looking for does not exist.") + expect(page).to have_text("You may have mistyped the address or the page may have moved.") + expect(page).to have_text("If you continue to experience problems please contact us at info@ksylvest.com.") end - it 'renders a page for unprocessable' do + it "renders a page for unprocessable" do visit unprocessable_path - expect(page).to have_text('The change you wanted was rejected.') - expect(page).to have_text('Maybe you tried to change something you do not have access to.') - expect(page).to have_text('If you continue to experience problems please contact us at info@ksylvest.com.') + expect(page).to have_text("The change you wanted was rejected.") + expect(page).to have_text("Maybe you tried to change something you do not have access to.") + expect(page).to have_text("If you continue to experience problems please contact us at info@ksylvest.com.") end - it 'renders a page for exception' do + it "renders a page for exception" do visit exception_path - expect(page).to have_text('Something went wrong.') - expect(page).to have_text('We have been notified of the issue and will try and fix it.') - expect(page).to have_text('If you continue to experience problems please contact us at info@ksylvest.com.') + expect(page).to have_text("Something went wrong.") + expect(page).to have_text("We have been notified of the issue and will try and fix it.") + expect(page).to have_text("If you continue to experience problems please contact us at info@ksylvest.com.") end end diff --git a/spec/system/pages_spec.rb b/spec/system/pages_spec.rb index 6b84e224..04a6a114 100644 --- a/spec/system/pages_spec.rb +++ b/spec/system/pages_spec.rb @@ -1,9 +1,9 @@ -require 'spec_helper' +require "spec_helper" -RSpec.describe 'Pages' do +RSpec.describe "Pages" do let(:entry) { create(:page) } - it 'lets a visitor view a page title and body' do + it "lets a visitor view a page title and body" do visit page_path(slug: entry.slug) expect(page).to have_text(entry.title) diff --git a/spec/system/portfolio_spec.rb b/spec/system/portfolio_spec.rb index 63cffeb3..4585b59c 100644 --- a/spec/system/portfolio_spec.rb +++ b/spec/system/portfolio_spec.rb @@ -1,7 +1,7 @@ -require 'spec_helper' +require "spec_helper" -RSpec.describe 'Portfolio' do - it 'links to every portfolio entry' do +RSpec.describe "Portfolio" do + it "links to every portfolio entry" do visit portfolio_path Portfolio.all.each do |portfolio| diff --git a/spec/system/posts_spec.rb b/spec/system/posts_spec.rb index 047c31f4..9dac0dab 100644 --- a/spec/system/posts_spec.rb +++ b/spec/system/posts_spec.rb @@ -1,9 +1,9 @@ -require 'spec_helper' +require "spec_helper" -RSpec.describe 'Posts' do +RSpec.describe "Posts" do let(:entry) { create(:post) } - it 'lets a visitor view a post title and body' do + it "lets a visitor view a post title and body" do visit post_path(segment: entry.segment, slug: entry.slug) expect(page).to have_text(entry.title) diff --git a/spec/system/projects_spec.rb b/spec/system/projects_spec.rb index fb5c6ddd..a1cacc16 100644 --- a/spec/system/projects_spec.rb +++ b/spec/system/projects_spec.rb @@ -1,7 +1,7 @@ -require 'spec_helper' +require "spec_helper" -RSpec.describe 'Projects' do - it 'links to every project entry' do +RSpec.describe "Projects" do + it "links to every project entry" do visit projects_path Project.all.each do |project| diff --git a/spec/system/search_spec.rb b/spec/system/search_spec.rb index 32fef348..3b641841 100644 --- a/spec/system/search_spec.rb +++ b/spec/system/search_spec.rb @@ -1,20 +1,20 @@ -require 'spec_helper' +require "spec_helper" -RSpec.describe 'Search' do +RSpec.describe "Search" do let(:searchables) do [ - create(:page, title: 'Rails', summary: 'Rails is a web application framework.'), - create(:post, title: 'swift', summary: 'Swift is a statically typed language.'), + create(:page, title: "Rails", summary: "Rails is a web application framework."), + create(:post, title: "swift", summary: "Swift is a statically typed language."), ] end - it 'filters post when searching' do + it "filters post when searching" do visit search_path searchables.each do |entry| - within('form') do - fill_in('Search', with: entry.title) - click_on('Search') + within("form") do + fill_in("Search", with: entry.title) + click_on("Search") end expect(page).to have_text(entry.title) expect(page).to have_text(entry.summary)