Browse Source

Fix tests

pull/165/head
Kat 4 years ago
parent
commit
51dd7fe393
  1. 2
      .env.example
  2. 3
      app/models/case_log.rb
  3. 2
      db/schema.rb
  4. 12
      spec/features/form/page_routing_spec.rb
  5. 2
      spec/models/case_log_spec.rb
  6. 2
      spec/models/form_handler_spec.rb

2
.env.example

@ -2,5 +2,3 @@ DB_USERNAME=postgres-user
DB_PASSWORD=postgres-password
CORE_EMAIL_USERNAME=email@example.com
CORE_EMAIL_PASSWORD=password123
OS_PLACES_API_KEY=xx

3
app/models/case_log.rb

@ -1,6 +1,3 @@
require "uri"
require "net/http"
require "json"
require "postcodes_io"
class CaseLogValidator < ActiveModel::Validator

2
db/schema.rb

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_12_09_092131) do
ActiveRecord::Schema.define(version: 2021_12_13_122642) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

12
spec/features/form/page_routing_spec.rb

@ -50,26 +50,26 @@ RSpec.describe "Form Page Routing" do
context "inferred answers routing", js: true do
it "shows question if the answer could not be inferred" do
visit("/case-logs/#{id}/property-postcode")
visit("/logs/#{id}/property-postcode")
fill_in("case-log-property-postcode-field", with: "P0 5ST")
click_button("Save and continue")
expect(page).to have_current_path("/case-logs/#{id}/do-you-know-the-local-authority")
expect(page).to have_current_path("/logs/#{id}/do-you-know-the-local-authority")
end
it "shows question if the answer could not be inferred" do
visit("/case-logs/#{id}/property-postcode")
visit("/logs/#{id}/property-postcode")
click_button("Save and continue")
expect(page).to have_current_path("/case-logs/#{id}/do-you-know-the-local-authority")
expect(page).to have_current_path("/logs/#{id}/do-you-know-the-local-authority")
end
it "does not show question if the answer could be inferred" do
stub_request(:get, /api.postcodes.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\"}}", headers: {})
visit("/case-logs/#{id}/property-postcode")
visit("/logs/#{id}/property-postcode")
fill_in("case-log-property-postcode-field", with: "P0 5ST")
click_button("Save and continue")
expect(page).to have_current_path("/case-logs/#{id}/property-wheelchair-accessible")
expect(page).to have_current_path("/logs/#{id}/property-wheelchair-accessible")
end
end
end

2
spec/models/case_log_spec.rb

@ -1020,7 +1020,7 @@ RSpec.describe Form, type: :model do
expect(record_from_db["month"]).to eq(10)
expect(record_from_db["year"]).to eq(2021)
end
context "addresses" do
before do
stub_request(:get, /api.postcodes.io/)

2
spec/models/form_handler_spec.rb

@ -15,7 +15,7 @@ RSpec.describe FormHandler do
form_handler = FormHandler.instance
form = form_handler.get_form("test_form")
expect(form).to be_a(Form)
expect(form.pages.count).to eq(26)
expect(form.pages.count).to eq(27)
end
end

Loading…
Cancel
Save