From 7b86842430696eb18d451a2d134580679e502c2e Mon Sep 17 00:00:00 2001 From: Vasili Kachalko Date: Thu, 2 Nov 2023 15:04:42 +0100 Subject: [PATCH] renaming classes for zeitwerk --- Gemfile | 4 +-- Gemfile.lock | 30 ++++++++----------- .../admin/form_answers_controller.rb | 2 +- .../assessor/form_answers_controller.rb | 2 +- app/controllers/form_controller.rb | 2 +- .../lieutenant/form_answers_controller.rb | 2 +- app/decorators/form_answer_decorator.rb | 8 ++--- app/form_pointers/financial_table.rb | 8 ++--- app/form_pointers/financial_year_pointer.rb | 8 ++--- app/form_pointers/form_financial_pointer.rb | 8 ++--- app/models/assessor_assignment.rb | 8 ++--- app/models/audit_log.rb | 4 +-- app/models/comment.rb | 4 +-- app/models/eligibility.rb | 2 +- app/models/feedback.rb | 4 +-- app/models/form_answer.rb | 20 ++++++------- app/models/group_leader.rb | 2 +- app/models/reports/all_entries.rb | 2 +- app/models/reports/citation_report.rb | 2 +- app/models/reports/csv_helper.rb | 2 +- app/models/reports/press_book_list.rb | 2 +- .../company_details/_sic_form.html.slim | 2 +- .../assessor/form_answers/_question.html.slim | 2 +- .../questions/_address_question.html.slim | 2 +- .../_assessor_details_question.html.slim | 2 +- .../qae_form/_address_question.html.slim | 2 +- .../_assessor_details_question.html.slim | 2 +- app/views/qae_form/_question.html.slim | 4 +-- config/application.rb | 11 +++++-- forms/award_years/v2022/qae_forms.rb | 4 +-- forms/award_years/v2022/qavs.rb | 24 +++++++-------- forms/award_years/v2022/qavs/qavs_step1.rb | 2 +- forms/award_years/v2022/qavs/qavs_step2.rb | 2 +- forms/award_years/v2022/qavs/qavs_step3.rb | 2 +- forms/award_years/v2022/qavs/qavs_step4.rb | 2 +- forms/award_years/v2022/qavs/qavs_step5.rb | 2 +- forms/award_years/v2023/qae_forms.rb | 4 +-- forms/award_years/v2023/qavs.rb | 24 +++++++-------- forms/award_years/v2023/qavs/qavs_step1.rb | 2 +- forms/award_years/v2023/qavs/qavs_step2.rb | 2 +- forms/award_years/v2023/qavs/qavs_step3.rb | 2 +- forms/award_years/v2023/qavs/qavs_step4.rb | 2 +- forms/award_years/v2023/qavs/qavs_step5.rb | 2 +- forms/award_years/v2024/qae_forms.rb | 4 +-- forms/award_years/v2024/qavs.rb | 24 +++++++-------- forms/award_years/v2024/qavs/qavs_step1.rb | 2 +- forms/award_years/v2024/qavs/qavs_step2.rb | 2 +- forms/award_years/v2024/qavs/qavs_step3.rb | 2 +- forms/award_years/v2024/qavs/qavs_step4.rb | 2 +- forms/award_years/v2024/qavs/qavs_step5.rb | 2 +- forms/qae_form_builder.rb | 4 +-- forms/qae_form_builder/address_question.rb | 2 +- .../assessor_details_question.rb | 2 +- .../by_years_label_question.rb | 2 +- forms/qae_form_builder/by_years_question.rb | 2 +- .../ceremonial_county_question.rb | 2 +- .../checkbox_seria_question.rb | 2 +- forms/qae_form_builder/comment_question.rb | 2 +- forms/qae_form_builder/confirm_question.rb | 2 +- .../contact_email_question.rb | 2 +- forms/qae_form_builder/contact_question.rb | 2 +- forms/qae_form_builder/country_question.rb | 2 +- forms/qae_form_builder/date_question.rb | 2 +- forms/qae_form_builder/dropdown_question.rb | 2 +- .../head_of_business_question.rb | 2 +- forms/qae_form_builder/header_question.rb | 2 +- .../multi_question_decorator.rb | 2 +- .../multi_question_validator.rb | 2 +- forms/qae_form_builder/number_question.rb | 2 +- .../one_option_by_years_label_question.rb | 2 +- .../one_option_by_years_question.rb | 2 +- .../options_business_name_changed_question.rb | 2 +- forms/qae_form_builder/options_question.rb | 2 +- .../previous_name_question.rb | 2 +- forms/qae_form_builder/qae_decorator.rb | 4 +-- forms/qae_form_builder/qae_form.rb | 6 ++-- forms/qae_form_builder/qae_form_decorator.rb | 4 +-- forms/qae_form_builder/question.rb | 12 ++++---- forms/qae_form_builder/regions_question.rb | 4 +-- .../sic_code_dropdown_question.rb | 2 +- forms/qae_form_builder/step.rb | 18 +++++------ forms/qae_form_builder/supporters_question.rb | 2 +- forms/qae_form_builder/text_question.rb | 2 +- forms/qae_form_builder/textarea_question.rb | 2 +- forms/qae_form_builder/upload_question.rb | 2 +- forms/qae_form_builder/user_info_question.rb | 2 +- forms/qae_form_builder/year_question.rb | 2 +- lib/{qae.rb => q_a_e.rb} | 0 lib/sic_code.rb | 4 +-- spec/unit/qae_form_builder_spec.rb | 20 ++++++------- 90 files changed, 203 insertions(+), 200 deletions(-) rename lib/{qae.rb => q_a_e.rb} (100%) diff --git a/Gemfile b/Gemfile index 3c62c946c..537d22ba7 100644 --- a/Gemfile +++ b/Gemfile @@ -180,11 +180,11 @@ end group :test do gem 'factory_bot_rails' - gem 'capybara', '3.33' + gem 'capybara', '~> 3.39' gem 'poltergeist' gem 'database_cleaner-active_record' gem 'launchy' - gem 'turnip', '~> 4.2.0' + gem 'turnip', '~> 4.4.0' gem 'shoulda-matchers', require: false gem 'pdf-inspector', require: 'pdf/inspector' gem 'codeclimate_circle_ci_coverage' diff --git a/Gemfile.lock b/Gemfile.lock index d174853ce..a792d03b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -143,13 +143,14 @@ GEM builder (3.2.4) byebug (11.1.3) callsite (0.0.11) - capybara (3.33.0) + capybara (3.39.2) addressable + matrix mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) - regexp_parser (~> 1.5) + regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) carrierwave (2.2.4) activemodel (>= 5.0.0) @@ -191,10 +192,11 @@ GEM crack (0.4.5) rexml crass (1.0.6) - cucumber-gherkin (14.2.0) - cucumber-messages (~> 12.4, >= 12.4.0) - cucumber-messages (12.4.0) - protobuf-cucumber (~> 3.10, >= 3.10.8) + cucumber-gherkin (27.0.0) + cucumber-messages (>= 19.1.4, < 23) + cucumber-messages (22.0.0) + cuke_modeler (3.20.1) + cucumber-gherkin (< 28.0) curb (0.9.10) database_cleaner-active_record (2.1.0) activerecord (>= 5.a) @@ -408,7 +410,6 @@ GEM rack-contrib railties method_source (1.0.0) - middleware (0.1.0) mime-types (3.5.1) mime-types-data (~> 3.2015) mime-types-data (3.2023.0808) @@ -469,11 +470,6 @@ GEM ttfunk (~> 1.7) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) - protobuf-cucumber (3.10.8) - activesupport (>= 3.2) - middleware - thor - thread_safe pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -582,7 +578,7 @@ GEM redis-store (>= 1.2, < 2) redis-store (1.9.2) redis (>= 4, < 6) - regexp_parser (1.8.2) + regexp_parser (2.8.2) reline (0.3.9) io-console (~> 0.5) representable (3.2.0) @@ -720,8 +716,8 @@ GEM timeout (0.4.0) trailblazer-option (0.1.2) ttfunk (1.7.0) - turnip (4.2.0) - cucumber-gherkin (~> 14.0) + turnip (4.4.0) + cuke_modeler (~> 3.15) rspec (>= 3.0, < 4.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) @@ -780,7 +776,7 @@ DEPENDENCIES bootscale bootstrap-sass (~> 3.4) browser (= 2.4.0) - capybara (= 3.33) + capybara (~> 3.39) carrierwave (~> 2.2.2) carrierwave-google-storage! ckeditor @@ -864,7 +860,7 @@ DEPENDENCIES sprockets-rails (>= 2.0.0) statesman (= 3.5.0) timecop - turnip (~> 4.2.0) + turnip (~> 4.4.0) uglifier (>= 2.7.2) vigilion (~> 1.0.4)! vigilion-rails (~> 2.1.0) diff --git a/app/controllers/admin/form_answers_controller.rb b/app/controllers/admin/form_answers_controller.rb index f27e1ecc2..310f19635 100644 --- a/app/controllers/admin/form_answers_controller.rb +++ b/app/controllers/admin/form_answers_controller.rb @@ -40,7 +40,7 @@ class Admin::FormAnswersController < Admin::BaseController expose(:questions_with_references) do all_form_questions.select do |q| - !q.is_a?(QAEFormBuilder::HeaderQuestion) && + !q.is_a?(QaeFormBuilder::HeaderQuestion) && (q.ref.present? || q.sub_ref.present?) end end diff --git a/app/controllers/assessor/form_answers_controller.rb b/app/controllers/assessor/form_answers_controller.rb index 4ffea4aeb..1c83c839a 100644 --- a/app/controllers/assessor/form_answers_controller.rb +++ b/app/controllers/assessor/form_answers_controller.rb @@ -11,7 +11,7 @@ class Assessor::FormAnswersController < Assessor::BaseController expose(:questions_with_references) do all_form_questions.select do |q| - !q.is_a?(QAEFormBuilder::HeaderQuestion) && + !q.is_a?(QaeFormBuilder::HeaderQuestion) && (q.ref.present? || q.sub_ref.present?) end end diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index 0a722a8c4..2316934c9 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -36,7 +36,7 @@ class FormController < ApplicationController expose(:questions_with_references) do all_form_questions.select do |q| - !q.is_a?(QAEFormBuilder::HeaderQuestion) && + !q.is_a?(QaeFormBuilder::HeaderQuestion) && (q.ref.present? || q.sub_ref.present?) end end diff --git a/app/controllers/lieutenant/form_answers_controller.rb b/app/controllers/lieutenant/form_answers_controller.rb index f72ac4376..d2441cb5d 100644 --- a/app/controllers/lieutenant/form_answers_controller.rb +++ b/app/controllers/lieutenant/form_answers_controller.rb @@ -15,7 +15,7 @@ class Lieutenant::FormAnswersController < Lieutenant::BaseController expose(:questions_with_references) do all_form_questions.select do |q| - !q.is_a?(QAEFormBuilder::HeaderQuestion) && + !q.is_a?(QaeFormBuilder::HeaderQuestion) && (q.ref.present? || q.sub_ref.present?) end end diff --git a/app/decorators/form_answer_decorator.rb b/app/decorators/form_answer_decorator.rb index ed7d74fc0..4af1182cd 100644 --- a/app/decorators/form_answer_decorator.rb +++ b/app/decorators/form_answer_decorator.rb @@ -168,7 +168,7 @@ def progress_text def average_growth_for(year) if object.sic_code.present? - sic = SICCode.find_by_code(object.sic_code) + sic = SicCode.find_by_code(object.sic_code) sic.by_year(year) if sic end end @@ -182,7 +182,7 @@ def all_average_growths def sic_code_name sic = object.sic_code if sic.present? - SICCode.find_by_code(sic).name + SicCode.find_by_code(sic).name end end @@ -194,7 +194,7 @@ def corp_responsibility_required_keys object.award_form.steps.detect do |step| step.short_title == "Declaration of Corporate Responsibility" end.questions.select do |q| - q.is_a?(QAEFormBuilder::TextareaQuestion) && q.required + q.is_a?(QaeFormBuilder::TextareaQuestion) && q.required end.map(&:key) .map(&:to_s) end @@ -212,7 +212,7 @@ def awarded? def average_growth_legend(years = [1, 2, 3]) growths = years.map { |y| average_growth_for(y) }.uniq growths.map do |g| - note = SICCode::NOTES[g] + note = SicCode::NOTES[g] "#{g} - #{note}" if note end.compact.join("\n") end diff --git a/app/form_pointers/financial_table.rb b/app/form_pointers/financial_table.rb index dd6dea586..9b4475bc0 100644 --- a/app/form_pointers/financial_table.rb +++ b/app/form_pointers/financial_table.rb @@ -142,9 +142,9 @@ def financial_years_number end def one_option_question? - question.is_a?(QAEFormBuilder::OneOptionByYearsLabelQuestionDecorator) || - question.is_a?(QAEFormBuilder::OneOptionByYearsQuestionDecorator) || - question.is_a?(QAEFormBuilder::OneOptionByYearsLabelQuestion) || - question.is_a?(QAEFormBuilder::OneOptionByYearsQuestion) + question.is_a?(QaeFormBuilder::OneOptionByYearsLabelQuestionDecorator) || + question.is_a?(QaeFormBuilder::OneOptionByYearsQuestionDecorator) || + question.is_a?(QaeFormBuilder::OneOptionByYearsLabelQuestion) || + question.is_a?(QaeFormBuilder::OneOptionByYearsQuestion) end end diff --git a/app/form_pointers/financial_year_pointer.rb b/app/form_pointers/financial_year_pointer.rb index 998f235ff..a8885b0e9 100644 --- a/app/form_pointers/financial_year_pointer.rb +++ b/app/form_pointers/financial_year_pointer.rb @@ -21,13 +21,13 @@ def data def fetch_data case question.delegate_obj - when QAEFormBuilder::ByYearsLabelQuestion + when QaeFormBuilder::ByYearsLabelQuestion fetch_year_labels - when QAEFormBuilder::ByYearsQuestion + when QaeFormBuilder::ByYearsQuestion fetch_years - when QAEFormBuilder::OneOptionByYearsLabelQuestion + when QaeFormBuilder::OneOptionByYearsLabelQuestion fetch_one_option_year_labels - when QAEFormBuilder::OneOptionByYearsQuestion + when QaeFormBuilder::OneOptionByYearsQuestion fetch_one_option_years end end diff --git a/app/form_pointers/form_financial_pointer.rb b/app/form_pointers/form_financial_pointer.rb index b49443a57..3dc76ab97 100644 --- a/app/form_pointers/form_financial_pointer.rb +++ b/app/form_pointers/form_financial_pointer.rb @@ -13,10 +13,10 @@ class FormFinancialPointer :options TARGET_FINANCIAL_DATA_QUESTION_TYPES = [ - QAEFormBuilder::ByYearsLabelQuestion, - QAEFormBuilder::ByYearsQuestion, - QAEFormBuilder::OneOptionByYearsLabelQuestion, - QAEFormBuilder::OneOptionByYearsQuestion + QaeFormBuilder::ByYearsLabelQuestion, + QaeFormBuilder::ByYearsQuestion, + QaeFormBuilder::OneOptionByYearsLabelQuestion, + QaeFormBuilder::OneOptionByYearsQuestion ] YEAR_LABELS = %w(day month year) IN_PROGRESS = "-" diff --git a/app/models/assessor_assignment.rb b/app/models/assessor_assignment.rb index 50ec5a492..3c111d68f 100644 --- a/app/models/assessor_assignment.rb +++ b/app/models/assessor_assignment.rb @@ -19,10 +19,10 @@ class AssessorAssignment < ApplicationRecord end begin :associations - belongs_to :assessor - belongs_to :form_answer - belongs_to :editable, polymorphic: true - belongs_to :award_year + belongs_to :assessor, optional: true + belongs_to :form_answer, optional: true + belongs_to :editable, polymorphic: true, optional: true + belongs_to :award_year, optional: true end begin :scopes diff --git a/app/models/audit_log.rb b/app/models/audit_log.rb index 9fe1d2ede..0e9fc472d 100644 --- a/app/models/audit_log.rb +++ b/app/models/audit_log.rb @@ -3,8 +3,8 @@ class AuditLog < ApplicationRecord validates :subject_id, presence: true validates :action_type, presence: true - belongs_to :subject, polymorphic: true - belongs_to :auditable, polymorphic: true + belongs_to :subject, polymorphic: true, optional: true + belongs_to :auditable, polymorphic: true, optional: true scope :data_export, -> { where(auditable_type: nil).or(AuditLog.where(action_type: "download_form_answer")) } scope :data_update, -> { where(auditable_type: "FormAnswer").where("action_type != 'download_form_answer'") } diff --git a/app/models/comment.rb b/app/models/comment.rb index 641f20a33..74bfbb6b4 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,6 +1,6 @@ class Comment < ApplicationRecord - belongs_to :commentable, polymorphic: true - belongs_to :authorable, polymorphic: true + belongs_to :commentable, polymorphic: true, optional: true + belongs_to :authorable, polymorphic: true, optional: true validates :body, presence: true diff --git a/app/models/eligibility.rb b/app/models/eligibility.rb index 43f3dab49..550376dc4 100644 --- a/app/models/eligibility.rb +++ b/app/models/eligibility.rb @@ -4,7 +4,7 @@ class Eligibility < ApplicationRecord AWARD_NAME = "" belongs_to :account - belongs_to :form_answer + belongs_to :form_answer, optional: true attr_accessor :current_step, :force_validate_now diff --git a/app/models/feedback.rb b/app/models/feedback.rb index bed274f16..1f448a124 100644 --- a/app/models/feedback.rb +++ b/app/models/feedback.rb @@ -2,13 +2,13 @@ class Feedback < ApplicationRecord has_paper_trail unless: Proc.new { |t| Rails.env.test? } - belongs_to :form_answer + belongs_to :form_answer, optional: true store_accessor :document, FeedbackForm.fields scope :submitted, -> { where submitted: true } belongs_to :authorable, polymorphic: true - belongs_to :award_year + belongs_to :award_year, optional: true validates :form_answer_id, uniqueness: true diff --git a/app/models/form_answer.rb b/app/models/form_answer.rb index 93763c7a9..697197c46 100644 --- a/app/models/form_answer.rb +++ b/app/models/form_answer.rb @@ -1,6 +1,6 @@ -require 'award_years/v2022/qae_forms' -require 'award_years/v2023/qae_forms' -require 'award_years/v2024/qae_forms' +require_relative '../../forms/award_years/v2022/qae_forms' +require_relative '../../forms/award_years/v2023/qae_forms' +require_relative '../../forms/award_years/v2024/qae_forms' class FormAnswer < ApplicationRecord include Statesman::Adapters::ActiveRecordQueries @@ -37,9 +37,9 @@ class FormAnswer < ApplicationRecord begin :associations belongs_to :user - belongs_to :account + belongs_to :account, optional: true belongs_to :award_year - belongs_to :company_details_editable, polymorphic: true + belongs_to :company_details_editable, polymorphic: true, optional: true belongs_to :ceremonial_county, optional: true has_one :form_basic_eligibility, class_name: 'Eligibility::Basic', dependent: :destroy @@ -51,8 +51,8 @@ class FormAnswer < ApplicationRecord has_one :admin_verdict, dependent: :destroy has_one :group_leader - belongs_to :primary_assessor, class_name: "Assessor", foreign_key: :primary_assessor_id - belongs_to :secondary_assessor, class_name: "Assessor", foreign_key: :secondary_assessor_id + belongs_to :primary_assessor, class_name: "Assessor", foreign_key: :primary_assessor_id, optional: true + belongs_to :secondary_assessor, class_name: "Assessor", foreign_key: :secondary_assessor_id, optional: true has_many :form_answer_attachments, dependent: :destroy has_many :support_letter_attachments, dependent: :destroy @@ -66,7 +66,7 @@ class FormAnswer < ApplicationRecord begin :validations validates :user, presence: true - validates :sic_code, format: { with: SICCode::REGEX }, allow_nil: true, allow_blank: true + validates :sic_code, format: { with: SicCode::REGEX }, allow_nil: true, allow_blank: true validate :validate_answers validates :ineligible_reason_nominator, presence: true, if: proc { state == "admin_not_eligible_nominator" } validates :ineligible_reason_group, presence: true, if: proc { state == "admin_not_eligible_group" } @@ -152,7 +152,7 @@ def award_form elsif self.class.const_defined?(award_form_class_name(year)) self.class.const_get(award_form_class_name(year)) else - AwardYears::V2024::QAEForms # default value + AwardYears::V2024::QaeForms # default value end else raise ArgumentError, "Can not find award form for the nomination in year: #{award_year.year}" @@ -429,7 +429,7 @@ def validate_answers end def award_form_class_name(year) - "::AwardYears::V#{year}::QAEForms" + "::AwardYears::V#{year}::QaeForms" end def self.transition_class diff --git a/app/models/group_leader.rb b/app/models/group_leader.rb index 2c373d7a3..874cb95d1 100644 --- a/app/models/group_leader.rb +++ b/app/models/group_leader.rb @@ -21,7 +21,7 @@ class GroupLeader < ApplicationRecord } } - belongs_to :form_answer + belongs_to :form_answer, optional: true scope :by_email, -> { order(:email) } scope :confirmed, -> { where.not(confirmed_at: nil) } diff --git a/app/models/reports/all_entries.rb b/app/models/reports/all_entries.rb index cc0c7b63e..916f9b285 100644 --- a/app/models/reports/all_entries.rb +++ b/app/models/reports/all_entries.rb @@ -1,5 +1,5 @@ class Reports::AllEntries - include Reports::CSVHelper + include Reports::CsvHelper MAPPING = [ { diff --git a/app/models/reports/citation_report.rb b/app/models/reports/citation_report.rb index bb8426c47..8b9b8d386 100644 --- a/app/models/reports/citation_report.rb +++ b/app/models/reports/citation_report.rb @@ -1,7 +1,7 @@ class Reports::CitationReport attr_reader :award_year, :scope - include Reports::CSVHelper + include Reports::CsvHelper MAPPING = [ { diff --git a/app/models/reports/csv_helper.rb b/app/models/reports/csv_helper.rb index 27398d950..022ceeb55 100644 --- a/app/models/reports/csv_helper.rb +++ b/app/models/reports/csv_helper.rb @@ -1,6 +1,6 @@ require "csv" -module Reports::CSVHelper +module Reports::CsvHelper def build CSV.generate(encoding: "UTF-8", force_quotes: true) do |csv| csv << headers diff --git a/app/models/reports/press_book_list.rb b/app/models/reports/press_book_list.rb index bf1355bd8..05e25cdb2 100644 --- a/app/models/reports/press_book_list.rb +++ b/app/models/reports/press_book_list.rb @@ -1,5 +1,5 @@ class Reports::PressBookList - include Reports::CSVHelper + include Reports::CsvHelper MAPPING = [ { diff --git a/app/views/admin/form_answers/company_details/_sic_form.html.slim b/app/views/admin/form_answers/company_details/_sic_form.html.slim index af5ee2786..0b4111de5 100644 --- a/app/views/admin/form_answers/company_details/_sic_form.html.slim +++ b/app/views/admin/form_answers/company_details/_sic_form.html.slim @@ -22,7 +22,7 @@ wrapper_html: { class: "form-group" }, input_html: { class: "form-control select2" }, as: :select, - collection: SICCode.collection, + collection: SicCode.collection, include_blank: false, label: false .govuk-button-group diff --git a/app/views/assessor/form_answers/_question.html.slim b/app/views/assessor/form_answers/_question.html.slim index 1d2f07610..9078c0863 100644 --- a/app/views/assessor/form_answers/_question.html.slim +++ b/app/views/assessor/form_answers/_question.html.slim @@ -13,7 +13,7 @@ fieldset class=question.fieldset_classes data=question.fieldset_data_hash span.todo = ref.to_s - unless question.title.blank? - - font_size = question.delegate_obj.is_a?(QAEFormBuilder::HeaderQuestion) ? "govuk-!-font-size-36" : "govuk-!-font-size-24" + - font_size = question.delegate_obj.is_a?(QaeFormBuilder::HeaderQuestion) ? "govuk-!-font-size-36" : "govuk-!-font-size-24" span class="govuk-body #{ font_size } govuk-!-font-weight-bold govuk-!-display-block" == question.title diff --git a/app/views/assessor/form_answers/questions/_address_question.html.slim b/app/views/assessor/form_answers/questions/_address_question.html.slim index f6c1b3ab7..e50a71bb0 100644 --- a/app/views/assessor/form_answers/questions/_address_question.html.slim +++ b/app/views/assessor/form_answers/questions/_address_question.html.slim @@ -65,5 +65,5 @@ div role="group" id="q_#{question.key}" .clear - klass = "#{sub_field_title.parameterize == 'postcode' ? 'govuk-input--width-10' : 'govuk-input--width-20'}" - - klass <<(QAEFormBuilder::AddressQuestionValidator::NO_VALIDATION_SUB_FIELDS.exclude?(sub_field_key) ? " required" : " not-required") + - klass <<(QaeFormBuilder::AddressQuestionValidator::NO_VALIDATION_SUB_FIELDS.exclude?(sub_field_key) ? " required" : " not-required") input.govuk-input.js-trigger-autosave class=klass type="text" id=question.input_name(suffix: sub_field_key) value=question.input_value(suffix: sub_field_key) name=question.input_name(suffix: sub_field_key) autocomplete="off" disabled="disabled" diff --git a/app/views/assessor/form_answers/questions/_assessor_details_question.html.slim b/app/views/assessor/form_answers/questions/_assessor_details_question.html.slim index 45a3c13bc..0237edf6a 100644 --- a/app/views/assessor/form_answers/questions/_assessor_details_question.html.slim +++ b/app/views/assessor/form_answers/questions/_assessor_details_question.html.slim @@ -13,5 +13,5 @@ .clear - klass = "#{sub_field_title.parameterize == "phone-number-optional" ? "govuk-input--width-10" : "govuk-input--width-20"}" - - klass <<(QAEFormBuilder::AssessorDetailsQuestionValidator::NO_VALIDATION_SUB_FIELDS.exclude?(sub_field_key) ? " required" : " not-required") + - klass <<(QaeFormBuilder::AssessorDetailsQuestionValidator::NO_VALIDATION_SUB_FIELDS.exclude?(sub_field_key) ? " required" : " not-required") input.govuk-input.js-trigger-autosave class=klass type="text" id=question.input_name(suffix: sub_field_key) value=question.input_value(suffix: sub_field_key) name=question.input_name(suffix: sub_field_key) autocomplete="off" disabled="disabled" diff --git a/app/views/qae_form/_address_question.html.slim b/app/views/qae_form/_address_question.html.slim index 809b9886c..baf38cb53 100644 --- a/app/views/qae_form/_address_question.html.slim +++ b/app/views/qae_form/_address_question.html.slim @@ -67,5 +67,5 @@ div role="group" id="q_#{question.key}" .clear - klass = "#{sub_field_title.parameterize == 'postcode' ? 'govuk-input--width-10' : 'govuk-input--width-20'}" - - klass <<(QAEFormBuilder::AddressQuestionValidator::NO_VALIDATION_SUB_FIELDS.exclude?(sub_field_key) ? " required" : " not-required") + - klass <<(QaeFormBuilder::AddressQuestionValidator::NO_VALIDATION_SUB_FIELDS.exclude?(sub_field_key) ? " required" : " not-required") input.govuk-input.js-trigger-autosave class=klass type="text" id=question.input_name(suffix: sub_field_key) value=question.input_value(suffix: sub_field_key) name=question.input_name(suffix: sub_field_key) autocomplete="off" *possible_read_only_ops(question.step.opts[:id]) diff --git a/app/views/qae_form/_assessor_details_question.html.slim b/app/views/qae_form/_assessor_details_question.html.slim index ac45c1804..6ac149794 100644 --- a/app/views/qae_form/_assessor_details_question.html.slim +++ b/app/views/qae_form/_assessor_details_question.html.slim @@ -13,5 +13,5 @@ .clear - klass = "#{sub_field_title.parameterize == "phone-number-optional" ? "govuk-input--width-10" : "govuk-input--width-20"}" - - klass <<(QAEFormBuilder::AssessorDetailsQuestionValidator::NO_VALIDATION_SUB_FIELDS.exclude?(sub_field_key) ? " required" : " not-required") + - klass <<(QaeFormBuilder::AssessorDetailsQuestionValidator::NO_VALIDATION_SUB_FIELDS.exclude?(sub_field_key) ? " required" : " not-required") input.govuk-input.js-trigger-autosave class=klass type="text" id=question.input_name(suffix: sub_field_key) value=question.input_value(suffix: sub_field_key) name=question.input_name(suffix: sub_field_key) autocomplete="off" *possible_read_only_ops(question.step.opts[:id]) diff --git a/app/views/qae_form/_question.html.slim b/app/views/qae_form/_question.html.slim index 1cde1c5e4..d916491bc 100644 --- a/app/views/qae_form/_question.html.slim +++ b/app/views/qae_form/_question.html.slim @@ -15,7 +15,7 @@ fieldset class=question.fieldset_classes data=question.fieldset_data_hash span.todo = ref.to_s - unless question.title.blank? - - font_size = question.delegate_obj.is_a?(QAEFormBuilder::HeaderQuestion) ? "govuk-!-font-size-36" : "govuk-!-font-size-24" + - font_size = question.delegate_obj.is_a?(QaeFormBuilder::HeaderQuestion) ? "govuk-!-font-size-36" : "govuk-!-font-size-24" span class="govuk-body #{ font_size } govuk-!-font-weight-bold govuk-!-display-block" == question.title @@ -44,7 +44,7 @@ fieldset class=question.fieldset_classes data=question.fieldset_data_hash span.todo = ref.to_s - - if question.delegate_obj.is_a?(QAEFormBuilder::HeaderQuestion) + - if question.delegate_obj.is_a?(QaeFormBuilder::HeaderQuestion) - if question.ref || question.sub_ref span.question-context.question-debug.govuk-hint = "Please note #{(question.ref || question.sub_ref).delete(" ")} is just a heading for the following sub-questions." diff --git a/config/application.rb b/config/application.rb index 963a194dd..90afbc1ed 100644 --- a/config/application.rb +++ b/config/application.rb @@ -8,6 +8,8 @@ module Qae class Application < Rails::Application + config.load_defaults 7.0 + #initializer :regenerate_require_cache, before: :load_environment_config do # Bootscale.regenerate #end @@ -15,6 +17,7 @@ class Application < Rails::Application # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # config.middleware.use Rack::SslEnforcer, except: "/healthcheck", except_environments: ["development", "test"] + config.autoloader = :zeitwerk if ENV['CORS_HOST'].present? config.middleware.insert_before 0, Rack::Cors do @@ -44,8 +47,12 @@ class Application < Rails::Application #NOTE: This works like Rails 4. For Rails 5, we can use # `config.eager_load_paths << Rails.root.join('lib')` but still it is not recommended for Threadsafty. # Need to take look in to it. - config.enable_dependency_loading = true - config.autoload_paths << Rails.root.join('lib') + config.eager_load = false + + config.autoload_once_paths << "#{root}/lib" + config.autoload_once_paths << "#{root}/forms" + config.autoload_paths << "#{root}/lib" + config.eager_load_paths << "#{root}/lib" config.generators do |g| g.test_framework :rspec diff --git a/forms/award_years/v2022/qae_forms.rb b/forms/award_years/v2022/qae_forms.rb index 7e345a35a..5e8f56962 100644 --- a/forms/award_years/v2022/qae_forms.rb +++ b/forms/award_years/v2022/qae_forms.rb @@ -1,4 +1,4 @@ -require 'award_years/v2022/qavs' +require_relative 'qavs' -class AwardYears::V2022::QAEForms +class AwardYears::V2022::QaeForms end diff --git a/forms/award_years/v2022/qavs.rb b/forms/award_years/v2022/qavs.rb index ff3a2171c..319b69945 100644 --- a/forms/award_years/v2022/qavs.rb +++ b/forms/award_years/v2022/qavs.rb @@ -1,29 +1,29 @@ -require "award_years/v2022/qavs/qavs_step1" -require "award_years/v2022/qavs/qavs_step2" -require "award_years/v2022/qavs/qavs_step3" -require "award_years/v2022/qavs/qavs_step4" -require "award_years/v2022/qavs/qavs_step5" +require_relative "qavs/qavs_step1" +require_relative "qavs/qavs_step2" +require_relative "qavs/qavs_step3" +require_relative "qavs/qavs_step4" +require_relative "qavs/qavs_step5" -class AwardYears::V2022::QAEForms +class AwardYears::V2022::QaeForms class << self def qavs - @qavs ||= QAEFormBuilder.build "Queen's Award for Voluntary Service Nomination" do + @qavs ||= QaeFormBuilder.build "Queen's Award for Voluntary Service Nomination" do step "nominee", - &AwardYears::V2022::QAEForms.qavs_step1 + &AwardYears::V2022::QaeForms.qavs_step1 step "recommendation", - &AwardYears::V2022::QAEForms.qavs_step2 + &AwardYears::V2022::QaeForms.qavs_step2 step "letters_of_support", { id: :letters_of_support_step }, - &AwardYears::V2022::QAEForms.qavs_step3 + &AwardYears::V2022::QaeForms.qavs_step3 step "submit_step", - &AwardYears::V2022::QAEForms.qavs_step4 + &AwardYears::V2022::QaeForms.qavs_step4 step "local_assessment_form", { id: :local_assessment }, - &AwardYears::V2022::QAEForms.qavs_step5 + &AwardYears::V2022::QaeForms.qavs_step5 end end end diff --git a/forms/award_years/v2022/qavs/qavs_step1.rb b/forms/award_years/v2022/qavs/qavs_step1.rb index 7254b3cf5..16d7e3184 100644 --- a/forms/award_years/v2022/qavs/qavs_step1.rb +++ b/forms/award_years/v2022/qavs/qavs_step1.rb @@ -1,5 +1,5 @@ # coding: utf-8 -class AwardYears::V2022::QAEForms +class AwardYears::V2022::QaeForms class << self def qavs_step1 @qavs_step1 ||= proc do diff --git a/forms/award_years/v2022/qavs/qavs_step2.rb b/forms/award_years/v2022/qavs/qavs_step2.rb index 1c1d06a6f..0f7c6fc68 100644 --- a/forms/award_years/v2022/qavs/qavs_step2.rb +++ b/forms/award_years/v2022/qavs/qavs_step2.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -class AwardYears::V2022::QAEForms +class AwardYears::V2022::QaeForms class << self def qavs_step2 @qavs_step2 ||= proc do diff --git a/forms/award_years/v2022/qavs/qavs_step3.rb b/forms/award_years/v2022/qavs/qavs_step3.rb index 5fd11d62b..be9d6502c 100644 --- a/forms/award_years/v2022/qavs/qavs_step3.rb +++ b/forms/award_years/v2022/qavs/qavs_step3.rb @@ -1,4 +1,4 @@ -class AwardYears::V2022::QAEForms +class AwardYears::V2022::QaeForms class << self def qavs_step3 @qavs_step3 ||= proc do diff --git a/forms/award_years/v2022/qavs/qavs_step4.rb b/forms/award_years/v2022/qavs/qavs_step4.rb index 3cda747c2..2cea63bdb 100644 --- a/forms/award_years/v2022/qavs/qavs_step4.rb +++ b/forms/award_years/v2022/qavs/qavs_step4.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -class AwardYears::V2022::QAEForms +class AwardYears::V2022::QaeForms class << self def qavs_step4 @qavs_step4 ||= proc do diff --git a/forms/award_years/v2022/qavs/qavs_step5.rb b/forms/award_years/v2022/qavs/qavs_step5.rb index 0da65b9c5..26b62d9d1 100644 --- a/forms/award_years/v2022/qavs/qavs_step5.rb +++ b/forms/award_years/v2022/qavs/qavs_step5.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -class AwardYears::V2022::QAEForms +class AwardYears::V2022::QaeForms class << self def qavs_step5 @qavs_step5 ||= proc do diff --git a/forms/award_years/v2023/qae_forms.rb b/forms/award_years/v2023/qae_forms.rb index 2835928a9..94fa614e0 100644 --- a/forms/award_years/v2023/qae_forms.rb +++ b/forms/award_years/v2023/qae_forms.rb @@ -1,4 +1,4 @@ -require 'award_years/v2023/qavs' +require_relative 'qavs' -class AwardYears::V2023::QAEForms +class AwardYears::V2023::QaeForms end diff --git a/forms/award_years/v2023/qavs.rb b/forms/award_years/v2023/qavs.rb index df3c93452..368ca2b39 100644 --- a/forms/award_years/v2023/qavs.rb +++ b/forms/award_years/v2023/qavs.rb @@ -1,29 +1,29 @@ -require "award_years/v2023/qavs/qavs_step1" -require "award_years/v2023/qavs/qavs_step2" -require "award_years/v2023/qavs/qavs_step3" -require "award_years/v2023/qavs/qavs_step4" -require "award_years/v2023/qavs/qavs_step5" +require_relative "qavs/qavs_step1" +require_relative "qavs/qavs_step2" +require_relative "qavs/qavs_step3" +require_relative "qavs/qavs_step4" +require_relative "qavs/qavs_step5" -class AwardYears::V2023::QAEForms +class AwardYears::V2023::QaeForms class << self def qavs - @qavs ||= QAEFormBuilder.build "King's Award for Voluntary Service Nomination" do + @qavs ||= QaeFormBuilder.build "King's Award for Voluntary Service Nomination" do step "nominee", - &AwardYears::V2023::QAEForms.qavs_step1 + &AwardYears::V2023::QaeForms.qavs_step1 step "recommendation", - &AwardYears::V2023::QAEForms.qavs_step2 + &AwardYears::V2023::QaeForms.qavs_step2 step "letters_of_support", { id: :letters_of_support_step }, - &AwardYears::V2023::QAEForms.qavs_step3 + &AwardYears::V2023::QaeForms.qavs_step3 step "submit_step", - &AwardYears::V2023::QAEForms.qavs_step4 + &AwardYears::V2023::QaeForms.qavs_step4 step "local_assessment_form", { id: :local_assessment }, - &AwardYears::V2023::QAEForms.qavs_step5 + &AwardYears::V2023::QaeForms.qavs_step5 end end end diff --git a/forms/award_years/v2023/qavs/qavs_step1.rb b/forms/award_years/v2023/qavs/qavs_step1.rb index c0a6a7e33..7dea24f84 100644 --- a/forms/award_years/v2023/qavs/qavs_step1.rb +++ b/forms/award_years/v2023/qavs/qavs_step1.rb @@ -1,5 +1,5 @@ # coding: utf-8 -class AwardYears::V2023::QAEForms +class AwardYears::V2023::QaeForms class << self def qavs_step1 @qavs_step1 ||= proc do diff --git a/forms/award_years/v2023/qavs/qavs_step2.rb b/forms/award_years/v2023/qavs/qavs_step2.rb index a88f29fb0..6ab2e7953 100644 --- a/forms/award_years/v2023/qavs/qavs_step2.rb +++ b/forms/award_years/v2023/qavs/qavs_step2.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -class AwardYears::V2023::QAEForms +class AwardYears::V2023::QaeForms class << self def qavs_step2 @qavs_step2 ||= proc do diff --git a/forms/award_years/v2023/qavs/qavs_step3.rb b/forms/award_years/v2023/qavs/qavs_step3.rb index aebdcb8e5..e74e9d877 100644 --- a/forms/award_years/v2023/qavs/qavs_step3.rb +++ b/forms/award_years/v2023/qavs/qavs_step3.rb @@ -1,4 +1,4 @@ -class AwardYears::V2023::QAEForms +class AwardYears::V2023::QaeForms class << self def qavs_step3 @qavs_step3 ||= proc do diff --git a/forms/award_years/v2023/qavs/qavs_step4.rb b/forms/award_years/v2023/qavs/qavs_step4.rb index acfb63602..fb43e46a8 100644 --- a/forms/award_years/v2023/qavs/qavs_step4.rb +++ b/forms/award_years/v2023/qavs/qavs_step4.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -class AwardYears::V2023::QAEForms +class AwardYears::V2023::QaeForms class << self def qavs_step4 @qavs_step4 ||= proc do diff --git a/forms/award_years/v2023/qavs/qavs_step5.rb b/forms/award_years/v2023/qavs/qavs_step5.rb index 2bedccf06..bd0d610bf 100644 --- a/forms/award_years/v2023/qavs/qavs_step5.rb +++ b/forms/award_years/v2023/qavs/qavs_step5.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -class AwardYears::V2023::QAEForms +class AwardYears::V2023::QaeForms class << self def qavs_step5 @qavs_step5 ||= proc do diff --git a/forms/award_years/v2024/qae_forms.rb b/forms/award_years/v2024/qae_forms.rb index b86d3a686..10112cd70 100644 --- a/forms/award_years/v2024/qae_forms.rb +++ b/forms/award_years/v2024/qae_forms.rb @@ -1,4 +1,4 @@ -require 'award_years/v2024/qavs' +require_relative 'qavs' -class AwardYears::V2024::QAEForms +class AwardYears::V2024::QaeForms end diff --git a/forms/award_years/v2024/qavs.rb b/forms/award_years/v2024/qavs.rb index 492f44e3d..a7c0ae68f 100644 --- a/forms/award_years/v2024/qavs.rb +++ b/forms/award_years/v2024/qavs.rb @@ -1,29 +1,29 @@ -require "award_years/v2024/qavs/qavs_step1" -require "award_years/v2024/qavs/qavs_step2" -require "award_years/v2024/qavs/qavs_step3" -require "award_years/v2024/qavs/qavs_step4" -require "award_years/v2024/qavs/qavs_step5" +require_relative "qavs/qavs_step1" +require_relative "qavs/qavs_step2" +require_relative "qavs/qavs_step3" +require_relative "qavs/qavs_step4" +require_relative "qavs/qavs_step5" -class AwardYears::V2024::QAEForms +class AwardYears::V2024::QaeForms class << self def qavs - @qavs ||= QAEFormBuilder.build "King's Award for Voluntary Service Nomination" do + @qavs ||= QaeFormBuilder.build "King's Award for Voluntary Service Nomination" do step "nominee", - &AwardYears::V2024::QAEForms.qavs_step1 + &AwardYears::V2024::QaeForms.qavs_step1 step "recommendation", - &AwardYears::V2024::QAEForms.qavs_step2 + &AwardYears::V2024::QaeForms.qavs_step2 step "letters_of_support", { id: :letters_of_support_step }, - &AwardYears::V2024::QAEForms.qavs_step3 + &AwardYears::V2024::QaeForms.qavs_step3 step "submit_step", - &AwardYears::V2024::QAEForms.qavs_step4 + &AwardYears::V2024::QaeForms.qavs_step4 step "local_assessment_form", { id: :local_assessment }, - &AwardYears::V2024::QAEForms.qavs_step5 + &AwardYears::V2024::QaeForms.qavs_step5 end end end diff --git a/forms/award_years/v2024/qavs/qavs_step1.rb b/forms/award_years/v2024/qavs/qavs_step1.rb index 3e85972e6..e660057b4 100644 --- a/forms/award_years/v2024/qavs/qavs_step1.rb +++ b/forms/award_years/v2024/qavs/qavs_step1.rb @@ -1,5 +1,5 @@ # coding: utf-8 -class AwardYears::V2024::QAEForms +class AwardYears::V2024::QaeForms class << self def qavs_step1 @qavs_step1 ||= proc do diff --git a/forms/award_years/v2024/qavs/qavs_step2.rb b/forms/award_years/v2024/qavs/qavs_step2.rb index 382295d6d..fefcb55da 100644 --- a/forms/award_years/v2024/qavs/qavs_step2.rb +++ b/forms/award_years/v2024/qavs/qavs_step2.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -class AwardYears::V2024::QAEForms +class AwardYears::V2024::QaeForms class << self def qavs_step2 @qavs_step2 ||= proc do diff --git a/forms/award_years/v2024/qavs/qavs_step3.rb b/forms/award_years/v2024/qavs/qavs_step3.rb index c72a12f4e..caab1d43f 100644 --- a/forms/award_years/v2024/qavs/qavs_step3.rb +++ b/forms/award_years/v2024/qavs/qavs_step3.rb @@ -1,4 +1,4 @@ -class AwardYears::V2024::QAEForms +class AwardYears::V2024::QaeForms class << self def qavs_step3 @qavs_step3 ||= proc do diff --git a/forms/award_years/v2024/qavs/qavs_step4.rb b/forms/award_years/v2024/qavs/qavs_step4.rb index 166195c69..2a5c1ffdc 100644 --- a/forms/award_years/v2024/qavs/qavs_step4.rb +++ b/forms/award_years/v2024/qavs/qavs_step4.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -class AwardYears::V2024::QAEForms +class AwardYears::V2024::QaeForms class << self def qavs_step4 @qavs_step4 ||= proc do diff --git a/forms/award_years/v2024/qavs/qavs_step5.rb b/forms/award_years/v2024/qavs/qavs_step5.rb index 9c8eba390..c7a0a4805 100644 --- a/forms/award_years/v2024/qavs/qavs_step5.rb +++ b/forms/award_years/v2024/qavs/qavs_step5.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -class AwardYears::V2024::QAEForms +class AwardYears::V2024::QaeForms class << self def qavs_step5 @qavs_step5 ||= proc do diff --git a/forms/qae_form_builder.rb b/forms/qae_form_builder.rb index cfd22f09f..b797b1faa 100644 --- a/forms/qae_form_builder.rb +++ b/forms/qae_form_builder.rb @@ -37,11 +37,11 @@ require "qae_form_builder/assessor_details_question" -class QAEFormBuilder +class QaeFormBuilder class << self def build title, &block - form = QAEForm.new title + form = QaeForm.new title form.instance_eval &block if block_given? form end diff --git a/forms/qae_form_builder/address_question.rb b/forms/qae_form_builder/address_question.rb index 27d9ca993..a72ed3355 100644 --- a/forms/qae_form_builder/address_question.rb +++ b/forms/qae_form_builder/address_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class AddressQuestionValidator < QuestionValidator NO_VALIDATION_SUB_FIELDS = [:street, :county] def errors diff --git a/forms/qae_form_builder/assessor_details_question.rb b/forms/qae_form_builder/assessor_details_question.rb index 9da49a918..bdeea5abe 100644 --- a/forms/qae_form_builder/assessor_details_question.rb +++ b/forms/qae_form_builder/assessor_details_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class AssessorDetailsQuestionValidator < QuestionValidator NO_VALIDATION_SUB_FIELDS = [:secondary_assessor_name, :phone] def errors diff --git a/forms/qae_form_builder/by_years_label_question.rb b/forms/qae_form_builder/by_years_label_question.rb index e98e32db6..66f486ddb 100644 --- a/forms/qae_form_builder/by_years_label_question.rb +++ b/forms/qae_form_builder/by_years_label_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class ByYearsLabelQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/by_years_question.rb b/forms/qae_form_builder/by_years_question.rb index 1547aed46..36624a67e 100644 --- a/forms/qae_form_builder/by_years_question.rb +++ b/forms/qae_form_builder/by_years_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class ByYearsQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/ceremonial_county_question.rb b/forms/qae_form_builder/ceremonial_county_question.rb index 5623d4dad..4b538857c 100644 --- a/forms/qae_form_builder/ceremonial_county_question.rb +++ b/forms/qae_form_builder/ceremonial_county_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class CeremonialCountyQuestionValidator < OptionsQuestionValidator end diff --git a/forms/qae_form_builder/checkbox_seria_question.rb b/forms/qae_form_builder/checkbox_seria_question.rb index 05ce55ca1..96ab6adb8 100644 --- a/forms/qae_form_builder/checkbox_seria_question.rb +++ b/forms/qae_form_builder/checkbox_seria_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class CheckboxSeriaQuestionValidator < QuestionValidator def errors result = super diff --git a/forms/qae_form_builder/comment_question.rb b/forms/qae_form_builder/comment_question.rb index cf7154725..27e01ac8f 100644 --- a/forms/qae_form_builder/comment_question.rb +++ b/forms/qae_form_builder/comment_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class CommentQuestionValidator < QuestionValidator def errors {} diff --git a/forms/qae_form_builder/confirm_question.rb b/forms/qae_form_builder/confirm_question.rb index 7f87e11f0..995f2ea1f 100644 --- a/forms/qae_form_builder/confirm_question.rb +++ b/forms/qae_form_builder/confirm_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class ConfirmQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/contact_email_question.rb b/forms/qae_form_builder/contact_email_question.rb index f322b879f..0766dbb23 100644 --- a/forms/qae_form_builder/contact_email_question.rb +++ b/forms/qae_form_builder/contact_email_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class ContactEmailQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/contact_question.rb b/forms/qae_form_builder/contact_question.rb index ac9d5b6c7..4566d0aa4 100644 --- a/forms/qae_form_builder/contact_question.rb +++ b/forms/qae_form_builder/contact_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class ContactQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/country_question.rb b/forms/qae_form_builder/country_question.rb index af99df646..88a2ab209 100644 --- a/forms/qae_form_builder/country_question.rb +++ b/forms/qae_form_builder/country_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class CountryQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/date_question.rb b/forms/qae_form_builder/date_question.rb index f32058be0..394019bfc 100644 --- a/forms/qae_form_builder/date_question.rb +++ b/forms/qae_form_builder/date_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class DateQuestionValidator < QuestionValidator def errors result = super diff --git a/forms/qae_form_builder/dropdown_question.rb b/forms/qae_form_builder/dropdown_question.rb index aefda5f5b..c4970f06d 100644 --- a/forms/qae_form_builder/dropdown_question.rb +++ b/forms/qae_form_builder/dropdown_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class DropdownQuestionValidator < OptionsQuestionValidator end diff --git a/forms/qae_form_builder/head_of_business_question.rb b/forms/qae_form_builder/head_of_business_question.rb index dd030f969..e199de154 100644 --- a/forms/qae_form_builder/head_of_business_question.rb +++ b/forms/qae_form_builder/head_of_business_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class HeadOfBusinessQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/header_question.rb b/forms/qae_form_builder/header_question.rb index 23bdab0e2..1c9b4ac5d 100644 --- a/forms/qae_form_builder/header_question.rb +++ b/forms/qae_form_builder/header_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class HeaderQuestionValidator < QuestionValidator def errors {} diff --git a/forms/qae_form_builder/multi_question_decorator.rb b/forms/qae_form_builder/multi_question_decorator.rb index 2a6aaf73d..f4cbb9697 100644 --- a/forms/qae_form_builder/multi_question_decorator.rb +++ b/forms/qae_form_builder/multi_question_decorator.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder::MultiQuestionDecorator < QAEFormBuilder::QuestionDecorator +class QaeFormBuilder::MultiQuestionDecorator < QaeFormBuilder::QuestionDecorator def entities @entities ||= (answers[delegate_obj.key.to_s] || []) end diff --git a/forms/qae_form_builder/multi_question_validator.rb b/forms/qae_form_builder/multi_question_validator.rb index f0e59d9fd..13813eb23 100644 --- a/forms/qae_form_builder/multi_question_validator.rb +++ b/forms/qae_form_builder/multi_question_validator.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder::MultiQuestionValidator < QAEFormBuilder::QuestionValidator +class QaeFormBuilder::MultiQuestionValidator < QaeFormBuilder::QuestionValidator def errors result = super diff --git a/forms/qae_form_builder/number_question.rb b/forms/qae_form_builder/number_question.rb index 1d13cb438..4007fb696 100644 --- a/forms/qae_form_builder/number_question.rb +++ b/forms/qae_form_builder/number_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class NumberQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/one_option_by_years_label_question.rb b/forms/qae_form_builder/one_option_by_years_label_question.rb index 3f5221945..b51c5b1ab 100644 --- a/forms/qae_form_builder/one_option_by_years_label_question.rb +++ b/forms/qae_form_builder/one_option_by_years_label_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class OneOptionByYearsLabelQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/one_option_by_years_question.rb b/forms/qae_form_builder/one_option_by_years_question.rb index bf41003c4..8496b73c8 100644 --- a/forms/qae_form_builder/one_option_by_years_question.rb +++ b/forms/qae_form_builder/one_option_by_years_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class OneOptionByYearsQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/options_business_name_changed_question.rb b/forms/qae_form_builder/options_business_name_changed_question.rb index 12474ceb2..313c0b422 100644 --- a/forms/qae_form_builder/options_business_name_changed_question.rb +++ b/forms/qae_form_builder/options_business_name_changed_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class OptionsBusinessNameChangedQuestionValidator < OptionsQuestionValidator end diff --git a/forms/qae_form_builder/options_question.rb b/forms/qae_form_builder/options_question.rb index 3b59600f6..b53809332 100644 --- a/forms/qae_form_builder/options_question.rb +++ b/forms/qae_form_builder/options_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class OptionsQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/previous_name_question.rb b/forms/qae_form_builder/previous_name_question.rb index d972f9580..f4681aa1b 100644 --- a/forms/qae_form_builder/previous_name_question.rb +++ b/forms/qae_form_builder/previous_name_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class PreviousNameQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/qae_decorator.rb b/forms/qae_form_builder/qae_decorator.rb index 47b61aa42..0f04e5afe 100644 --- a/forms/qae_form_builder/qae_decorator.rb +++ b/forms/qae_form_builder/qae_decorator.rb @@ -1,6 +1,6 @@ -class QAEFormBuilder +class QaeFormBuilder - class QAEDecorator + class QaeDecorator attr_reader :delegate_obj def initialize obj, decorator_options = {} diff --git a/forms/qae_form_builder/qae_form.rb b/forms/qae_form_builder/qae_form.rb index ae4aa0d04..90e524b6c 100644 --- a/forms/qae_form_builder/qae_form.rb +++ b/forms/qae_form_builder/qae_form.rb @@ -1,6 +1,6 @@ -class QAEFormBuilder +class QaeFormBuilder - class QAEForm + class QaeForm attr_reader :title, :opts, :steps, :questions_by_key def initialize title, opts={} @@ -16,7 +16,7 @@ def [] key end def decorate options = {} - QAEFormDecorator.new self, options + QaeFormDecorator.new self, options end def step title, options = {}, &block diff --git a/forms/qae_form_builder/qae_form_decorator.rb b/forms/qae_form_builder/qae_form_decorator.rb index 2c42dbb87..c99ba22bb 100644 --- a/forms/qae_form_builder/qae_form_decorator.rb +++ b/forms/qae_form_builder/qae_form_decorator.rb @@ -1,6 +1,6 @@ -class QAEFormBuilder +class QaeFormBuilder - class QAEFormDecorator < QAEDecorator + class QaeFormDecorator < QaeDecorator def form_name @decorator_options[:form_name] || 'form' diff --git a/forms/qae_form_builder/question.rb b/forms/qae_form_builder/question.rb index aeafb96d9..994804e3b 100644 --- a/forms/qae_form_builder/question.rb +++ b/forms/qae_form_builder/question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class QuestionValidator # multifield questions that can not be simply validated SKIP_PRESENCE_VALIDATION_QUESTIONS = [ @@ -50,7 +50,7 @@ def limit_with_buffer(limit) end end - class QuestionDecorator < QAEDecorator + class QuestionDecorator < QaeDecorator def input_name options = {} if options[:index] suffix = options.fetch(:suffix) @@ -152,7 +152,7 @@ def validate error = {} question_class = delegate_obj.class.name.demodulize - validator_class = "QAEFormBuilder::#{question_class}Validator".constantize + validator_class = "QaeFormBuilder::#{question_class}Validator".constantize validator = validator_class.new(self, answers) errors.merge!(validator.errors) @@ -260,11 +260,11 @@ def children_conditions(questions_with_references) end def can_have_conditional_hints? - delegate_obj.is_a?(QAEFormBuilder::OptionsQuestion) + delegate_obj.is_a?(QaeFormBuilder::OptionsQuestion) end def can_have_parent_conditional_hints? - !delegate_obj.is_a?(QAEFormBuilder::HeaderQuestion) + !delegate_obj.is_a?(QaeFormBuilder::HeaderQuestion) end def pdf_conditional_hints(questions_with_references) @@ -483,7 +483,7 @@ def title def decorate options = {} kls_name = self.class.name.split('::').last - kls = QAEFormBuilder.const_get "#{kls_name}Decorator" rescue nil + kls = QaeFormBuilder.const_get "#{kls_name}Decorator" rescue nil (kls || QuestionDecorator).new self, options end diff --git a/forms/qae_form_builder/regions_question.rb b/forms/qae_form_builder/regions_question.rb index fa3ac1f2c..0d246946c 100644 --- a/forms/qae_form_builder/regions_question.rb +++ b/forms/qae_form_builder/regions_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class RegionsQuestionValidator < DropdownQuestionValidator def errors result = super @@ -20,7 +20,7 @@ class RegionsQuestionBuilder < DropdownQuestionBuilder class RegionsQuestionDecorator < QuestionDecorator def regions - ::QAEFormBuilder::AddressQuestionDecorator::REGIONS.sort + ::QaeFormBuilder::AddressQuestionDecorator::REGIONS.sort end def entities diff --git a/forms/qae_form_builder/sic_code_dropdown_question.rb b/forms/qae_form_builder/sic_code_dropdown_question.rb index e6824aab4..fe6b69b8d 100644 --- a/forms/qae_form_builder/sic_code_dropdown_question.rb +++ b/forms/qae_form_builder/sic_code_dropdown_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class SicCodeDropdownQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/step.rb b/forms/qae_form_builder/step.rb index 634774ba8..db5148a79 100644 --- a/forms/qae_form_builder/step.rb +++ b/forms/qae_form_builder/step.rb @@ -1,8 +1,8 @@ require 'active_support/inflector' -class QAEFormBuilder +class QaeFormBuilder - class StepDecorator < QAEDecorator + class StepDecorator < QaeDecorator QUESTIONS_WITH_NOT_REJECTING_BLANKS_ON_SAVE = %w( innovation_materials @@ -49,7 +49,7 @@ def allowed_questions_params_list(form_data) allowed_params[question.key] = hashify_params(form_data[question.key]) question_possible_sub_keys(question).each do |sub_question_key| - allowed_params[sub_question_key] = if question.delegate_obj.is_a?(QAEFormBuilder::ByYearsQuestion) || question.delegate_obj.is_a?(QAEFormBuilder::OneOptionByYearsQuestion) + allowed_params[sub_question_key] = if question.delegate_obj.is_a?(QaeFormBuilder::ByYearsQuestion) || question.delegate_obj.is_a?(QaeFormBuilder::OneOptionByYearsQuestion) # Sometimes users can input commas, we are stripping them form_data[sub_question_key].to_s.delete(",") else @@ -57,7 +57,7 @@ def allowed_questions_params_list(form_data) end end - if question.delegate_obj.is_a?(QAEFormBuilder::UploadQuestion) && + if question.delegate_obj.is_a?(QaeFormBuilder::UploadQuestion) && hashify_params(form_data[question.key]).nil? # This code handles case when user removes all attachments / links # from Form: Add Website Address/Documents section @@ -96,7 +96,7 @@ def question_possible_sub_keys(question) if by_year_conditions.present? sub_question_keys += question.by_year_conditions.map do |c| (1..c.years).map do |y| - if question.delegate_obj.is_a?(QAEFormBuilder::ByYearsLabelQuestion) + if question.delegate_obj.is_a?(QaeFormBuilder::ByYearsLabelQuestion) [:day, :month, :year].map do |i| "#{y}of#{c.years}#{i}" end @@ -107,9 +107,9 @@ def question_possible_sub_keys(question) end.flatten end - if question.delegate_obj.is_a?(QAEFormBuilder::OneOptionByYearsLabelQuestion) || question.delegate_obj.is_a?(QAEFormBuilder::OneOptionByYearsQuestion) + if question.delegate_obj.is_a?(QaeFormBuilder::OneOptionByYearsLabelQuestion) || question.delegate_obj.is_a?(QaeFormBuilder::OneOptionByYearsQuestion) sub_question_keys += (1..3).map do |y| - if question.delegate_obj.is_a?(QAEFormBuilder::OneOptionByYearsLabelQuestion) + if question.delegate_obj.is_a?(QaeFormBuilder::OneOptionByYearsLabelQuestion) [:day, :month, :year].map do |i| "#{y}of3#{i}" end @@ -149,8 +149,8 @@ def submit text, &block end def method_missing(meth, *args, &block) - klass_builder = QAEFormBuilder.const_get("#{meth.to_s.camelize}QuestionBuilder") rescue nil - klass = QAEFormBuilder.const_get("#{meth.to_s.camelize}Question") rescue nil + klass_builder = QaeFormBuilder.const_get("#{meth.to_s.camelize}QuestionBuilder") rescue nil + klass = QaeFormBuilder.const_get("#{meth.to_s.camelize}Question") rescue nil if klass_builder && klass && args.length >= 2 && args.length <= 3 id, title, opts = args diff --git a/forms/qae_form_builder/supporters_question.rb b/forms/qae_form_builder/supporters_question.rb index c1fe02d06..67a55a3d8 100644 --- a/forms/qae_form_builder/supporters_question.rb +++ b/forms/qae_form_builder/supporters_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class SupportersQuestionValidator < QuestionValidator MIN_LIMIT = 2 diff --git a/forms/qae_form_builder/text_question.rb b/forms/qae_form_builder/text_question.rb index d6d7e3efa..34f9c03a2 100644 --- a/forms/qae_form_builder/text_question.rb +++ b/forms/qae_form_builder/text_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class TextQuestionValidator < QuestionValidator # regex source: https://stackoverflow.com/questions/46155/how-to-validate-an-email-address-in-javascript/13178771#13178771 EMAIL_REGEX = /\A([a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)\z/ diff --git a/forms/qae_form_builder/textarea_question.rb b/forms/qae_form_builder/textarea_question.rb index 4b81e308e..42833056f 100644 --- a/forms/qae_form_builder/textarea_question.rb +++ b/forms/qae_form_builder/textarea_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class TextareaQuestionValidator < QuestionValidator def errors result = super diff --git a/forms/qae_form_builder/upload_question.rb b/forms/qae_form_builder/upload_question.rb index 3f7e3365a..8116ee258 100644 --- a/forms/qae_form_builder/upload_question.rb +++ b/forms/qae_form_builder/upload_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class UploadQuestionValidator < QuestionValidator end diff --git a/forms/qae_form_builder/user_info_question.rb b/forms/qae_form_builder/user_info_question.rb index 79e41d823..b368684e6 100644 --- a/forms/qae_form_builder/user_info_question.rb +++ b/forms/qae_form_builder/user_info_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class UserInfoQuestionValidator < QuestionValidator def errors result = super diff --git a/forms/qae_form_builder/year_question.rb b/forms/qae_form_builder/year_question.rb index b19177716..7b45bde25 100644 --- a/forms/qae_form_builder/year_question.rb +++ b/forms/qae_form_builder/year_question.rb @@ -1,4 +1,4 @@ -class QAEFormBuilder +class QaeFormBuilder class YearQuestionValidator < QuestionValidator def errors result = super diff --git a/lib/qae.rb b/lib/q_a_e.rb similarity index 100% rename from lib/qae.rb rename to lib/q_a_e.rb diff --git a/lib/sic_code.rb b/lib/sic_code.rb index 47162da86..2aa61b198 100644 --- a/lib/sic_code.rb +++ b/lib/sic_code.rb @@ -1,6 +1,6 @@ require "csv" -class SICCode < ActiveYaml::Base +class SicCode < ActiveYaml::Base REGEX = /\A\d{4}(\/\d{1})?\z/ # based on the sic codes spreadsheet set_root_path "#{Rails.root}/db/fixtures" @@ -52,6 +52,6 @@ def name end def self.collection - SICCode.all.sort_by(&:code).map { |sic| [sic.name, sic.code] } + SicCode.all.sort_by(&:code).map { |sic| [sic.name, sic.code] } end end diff --git a/spec/unit/qae_form_builder_spec.rb b/spec/unit/qae_form_builder_spec.rb index 93a4a7e09..0fd0fe31c 100644 --- a/spec/unit/qae_form_builder_spec.rb +++ b/spec/unit/qae_form_builder_spec.rb @@ -1,20 +1,20 @@ require 'rails_helper' -describe QAEFormBuilder do +describe QaeFormBuilder do - it 'should build QAEFormBuilder::Form instances' do - empty = QAEFormBuilder.build 'test' + it 'should build QaeFormBuilder::Form instances' do + empty = QaeFormBuilder.build 'test' expect(empty.title).to eq('test') - expect(empty).to be_instance_of(QAEFormBuilder::QAEForm) + expect(empty).to be_instance_of(QaeFormBuilder::QAEForm) end it 'should build 0 steps for empty block' do - empty = QAEFormBuilder.build 'test' + empty = QaeFormBuilder.build 'test' expect(empty.steps).to eq([]) end it 'should build form steps' do - sample = QAEFormBuilder.build 'test' do + sample = QaeFormBuilder.build 'test' do step 'eligibility' step 'company_info' step 'goods_or_services', custom_option: :foo @@ -27,7 +27,7 @@ end it 'should build questions inside steps' do - sample = QAEFormBuilder.build 'test' do + sample = QaeFormBuilder.build 'test' do step 'eligibility' do text :org_kind, 'What kind of organisation are you?' text :org_uk, 'Is your business based in UK?' do @@ -48,7 +48,7 @@ end it 'should navigate between steps with decorator' do - sample = QAEFormBuilder.build 'test' do + sample = QaeFormBuilder.build 'test' do step 'A', 'A' step 'B', 'B' end @@ -67,7 +67,7 @@ end it 'should report visible? depending on conditionals' do - sample = QAEFormBuilder.build 'test' do + sample = QaeFormBuilder.build 'test' do step 'test_step' do options :parent, 'Parent' do yes_no @@ -87,7 +87,7 @@ describe "Drop conditions" do let(:sample) do - QAEFormBuilder.build 'test' do + QaeFormBuilder.build 'test' do step 'test_step' do options :grandparent, 'Grand' do option '2 years', '2'