Browse Source

feat: remove text input for Other option

pull/936/head
natdeanlewissoftwire 3 years ago
parent
commit
c5752e43da
  1. 1
      app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb
  2. 10
      app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb
  3. 10
      app/models/form/sales/questions/other_buyer2_relationship_to_buyer1.rb
  4. 5
      db/migrate/20221005150022_remove_otherrelat2_from_sales_log.rb
  5. 11
      db/schema.rb
  6. 2
      spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb
  7. 16
      spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb
  8. 37
      spec/models/form/sales/questions/other_buyer2_relationship_to_buyer1_spec.rb

1
app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb

@ -13,7 +13,6 @@ class Form::Sales::Pages::Buyer2RelationshipToBuyer1 < ::Form::Page
def questions def questions
@questions ||= [ @questions ||= [
Form::Sales::Questions::Buyer2RelationshipToBuyer1.new(nil, nil, self), Form::Sales::Questions::Buyer2RelationshipToBuyer1.new(nil, nil, self),
Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1.new(nil, nil, self),
] ]
end end
end end

10
app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb

@ -8,16 +8,6 @@ class Form::Sales::Questions::Buyer2RelationshipToBuyer1 < ::Form::Question
@hint_text = "" @hint_text = ""
@page = page @page = page
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@conditional_for = {
"otherrelat2" => %w[X],
}
@hidden_in_check_answers = {
"depends_on" => [
{
"relat2" => "X",
},
],
}
end end
ANSWER_OPTIONS = { ANSWER_OPTIONS = {

10
app/models/form/sales/questions/other_buyer2_relationship_to_buyer1.rb

@ -1,10 +0,0 @@
class Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "otherrelat2"
@check_answer_label = "Buyer 2's relationship to buyer 1"
@header = "Buyer 2's relationship to buyer 1"
@type = "text"
@page = page
end
end

5
db/migrate/20221005150022_remove_otherrelat2_from_sales_log.rb

@ -0,0 +1,5 @@
class RemoveOtherrelat2FromSalesLog < ActiveRecord::Migration[7.0]
def change
remove_column :sales_logs, :otherrelat2, :string
end
end

11
db/schema.rb

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2022_10_04_184301) do ActiveRecord::Schema[7.0].define(version: 2022_10_05_150022) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -333,10 +333,12 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_184301) do
t.integer "jointmore" t.integer "jointmore"
t.integer "jointpur" t.integer "jointpur"
t.integer "beds" t.integer "beds"
t.integer "companybuy"
t.integer "age1" t.integer "age1"
t.integer "age1_known" t.integer "age1_known"
t.integer "companybuy"
t.string "sex1" t.string "sex1"
t.integer "national"
t.string "othernational"
t.integer "ethnic" t.integer "ethnic"
t.integer "ethnic_group" t.integer "ethnic_group"
t.integer "buy1livein" t.integer "buy1livein"
@ -346,15 +348,12 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_184301) do
t.integer "age2" t.integer "age2"
t.integer "age2_known" t.integer "age2_known"
t.string "relat2" t.string "relat2"
t.string "otherrelat2"
t.string "sex2" t.string "sex2"
t.integer "noint" t.integer "noint"
t.integer "buy2livein" t.integer "buy2livein"
t.integer "ecstat2" t.integer "ecstat2"
t.integer "ecstat1"
t.integer "national"
t.string "othernational"
t.integer "privacynotice" t.integer "privacynotice"
t.integer "ecstat1"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"

2
spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb

@ -12,7 +12,7 @@ RSpec.describe Form::Sales::Pages::Buyer2RelationshipToBuyer1, type: :model do
end end
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[relat2 otherrelat2]) expect(page.questions.map(&:id)).to eq(%w[relat2])
end end
it "has the correct id" do it "has the correct id" do

16
spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb

@ -43,20 +43,4 @@ RSpec.describe Form::Sales::Questions::Buyer2RelationshipToBuyer1, type: :model
"R" => { "value" => "Buyer prefers not to say" }, "R" => { "value" => "Buyer prefers not to say" },
}) })
end end
it "has correct conditional for" do
expect(question.conditional_for).to eq({
"otherrelat2" => %w[X],
})
end
it "has correct hidden in check answers" do
expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{
"relat2" => "X",
},
],
})
end
end end

37
spec/models/form/sales/questions/other_buyer2_relationship_to_buyer1_spec.rb

@ -1,37 +0,0 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("otherrelat2")
end
it "has the correct header" do
expect(question.header).to eq("Buyer 2's relationship to buyer 1")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Buyer 2's relationship to buyer 1")
end
it "has the correct type" do
expect(question.type).to eq("text")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
end
Loading…
Cancel
Save