Stéphane Meny
3 years ago
committed by
GitHub
50 changed files with 676 additions and 709 deletions
@ -1,8 +1,13 @@ |
|||||||
require "rails_helper" |
require "rails_helper" |
||||||
|
require_relative "../request_helper" |
||||||
|
|
||||||
RSpec.describe FormPageErrorHelper do |
RSpec.describe FormPageErrorHelper do |
||||||
|
before do |
||||||
|
RequestHelper.stub_http_requests |
||||||
|
end |
||||||
|
|
||||||
describe "#remove_other_page_errors" do |
describe "#remove_other_page_errors" do |
||||||
context "removes non base other questions" do |
context "when non base other questions are removed" do |
||||||
let!(:case_log) { FactoryBot.create(:case_log, :in_progress) } |
let!(:case_log) { FactoryBot.create(:case_log, :in_progress) } |
||||||
let!(:form) { case_log.form } |
let!(:form) { case_log.form } |
||||||
|
|
@ -1,33 +1,35 @@ |
|||||||
require "rails_helper" |
require "rails_helper" |
||||||
require "rake" |
require "rake" |
||||||
|
|
||||||
describe "rake form_definition:validate_all", type: :task do |
RSpec.describe "form_definition" do |
||||||
subject(:task) { Rake::Task["form_definition:validate_all"] } |
describe ":validate_all", type: :task do |
||||||
|
subject(:task) { Rake::Task["form_definition:validate_all"] } |
||||||
|
|
||||||
before do |
before do |
||||||
Rake.application.rake_require("tasks/form_definition") |
Rake.application.rake_require("tasks/form_definition") |
||||||
Rake::Task.define_task(:environment) |
Rake::Task.define_task(:environment) |
||||||
task.reenable |
task.reenable |
||||||
end |
end |
||||||
|
|
||||||
it "runs the validate task for each form definition in the project" do |
it "runs the validate task for each form definition in the project" do |
||||||
expect(Rake::Task["form_definition:validate"]).to receive(:invoke).exactly(4).times |
expect(Rake::Task["form_definition:validate"]).to receive(:invoke).exactly(4).times |
||||||
task.invoke |
task.invoke |
||||||
|
end |
||||||
end |
end |
||||||
end |
|
||||||
|
|
||||||
describe "rake form_definition:validate", type: :task do |
describe ":validate", type: :task do |
||||||
subject(:task) { Rake::Task["form_definition:validate"] } |
subject(:task) { Rake::Task["form_definition:validate"] } |
||||||
|
|
||||||
before do |
before do |
||||||
Rake.application.rake_require("tasks/form_definition") |
Rake.application.rake_require("tasks/form_definition") |
||||||
Rake::Task.define_task(:environment) |
Rake::Task.define_task(:environment) |
||||||
allow(JSON::Validator).to receive(:validate).and_return(true) |
allow(JSON::Validator).to receive(:validate).and_return(true) |
||||||
task.reenable |
task.reenable |
||||||
end |
end |
||||||
|
|
||||||
it "runs the validate task for the given form definition" do |
it "runs the validate task for the given form definition" do |
||||||
expect(JSON::Validator).to receive(:validate!).at_least(1).time |
expect(JSON::Validator).to receive(:validate!).at_least(1).time |
||||||
task.invoke("config/forms/2021_2022.json") |
task.invoke("config/forms/2021_2022.json") |
||||||
|
end |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -1,22 +1,23 @@ |
|||||||
require "rails_helper" |
require "rails_helper" |
||||||
|
|
||||||
RSpec.describe Form::Section, type: :model do |
RSpec.describe Form::Section, type: :model do |
||||||
|
subject(:section) { described_class.new(section_id, section_definition, form) } |
||||||
|
|
||||||
let(:case_log) { FactoryBot.build(:case_log) } |
let(:case_log) { FactoryBot.build(:case_log) } |
||||||
let(:form) { case_log.form } |
let(:form) { case_log.form } |
||||||
let(:section_id) { "household" } |
let(:section_id) { "household" } |
||||||
let(:section_definition) { form.form_definition["sections"][section_id] } |
let(:section_definition) { form.form_definition["sections"][section_id] } |
||||||
subject { Form::Section.new(section_id, section_definition, form) } |
|
||||||
|
|
||||||
it "has an id" do |
it "has an id" do |
||||||
expect(subject.id).to eq(section_id) |
expect(section.id).to eq(section_id) |
||||||
end |
end |
||||||
|
|
||||||
it "has a label" do |
it "has a label" do |
||||||
expect(subject.label).to eq("About the household") |
expect(section.label).to eq("About the household") |
||||||
end |
end |
||||||
|
|
||||||
it "has subsections" do |
it "has subsections" do |
||||||
expected_subsections = %w[household_characteristics household_needs] |
expected_subsections = %w[household_characteristics household_needs] |
||||||
expect(subject.subsections.map(&:id)).to eq(expected_subsections) |
expect(section.subsections.map(&:id)).to eq(expected_subsections) |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -1,11 +1,12 @@ |
|||||||
require "rails_helper" |
require "rails_helper" |
||||||
|
|
||||||
RSpec.describe ErrorSummaryFullMessagesPresenter do |
RSpec.describe ErrorSummaryFullMessagesPresenter do |
||||||
|
subject(:error_summary_presenter) { described_class.new(error_messages) } |
||||||
|
|
||||||
let(:error_messages) { { reset_password_token: %w[expired] } } |
let(:error_messages) { { reset_password_token: %w[expired] } } |
||||||
let(:formatted_error_messages) { [[:reset_password_token, "Reset password token expired"]] } |
let(:formatted_error_messages) { [[:reset_password_token, "Reset password token expired"]] } |
||||||
subject { described_class.new(error_messages) } |
|
||||||
|
|
||||||
it "formats messages to include the attribute name" do |
it "formats messages to include the attribute name" do |
||||||
expect(subject.formatted_error_messages).to eq(formatted_error_messages) |
expect(error_summary_presenter.formatted_error_messages).to eq(formatted_error_messages) |
||||||
end |
end |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue