Browse Source

Update nationality all csv labels

pull/2328/head
Kat 2 years ago
parent
commit
8607f9f3f9
  1. 6
      app/models/form/lettings/questions/nationality_all.rb
  2. 6
      app/models/form/sales/questions/nationality_all.rb
  3. 14
      spec/services/csv/lettings_log_csv_service_spec.rb
  4. 14
      spec/services/csv/sales_log_csv_service_spec.rb

6
app/models/form/lettings/questions/nationality_all.rb

@ -15,4 +15,10 @@ class Form::Lettings::Questions::NationalityAll < ::Form::Question
end end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 36, 2024 => 35 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 36, 2024 => 35 }.freeze
def label_from_value(value)
return unless value
answer_options[value.to_s]["name"]
end
end end

6
app/models/form/sales/questions/nationality_all.rb

@ -21,4 +21,10 @@ class Form::Sales::Questions::NationalityAll < ::Form::Question
@buyer_index == 1 ? 26 : 34 @buyer_index == 1 ? 26 : 34
end end
end end
def label_from_value(value)
return unless value
answer_options[value.to_s]["name"]
end
end end

14
spec/services/csv/lettings_log_csv_service_spec.rb

@ -171,6 +171,7 @@ RSpec.describe Csv::LettingsLogCsvService do
context "when the current form is 2024" do context "when the current form is 2024" do
let(:now) { Time.zone.local(2024, 4, 1) } let(:now) { Time.zone.local(2024, 4, 1) }
let(:fixed_time) { Time.zone.local(2024, 4, 1) }
it "exports the CSV with 2024 ordering and all values correct" do it "exports the CSV with 2024 ordering and all values correct" do
expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_labels_24.csv") expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_labels_24.csv")
@ -181,6 +182,19 @@ RSpec.describe Csv::LettingsLogCsvService do
end end
expect(csv).to eq expected_content expect(csv).to eq expected_content
end end
context "when the log has nationality_all" do
before do
log.update!(nationality_all: 36)
end
it "exports the id for under the heading 'nationality_all'" do
expect(log.nationality_all).to eq 36
nationality_all_column_index = csv.first.index("nationality_all")
nationality_all_value = csv.second[nationality_all_column_index]
expect(nationality_all_value).to eq "Australia"
end
end
end end
context "when the current form is 2023" do context "when the current form is 2023" do

14
spec/services/csv/sales_log_csv_service_spec.rb

@ -166,6 +166,7 @@ RSpec.describe Csv::SalesLogCsvService do
end end
context "when the current form is 2024" do context "when the current form is 2024" do
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
let(:now) { Time.zone.local(2024, 5, 1) } let(:now) { Time.zone.local(2024, 5, 1) }
it "exports the CSV with the 2024 ordering and all values correct" do it "exports the CSV with the 2024 ordering and all values correct" do
@ -177,6 +178,19 @@ RSpec.describe Csv::SalesLogCsvService do
end end
expect(csv).to eq expected_content expect(csv).to eq expected_content
end end
context "when the log has nationality_all" do
before do
log.update!(nationality_all: 36)
end
it "exports the id for under the heading 'nationality_all'" do
expect(log.nationality_all).to eq 36
nationality_all_column_index = csv.first.index("nationality_all")
nationality_all_value = csv.second[nationality_all_column_index]
expect(nationality_all_value).to eq "Australia"
end
end
end end
context "when the current form is 2023" do context "when the current form is 2023" do

Loading…
Cancel
Save