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

surveys: add a handler for the URL we sent in the letters #152

Merged
merged 3 commits into from
May 10, 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
2 changes: 1 addition & 1 deletion Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ group :bsp_tests, halt_on_fail: true do
# Below are examples overriding defaults

cmd: 'bin/cucumber',
cmd_additional_args: '--profile rerun',
cmd_additional_args: '--profile rerun --fail-fast',

# all_after_pass: false,
# all_on_start: false,
Expand Down
10 changes: 10 additions & 0 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class PagesController < ApplicationController
before_action :check_uprn_link, only: :index

def index
respond_to do |format|
format.html
Expand All @@ -10,4 +12,12 @@ def help
format.html
end
end

private

def check_uprn_link
return if params[:uprn].nil?

redirect_to survey_url(uprn: params[:uprn])
end
end
5 changes: 5 additions & 0 deletions app/controllers/surveys_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class SurveysController < ApplicationController
before_action :find_survey
before_action :preset_uprn, only: :edit

rescue_from Survey::RecordNotFound do
redirect_to new_survey_url
Expand Down Expand Up @@ -44,4 +45,8 @@ def survey_params
def section_param
params[:section].to_s
end

def preset_uprn
@survey.uprn = params[:uprn] if params[:uprn]
end
end
6 changes: 6 additions & 0 deletions features/alex_fills_in_a_survey.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ Feature: Alex fills in a report about a building
Then the page contains "Building height"
When I press "Back"
Then the page contains "Building management details"

Scenario: Alex opens a survey link
Given a building exists with UPRN 777
When I open a survey link for UPRN 777
Then the page contains "What is the building’s UPRN?"
And the input for "UPRN" contains "777"
6 changes: 5 additions & 1 deletion features/step_definitions/survey_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@
end
end

Given('I see the summary {string} with') do |summary, table|
When('I open a survey link for UPRN {int}') do |uprn|
visit "/?uprn=#{uprn}"
end

Then('I see the summary {string} with') do |summary, table|
within(:summary, summary) do
table.rows.each_with_index do |(name, value, url), index|
within(:xpath, "./div[#{index + 1}]") do
Expand Down
4 changes: 4 additions & 0 deletions features/step_definitions/web_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,7 @@
check option
end
end

Then('the input for {string} contains {string}') do |label, value|
expect(page.find_field(label).value).to eq value
end