Skip to content

Commit

Permalink
renaming classes for zeitwerk
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamfall committed Nov 2, 2023
1 parent 8e0dcd7 commit f02bdd6
Show file tree
Hide file tree
Showing 86 changed files with 181 additions and 185 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
30 changes: 13 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/form_answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/assessor/form_answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/form_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/lieutenant/form_answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions app/decorators/form_answer_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions app/form_pointers/financial_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions app/form_pointers/financial_year_pointer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions app/form_pointers/form_financial_pointer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "-"
Expand Down
8 changes: 4 additions & 4 deletions app/models/assessor_assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/audit_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'") }
Expand Down
4 changes: 2 additions & 2 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/feedback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions app/models/form_answer.rb
Original file line number Diff line number Diff line change
@@ -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/v2022/qae_forms'
require_relative '../../forms/v2023/qae_forms'
require_relative '../../forms/v2024/qae_forms'

class FormAnswer < ApplicationRecord
include Statesman::Adapters::ActiveRecordQueries
Expand Down Expand Up @@ -39,7 +39,7 @@ class FormAnswer < ApplicationRecord
belongs_to :user
belongs_to :account
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
Expand All @@ -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

Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/reports/all_entries.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Reports::AllEntries
include Reports::CSVHelper
include Reports::CsvHelper

MAPPING = [
{
Expand Down
2 changes: 1 addition & 1 deletion app/models/reports/citation_report.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Reports::CitationReport
attr_reader :award_year, :scope

include Reports::CSVHelper
include Reports::CsvHelper

MAPPING = [
{
Expand Down
2 changes: 1 addition & 1 deletion app/models/reports/csv_helper.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/reports/press_book_list.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Reports::PressBookList
include Reports::CSVHelper
include Reports::CsvHelper

MAPPING = [
{
Expand Down
2 changes: 1 addition & 1 deletion app/views/assessor/form_answers/_question.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion app/views/qae_form/_address_question.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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])
2 changes: 1 addition & 1 deletion app/views/qae_form/_assessor_details_question.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Loading

0 comments on commit f02bdd6

Please sign in to comment.