Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new test to increase coverage for continuous deployment #741

Merged
merged 2 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions app/controllers/links_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/controllers/links_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 16 additions & 3 deletions spec/requests/healthcheck_spec.rb
Original file line number Diff line number Diff line change
@@ -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