Skip to content

Commit 000b495

Browse files
authored
Merge pull request alphagov#328 from alphagov/ldeb-support-ruby-3.x
Add tests for Ruby 3.x support
2 parents f670bf5 + 031169c commit 000b495

22 files changed

+2918
-200
lines changed

.github/workflows/publish.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ jobs:
4646
steps:
4747
- uses: actions/checkout@v2
4848

49-
- uses: actions/setup-node@v2
49+
- uses: actions/setup-node@v3
5050
with:
51+
node-version-file: '.nvmrc'
5152
cache: 'npm'
52-
node-version: '14'
5353

5454
- uses: ruby/setup-ruby@v1
5555
with:

.github/workflows/test.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ jobs:
77
name: Test
88
runs-on: ubuntu-latest
99

10+
strategy:
11+
matrix:
12+
ruby: ['2.7', '3.2']
13+
1014
steps:
1115
- uses: actions/checkout@v2
1216

13-
- uses: actions/setup-node@v2
17+
- uses: actions/setup-node@v3
1418
with:
15-
node-version: '14'
19+
node-version-file: '.nvmrc'
1620
cache: 'npm'
1721

1822
- uses: ruby/setup-ruby@v1
1923
with:
24+
ruby-version: ${{ matrix.ruby }}
2025
bundler-cache: true
2126

2227
- name: Run tests

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14
1+
18

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ inherit_gem:
22
rubocop-govuk:
33
- config/default.yml
44

5+
AllCops:
6+
TargetRubyVersion: 2.7
7+
58
Layout/HeredocIndentation:
69
Enabled: false
710

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- You no longer need to downgrade Haml yourself, `bundle install` will now make sure Haml 6 is not installed (see issue [#318: Error: Filters is not a module](https://github.com/alphagov/tech-docs/gem/issues/318)).
8+
59
## 3.3.1
610

711
This change solves a potential security issue with HTML snippets. Pages indexed in search results have their entire contents indexed, including any HTML code snippets. These HTML snippets would appear in the search results unsanitised, making it possible to render arbitrary HTML or run arbitrary scripts.

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
source 'https://rubygems.org'
1+
source "https://rubygems.org"
22

33
# Specify your gem's dependencies in govuk_tech_docs.gemspec
44
gemspec

govuk_tech_docs.gemspec

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# coding: utf-8
2-
lib = File.expand_path("../lib", __FILE__)
1+
require "English"
2+
3+
lib = File.expand_path("lib", __dir__)
34
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
45
require "govuk_tech_docs/version"
56

67
`npm install`
7-
abort 'npm install failed' unless $?.success?
8+
abort "npm install failed" unless $CHILD_STATUS.success?
89

9-
unless File.exist?('node_modules/govuk-frontend/govuk/all.scss')
10-
abort 'govuk-frontend npm package not installed'
10+
unless File.exist?("node_modules/govuk-frontend/govuk/all.scss")
11+
abort "govuk-frontend npm package not installed"
1112
end
1213

1314
Gem::Specification.new do |spec|
@@ -16,8 +17,8 @@ Gem::Specification.new do |spec|
1617
spec.authors = ["Government Digital Service"]
1718
spec.email = ["govuk-dev@digital.cabinet-office.gov.uk"]
1819

19-
spec.summary = %q{Gem to distribute the GOV.UK Tech Docs Template}
20-
spec.description = %q{Gem to distribute the GOV.UK Tech Docs Template. See https://github.com/alphagov/tech-docs-gem for the project.}
20+
spec.summary = "Gem to distribute the GOV.UK Tech Docs Template"
21+
spec.description = "Gem to distribute the GOV.UK Tech Docs Template. See https://github.com/alphagov/tech-docs-gem for the project."
2122
spec.homepage = "https://github.com/alphagov/tech-docs-gem"
2223
spec.license = "MIT"
2324

@@ -30,7 +31,9 @@ Gem::Specification.new do |spec|
3031

3132
spec.bindir = "exe"
3233
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33-
spec.require_paths = ["lib"]
34+
spec.require_paths = %w[lib]
35+
36+
spec.required_ruby_version = ">= 2.7.0"
3437

3538
spec.add_dependency "autoprefixer-rails", "~> 10.2"
3639
spec.add_dependency "chronic", "~> 0.10.2"
@@ -44,11 +47,12 @@ Gem::Specification.new do |spec|
4447
spec.add_dependency "nokogiri"
4548
spec.add_dependency "openapi3_parser", "~> 0.9.0"
4649
spec.add_dependency "redcarpet", "~> 3.5.1"
50+
spec.add_dependency "haml", "< 6.0.0"
4751

4852
spec.add_development_dependency "byebug"
4953
spec.add_development_dependency "capybara", "~> 3.32"
5054
spec.add_development_dependency "jasmine", "~> 3.5.0"
5155
spec.add_development_dependency "rake", "~> 13.0"
5256
spec.add_development_dependency "rspec", "~> 3.9.0"
53-
spec.add_development_dependency "rubocop-govuk", "~> 3.5.0"
57+
spec.add_development_dependency "rubocop-govuk", "~> 4.10.0"
5458
end

lib/govuk_tech_docs.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def format_date(date)
8686
def active_page(page_path)
8787
[
8888
page_path == "/" && current_page.path == "index.html",
89-
("/" + current_page.path) == page_path,
90-
current_page.data.parent != nil && current_page.data.parent.to_s == page_path,
89+
"/#{current_page.path}" == page_path,
90+
!current_page.data.parent.nil? && current_page.data.parent.to_s == page_path,
9191
].any?
9292
end
9393
end
@@ -109,9 +109,9 @@ def active_page(page_path)
109109
search.resources = [""]
110110

111111
search.fields = {
112-
title: { boost: 100, store: true, required: true },
112+
title: { boost: 100, store: true, required: true },
113113
content: { boost: 50, store: true },
114-
url: { index: false, store: true },
114+
url: { index: false, store: true },
115115
}
116116

117117
search.pipeline_remove = %w[stemmer stopWordFilter]

lib/govuk_tech_docs/api_reference/api_reference_extension.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def initialize(app, options_hash = {}, &block)
3737

3838
def uri?(string)
3939
uri = URI.parse(string)
40-
%w(http https).include?(uri.scheme)
40+
%w[http https].include?(uri.scheme)
4141
rescue URI::BadURIError
4242
false
4343
rescue URI::InvalidURIError

0 commit comments

Comments
 (0)