Skip to content

Commit

Permalink
Merge pull request #1413 from alphagov/update-llm-test-suite
Browse files Browse the repository at this point in the history
added council page index and show test cases to request tests
  • Loading branch information
georges1996 authored Oct 8, 2024
2 parents bae26ea + defc967 commit 66870b4
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 256 deletions.
1 change: 1 addition & 0 deletions app/views/links/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% content_for :page_title, "Broken Links" %>
<%= render partial: "shared/flash" %>

<%= render "govuk_publishing_components/components/heading", {
text: "Broken Links (showing top 200 of #{@total_broken_links})",
Expand Down
1 change: 1 addition & 0 deletions app/views/local_authorities/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% content_for :page_title, @authority.name %>
<%= render partial: "shared/flash" %>

<%= render "govuk_publishing_components/components/heading", {
text: @authority.name,
Expand Down
72 changes: 0 additions & 72 deletions spec/controllers/links_controller_spec.rb

This file was deleted.

137 changes: 0 additions & 137 deletions spec/controllers/local_authorities_controller_spec.rb

This file was deleted.

41 changes: 0 additions & 41 deletions spec/controllers/services_controller_spec.rb

This file was deleted.

48 changes: 48 additions & 0 deletions spec/requests/broken_links_page_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
RSpec.describe "Broken links page" do
it_behaves_like "redirects non-GDS Editors to services page", "/"
end

describe "Broken links page" do
before do
login_as_gds_editor
@local_authority = create(:local_authority, name: "North Midlands")
@service = create(:service, label: "Aardvark Wardens")
@interaction = create(:interaction, label: "Reporting")
@service_interaction = create(:service_interaction, service: @service, interaction: @interaction)
end

context "GET edit" do
it "GET edit handles URL passed in via flash" do
get "/local_authorities/north-midlands/services/aardvark-wardens/reporting/edit"
expect(response).to have_http_status(:ok)

flash_hash = ActionDispatch::Flash::FlashHash.new
flash_hash[:link_url] = "https://www.example.com"
session["flash"] = flash_hash.to_session_value

get "/local_authorities/north-midlands/services/aardvark-wardens/reporting/edit"
expect(response).to have_http_status(:ok)
end
end

context "GET homepage_links_status_csv" do
it "returns a 200 response" do
get "/check_homepage_links_status.csv"
expect(response).to have_http_status(:ok)
expect(response.headers["Content-Type"]).to eq("text/csv")
end
end

context "GET links_status_csv" do
it "returns a 200 response" do
get "/check_links_status.csv"
expect(response).to have_http_status(:ok)
expect(response.headers["Content-Type"]).to eq("text/csv")
end
end

context "GET bad_links_url_and_status_csv" do
it "returns a 200 response" do
get "/bad_links_url_status.csv"
expect(response).to have_http_status(:ok)
expect(response.headers["Content-Type"]).to eq("text/csv")
end
end
end
50 changes: 49 additions & 1 deletion spec/requests/council_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
it_behaves_like "redirects non-GDS Editors to services page", "/local_authorities/north-midlands/download_links_form"
it_behaves_like "redirects non-GDS Editors to services page", "/local_authorities/north-midlands/upload_links_form"

describe "GET #index" do
context "when there is sufficient data" do
it "returns http succcess" do
login_as_gds_editor

get "/local_authorities"
expect(response).to have_http_status(:ok)
end
end
end

describe "GET #show" do
it "returns http success" do
login_as_gds_editor

get "/local_authorities/north-midlands"
expect(response).to have_http_status(:ok)
end
end

describe "PATCH local_authorities/:local_authority_slug" do
context "as a GDS Editor" do
before { login_as_gds_editor }
Expand All @@ -31,14 +51,25 @@
end
end

describe "GET bad_homepage_url_and_status_csv" do
it "retrieves HTTP success" do
login_as_gds_editor

get "/bad_homepage_url_status.csv"
expect(response).to have_http_status(:ok)
expect(response.headers["Content-Type"]).to eq("text/csv")
end
end

describe "POST local_authorities/:local_authority_slug/download_links_csv" do
context "as a GDS Editor" do
before { login_as_gds_editor }

it "returns 200 OK" do
post "/local_authorities/north-midlands/download_links_csv", params: { links_status_checkbox: %w[ok] }
post "/local_authorities/north-midlands/download_links_csv", params: { links_status_checkbox: %w[ok broken] }

expect(response).to have_http_status(:ok)
expect(response.headers["Content-Type"]).to eq("text/csv")
end
end

Expand Down Expand Up @@ -75,5 +106,22 @@
end
end
end

context "with a valid CSV" do
before { @local_authority = create(:local_authority, gss: "S1") }
let(:path) { Rails.root.join("spec/lib/local-links-manager/import/fixtures/imported_links.csv") }
let(:csv) { Rack::Test::UploadedFile.new(path, "text/csv", true) }
let(:url_regex) { /http:\/\/.+\/local_authorities\/north-midlands/ }

it "retrieves HTTP found" do
login_as_gds_editor

post "/local_authorities/north-midlands/upload_links_csv", params: { csv: }

expect(response.status).to eq(302)
expect(response.location).to match(url_regex)
expect(response.headers["Content-Type"]).to eq("text/html; charset=utf-8")
end
end
end
end
Loading

0 comments on commit 66870b4

Please sign in to comment.