Fix hound warnings
This commit is contained in:
@@ -54,7 +54,8 @@ module AdminHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def menu_customization?
|
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
|
end
|
||||||
|
|
||||||
def menu_homepage?
|
def menu_homepage?
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class SiteCustomization::Page < ActiveRecord::Base
|
class SiteCustomization::Page < ActiveRecord::Base
|
||||||
VALID_STATUSES = %w(draft published)
|
VALID_STATUSES = %w[draft published]
|
||||||
has_many :cards, class_name: 'Widget::Card', foreign_key: 'site_customization_page_id'
|
has_many :cards, class_name: "Widget::Card", foreign_key: "site_customization_page_id"
|
||||||
|
|
||||||
translates :title, touch: true
|
translates :title, touch: true
|
||||||
translates :subtitle, 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 }
|
format: { with: /\A[0-9a-zA-Z\-_]*\Z/, message: :slug_format }
|
||||||
validates :status, presence: true, inclusion: { in: VALID_STATUSES }
|
validates :status, presence: true, inclusion: { in: VALID_STATUSES }
|
||||||
|
|
||||||
scope :published, -> { where(status: 'published').order('id DESC') }
|
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_more_info_flag, -> { where(status: "published",
|
||||||
scope :with_same_locale, -> { joins(:translations).where("site_customization_page_translations.locale": I18n.locale) }
|
more_info_flag: true).order("id ASC") }
|
||||||
|
scope :with_same_locale, -> { joins(:translations)
|
||||||
|
.where("site_customization_page_translations.locale": I18n.locale) }
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"/#{slug}"
|
"/#{slug}"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class Widget::Card < ActiveRecord::Base
|
class Widget::Card < ActiveRecord::Base
|
||||||
include Imageable
|
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'
|
# table_name must be set before calls to 'translates'
|
||||||
self.table_name = "widget_cards"
|
self.table_name = "widget_cards"
|
||||||
|
|||||||
@@ -134,23 +134,23 @@ feature 'Admin legislation processes' do
|
|||||||
|
|
||||||
scenario "Create a legislation process with an image", :js do
|
scenario "Create a legislation process with an image", :js do
|
||||||
visit new_admin_legislation_process_path()
|
visit new_admin_legislation_process_path()
|
||||||
fill_in 'Process Title', with: 'An example legislation process'
|
fill_in "Process Title", with: "An example legislation process"
|
||||||
fill_in 'Summary', with: 'Summary of the process'
|
fill_in "Summary", with: "Summary of the process"
|
||||||
|
|
||||||
base_date = Date.current
|
base_date = Date.current
|
||||||
fill_in 'legislation_process[start_date]', with: base_date.strftime("%d/%m/%Y")
|
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")
|
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'))
|
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 "An example legislation process"
|
||||||
expect(page).to have_content 'Process created successfully'
|
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).to have_content "An example legislation process"
|
||||||
expect(page).not_to have_content 'Summary of the process'
|
expect(page).not_to have_content "Summary of the process"
|
||||||
expect(page).to have_css("img[alt='#{Legislation::Process.last.title}']")
|
expect(page).to have_css("img[alt='#{Legislation::Process.last.title}']")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require 'rails_helper'
|
require "rails_helper"
|
||||||
|
|
||||||
describe LegislationHelper do
|
describe LegislationHelper do
|
||||||
let(:process) { build(:legislation_process) }
|
let(:process) { build(:legislation_process) }
|
||||||
|
|||||||
@@ -193,7 +193,8 @@ describe Legislation::Process do
|
|||||||
expect {
|
expect {
|
||||||
process1 = create(:legislation_process, background_color: "#123ghi", font_color: "#fff")
|
process1 = create(:legislation_process, background_color: "#123ghi", font_color: "#fff")
|
||||||
process2 = create(:legislation_process, background_color: "#ffffffff", font_color: "#123")
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user