Browse Source

fix linter complaints

pull/1568/head
Arthur Campbell 3 years ago
parent
commit
90bf0c0ef8
  1. 12
      spec/factories/page.rb
  2. 10
      spec/factories/subsection.rb
  3. 6
      spec/services/csv/sales_log_csv_service_spec.rb

12
spec/factories/page.rb

@ -9,12 +9,12 @@ FactoryBot.define do
end end
after :build do |page, evaluator| after :build do |page, evaluator|
if q = evaluator.question page.questions = if (q = evaluator.question)
q.page = page q.page = page
page.questions = [q] [q]
elsif else
page.questions = [build(:question, id: evaluator.question_id, page:)] [build(:question, id: evaluator.question_id, page:)]
end end
end end
end end
end end

10
spec/factories/subsection.rb

@ -9,11 +9,11 @@ FactoryBot.define do
end end
after :build do |subsection, evaluator| after :build do |subsection, evaluator|
if evaluator.questions subsection.pages = if evaluator.questions
subsection.pages = evaluator.questions.map { |question| build(:page, :with_question, question:, subsection:) } evaluator.questions.map { |question| build(:page, :with_question, question:, subsection:) }
else else
subsection.pages = evaluator.question_ids.map { |id| build(:page, :with_question, question_id: id, subsection:) } evaluator.question_ids.map { |question_id| build(:page, :with_question, question_id:, subsection:) }
end end
end end
end end
end end

6
spec/services/csv/sales_log_csv_service_spec.rb

@ -40,12 +40,12 @@ RSpec.describe Csv::SalesLogCsvService do
allow(form_handler_mock).to receive(:ordered_sales_questions_for_all_years).and_return(sales_form.questions) allow(form_handler_mock).to receive(:ordered_sales_questions_for_all_years).and_return(sales_form.questions)
end end
context "to return questions with particular ids" do context "when it returns questions with particular ids" do
let(:question_ids) { %w[type age1 buy1livein exdate] } let(:question_ids) { %w[type age1 buy1livein exdate] }
it "includes log attributes related to questions to the headers" do it "includes log attributes related to questions to the headers" do
headers = csv.first headers = csv.first
expect(headers).to include *question_ids.first(3) expect(headers).to include(*question_ids.first(3))
end end
it "removes some log attributes related to questions from the headers and replaces them with their derived values in the correct order" do it "removes some log attributes related to questions from the headers and replaces them with their derived values in the correct order" do
@ -55,7 +55,7 @@ RSpec.describe Csv::SalesLogCsvService do
end end
end end
context "to return questions with particular features" do context "when it returns questions with particular features" do
let(:questions) do let(:questions) do
[ [
build(:question, id: "attribute_value_check", type: "interruption_screen"), build(:question, id: "attribute_value_check", type: "interruption_screen"),

Loading…
Cancel
Save