Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/rails-html-sanitizer-1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulDoyle-EA authored Jan 7, 2025
2 parents 702c2d5 + a4fdbc8 commit b55c4a3
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 297 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ jobs:
# https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/6
- name: Run unit tests
run: |
bundle exec rails test
bundle exec rspec
sed -i 's/\/home\/runner\/work\/waste-carriers-engine\/waste-carriers-engine\//\/github\/workspace\//g' coverage/coverage.json
- name: Update coverage output
run: |
sed -i "s@/home/runner/work/DEFRA/pafs_core@/github/workspace@g" coverage/coverage.json
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
uses: sonarsource/sonarqube-scan-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This is provided automatically by GitHub
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # This needs to be set in your repo; settings -> secrets
127 changes: 66 additions & 61 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ PATH
countries (~> 5.5.0)
defra_ruby_address (~> 0.1.0)
defra_ruby_alert (~> 2.2.1)
defra_ruby_companies_house
defra_ruby_email (~> 1.3.0)
defra_ruby_govpay
defra_ruby_validators (~> 2.6)
defra_ruby_validators (~> 3.0)
high_voltage (~> 3.1.2)
jbuilder (~> 2.11.5)
mongo_session_store (~> 3.2.1)
Expand All @@ -27,67 +28,67 @@ GEM
specs:
aasm (5.5.0)
concurrent-ruby (~> 1.0)
actioncable (7.0.8.6)
actionpack (= 7.0.8.6)
activesupport (= 7.0.8.6)
actioncable (7.0.8.7)
actionpack (= 7.0.8.7)
activesupport (= 7.0.8.7)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.8.6)
actionpack (= 7.0.8.6)
activejob (= 7.0.8.6)
activerecord (= 7.0.8.6)
activestorage (= 7.0.8.6)
activesupport (= 7.0.8.6)
actionmailbox (7.0.8.7)
actionpack (= 7.0.8.7)
activejob (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.8.6)
actionpack (= 7.0.8.6)
actionview (= 7.0.8.6)
activejob (= 7.0.8.6)
activesupport (= 7.0.8.6)
actionmailer (7.0.8.7)
actionpack (= 7.0.8.7)
actionview (= 7.0.8.7)
activejob (= 7.0.8.7)
activesupport (= 7.0.8.7)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.8.6)
actionview (= 7.0.8.6)
activesupport (= 7.0.8.6)
actionpack (7.0.8.7)
actionview (= 7.0.8.7)
activesupport (= 7.0.8.7)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.8.6)
actionpack (= 7.0.8.6)
activerecord (= 7.0.8.6)
activestorage (= 7.0.8.6)
activesupport (= 7.0.8.6)
actiontext (7.0.8.7)
actionpack (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.8.6)
activesupport (= 7.0.8.6)
actionview (7.0.8.7)
activesupport (= 7.0.8.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.8.6)
activesupport (= 7.0.8.6)
activejob (7.0.8.7)
activesupport (= 7.0.8.7)
globalid (>= 0.3.6)
activemodel (7.0.8.6)
activesupport (= 7.0.8.6)
activerecord (7.0.8.6)
activemodel (= 7.0.8.6)
activesupport (= 7.0.8.6)
activestorage (7.0.8.6)
actionpack (= 7.0.8.6)
activejob (= 7.0.8.6)
activerecord (= 7.0.8.6)
activesupport (= 7.0.8.6)
activemodel (7.0.8.7)
activesupport (= 7.0.8.7)
activerecord (7.0.8.7)
activemodel (= 7.0.8.7)
activesupport (= 7.0.8.7)
activestorage (7.0.8.7)
actionpack (= 7.0.8.7)
activejob (= 7.0.8.7)
activerecord (= 7.0.8.7)
activesupport (= 7.0.8.7)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.8.6)
activesupport (7.0.8.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand Down Expand Up @@ -138,11 +139,14 @@ GEM
database_cleaner-mongoid (2.0.1)
database_cleaner-core (~> 2.0.0)
mongoid
date (3.4.0)
date (3.4.1)
defra_ruby_address (0.1.0)
rest-client (~> 2.0)
defra_ruby_alert (2.2.1)
airbrake
defra_ruby_companies_house (1.0.3)
i18n
rest-client (~> 2.0)
defra_ruby_email (1.3.0)
notifications-ruby-client
rails
Expand All @@ -152,8 +156,9 @@ GEM
defra_ruby_style (0.3.0)
rubocop (>= 1.0, < 2.0)
defra_ruby_template (5.4.1)
defra_ruby_validators (2.7.2)
defra_ruby_validators (3.0.0)
activemodel
defra_ruby_companies_house
i18n
matrix
os_map_ref
Expand Down Expand Up @@ -207,7 +212,7 @@ GEM
html-attributes-utils (1.0.2)
activesupport (>= 6.1.4.4)
http-accept (1.7.0)
http-cookie (1.0.7)
http-cookie (1.0.8)
domain_name (~> 0.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
Expand All @@ -218,7 +223,7 @@ GEM
json (2.6.3)
jwt (2.7.1)
language_server-protocol (3.17.0.3)
logger (1.6.1)
logger (1.6.4)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -233,10 +238,10 @@ GEM
mime-types (3.6.0)
logger
mime-types-data (~> 3.2015)
mime-types-data (3.2024.1105)
mime-types-data (3.2024.1203)
mini_mime (1.1.5)
mini_portile2 (2.8.8)
minitest (5.25.1)
minitest (5.25.4)
mongo (2.19.3)
bson (>= 4.14.1, < 5.0.0)
mongo_session_store (3.2.1)
Expand Down Expand Up @@ -273,7 +278,7 @@ GEM
parser (3.2.2.4)
ast (~> 2.4.1)
racc
phonelib (0.9.3)
phonelib (0.10.1)
protocol-hpack (1.4.2)
protocol-http (0.25.0)
protocol-http1 (0.16.0)
Expand All @@ -292,20 +297,20 @@ GEM
rack (2.2.10)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8.6)
actioncable (= 7.0.8.6)
actionmailbox (= 7.0.8.6)
actionmailer (= 7.0.8.6)
actionpack (= 7.0.8.6)
actiontext (= 7.0.8.6)
actionview (= 7.0.8.6)
activejob (= 7.0.8.6)
activemodel (= 7.0.8.6)
activerecord (= 7.0.8.6)
activestorage (= 7.0.8.6)
activesupport (= 7.0.8.6)
rails (7.0.8.7)
actioncable (= 7.0.8.7)
actionmailbox (= 7.0.8.7)
actionmailer (= 7.0.8.7)
actionpack (= 7.0.8.7)
actiontext (= 7.0.8.7)
actionview (= 7.0.8.7)
activejob (= 7.0.8.7)
activemodel (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
bundler (>= 1.15.0)
railties (= 7.0.8.6)
railties (= 7.0.8.7)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -317,9 +322,9 @@ GEM
rails-html-sanitizer (1.6.1)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.0.8.6)
actionpack (= 7.0.8.6)
activesupport (= 7.0.8.6)
railties (7.0.8.7)
actionpack (= 7.0.8.7)
activesupport (= 7.0.8.7)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "defra_ruby_companies_house"
require "defra_ruby/companies_house"

module WasteCarriersEngine
class CheckRegisteredCompanyNameFormsController < ::WasteCarriersEngine::FormsController
Expand All @@ -26,7 +26,8 @@ def transient_registration_attributes
end

def company_name
DefraRubyCompaniesHouse.new(@transient_registration.company_no).company_name
company_details = DefraRuby::CompaniesHouse::API.run(company_number: @transient_registration.company_no)
company_details[:company_name]
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class CheckRegisteredCompanyNameForm < ::WasteCarriersEngine::BaseForm
validates :temp_use_registered_company_details, "waste_carriers_engine/yes_no": true

def registered_company_name
companies_house_service.company_name
@registered_company_name ||= companies_house_details[:company_name]
end

def registered_office_address_lines
companies_house_service.registered_office_address_lines
@registered_office_address_lines ||= companies_house_details[:registered_office_address]
end

def submit(params)
Expand All @@ -26,8 +26,8 @@ def submit(params)

private

def companies_house_service
@_companies_house_service ||= DefraRubyCompaniesHouse.new(company_no)
def companies_house_details
@_companies_house_details ||= DefraRuby::CompaniesHouse::API.run(company_number: company_no)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "defra_ruby_companies_house"
require "defra_ruby/companies_house"

module WasteCarriersEngine
# rubocop:disable Metrics/ModuleLength
Expand Down Expand Up @@ -258,9 +258,11 @@ def company_status_invalid?
return false if company_no.blank? || overseas?

begin
company_status = DefraRubyCompaniesHouse.new(company_no).company_status
company_status = DefraRuby::CompaniesHouse::API.run(company_number: company_no)[:company_status]
!%w[active voluntary-arrangement].include?(company_status)
rescue StandardError
rescue StandardError => e
Rails.logger.error "Error checking company status: #{e}"
Airbrake.notify(e)
true
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# frozen_string_literal: true

require "defra_ruby_companies_house"
require "defra_ruby/companies_house"

module WasteCarriersEngine
class RefreshCompaniesHouseNameService < WasteCarriersEngine::BaseService
def run(reg_identifier:)
registration = Registration.find_by(reg_identifier: reg_identifier)

company_name = DefraRubyCompaniesHouse.new(registration.company_no).company_name
registration.registered_company_name = company_name
company_details = DefraRuby::CompaniesHouse::API.run(company_number: registration.company_no)

registration.registered_company_name = company_details[:company_name]
registration.companies_house_updated_at = Time.current
registration.save!

Expand Down
55 changes: 0 additions & 55 deletions lib/defra_ruby_companies_house.rb

This file was deleted.

Loading

0 comments on commit b55c4a3

Please sign in to comment.