Skip to content

Commit

Permalink
Merge pull request #3037 from alphagov/remove-router-api
Browse files Browse the repository at this point in the history
Remove Router API usage
  • Loading branch information
theseanything authored Dec 12, 2024
2 parents 1b4718f + bf4c56b commit 5fb4f37
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 51 deletions.
11 changes: 0 additions & 11 deletions lib/data_hygiene/document_status_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ def content_store?
false
end

def router?
routes.each do |route|
route = GdsApi.router.get_route(route[:path])
return false unless route["backend_id"] == edition.rendering_app
end

true
rescue GdsApi::HTTPNotFound
false
end

private

attr_reader :document
Expand Down
6 changes: 2 additions & 4 deletions lib/tasks/data_hygiene.rake
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,17 @@ namespace :data_hygiene do
end
end

desc "Check the status of a document whether it's in Content Store or Router."
desc "Check the status of a document whether it's in Content Store"
task :document_status_check, %i[content_id locale] => :environment do |_, args|
document = Document.find_by!(args.to_hash)
status = DataHygiene::DocumentStatusChecker.new(document)

content_store = status.content_store?
router = status.router?

puts "Has the document made it to:"
puts "Content Store? #{content_store ? 'Yes' : 'No'}"
puts "Router? #{router ? 'Yes' : 'No'}"

unless content_store && router
unless content_store
puts ""
puts "You could try running:"
puts "rake 'represent_downstream:content_id[#{args[:content_id]}]'"
Expand Down
36 changes: 0 additions & 36 deletions spec/lib/data_hygiene/document_status_checker_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require "gds_api/test_helpers/content_store"
require "gds_api/test_helpers/router"

RSpec.describe DataHygiene::DocumentStatusChecker do
include GdsApi::TestHelpers::ContentStore
include GdsApi::TestHelpers::Router

let(:base_path) { "/base-path" }

Expand Down Expand Up @@ -40,38 +38,4 @@
end
end
end

describe "router status" do
subject { described_class.new(document).router? }

around do |example|
ClimateControl.modify ROUTER_API_BEARER_TOKEN: "token" do
example.run
end
end

context "with a published live edition" do
let(:edition) { create(:live_edition, base_path:) }
let(:document) { edition.document }

context "and there is no content item" do
before { stub_router_doesnt_have_route(base_path) }
it { is_expected.to be false }
end

context "and there is a content item" do
before { stub_router_has_backend_route(base_path, backend_id:) }

context "with the same backend_id" do
let(:backend_id) { edition.rendering_app }
it { is_expected.to be true }
end

context "with a different backend_id" do
let(:backend_id) { "nothing" }
it { is_expected.to be false }
end
end
end
end
end

0 comments on commit 5fb4f37

Please sign in to comment.