From 2695e19e2fc2bcffb8200b81e1f190c98ed6ff90 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 29 Jan 2019 17:54:02 +0100 Subject: [PATCH] Fix hound warnings --- app/helpers/admin_helper.rb | 3 ++- app/models/site_customization/page.rb | 12 +++++----- app/models/widget/card.rb | 2 +- .../admin/legislation/processes_spec.rb | 22 +++++++++---------- spec/helpers/legislation_helper_spec.rb | 2 +- spec/models/legislation/process_spec.rb | 3 ++- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 06e8c3eb7..239c2a616 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -54,7 +54,8 @@ module AdminHelper end def menu_customization? - ["pages", "banners", "information_texts"].include?(controller_name) || menu_homepage? || menu_pages? + ["pages", "banners", "information_texts"].include?(controller_name) || + menu_homepage? || menu_pages? end def menu_homepage? diff --git a/app/models/site_customization/page.rb b/app/models/site_customization/page.rb index 9d3c6b37e..a4bb213ad 100644 --- a/app/models/site_customization/page.rb +++ b/app/models/site_customization/page.rb @@ -1,6 +1,6 @@ class SiteCustomization::Page < ActiveRecord::Base - VALID_STATUSES = %w(draft published) - has_many :cards, class_name: 'Widget::Card', foreign_key: 'site_customization_page_id' + VALID_STATUSES = %w[draft published] + has_many :cards, class_name: "Widget::Card", foreign_key: "site_customization_page_id" translates :title, touch: true translates :subtitle, touch: true @@ -13,9 +13,11 @@ class SiteCustomization::Page < ActiveRecord::Base format: { with: /\A[0-9a-zA-Z\-_]*\Z/, message: :slug_format } validates :status, presence: true, inclusion: { in: VALID_STATUSES } - scope :published, -> { where(status: 'published').order('id DESC') } - scope :with_more_info_flag, -> { where(status: 'published', more_info_flag: true).order('id ASC') } - scope :with_same_locale, -> { joins(:translations).where("site_customization_page_translations.locale": I18n.locale) } + scope :published, -> { where(status: "published").order("id DESC") } + scope :with_more_info_flag, -> { where(status: "published", + more_info_flag: true).order("id ASC") } + scope :with_same_locale, -> { joins(:translations) + .where("site_customization_page_translations.locale": I18n.locale) } def url "/#{slug}" diff --git a/app/models/widget/card.rb b/app/models/widget/card.rb index bc7da86d2..5ec0d4944 100644 --- a/app/models/widget/card.rb +++ b/app/models/widget/card.rb @@ -1,6 +1,6 @@ class Widget::Card < ActiveRecord::Base include Imageable - belongs_to :page, class_name: 'SiteCustomization::Page', foreign_key: 'site_customization_page_id' + belongs_to :page, class_name: "SiteCustomization::Page", foreign_key: "site_customization_page_id" # table_name must be set before calls to 'translates' self.table_name = "widget_cards" diff --git a/spec/features/admin/legislation/processes_spec.rb b/spec/features/admin/legislation/processes_spec.rb index e56bca81b..b5842c235 100644 --- a/spec/features/admin/legislation/processes_spec.rb +++ b/spec/features/admin/legislation/processes_spec.rb @@ -134,23 +134,23 @@ feature 'Admin legislation processes' do scenario "Create a legislation process with an image", :js do visit new_admin_legislation_process_path() - fill_in 'Process Title', with: 'An example legislation process' - fill_in 'Summary', with: 'Summary of the process' + fill_in "Process Title", with: "An example legislation process" + fill_in "Summary", with: "Summary of the process" base_date = Date.current - fill_in 'legislation_process[start_date]', with: base_date.strftime("%d/%m/%Y") - fill_in 'legislation_process[end_date]', with: (base_date + 5.days).strftime("%d/%m/%Y") - imageable_attach_new_file(create(:image), Rails.root.join('spec/fixtures/files/clippy.jpg')) + fill_in "legislation_process[start_date]", with: base_date.strftime("%d/%m/%Y") + fill_in "legislation_process[end_date]", with: (base_date + 5.days).strftime("%d/%m/%Y") + imageable_attach_new_file(create(:image), Rails.root.join("spec/fixtures/files/clippy.jpg")) - click_button 'Create process' + click_button "Create process" - expect(page).to have_content 'An example legislation process' - expect(page).to have_content 'Process created successfully' + expect(page).to have_content "An example legislation process" + expect(page).to have_content "Process created successfully" - click_link 'Click to visit' + click_link "Click to visit" - expect(page).to have_content 'An example legislation process' - expect(page).not_to have_content 'Summary of the process' + expect(page).to have_content "An example legislation process" + expect(page).not_to have_content "Summary of the process" expect(page).to have_css("img[alt='#{Legislation::Process.last.title}']") end end diff --git a/spec/helpers/legislation_helper_spec.rb b/spec/helpers/legislation_helper_spec.rb index 9d88aa8c8..627155123 100644 --- a/spec/helpers/legislation_helper_spec.rb +++ b/spec/helpers/legislation_helper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe LegislationHelper do let(:process) { build(:legislation_process) } diff --git a/spec/models/legislation/process_spec.rb b/spec/models/legislation/process_spec.rb index c2b1c8214..274487cd6 100644 --- a/spec/models/legislation/process_spec.rb +++ b/spec/models/legislation/process_spec.rb @@ -193,7 +193,8 @@ describe Legislation::Process do expect { process1 = create(:legislation_process, background_color: "#123ghi", font_color: "#fff") process2 = create(:legislation_process, background_color: "#ffffffff", font_color: "#123") - }.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Background color is invalid") + }.to raise_error(ActiveRecord::RecordInvalid, + "Validation failed: Background color is invalid") end end