Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to govuk-lint 3.2.0 #412

Merged
merged 6 commits into from
Jul 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Metrics/BlockLength:
Exclude:
- 'test/**/*_test.rb'
41 changes: 16 additions & 25 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,34 @@ ruby File.read(".ruby-version").strip
gem 'airbrake', '~> 5.5'
gem 'airbrake-ruby', '1.5'

gem 'govuk_frontend_toolkit', '5.1.0'
gem 'asset_bom_removal-rails', '~> 1.0.0'
gem 'dalli'
gem 'gds-api-adapters', '~> 43.0'
gem 'govuk_ab_testing', '~> 2.0'
gem 'govuk_elements_rails', '3.0.1'
gem 'govuk_frontend_toolkit', '5.1.0'
gem 'htmlentities', '4.3.4'
gem 'logstasher', '0.6.1'
gem 'plek', '1.11'
gem 'rails', '~> 5.0'
gem 'sass-rails', '~> 5.0.4'
if ENV['SLIMMER_DEV']
gem 'slimmer', path: '../slimmer'
else
gem 'slimmer', '~> 10.1.3'
end
gem 'uglifier', '>= 1.3.0'
gem 'unicorn', '4.8'
gem 'rack_strip_client_ip', '~> 0.0.2'
gem 'rails', '~> 5.0'
gem 'rails-controller-testing', '~> 0.1'
gem 'rails-i18n', '>= 4.0.4'
gem 'rails_translation_manager', '~> 0.0.2'
gem 'rails-controller-testing', '~> 0.1'
gem 'govuk_ab_testing', '~> 2.0'
gem 'htmlentities', '4.3.4'
gem 'sass-rails', '~> 5.0.4'
gem 'slimmer', '~> 10.1.3'
gem 'statsd-ruby', '1.3.0', require: 'statsd'
gem 'dalli'
gem 'asset_bom_removal-rails', '~> 1.0.0'

if ENV['API_DEV']
gem 'gds-api-adapters', path: '../gds-api-adapters'
else
gem 'gds-api-adapters', '~> 43.0'
end
gem 'uglifier', '>= 1.3.0'
gem 'unicorn', '4.8'

gem 'govuk_navigation_helpers', '~> 6.3'

group :development, :test do
gem 'govuk_schemas'
gem 'govuk-lint'
gem 'pry-byebug'
gem 'jasmine-rails', '~> 0.14.0'
gem 'govuk_publishing_components', '~> 0.3.0'
gem 'govuk_schemas'
gem 'jasmine-rails', '~> 0.14.0'
gem 'pry-byebug'
end

group :development do
Expand All @@ -52,7 +43,7 @@ end

group :test do
gem 'capybara'
gem 'webmock', '~> 1.18.0', require: false
gem 'mocha'
gem 'poltergeist', require: false
gem 'webmock', '~> 1.18.0', require: false
end
20 changes: 11 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ GEM
money (~> 6.7)
nokogiri (~> 1.5)
sanitize (~> 2.1.0)
govuk-lint (1.2.1)
rubocop (~> 0.39.0)
govuk-lint (3.2.0)
rubocop (~> 0.49.0)
scss_lint
govuk_ab_testing (2.0.0)
govuk_elements_rails (3.0.1)
Expand Down Expand Up @@ -222,17 +222,19 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.2.1)
rainbow (2.2.2)
rake
raindrops (0.17.0)
rake (11.2.2)
rake (12.0.0)
request_store (1.3.1)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
robotex (1.0.0)
rubocop (0.39.0)
parser (>= 2.3.0.7, < 3.0)
rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
Expand All @@ -241,14 +243,14 @@ GEM
safe_yaml (1.0.4)
sanitize (2.1.0)
nokogiri (>= 1.4.4)
sass (3.4.22)
sass (3.4.25)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
scss_lint (0.52.0)
scss_lint (0.54.0)
rake (>= 0.9, < 13)
sass (~> 3.4.20)
slimmer (10.1.3)
Expand Down Expand Up @@ -278,7 +280,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.4)
unicode-display_width (1.1.3)
unicode-display_width (1.3.0)
unicorn (4.8.0)
kgio (~> 2.6)
rack
Expand Down
4 changes: 0 additions & 4 deletions app/assets/stylesheets/components/_download-link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
}
}


// scss-lint:disable SelectorFormat
.app-c-download-link__icon {
margin-right: 0.5em;
height: 1.31578947368em; // 25 / 19
width: 1.31578947368em;
vertical-align: middle;
}
// scss-lint:enable SelectorFormat

2 changes: 0 additions & 2 deletions app/assets/stylesheets/components/_print-link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
margin-top: 2em;
margin-bottom: 2em;

// scss-lint:disable SelectorFormat
.app-c-print-link__link {
background: image-url("icon-print.png") no-repeat 0 50%;
padding: 0.5em 0 0.5em 28px;
Expand All @@ -12,5 +11,4 @@
background-size: 16px 18px;
}
}
// scss-lint:enable SelectorFormat
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ def load_content_item
@content_item = present(random_example)
end

def set_expiry
end
def set_expiry; end
end
66 changes: 35 additions & 31 deletions app/presenters/contact_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ def title_and_context

def related_items
sections = []
sections << {
title: "Elsewhere on GOV.UK",
items: quick_links
} if quick_links.any?
if quick_links.any?
sections << {
title: "Elsewhere on GOV.UK",
items: quick_links
}
end

sections << {
title: "Other contacts",
items: related_contacts_links
} if related_contacts_links.any?
if related_contacts_links.any?
sections << {
title: "Other contacts",
items: related_contacts_links
}
end

