Fix hound warnings

This commit is contained in:
decabeza
2019-01-29 17:54:02 +01:00
parent 41fe1e3922
commit 2695e19e2f
6 changed files with 24 additions and 20 deletions

View File

@@ -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?

View File

@@ -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}"

View File

@@ -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"

View File

@@ -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

View File

@@ -1,4 +1,4 @@
require 'rails_helper'
require "rails_helper"
describe LegislationHelper do
let(:process) { build(:legislation_process) }

View File

@@ -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