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_relative "../request_helper" |
||||
|
||||
RSpec.describe FormPageErrorHelper do |
||||
before do |
||||
RequestHelper.stub_http_requests |
||||
end |
||||
|
||||
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!(:form) { case_log.form } |
||||
|
@ -1,33 +1,35 @@
|
||||
require "rails_helper" |
||||
require "rake" |
||||
|
||||
describe "rake form_definition:validate_all", type: :task do |
||||
subject(:task) { Rake::Task["form_definition:validate_all"] } |
||||
RSpec.describe "form_definition" do |
||||
describe ":validate_all", type: :task do |
||||
subject(:task) { Rake::Task["form_definition:validate_all"] } |
||||
|
||||
before do |
||||
Rake.application.rake_require("tasks/form_definition") |
||||
Rake::Task.define_task(:environment) |
||||
task.reenable |
||||
end |
||||
before do |
||||
Rake.application.rake_require("tasks/form_definition") |
||||
Rake::Task.define_task(:environment) |
||||
task.reenable |
||||
end |
||||
|
||||
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 |
||||
task.invoke |
||||
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 |
||||
task.invoke |
||||
end |
||||
end |
||||
end |
||||
|
||||
describe "rake form_definition:validate", type: :task do |
||||
subject(:task) { Rake::Task["form_definition:validate"] } |
||||
describe ":validate", type: :task do |
||||
subject(:task) { Rake::Task["form_definition:validate"] } |
||||
|
||||
before do |
||||
Rake.application.rake_require("tasks/form_definition") |
||||
Rake::Task.define_task(:environment) |
||||
allow(JSON::Validator).to receive(:validate).and_return(true) |
||||
task.reenable |
||||
end |
||||
before do |
||||
Rake.application.rake_require("tasks/form_definition") |
||||
Rake::Task.define_task(:environment) |
||||
allow(JSON::Validator).to receive(:validate).and_return(true) |
||||
task.reenable |
||||
end |
||||
|
||||
it "runs the validate task for the given form definition" do |
||||
expect(JSON::Validator).to receive(:validate!).at_least(1).time |
||||
task.invoke("config/forms/2021_2022.json") |
||||
it "runs the validate task for the given form definition" do |
||||
expect(JSON::Validator).to receive(:validate!).at_least(1).time |
||||
task.invoke("config/forms/2021_2022.json") |
||||
end |
||||
end |
||||
end |
||||
|
@ -1,22 +1,23 @@
|
||||
require "rails_helper" |
||||
|
||||
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(:form) { case_log.form } |
||||
let(:section_id) { "household" } |
||||
let(:section_definition) { form.form_definition["sections"][section_id] } |
||||
subject { Form::Section.new(section_id, section_definition, form) } |
||||
|
||||
it "has an id" do |
||||
expect(subject.id).to eq(section_id) |
||||
expect(section.id).to eq(section_id) |
||||
end |
||||
|
||||
it "has a label" do |
||||
expect(subject.label).to eq("About the household") |
||||
expect(section.label).to eq("About the household") |
||||
end |
||||
|
||||
it "has subsections" do |
||||
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 |
||||
|
@ -1,11 +1,12 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe ErrorSummaryFullMessagesPresenter do |
||||
subject(:error_summary_presenter) { described_class.new(error_messages) } |
||||
|
||||
let(:error_messages) { { reset_password_token: %w[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 |
||||
expect(subject.formatted_error_messages).to eq(formatted_error_messages) |
||||
expect(error_summary_presenter.formatted_error_messages).to eq(formatted_error_messages) |
||||
end |
||||
end |
||||
|
Loading…
Reference in new issue