From 6d2c08f3902ee3a4989877d1afb0a6f5f94a5d9d Mon Sep 17 00:00:00 2001 From: ramya vidapanakal Date: Thu, 3 Oct 2024 09:55:40 +0100 Subject: [PATCH 1/9] added council page index and show test cases to request tests --- spec/requests/council_page_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/requests/council_page_spec.rb b/spec/requests/council_page_spec.rb index 2a02bd3c4..a12ecc8d1 100644 --- a/spec/requests/council_page_spec.rb +++ b/spec/requests/council_page_spec.rb @@ -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(200) + 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(200) + end + end + describe "PATCH local_authorities/:local_authority_slug" do context "as a GDS Editor" do before { login_as_gds_editor } From 44aa6a8bfb26a1027d31e9c8046d2031f8ae362a Mon Sep 17 00:00:00 2001 From: ramya vidapanakal Date: Thu, 3 Oct 2024 11:47:28 +0100 Subject: [PATCH 2/9] updated edit homepage URL,upload and download links test cases in council page spec --- spec/requests/council_page_spec.rb | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/spec/requests/council_page_spec.rb b/spec/requests/council_page_spec.rb index a12ecc8d1..dd1651ff1 100644 --- a/spec/requests/council_page_spec.rb +++ b/spec/requests/council_page_spec.rb @@ -51,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(200) + 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 @@ -95,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 From e5af2dba9032fad0dddd18435231d7accf984bd4 Mon Sep 17 00:00:00 2001 From: ramya vidapanakal Date: Thu, 3 Oct 2024 11:59:04 +0100 Subject: [PATCH 3/9] added system test for council page to test uploading csv with errors --- spec/system/upload_links_csv_spec.rb | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 spec/system/upload_links_csv_spec.rb diff --git a/spec/system/upload_links_csv_spec.rb b/spec/system/upload_links_csv_spec.rb new file mode 100644 index 000000000..557fb141d --- /dev/null +++ b/spec/system/upload_links_csv_spec.rb @@ -0,0 +1,52 @@ +RSpec.describe "Council page" do + let!(:local_authority) { create(:district_council, slug: "north-midlands", gss: "S1") } + let(:fixture_path) { "spec/lib/local-links-manager/import/fixtures/" } + + context "with errors in the CSV" do + before do + login_as_gds_editor + interaction = create(:interaction, lgil_code: 1) + 6.times do |i| + service = create(:service, lgsl_code: i + 1) + create(:service_interaction, service:, interaction:) + end + end + + it "shows the all error message if all lines are broken" do + visit "/local_authorities/north-midlands/upload_links_form" + + attach_file(Rails.root.join(fixture_path, "imported_links_all_errors.csv")) + expect(page).to have_button("Upload Links") + click_button "Upload Links" + + expect(page).to have_content("Errors on all lines. Ensure a New URL column exists, with all rows either blank or a valid URL") + end + + it "shows the many error message if many lines are broken" do + visit "/local_authorities/north-midlands/upload_links_form" + + attach_file(Rails.root.join(fixture_path, "imported_links_many_errors.csv")) + expect(page).to have_button("Upload Links") + click_button "Upload Links" + expect(page).to have_content("74 Errors detected. Please ensure a valid entry in the New URL column for lines (showing first 50):") + end + + it "shows the few error message if few lines are broken" do + visit "/local_authorities/north-midlands/upload_links_form" + + attach_file(Rails.root.join(fixture_path, "imported_links_few_errors.csv")) + expect(page).to have_button("Upload Links") + click_button "Upload Links" + expect(page).to have_content("2 Errors detected. Please ensure a valid entry in the New URL column for lines:") + end + + it "shows the nothing to import info if it didn't import anything" do + visit "/local_authorities/north-midlands/upload_links_form" + + attach_file(Rails.root.join(fixture_path, "imported_links_nothing_to_import.csv")) + expect(page).to have_button("Upload Links") + click_button "Upload Links" + expect(page).to have_content("No records updated. (If you were expecting updates, check the format of the uploaded file)") + end + end +end From 031dc54f3ac5821e164335364edfec710da19701 Mon Sep 17 00:00:00 2001 From: ramya vidapanakal Date: Thu, 3 Oct 2024 12:37:13 +0100 Subject: [PATCH 4/9] updated index,show and download links request tests for services page spec --- spec/requests/services_page_spec.rb | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/spec/requests/services_page_spec.rb b/spec/requests/services_page_spec.rb index 331a1054e..bb2308d93 100644 --- a/spec/requests/services_page_spec.rb +++ b/spec/requests/services_page_spec.rb @@ -21,6 +21,39 @@ allow_any_instance_of(LocalLinksManager::Export::ServiceLinksExporter).to receive(:export_links).and_return(exported_data) end + before { login_as_gds_editor } + + context "GET #index" do + it "returns http success for services index page" do + get "/services" + expect(response).to have_http_status(200) + end + end + + context "Get #show" do + it "returns http success" do + get "/services/aardvark-wardens" + expect(response).to have_http_status(200) + end + end + + context "GET #download_links_form and POST #download_links_csv" do + let(:exported_data) { "some_data" } + + before do + allow_any_instance_of(LocalLinksManager::Export::ServiceLinksExporter).to receive(:export_links).and_return(exported_data) + end + + it "returns a success response" do + create(:service) + get "/services/aardvark-wardens/download_links_form" + expect(response).to be_successful + + post "/services/aardvark-wardens/download_links_csv" + expect(response).to be_successful + end + end + context "as a GDS Editor" do before { login_as_gds_editor } From d8fad3cf3cc62ca8330919fd03fcb509a017b6b7 Mon Sep 17 00:00:00 2001 From: ramya vidapanakal Date: Thu, 3 Oct 2024 12:49:34 +0100 Subject: [PATCH 5/9] removed duplicate test case in services page spec --- spec/requests/services_page_spec.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/spec/requests/services_page_spec.rb b/spec/requests/services_page_spec.rb index bb2308d93..b1e3b0092 100644 --- a/spec/requests/services_page_spec.rb +++ b/spec/requests/services_page_spec.rb @@ -54,16 +54,6 @@ end end - context "as a GDS Editor" do - before { login_as_gds_editor } - - it "returns 200 OK" do - post "/services/aardvark-wardens/download_links_csv" - - expect(response).to have_http_status(:ok) - end - end - context "as a department user from the owning department" do before { login_as_department_user(organisation_slug: owning_department) } @@ -89,9 +79,13 @@ context "as a GDS Editor" do before { login_as_gds_editor } + it "returns a success response" do + get "/services/aardvark-wardens/upload_links_form" + expect(response).to be_successful + end + it "returns 302 Found" do post "/services/aardvark-wardens/upload_links_csv" - expect(response).to have_http_status(:found) end end From 9582ed0ca23f4fbfe9d98e9bb3b821b1ff9f48f2 Mon Sep 17 00:00:00 2001 From: ramya vidapanakal Date: Thu, 3 Oct 2024 18:17:37 +0100 Subject: [PATCH 6/9] added edit link,links csv test cases to broken links page spec and update link test cases to edit link page spec --- spec/requests/broken_links_page_spec.rb | 48 +++++++++++++++++++++++++ spec/requests/edit_link_page_spec.rb | 9 +++++ 2 files changed, 57 insertions(+) diff --git a/spec/requests/broken_links_page_spec.rb b/spec/requests/broken_links_page_spec.rb index f648f1427..c2a3c58ab 100644 --- a/spec/requests/broken_links_page_spec.rb +++ b/spec/requests/broken_links_page_spec.rb @@ -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(200) + 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(200) + expect(response.headers["Content-Type"]).to eq("text/csv") + end + end +end diff --git a/spec/requests/edit_link_page_spec.rb b/spec/requests/edit_link_page_spec.rb index cdf490efe..8e55ce05d 100644 --- a/spec/requests/edit_link_page_spec.rb +++ b/spec/requests/edit_link_page_spec.rb @@ -26,8 +26,17 @@ it "updates the link" do put path, params: { url: } + expect(Link.last.url).to eq("http://www.example.com/new") + expect(flash[:danger]).to be nil expect(link.reload.url).to eq(url) end + + it "catches invalid links" do + put path, params: { url: "ftp://who" } + + expect(response).to have_http_status(:found) + expect(flash[:danger]).not_to be nil + end end context "as a department user from the owning department" do From 129b159bca866d866df9ff3ec909a6e7619e293d Mon Sep 17 00:00:00 2001 From: ramya vidapanakal Date: Fri, 4 Oct 2024 09:55:57 +0100 Subject: [PATCH 7/9] fixed code partial in views and updated system test case for delete link --- app/views/links/index.html.erb | 1 + app/views/local_authorities/show.html.erb | 1 + spec/system/edit_link_page_spec.rb | 2 ++ 3 files changed, 4 insertions(+) diff --git a/app/views/links/index.html.erb b/app/views/links/index.html.erb index 3840ad8cb..dd24ae1e6 100644 --- a/app/views/links/index.html.erb +++ b/app/views/links/index.html.erb @@ -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})", diff --git a/app/views/local_authorities/show.html.erb b/app/views/local_authorities/show.html.erb index 373bf5b57..bce773743 100644 --- a/app/views/local_authorities/show.html.erb +++ b/app/views/local_authorities/show.html.erb @@ -1,4 +1,5 @@ <% content_for :page_title, @authority.name %> +<%= render partial: "shared/flash" %> <%= render "govuk_publishing_components/components/heading", { text: @authority.name, diff --git a/spec/system/edit_link_page_spec.rb b/spec/system/edit_link_page_spec.rb index 006c7814b..8b560868f 100644 --- a/spec/system/edit_link_page_spec.rb +++ b/spec/system/edit_link_page_spec.rb @@ -23,6 +23,8 @@ visit "/local_authorities/north-midlands/services/aardvark-wardens/reporting/edit" expect(page).to have_button("Delete") + click_on "Delete" + expect(page).to have_content("Link has been deleted") end end end From e5401aa738867a77d62839508bb7070abc7ba788 Mon Sep 17 00:00:00 2001 From: ramya vidapanakal Date: Mon, 7 Oct 2024 13:40:57 +0100 Subject: [PATCH 8/9] updated expected test status to be ok for better readability --- spec/requests/broken_links_page_spec.rb | 4 ++-- spec/requests/council_page_spec.rb | 6 +++--- spec/requests/services_page_spec.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/requests/broken_links_page_spec.rb b/spec/requests/broken_links_page_spec.rb index c2a3c58ab..5aea544be 100644 --- a/spec/requests/broken_links_page_spec.rb +++ b/spec/requests/broken_links_page_spec.rb @@ -36,7 +36,7 @@ context "GET links_status_csv" do it "returns a 200 response" do get "/check_links_status.csv" - expect(response).to have_http_status(200) + expect(response).to have_http_status(:ok) expect(response.headers["Content-Type"]).to eq("text/csv") end end @@ -44,7 +44,7 @@ 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(200) + expect(response).to have_http_status(:ok) expect(response.headers["Content-Type"]).to eq("text/csv") end end diff --git a/spec/requests/council_page_spec.rb b/spec/requests/council_page_spec.rb index dd1651ff1..d0ccbb635 100644 --- a/spec/requests/council_page_spec.rb +++ b/spec/requests/council_page_spec.rb @@ -13,7 +13,7 @@ login_as_gds_editor get "/local_authorities" - expect(response).to have_http_status(200) + expect(response).to have_http_status(:ok) end end end @@ -23,7 +23,7 @@ login_as_gds_editor get "/local_authorities/north-midlands" - expect(response).to have_http_status(200) + expect(response).to have_http_status(:ok) end end @@ -56,7 +56,7 @@ login_as_gds_editor get "/bad_homepage_url_status.csv" - expect(response).to have_http_status(200) + expect(response).to have_http_status(:ok) expect(response.headers["Content-Type"]).to eq("text/csv") end end diff --git a/spec/requests/services_page_spec.rb b/spec/requests/services_page_spec.rb index b1e3b0092..018bc142c 100644 --- a/spec/requests/services_page_spec.rb +++ b/spec/requests/services_page_spec.rb @@ -33,7 +33,7 @@ context "Get #show" do it "returns http success" do get "/services/aardvark-wardens" - expect(response).to have_http_status(200) + expect(response).to have_http_status(:ok) end end From defc96731762afa91d65cf8c67a96845fdfbfa02 Mon Sep 17 00:00:00 2001 From: ramya vidapanakal Date: Tue, 8 Oct 2024 09:12:57 +0100 Subject: [PATCH 9/9] removed the controller test cases --- spec/controllers/links_controller_spec.rb | 72 --------- .../local_authorities_controller_spec.rb | 137 ------------------ spec/controllers/services_controller_spec.rb | 41 ------ 3 files changed, 250 deletions(-) delete mode 100644 spec/controllers/links_controller_spec.rb delete mode 100644 spec/controllers/local_authorities_controller_spec.rb delete mode 100644 spec/controllers/services_controller_spec.rb diff --git a/spec/controllers/links_controller_spec.rb b/spec/controllers/links_controller_spec.rb deleted file mode 100644 index b57f6c43e..000000000 --- a/spec/controllers/links_controller_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -RSpec.describe LinksController, type: :controller do - before do - login_as_gds_editor - @local_authority = create(:local_authority) - @service = create(:service) - @interaction = create(:interaction) - @service_interaction = create(:service_interaction, service: @service, interaction: @interaction) - end - - describe "GET destroy" do - it "deletes link and redirects" do - get :destroy, params: { local_authority_slug: @local_authority.slug, service_slug: @service.slug, interaction_slug: @interaction.slug } - expect(response).to have_http_status(302) - expect(flash[:success]).to match("Link has been deleted") - end - end - - describe "GET edit" do - it "retrieves HTTP success" do - get :edit, params: { local_authority_slug: @local_authority.slug, service_slug: @service.slug, interaction_slug: @interaction.slug } - expect(response).to have_http_status(200) - end - - it "handles a URL passed in via flash" do - flash_hash = ActionDispatch::Flash::FlashHash.new - flash_hash[:link_url] = "https://www.example.com" - session["flash"] = flash_hash.to_session_value - - get :edit, params: { local_authority_slug: @local_authority.slug, service_slug: @service.slug, interaction_slug: @interaction.slug } - expect(response).to have_http_status(200) - end - end - - describe "POST edit" do - it "updates valid links" do - post :update, params: { local_authority_slug: @local_authority.slug, service_slug: @service.slug, interaction_slug: @interaction.slug, url: "http://www.example.com/new" } - expect(response).to have_http_status(302) - expect(Link.last.url).to eq("http://www.example.com/new") - expect(flash[:danger]).to be nil - end - - it "catches invalid links" do - post :update, params: { local_authority_slug: @local_authority.slug, service_slug: @service.slug, interaction_slug: @interaction.slug, url: "ftp://who" } - expect(response).to have_http_status(302) - expect(flash[:danger]).not_to be nil - end - end - - describe "GET homepage_links_status_csv" do - it "retrieves HTTP success" do - get :homepage_links_status_csv - expect(response).to have_http_status(200) - expect(response.headers["Content-Type"]).to eq("text/csv") - end - end - - describe "GET links_status_csv" do - it "retrieves HTTP success" do - get :links_status_csv - expect(response).to have_http_status(200) - expect(response.headers["Content-Type"]).to eq("text/csv") - end - end - - describe "GET bad_links_url_and_status_csv" do - it "retrieves HTTP success" do - get :bad_links_url_and_status_csv - expect(response).to have_http_status(200) - expect(response.headers["Content-Type"]).to eq("text/csv") - end - end -end diff --git a/spec/controllers/local_authorities_controller_spec.rb b/spec/controllers/local_authorities_controller_spec.rb deleted file mode 100644 index b60d56125..000000000 --- a/spec/controllers/local_authorities_controller_spec.rb +++ /dev/null @@ -1,137 +0,0 @@ -RSpec.describe LocalAuthoritiesController, type: :controller do - describe "GET #index" do - context "when there is sufficient data" do - it "returns http succcess" do - login_as_gds_editor - create(:local_authority) - get :index - expect(response).to have_http_status(200) - end - end - end - - describe "GET #show" do - before do - @local_authority = create(:local_authority, name: "Angus") - @service = create(:service, label: "Service 1", lgsl_code: 1) - end - - it "returns http success" do - login_as_gds_editor - get :show, params: { local_authority_slug: @local_authority.slug, service_slug: @service.slug } - expect(response).to have_http_status(200) - end - end - - describe "GET #edit_url" do - before do - @local_authority = create(:local_authority, name: "Angus") - @service = create(:service, label: "Service 1", lgsl_code: 1) - end - - it "returns http success" do - login_as_gds_editor - get :edit_url, params: { local_authority_slug: @local_authority.slug } - expect(response).to have_http_status(200) - end - end - - describe "POST #update" do - before do - @local_authority = create(:local_authority, name: "Angus") - @service = create(:service, label: "Service 1", lgsl_code: 1) - end - - it "returns http redirect" do - login_as_gds_editor - post :update, params: { local_authority_slug: @local_authority.slug, homepage_url: "http://www.example.com/new-homepage" } - expect(response).to have_http_status(302) - @local_authority.reload - expect(@local_authority.homepage_url).to eq("http://www.example.com/new-homepage") - end - end - - describe "GET bad_homepage_url_and_status_csv" do - it "retrieves HTTP success" do - login_as_gds_editor - get :bad_homepage_url_and_status_csv - expect(response).to have_http_status(200) - expect(response.headers["Content-Type"]).to eq("text/csv") - end - end - - describe "GET download_links_csv" do - before do - @local_authority = create(:local_authority) - end - - it "retrieves HTTP success" do - login_as_gds_editor - get( - :download_links_csv, - params: { - local_authority_slug: @local_authority.slug, - links_status_checkbox: %w[ok broken caution missing pending], - }, - ) - expect(response).to have_http_status(200) - expect(response.headers["Content-Type"]).to eq("text/csv") - end - end - - describe "POST upload_links_csv" do - 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\/#{@local_authority.slug}/ } - - it "retrieves HTTP found" do - login_as_gds_editor - post(:upload_links_csv, params: { local_authority_slug: @local_authority.slug, 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 - - context "with errors in the CSV" do - before do - login_as_gds_editor - interaction = create(:interaction, lgil_code: 1) - 6.times do |i| - service = create(:service, lgsl_code: i + 1) - create(:service_interaction, service:, interaction:) - end - end - - let(:local_authority) { create(:local_authority, gss: "S1") } - let(:fixture_path) { "spec/lib/local-links-manager/import/fixtures/" } - - it "shows the all error message if all lines are broken" do - csv = Rack::Test::UploadedFile.new(Rails.root.join(fixture_path, "imported_links_all_errors.csv"), "text/csv", true) - post(:upload_links_csv, params: { local_authority_slug: local_authority.slug, csv: }) - expect(flash[:danger]).to eq("Errors on all lines. Ensure a New URL column exists, with all rows either blank or a valid URL") - end - - it "shows the many error message if many lines are broken" do - csv = Rack::Test::UploadedFile.new(Rails.root.join(fixture_path, "imported_links_many_errors.csv"), "text/csv", true) - post(:upload_links_csv, params: { local_authority_slug: local_authority.slug, csv: }) - expect(flash[:danger].first).to eq("74 Errors detected. Please ensure a valid entry in the New URL column for lines (showing first 50):") - end - - it "shows the few error message if few lines are broken" do - csv = Rack::Test::UploadedFile.new(Rails.root.join(fixture_path, "imported_links_few_errors.csv"), "text/csv", true) - post(:upload_links_csv, params: { local_authority_slug: local_authority.slug, csv: }) - expect(flash[:danger].first).to eq("2 Errors detected. Please ensure a valid entry in the New URL column for lines:") - end - - it "shows the nothing to import info if it didn't import anything" do - csv = Rack::Test::UploadedFile.new(Rails.root.join(fixture_path, "imported_links_nothing_to_import.csv"), "text/csv", true) - post(:upload_links_csv, params: { local_authority_slug: local_authority.slug, csv: }) - expect(flash[:info]).to eq("No records updated. (If you were expecting updates, check the format of the uploaded file)") - end - end - end -end diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb deleted file mode 100644 index 968d11f3a..000000000 --- a/spec/controllers/services_controller_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -RSpec.describe ServicesController, type: :controller do - before { login_as_gds_editor } - - describe "GET #index" do - it "returns http succcess" do - create(:service) - get :index - expect(response).to have_http_status(200) - end - end - - describe "GET #show" do - it "returns http success" do - service = create(:service) - get :show, params: { service_slug: service.slug } - expect(response).to have_http_status(200) - end - end - - describe "GET #download_links_form" do - it "returns a success response" do - service = create(:service) - get :download_links_form, params: { service_slug: service.slug } - expect(response).to be_successful - end - end - - describe "POST #download_links_csv" do - let(:service) { create(:service) } - let(:exported_data) { "some_data" } - - before do - allow_any_instance_of(LocalLinksManager::Export::ServiceLinksExporter).to receive(:export_links).and_return(exported_data) - end - - it "returns a success response" do - post :download_links_csv, params: { service_slug: service.slug } - expect(response).to be_successful - end - end -end