From 4db95bd3c61e06526c59687c63b1242fe938a4d1 Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Wed, 19 Jul 2017 15:03:23 -0400 Subject: [PATCH] Change to double quotes --- .rubocop.yml | 3 --- app/controllers/application_controller.rb | 2 +- app/controllers/categories_controller.rb | 6 +++--- app/controllers/contacts_controller.rb | 6 +++--- app/controllers/home_controller.rb | 2 +- app/controllers/photos_controller.rb | 2 +- app/controllers/sessions_controller.rb | 2 +- app/validators/email_validator.rb | 2 +- app/views/layouts/application.html.erb | 12 +++++------ app/views/pages/show.html.erb | 6 +++--- app/views/shared/_fonts.html.erb | 2 +- app/views/shared/_main_nav.html.erb | 4 ++-- spec/controllers/contacts_controller_spec.rb | 22 ++++++++++---------- spec/controllers/home_controller_spec.rb | 6 +++--- spec/controllers/pages_controller_spec.rb | 10 ++++----- spec/controllers/photos_controller_spec.rb | 6 +++--- spec/controllers/views_controller_spec.rb | 8 +++---- spec/factories/contacts.rb | 6 +++--- spec/factories/pages.rb | 6 +++--- spec/factories/photos.rb | 6 +++--- spec/features/visitor_navigates_site_spec.rb | 22 ++++++++++---------- spec/models/category_spec.rb | 8 +++---- spec/models/contact_spec.rb | 6 +++--- spec/models/photo_spec.rb | 4 ++-- spec/models/user_spec.rb | 8 +++---- 25 files changed, 82 insertions(+), 85 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7d174e5..087e03e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,3 @@ -Metrics/LineLength: - Max: 120 - Documentation: Enabled: false diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 261b08d..199840c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -13,6 +13,6 @@ class ApplicationController < ActionController::Base end def render_404 - render 'errors/not_found', status: :not_found + render "errors/not_found", status: :not_found end end diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index ec46137..e565129 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -2,11 +2,11 @@ class CategoriesController < ApplicationController # GET /categories # GET /categories.xml def index - @categories = Category.order('sort ASC').page(params[:page]).per(4) + @categories = Category.order("sort ASC").page(params[:page]).per(4) - @photos = Photo.featured.limit(2).order('RANDOM()') + @photos = Photo.featured.limit(2).order("RANDOM()") - @page_title = 'Portfolio' + @page_title = "Portfolio" @num_blank = 4 - @categories.length diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index d352acf..ff7a060 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -1,16 +1,16 @@ class ContactsController < ApplicationController def new @contact = Contact.new(id: 1) - @page_title = 'Contact' + @page_title = "Contact" end def create @contact = Contact.new(params[:contact]) if @contact.valid? Notifier.contact_notification(@contact).deliver - redirect_to(:new_contact, notice: t('contact.thanks')) + redirect_to(:new_contact, notice: t("contact.thanks")) else - flash[:alert] = t('contact.invalid') + flash[:alert] = t("contact.invalid") render :new end end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 07e608b..401ddac 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,5 +1,5 @@ class HomeController < ApplicationController def index - @photos = Photo.featured.order('RANDOM()').limit(1) + @photos = Photo.featured.order("RANDOM()").limit(1) end end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index ee002c2..104106f 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -25,6 +25,6 @@ class PhotosController < ApplicationController def all @photos = Photo.enabled.order(taken_at: :desc) .page(params[:page]) - @page_title = 'All Photos' + @page_title = "All Photos" end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 1ed7758..7f27d79 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,5 +1,5 @@ class SessionsController < ApplicationController - layout 'admin/login' + layout "admin/login" skip_before_action :require_login, only: [:new, :create], raise: false diff --git a/app/validators/email_validator.rb b/app/validators/email_validator.rb index 008c2ec..06af44d 100644 --- a/app/validators/email_validator.rb +++ b/app/validators/email_validator.rb @@ -2,6 +2,6 @@ class EmailValidator < ActiveModel::EachValidator def validate_each(object, attribute, value) return if value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i - object.errors[attribute] << (options[:message] || 'is not valid') + object.errors[attribute] << (options[:message] || "is not valid") end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9b3768c..fc279de 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,10 +7,10 @@ - <%= stylesheet_link_tag 'application' %> - <%= javascript_include_tag 'application' %> + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application" %> <%= render "shared/fonts" %> - <%= favicon_link_tag 'favicon.ico' %> + <%= favicon_link_tag "favicon.ico" %> <%= csrf_meta_tags %> @@ -23,7 +23,7 @@
- <%= link_to image_tag(asset_url('title.svg'), alt: 'Dan Barber Photography', width: 236), '/' %> + <%= link_to image_tag(asset_url("title.svg"), alt: "Dan Barber Photography", width: 236), "/" %>
<%= yield :navigation %> @@ -33,12 +33,12 @@ <%= yield %>
- <%= render 'shared/footer' %> + <%= render "shared/footer" %> - <%= render 'shared/analytics' if Rails.env.production? %> + <%= render "shared/analytics" if Rails.env.production? %> diff --git a/app/views/pages/show.html.erb b/app/views/pages/show.html.erb index 542f3f8..0351f6b 100644 --- a/app/views/pages/show.html.erb +++ b/app/views/pages/show.html.erb @@ -2,7 +2,7 @@
- <%= link_to content_tag(:span, 'portfolio'), controller: 'categories' %> + <%= link_to content_tag(:span, "portfolio"), controller: "categories" %>
<% end %> @@ -12,7 +12,7 @@ -
+
);">
@@ -22,5 +22,5 @@
- <%= link_to content_tag(:span, 'contact'), new_contact_path %> + <%= link_to content_tag(:span, "contact"), new_contact_path %>
diff --git a/app/views/shared/_fonts.html.erb b/app/views/shared/_fonts.html.erb index 5a8dc66..3a2a578 100644 --- a/app/views/shared/_fonts.html.erb +++ b/app/views/shared/_fonts.html.erb @@ -1,3 +1,3 @@ <% if !Rails.env.test? %> - <%= stylesheet_link_tag 'https://cloud.typography.com/7434852/6922572/css/fonts.css' %> + <%= stylesheet_link_tag "https://cloud.typography.com/7434852/6922572/css/fonts.css" %> <% end %> diff --git a/app/views/shared/_main_nav.html.erb b/app/views/shared/_main_nav.html.erb index 2dd41cc..a309de1 100644 --- a/app/views/shared/_main_nav.html.erb +++ b/app/views/shared/_main_nav.html.erb @@ -1,6 +1,6 @@
- <%= link_to content_tag(:span, 'about'), page_path(:about) %> + <%= link_to content_tag(:span, "about"), page_path(:about) %>
- <%= link_to content_tag(:span, 'portfolio'), controller: 'categories' %> + <%= link_to content_tag(:span, "portfolio"), controller: "categories" %>
diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index df62a53..5e09217 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -1,8 +1,8 @@ -require 'spec_helper' +require "spec_helper" describe ContactsController, type: :controller do - describe 'GET new' do - it 'renders the contact form' do + describe "GET new" do + it "renders the contact form" do get :new expect(response).to render_template(:new) end @@ -10,28 +10,28 @@ describe ContactsController, type: :controller do let(:contact_params) do { - name: 'Dan Barber', - email: 'danbee@gmail.com', - message: 'This is a message.', + name: "Dan Barber", + email: "danbee@gmail.com", + message: "This is a message.", } end - describe 'POST create' do - it 'saves a new contact' do + describe "POST create" do + it "saves a new contact" 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 } expect(Notifier).to have_received(:contact_notification).with(valid_contact) - expect(flash[:notice]).to eql(I18n.t('contact.thanks')) + expect(flash[:notice]).to eql(I18n.t("contact.thanks")) expect(response).to redirect_to(:new_contact) end - it 're-renders the form if params are missing' 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: {} } - expect(flash[:alert]).to eql(I18n.t('contact.invalid')) + expect(flash[:alert]).to eql(I18n.t("contact.invalid")) expect(response).to render_template(:new) end end diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 6c8f84e..00efe13 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,8 +1,8 @@ -require 'spec_helper' +require "spec_helper" describe HomeController, type: :controller do - describe 'GET index' do - it 'renders the index template' do + describe "GET index" do + it "renders the index template" do get :index expect(response).to render_template(:index) end diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index 1d0426b..1e2c2de 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -1,16 +1,16 @@ -require 'spec_helper' +require "spec_helper" describe PagesController, type: :controller do - describe 'GET show' do + describe "GET show" do let(:test_page) { create(:page) } - it 'renders a page' do + it "renders a page" do 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' } + it "renders 404 for a non existant page" do + get :show, params: { name: "not-a-page" } expect(response.status).to eql(404) end end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index d39efe3..867cb68 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -1,8 +1,8 @@ -require 'spec_helper' +require "spec_helper" describe PhotosController, type: :controller do - describe 'GET index' do - it 'renders the index template' do + describe "GET index" do + it "renders the index template" do get :index expect(response).to render_template(:index) end diff --git a/spec/controllers/views_controller_spec.rb b/spec/controllers/views_controller_spec.rb index e3a6b77..fd129af 100644 --- a/spec/controllers/views_controller_spec.rb +++ b/spec/controllers/views_controller_spec.rb @@ -1,16 +1,16 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe ViewsController, type: :controller do - describe 'POST create' do + describe "POST create" do let(:photo) { create(:photo) } - it 'logs a photo view' do + it "logs a photo view" do expect_any_instance_of(Photo).to receive(:log_view).once 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 + it "responds with not_found if the photo is not present" do post :create, params: { photo_id: 999 } expect(response.status).to eql(404) end diff --git a/spec/factories/contacts.rb b/spec/factories/contacts.rb index 863b5a2..7dd2aa6 100644 --- a/spec/factories/contacts.rb +++ b/spec/factories/contacts.rb @@ -2,8 +2,8 @@ FactoryGirl.define do factory :contact do - email 'test@danbarberphoto.com' - name 'Dan Barber' - message 'This is a message.' + email "test@danbarberphoto.com" + name "Dan Barber" + message "This is a message." end end diff --git a/spec/factories/pages.rb b/spec/factories/pages.rb index e74e9a6..2e93c52 100644 --- a/spec/factories/pages.rb +++ b/spec/factories/pages.rb @@ -2,8 +2,8 @@ FactoryGirl.define do factory :page do - name 'page' - title 'Page' - content 'This is a page.' + name "page" + title "Page" + content "This is a page." end end diff --git a/spec/factories/photos.rb b/spec/factories/photos.rb index f0716fa..e86d148 100644 --- a/spec/factories/photos.rb +++ b/spec/factories/photos.rb @@ -2,8 +2,8 @@ FactoryGirl.define do factory :photo do - title 'A Photo' - description 'A lovely photo of a tree' - image Rails.root.join('spec/fixtures/photo.jpg') + title "A Photo" + description "A lovely photo of a tree" + image Rails.root.join("spec/fixtures/photo.jpg") end end diff --git a/spec/features/visitor_navigates_site_spec.rb b/spec/features/visitor_navigates_site_spec.rb index e074523..65f4207 100644 --- a/spec/features/visitor_navigates_site_spec.rb +++ b/spec/features/visitor_navigates_site_spec.rb @@ -1,7 +1,7 @@ -require 'spec_helper' +require "spec_helper" -feature 'visitor navigates site' do - it 'shows the featured image on the home page' do +feature "visitor navigates site" do + it "shows the featured image on the home page" do category = create(:category) photo = create(:photo, featured: true, categories: [category]) @@ -9,7 +9,7 @@ feature 'visitor navigates site' do expect(page).to have_selector("a[data-id='#{photo.id}']") end - it 'increments the view counter when an image is displayed', js: true do + it "increments the view counter when an image is displayed", js: true do category = create(:category) photo = create(:photo, featured: true, categories: [category]) @@ -19,7 +19,7 @@ feature 'visitor navigates site' do page.find(selector).click - expect(page).to have_selector('img.fancybox-image') + expect(page).to have_selector("img.fancybox-image") wait_for_ajax photo.reload @@ -27,20 +27,20 @@ feature 'visitor navigates site' do expect(photo.views).to eq(1) end - it 'shows the categories' do + it "shows the categories" do categories = create_list(:category, 5) visit root_path - click_link 'portfolio' + click_link "portfolio" expect(page).to have_link(categories.first.name.downcase) - click_link '→' + click_link "→" expect(page).to have_link(categories.last.name.downcase) end - it 'shows the photos for the category' do + it "shows the photos for the category" do category = create(:category) photo = create(:photo, featured: true, categories: [category]) @@ -52,13 +52,13 @@ feature 'visitor navigates site' do expect(page).to have_selector(selector) end - it 'shows the second page of photos' do + it "shows the second page of photos" do category = create(:category) photos = create_list(:photo, 12, featured: true, categories: [category]) visit url_for([category, :photos]) - click_link '→' + click_link "→" selector = "a[data-id='#{photos.last.id}']" expect(page).to have_selector(selector) diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index de64ff4..1126ac6 100644 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe Category do it { should have_and_belong_to_many(:photos) } @@ -7,9 +7,9 @@ describe Category do it { should validate_uniqueness_of(:name) } it { should validate_uniqueness_of(:slug) } - let(:category) { create(:category, name: 'A Test Category') } + let(:category) { create(:category, name: "A Test Category") } - it 'should have a slug generated from name' do - expect(category.slug).to eql('a-test-category') + it "should have a slug generated from name" do + expect(category.slug).to eql("a-test-category") end end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 214a253..e0b2d63 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -1,12 +1,12 @@ -require 'spec_helper' +require "spec_helper" describe Contact do it { should validate_presence_of(:email) } it { should validate_presence_of(:name) } it { should validate_presence_of(:message) } - it { should allow_value('test@test.com').for(:email) } - it { should_not allow_value('test@test').for(:email) } + it { should allow_value("test@test.com").for(:email) } + it { should_not allow_value("test@test").for(:email) } let(:contact) { build(:contact) } end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index b0d0128..a29977d 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe Photo do it { should have_and_belong_to_many(:categories) } @@ -7,7 +7,7 @@ describe Photo do let(:photo) { create(:photo) } - it 'logs a view' do + it "logs a view" do expect { photo.log_view }.to change { photo.views }.by(1) end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a06a273..d538a20 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,12 +1,12 @@ -require 'spec_helper' +require "spec_helper" RSpec.describe User, type: :model do it { is_expected.to validate_presence_of(:email) } it { is_expected.to validate_presence_of(:password_digest) } - it 'validates uniqueness of email' do - create(:user, email: 'test@example.com') - user = User.new(email: 'test@example.com') + it "validates uniqueness of email" do + create(:user, email: "test@example.com") + user = User.new(email: "test@example.com") expect(user).to validate_uniqueness_of(:email) end