diff --git a/app/controllers/links_controller.rb b/app/controllers/links_controller.rb index 402fbea9a..924441edd 100644 --- a/app/controllers/links_controller.rb +++ b/app/controllers/links_controller.rb @@ -33,12 +33,8 @@ def update end def destroy - if @link.make_missing - redirect("deleted") - else - flash[:danger] = "Could not delete link." - redirect_back - end + @link.make_missing + redirect("deleted") end def homepage_links_status_csv diff --git a/config/routes.rb b/config/routes.rb index cbbdbdeb7..52ef81173 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,10 @@ Rails.application.routes.draw do root to: "links#index" - get "/healthcheck", to: proc { [200, {}, %w[OK]] } + get "/healthcheck", to: GovukHealthcheck.rack_response( + GovukHealthcheck::ActiveRecord, + GovukHealthcheck::SidekiqRedis, + ) resources "local_authorities", only: %i[index show], param: :local_authority_slug do member do diff --git a/spec/controllers/links_controller_spec.rb b/spec/controllers/links_controller_spec.rb index 045dce78e..48a9601d9 100644 --- a/spec/controllers/links_controller_spec.rb +++ b/spec/controllers/links_controller_spec.rb @@ -4,6 +4,15 @@ @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 diff --git a/spec/requests/healthcheck_spec.rb b/spec/requests/healthcheck_spec.rb index 82f39a160..f86eaf063 100644 --- a/spec/requests/healthcheck_spec.rb +++ b/spec/requests/healthcheck_spec.rb @@ -1,8 +1,21 @@ RSpec.describe "healthcheck path", type: :request do - it "should respond with 'OK'" do + before do get "/healthcheck" + end + + it "returns a 200 HTTP status" do + expect(response).to have_http_status(:ok) + end + + it "returns postgres connection status" do + json = JSON.parse(response.body) + + expect(json["checks"]).to include("database_connectivity") + end + + it "returns redis connections status" do + json = JSON.parse(response.body) - expect(response.status).to eq(200) - expect(response.body).to eq("OK") + expect(json["checks"]).to include("redis_connectivity") end end