{
sections: sections
Expand All @@ -42,33 +46,13 @@ def online_form_body

def phone
phone_number_groups.map do |group|
details = {
numbers: [
{
label: 'Telephone',
number: group['number']
},
{
label: 'Textphone',
number: group['textphone']
},
{
label: 'Outside UK',
number: group['international_phone']
},
{
label: 'Fax',
number: group['fax']
}
],
{
numbers: phone_numbers_in_group(group),
title: group['title'],
description: group['description'].try(:strip).try(:html_safe),
opening_times: group['open_hours'].try(:strip).try(:html_safe),
best_time_to_call: group['best_time_to_call'].try(:strip).try(:html_safe)
}

details[:numbers].select! { |n| n[:number].present? }
details
end
end

Expand Down Expand Up @@ -128,7 +112,6 @@ def webchat_open_url
"https://online.hmrc.gov.uk/webchatprod/templates/chat/hmrc7/chat.html?entryPointId=#{webchat_id}&templateName=hmrc7&languageCode=en&countryCode=US&ver=v11"
end


def breadcrumbs
return [] if content_item["links"]['organisations'].try(:length) != 1

Expand All @@ -155,6 +138,27 @@ def breadcrumbs

private

def phone_numbers_in_group(group)
[
{
label: 'Telephone',
number: group['number']
},
{
label: 'Textphone',
number: group['textphone']
},
{
label: 'Outside UK',
number: group['international_phone']
},
{
label: 'Fax',
number: group['fax']
}
].select { |n| n[:number].present? }
end

def webchat_id
webchat_ids[content_item["base_path"]]
end
Expand Down
3 changes: 2 additions & 1 deletion app/presenters/contents_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def contents_link(text, id)
track_category: 'contentsClicked',
track_action: 'leftColumnH2',
track_label: id
})
}
)
end

private
Expand Down
7 changes: 4 additions & 3 deletions app/presenters/guide_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ def page_title
end

def has_parts?
Airbrake.notify("Guide with no parts",
error_message: "Guide rendered without any parts at #{base_path}"
) unless parts.any?
unless parts.any?
Airbrake.notify("Guide with no parts",
error_message: "Guide rendered without any parts at #{base_path}")
end

parts.any?
end
Expand Down
28 changes: 16 additions & 12 deletions app/presenters/parts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Parts
def parts
raw_parts.each_with_index.map do |part, i|
# Link to base_path for first part
part['full_path'] = (i == 0) ? base_path : "#{base_path}/#{part['slug']}"
part['full_path'] = i.zero? ? base_path : "#{base_path}/#{part['slug']}"
part
end
end
Expand Down Expand Up @@ -39,17 +39,21 @@ def parts_navigation_second_list_start
def previous_and_next_navigation
nav = {}

nav[:previous_page] = {
url: previous_part['full_path'],
title: I18n.t('multi_page.previous_page'),
label: previous_part['title']
} if previous_part
if previous_part
nav[:previous_page] = {
url: previous_part['full_path'],
title: I18n.t('multi_page.previous_page'),
label: previous_part['title']
}
end

nav[:next_page] = {
url: next_part['full_path'],
title: I18n.t('multi_page.next_page'),
label: next_part['title']
} if next_part
if next_part
nav[:next_page] = {
url: next_part['full_path'],
title: I18n.t('multi_page.next_page'),
label: next_part['title']
}
end

nav
end
Expand Down Expand Up @@ -92,7 +96,7 @@ def next_part
end

def previous_part
parts[current_part_index - 1] if current_part_index > 0
parts[current_part_index - 1] if current_part_index.positive?
end

def current_part_index
Expand Down
10 changes: 5 additions & 5 deletions app/presenters/specialist_document_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ def value_or_array_of_values(values)
# Finder is a required link that must have 1 item
def finder
parent_finder = content_item.dig("links", "finder", 0)
Airbrake.notify("Finder not found",
error_message: "Finder not found in #{base_path} content item"
) if parent_finder.nil?
if parent_finder.nil?
Airbrake.notify("Finder not found",
error_message: "Finder not found in #{base_path} content item")
end

parent_finder
end
Expand Down Expand Up @@ -138,8 +139,7 @@ def facet_blocks(facet, values)
facet_block(facet, allowed_value)
else
Airbrake.notify("Facet value not in list of allowed values",
error_message: "Facet value '#{value}' not an allowed value for facet '#{facet['name']}' on #{base_path} content item"
)
error_message: "Facet value '#{value}' not an allowed value for facet '#{facet['name']}' on #{base_path} content item")
value
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/content_items/travel_advice.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ atom_feed(root_url: @content_item.web_url, id: @content_item.web_url) do |feed|
end
feed.entry(@content_item, id: "#{@content_item.web_url}##{@content_item.atom_public_updated_at}", url: @content_item.web_url, updated: @content_item.atom_public_updated_at) do |entry|
entry.title(@content_item.title)
entry.link(:rel => "self", :type => "application/atom+xml", :href => "#{@content_item.web_url}.atom")
entry.summary(:type => :xhtml) do |summary|
entry.link(rel: "self", type: "application/atom+xml", href: "#{@content_item.web_url}.atom")
entry.summary(type: :xhtml) do |summary|
summary << @content_item.atom_change_description
end
end
Expand Down
3 changes: 2 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class Application < Rails::Application
:es, 'es-419', :et, :fa, :fr, :he, :hi, :hu, :hy, :id,
:it, :ja, :ka, :ko, :lt, :lv, :ms, :pl, :ps, :pt, :ro,
:ru, :si, :sk, :so, :sq, :sr, :sw, :ta, :th, :tk, :tr,
:uk, :ur, :uz, :vi, :zh, 'zh-hk', 'zh-tw']
:uk, :ur, :uz, :vi, :zh, 'zh-hk', 'zh-tw'
]

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found).
Expand Down
Loading