Skip to content

Commit

Permalink
Merge pull request #2648 from alphagov/add-heroku-deploy-button
Browse files Browse the repository at this point in the history
Add "Deploy to Heroku" button to README
  • Loading branch information
floehopper authored Jul 21, 2016
2 parents f5d65e2 + 62e502f commit efd0058
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Read more in [Lisa Scott's GDS blog post](https://gds.blog.gov.uk/2012/02/16/smart-answers-are-smart/).

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

## Screenshots

![Student Finance Forms screenshot](./doc/assets/govuk-student-finance-forms.png)
Expand Down
16 changes: 16 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Smart Answers",
"website": "https://www.gov.uk/",
"repository": "https://github.com/alphagov/smart-answers",
"success_url": "/",
"env": {
"GOVUK_APP_DOMAIN": "integration.publishing.service.gov.uk",
"PLEK_SERVICE_CONTENTAPI_URI": "https://www.gov.uk/api",
"PLEK_SERVICE_STATIC_URI": "https://assets-origin.integration.publishing.service.gov.uk/",
"RUNNING_ON_HEROKU": "true",
"EXPOSE_GOVSPEAK": "true",
"ERRBIT_ENV": "integration"
},
"image": "heroku/ruby",
"buildpacks": [ { "url": "heroku/ruby" } ]
}
6 changes: 5 additions & 1 deletion app/controllers/smart_answers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
class SmartAnswersController < ApplicationController
before_action :find_smart_answer
before_action :find_smart_answer, except: %w(index)
before_action :redirect_response_to_canonical_url, only: %w{show}
before_action :set_header_footer_only, only: %w{visualise}

rescue_from SmartAnswer::FlowRegistry::NotFound, with: :error_404
rescue_from SmartAnswer::InvalidNode, with: :error_404

def index
@flows = flow_registry.flows.sort_by(&:name)
end

def show
set_slimmer_artefact(@presenter.artefact)
respond_to do |format|
Expand Down
7 changes: 7 additions & 0 deletions app/views/smart_answers/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1>Smart Answers</h1>

<ul>
<% @flows.each do |flow| %>
<li><%= link_to flow.name, smart_answer_path(flow.name) %></li>
<% end %>
</ul>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
SmartAnswers::Application.routes.draw do
root to: 'smart_answers#index'

get 'healthcheck', to: proc { [200, {}, ['']] }

constraints id: /[a-z0-9-]+/i do
Expand Down
4 changes: 4 additions & 0 deletions test/functional/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ class RoutingTest < ActionDispatch::IntegrationTest
get "/non-gb-driving-licence%E2%EF%BF%BD%EF%BF%BD"
end
end

should "route root path to smart answers controller index action" do
assert_routing "/", controller: "smart_answers", action: "index"
end
end
26 changes: 26 additions & 0 deletions test/functional/smart_answers_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,32 @@ def teardown
teardown_fixture_flows
end

context "GET /" do
setup do
@flow_a = stub("flow", name: "flow-a")
@flow_b = stub("flow", name: "flow-b")
registry = stub("Flow registry")
registry.stubs(:flows).returns([@flow_b, @flow_a])
@controller.stubs(:flow_registry).returns(registry)
end

should "assign flows sorted alphabetically by name" do
get :index
assert_equal [@flow_a, @flow_b], assigns(:flows)
end

should "render index template" do
get :index
assert_template "index"
end

should "render list of links to flows" do
get :index
assert_select "ul li a[href='/flow-a']", text: "flow-a"
assert_select "ul li a[href='/flow-b']", text: "flow-b"
end
end

context "GET /<slug>" do
should "respond with 404 if not found" do
@registry = stub("Flow registry")
Expand Down

0 comments on commit efd0058

Please sign in to comment.