diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..e99e643666 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs +# @see http://editorconfig.org +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = spaces +tab_width = 2 + +[*.{rb,rake,erb,slim,js,ts,coffee,json,yml,css,pcss,scss,sh,markdown,md,html}] +indent_size = 2 diff --git a/.rubocop.yml b/.rubocop.yml index 6235532790..5681a931d2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -68,6 +68,10 @@ Layout/SpaceInsideHashLiteralBraces: Enabled: true EnforcedStyle: space +# If we want a boolean called :true, we should allow that. These are likely not mistakes. +Lint/BooleanSymbol: + Enabled: false + Metrics/ModuleLength: Enabled: false @@ -92,6 +96,9 @@ Naming/VariableNumber: Naming/MemoizedInstanceVariableName: EnforcedStyleForLeadingUnderscores: optional +Performance/MapCompact: + Enabled: false + Rails: Enabled: true @@ -102,30 +109,44 @@ Rails/ApplicationRecord: Rails/FindBy: Enabled: false +Rails/HasManyOrHasOneDependent: + Enabled: false + Rails/Output: Exclude: - lib/**/* - db/migrate/**/*.rb Rails/SkipsModelValidations: - Exclude: - - db/migrate/**/*.rb - - spec/**/*.rb + Enabled: false -Style/HashConversion: +Rails/UnknownEnv: + Environments: + - production + - staging + - development + - test + +Style/ArgumentsForwarding: Enabled: false -Style/TrailingCommaInArrayLiteral: - EnforcedStyleForMultiline: comma +Style/Documentation: + Enabled: false -Style/TrailingCommaInHashLiteral: - EnforcedStyleForMultiline: consistent_comma +Style/EmptyMethod: + EnforcedStyle: compact -Style/TrailingCommaInArguments: - EnforcedStyleForMultiline: consistent_comma +Style/HashConversion: + Enabled: false -Style/WordArray: - MinSize: 0 +Style/NumericLiteralPrefix: + Enabled: false + +Style/SafeNavigation: + Enabled: false + +Style/SingleLineMethods: + AllowIfMethodIsEmpty: true Style/StringLiterals: EnforcedStyle: double_quotes @@ -133,8 +154,17 @@ Style/StringLiterals: Style/StringLiteralsInInterpolation: EnforcedStyle: double_quotes -Style/Documentation: - Enabled: false +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInHashLiteral: + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInArguments: + EnforcedStyleForMultiline: comma + +Style/WordArray: + MinSize: 0 Metrics/ClassLength: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8cf1809a30..8524129238 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,1263 +1,7 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-05-09 02:46:54 UTC using RuboCop version 1.63.4. +# on 2024-05-18 19:36:27 UTC using RuboCop version 1.63.4. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: IndentationWidth. -Layout/AssignmentIndentation: - Exclude: - - 'app/helpers/case_summary_helper.rb' - -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith. -# SupportedStylesAlignWith: either, start_of_block, start_of_line -Layout/BlockAlignment: - Exclude: - - 'app/form_pointers/financial_summary_pointer.rb' - - 'app/models/form_answer.rb' - - 'config/routes.rb' - - 'forms/qae_form_builder/by_years_label_question.rb' - - 'spec/features/account/collaborators_spec.rb' - - 'spec/interactors/add_collaborator_spec.rb' - - 'spec/models/assessors_import/builder_spec.rb' - - 'spec/models/award_year_spec.rb' - - 'spec/models/eligibility/mobility_spec.rb' - -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -Layout/BlockEndNewline: - Exclude: - - 'app/controllers/concerns/assessor_assignment_context.rb' - - 'app/models/form_answer.rb' - - 'forms/qae_form_builder/about_section_question.rb' - - 'spec/decorators/user_decorator_spec.rb' - - 'spec/factories/eligibility.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -Layout/ClosingParenthesisIndentation: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/models/form_answer.rb' - - 'app/pdf_generators/case_summary_pdfs/general/draw_elements.rb' - - 'app/services/form_answer_auditor.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/CommentIndentation: - Exclude: - - 'app/models/reports/admin_report.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Exclude: - - 'app/decorators/form_answer_decorator.rb' - - 'forms/qae_form_builder/regions_question.rb' - - 'forms/qae_form_builder/upload_question.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstArgumentIndentation: - Exclude: - - 'app/search/form_answer_search.rb' - - 'spec/models/form_answer_state_machine_spec.rb' - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/FirstHashElementIndentation: - Exclude: - - 'app/controllers/concerns/audit_certificate_context.rb' - - 'app/pdf_generators/qae_pdf_forms/general/draw_elements.rb' - - 'spec/models/reports/form_document_picker_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/HashAlignment: - Exclude: - - 'app/pdf_generators/qae_pdf_forms/custom_questions/textarea.rb' - -# Offense count: 59 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Width, AllowedPatterns. -Layout/IndentationWidth: - Enabled: false - -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. -Layout/LeadingCommentSpace: - Exclude: - - 'app/decorators/form_answer_decorator.rb' - - 'app/helpers/mailer_helper.rb' - - 'app/models/form_answer.rb' - - 'app/models/forms_lost_financial_data_detector.rb' - - 'app/services/performance_platform_service.rb' - - 'config/application.rb' - - 'config/initializers/devise.rb' - - 'forms/qae_form_builder/queen_award_applications_question.rb' - - 'forms/qae_form_builder/queen_award_holder_question.rb' - - 'spec/acceptance/steps/application_form_creation_steps.rb' - - 'spec/features/assessor/sorting_by_assessors_spec.rb' - - 'spec/support/capybara.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/LeadingEmptyLines: - Exclude: - - 'forms/award_years/v2018/social_mobility/social_mobility_step3.rb' - -# Offense count: 32 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineArrayBraceLayout: - Exclude: - - 'forms/award_years/v2020/innovation/innovation_step1.rb' - - 'forms/award_years/v2020/international_trade/international_trade_step1.rb' - - 'forms/award_years/v2020/social_mobility/social_mobility_step1.rb' - - 'forms/award_years/v2021/innovation/innovation_step1.rb' - - 'forms/award_years/v2021/international_trade/international_trade_step1.rb' - - 'forms/award_years/v2021/social_mobility/social_mobility_step1.rb' - - 'forms/award_years/v2022/innovation/innovation_step1.rb' - - 'forms/award_years/v2022/international_trade/international_trade_step1.rb' - - 'forms/award_years/v2022/social_mobility/social_mobility_step1.rb' - - 'forms/award_years/v2023/innovation/innovation_step1.rb' - - 'forms/award_years/v2023/international_trade/international_trade_step1.rb' - - 'forms/award_years/v2023/social_mobility/social_mobility_step1.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultilineFinalElement. -Layout/MultilineHashKeyLineBreaks: - Exclude: - - 'spec/features/admin/form_answers/download_all_case_summary_pdf_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceAfterColon: - Exclude: - - 'app/helpers/search_helper.rb' - - 'spec/acceptance/steps/application_form_creation_steps.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceAfterMethodName: - Exclude: - - 'app/models/user.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceAroundKeyword: - Exclude: - - 'spec/services/assessor_assignment_service_spec.rb' - -# Offense count: 26 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Enabled: false - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceBeforeComma: - Exclude: - - 'lib/tasks/users_reports.rake' - - 'spec/controllers/admin/form_answer_state_transitions_controller_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Exclude: - - 'spec/features/users/post_submission_dashboard_spec.rb' - -# Offense count: 11 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: require_no_space, require_space -Layout/SpaceInLambdaLiteral: - Exclude: - - 'app/models/form_answer.rb' - - 'app/models/user.rb' - - 'app/value_objects/current_queens_award.rb' - - 'app/value_objects/form_link.rb' - - 'app/value_objects/position.rb' - -# Offense count: 169 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBrackets: space, no_space -Layout/SpaceInsideArrayLiteralBrackets: - Exclude: - - 'app/form_pointers/form_financial_pointer.rb' - - 'app/models/palace_attendee.rb' - - 'app/services/check_account_on_bounces_email.rb' - - 'config/environments/production.rb' - - 'config/initializers/devise.rb' - - 'forms/award_years/v2022/social_mobility/social_mobility_step2.rb' - - 'forms/award_years/v2023/social_mobility/social_mobility_step2.rb' - - 'forms/award_years/v2024/social_mobility/social_mobility_step3.rb' - - 'forms/award_years/v2025/social_mobility/social_mobility_step3.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, compact, no_space -Layout/SpaceInsideParens: - Exclude: - - 'app/policies/press_summary_policy.rb' - - 'spec/models/assessor_assignment_spec.rb' - - 'spec/support/shared_contexts/admin_feedback_pdf_file_checks.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceInsidePercentLiteralDelimiters: - Exclude: - - 'config/initializers/assets.rb' - -# Offense count: 22 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingEmptyLines: - Enabled: false - -# Offense count: 9 -# This cop supports safe autocorrection (--autocorrect). -Lint/AmbiguousOperator: - Exclude: - - 'app/helpers/form_answer_helper.rb' - - 'app/pdf_generators/qae_pdf_forms/general/question_pointer.rb' - - 'forms/declaration_of_responsibility_form.rb' - - 'forms/qae_form_builder.rb' - - 'forms/qae_form_builder/matrix_question.rb' - - 'forms/qae_form_builder/qae_form.rb' - - 'forms/qae_form_builder/step.rb' - -# Offense count: 12 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowSafeAssignment. -Lint/AssignmentInCondition: - Exclude: - - 'app/controllers/concerns/audit_certificate_context.rb' - - 'app/controllers/users/actual_figures_controller.rb' - - 'app/controllers/users/audit_certificates_controller.rb' - - 'app/controllers/users/vat_returns_controller.rb' - - 'app/form_pointers/form_financial_pointer.rb' - - 'app/models/assessor_assignment.rb' - - 'app/models/concerns/mailgun_helper.rb' - - 'app/models/reports/dashboard/base.rb' - - 'app/models/reports/data_pickers/form_document_picker.rb' - - 'app/pdf_generators/pdf_audit_certificates/base.rb' - - 'app/validators/file_size_validator.rb' - -# Offense count: 300 -# This cop supports unsafe autocorrection (--autocorrect-all). -Lint/BooleanSymbol: - Enabled: false - -# Offense count: 1 -# Configuration parameters: AllowedMethods. -# AllowedMethods: enums -Lint/ConstantDefinitionInBlock: - Exclude: - - 'spec/decorators/form_answer_decorator_spec.rb' - -# Offense count: 8 -Lint/DuplicateMethods: - Exclude: - - 'app/models/assessor.rb' - - 'app/pdf_generators/case_summary_pdfs/general/data_pointer.rb' - - 'app/pdf_generators/hard_copy_generators/base.rb' - - 'app/policies/feedback_policy.rb' - - 'app/policies/press_summary_policy.rb' - - 'app/services/notifiers/account_notifier.rb' - - 'forms/qae_form_builder/question.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Lint/EnsureReturn: - Exclude: - - 'app/form_pointers/financial_table.rb' - -# Offense count: 3 -Lint/IneffectiveAccessModifier: - Exclude: - - 'app/models/assessor.rb' - - 'app/models/form_answer.rb' - -# Offense count: 2 -Lint/LiteralAsCondition: - Exclude: - - 'app/pdf_generators/qae_pdf_forms/general/question_pointer.rb' - -# Offense count: 2 -Lint/NonLocalExitFromIterator: - Exclude: - - 'spec/support/form_answer_filtering_test_helper.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -Lint/ParenthesesAsGroupedExpression: - Exclude: - - 'app/pdf_generators/qae_pdf_forms/general/draw_elements.rb' - - 'spec/models/eligibility_spec.rb' - - 'spec/models/reports/admin/assessor_judge_admin_data_report_spec.rb' - -# Offense count: 1 -Lint/RescueException: - Exclude: - - 'app/models/concerns/mailgun_helper.rb' - -# Offense count: 1 -# Configuration parameters: IgnoreImplicitReferences. -Lint/ShadowedArgument: - Exclude: - - 'app/pdf_generators/qae_pdf_forms/custom_questions/textarea.rb' - -# Offense count: 62 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: strict, consistent -Lint/SymbolConversion: - Exclude: - - 'app/helpers/region_helper.rb' - - 'app/models/form_answer.rb' - - 'forms/qae_form_builder/matrix_question.rb' - - 'forms/qae_form_builder/question.rb' - -# Offense count: 1 -# Configuration parameters: AllowKeywordBlockArguments. -Lint/UnderscorePrefixedVariableName: - Exclude: - - 'spec/support/shared_contexts/admin_all_case_summaries_pdf_generation.rb' - -# Offense count: 32 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect. -Lint/UselessAssignment: - Enabled: false - -# Offense count: 21 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects. -Lint/Void: - Exclude: - - 'app/models/assessor_assignment.rb' - - 'app/models/audit_certificate.rb' - - 'app/models/form_answer.rb' - - 'app/models/form_answer_attachment.rb' - - 'app/models/support_letter.rb' - - 'app/models/support_letter_attachment.rb' - - 'app/models/supporter.rb' - - 'app/models/user.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: lowercase, uppercase -Naming/HeredocDelimiterCase: - Exclude: - - 'app/models/reports/data_pickers/assessor_progress_picker.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Performance/BlockGivenWithExplicitBlock: - Exclude: - - 'forms/qae_form_builder.rb' - - 'forms/qae_form_builder/qae_form.rb' - - 'forms/qae_form_builder/step.rb' - -# Offense count: 15 -# Configuration parameters: MinSize. -Performance/CollectionLiteralInLoop: - Exclude: - - 'app/models/assessors_import/builder.rb' - - 'app/models/award_year.rb' - - 'app/models/forms_lost_financial_data_detector.rb' - - 'forms/appraisal_form.rb' - - 'forms/qae_form_builder/step.rb' - - 'lib/tasks/form_answers.rake' - - 'spec/features/admin/form_answers/download_all_case_summary_pdf_spec.rb' - - 'spec/support/shared_contexts/admin_all_case_summaries_pdf_generation.rb' - - 'spec/support/shared_contexts/admin_application_case_summaries_pdf_download.rb' - - 'spec/support/shared_contexts/admin_feedback_pdf_file_checks.rb' - - 'spec/unit/pdf_generators/case_summary_pdfs/base_spec.rb' - -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -Performance/Count: - Exclude: - - 'forms/qae_form_builder/sub_fields_question.rb' - - 'forms/qae_form_builder/text_question.rb' - - 'forms/qae_form_builder/textarea_question.rb' - -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -Performance/Detect: - Exclude: - - 'spec/support/shared_contexts/pdf_file_checks.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnabledForFlattenWithoutParams. -Performance/FlatMap: - Exclude: - - 'forms/qae_form_builder/about_section_question.rb' - - 'spec/features/admin/form_answers/generation_of_csv_reports_spec.rb' - -# Offense count: 6 -# This cop supports unsafe autocorrection (--autocorrect-all). -Performance/InefficientHashSearch: - Exclude: - - 'app/models/reports/admin_report.rb' - - 'app/models/reports/assessor_report.rb' - - 'app/pdf_generators/qae_pdf_forms/general/question_pointer.rb' - - 'forms/qae_form_builder/address_question.rb' - -# Offense count: 9 -# This cop supports unsafe autocorrection (--autocorrect-all). -Performance/MapCompact: - Exclude: - - 'app/decorators/form_answer_decorator.rb' - - 'app/models/assessor.rb' - - 'app/models/reports/compiled_press_book.rb' - - 'app/models/reports/form_answer.rb' - - 'app/pdf_generators/feedback_pdfs/general/data_pointer.rb' - - 'app/pdf_generators/qae_pdf_forms/custom_questions/lists.rb' - - 'forms/appraisal_form.rb' - -# Offense count: 1 -Performance/MapMethodChain: - Exclude: - - 'app/decorators/form_answer_decorator.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Performance/RedundantBlockCall: - Exclude: - - 'app/helpers/form_answer_helper.rb' - -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowRegexpMatch. -Performance/RedundantEqualityComparisonBlock: - Exclude: - - 'app/pdf_generators/qae_pdf_forms/custom_questions/by_year.rb' - - 'forms/qae_form_builder/question.rb' - -# Offense count: 7 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: MaxKeyValuePairs. -Performance/RedundantMerge: - Exclude: - - 'app/controllers/concerns/audit_certificate_context.rb' - - 'app/controllers/form_controller.rb' - - 'app/controllers/users/actual_figures_controller.rb' - - 'app/controllers/users/audit_certificates_controller.rb' - - 'app/controllers/users/vat_returns_controller.rb' - - 'spec/mailers/account_mailers/buckingham_palace_invite_mailer_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Performance/RedundantSortBlock: - Exclude: - - 'spec/models/settings_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Performance/RedundantSplitRegexpArgument: - Exclude: - - 'app/validators/file_size_validator.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Performance/RegexpMatch: - Exclude: - - 'app/services/assessor_assignment_service.rb' - - 'app/services/company_registration_number.rb' - -# Offense count: 91 -# This cop supports safe autocorrection (--autocorrect). -Performance/StringIdentifierArgument: - Enabled: false - -# Offense count: 4 -# This cop supports unsafe autocorrection (--autocorrect-all). -Performance/StringInclude: - Exclude: - - 'app/models/reports/user.rb' - - 'app/pdf_generators/qae_pdf_forms/general/question_pointer.rb' - - 'spec/lib/qae_form_builder_spec.rb' - - 'spec/rails_helper.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -Performance/StringReplacement: - Exclude: - - 'app/decorators/form_answer_decorator.rb' - - 'app/pdf_generators/hard_copy_generators/aggregated_base.rb' - - 'app/pdf_generators/hard_copy_generators/base.rb' - - 'app/pdf_generators/qae_pdf_forms/custom_questions/textarea.rb' - -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: OnlySumOrWithInitialValue. -Performance/Sum: - Exclude: - - 'forms/qae_form_builder/qae_form_decorator.rb' - - 'forms/qae_form_builder/step.rb' - -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -Rails/ApplicationController: - Exclude: - - 'app/controllers/admin/session_checks_controller.rb' - - 'app/controllers/assessor/session_checks_controller.rb' - - 'app/controllers/judge/session_checks_controller.rb' - -# Offense count: 4 -# This cop supports unsafe autocorrection (--autocorrect-all). -Rails/ApplicationRecord: - Exclude: - - 'app/models/audit_certificate.rb' - - 'app/models/commercial_figures_file.rb' - - 'app/models/shortlisted_documents_wrapper.rb' - - 'app/models/vat_returns_file.rb' - -# Offense count: 22 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent. -Rails/Blank: - Enabled: false - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforceForPrefixed. -Rails/Delegate: - Exclude: - - 'app/controllers/concerns/assessment_submission_mixin.rb' - - 'app/decorators/form_answer_decorator.rb' - - 'app/models/reports/data_pickers/user_picker.rb' - - 'forms/qae_form_builder/trade_commercial_success_question.rb' - -# Offense count: 22 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: slashes, arguments -Rails/FilePath: - Enabled: false - -# Offense count: 20 -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/HasManyOrHasOneDependent: - Exclude: - - 'app/models/account.rb' - - 'app/models/admin.rb' - - 'app/models/assessor.rb' - - 'app/models/award_year.rb' - - 'app/models/form_answer.rb' - - 'app/models/shortlisted_documents_wrapper.rb' - - 'app/models/user.rb' - -# Offense count: 15 -# Configuration parameters: Include. -# Include: app/helpers/**/*.rb -Rails/HelperInstanceVariable: - Exclude: - - 'app/helpers/appraisal_form_helper.rb' - - 'app/helpers/form_helper.rb' - - 'app/helpers/partials_visibility_helper.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Rails/IndexWith: - Exclude: - - 'app/services/form_answer_versions_dispatcher.rb' - -# Offense count: 6 -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/InverseOf: - Exclude: - - 'app/models/award_year.rb' - - 'app/models/form_answer.rb' - - 'app/models/user.rb' - -# Offense count: 18 -# Configuration parameters: Include. -# Include: app/controllers/**/*.rb -Rails/LexicallyScopedActionFilter: - Exclude: - - 'app/controllers/account/base_controller.rb' - - 'app/controllers/admin/form_answers_controller.rb' - - 'app/controllers/assessor/form_answers_controller.rb' - - 'app/controllers/content_only_controller.rb' - - 'app/controllers/form/base_controller.rb' - - 'app/controllers/form/materials_base_controller.rb' - - 'app/controllers/form_award_eligibilities_controller.rb' - - 'app/controllers/form_controller.rb' - - 'app/controllers/users/base_controller.rb' - - 'app/controllers/users/press_summaries_controller.rb' - - 'app/controllers/users/registrations_controller.rb' - -# Offense count: 4 -# This cop supports unsafe autocorrection (--autocorrect-all). -Rails/NegateInclude: - Exclude: - - 'app/form_pointers/form_answers_base_pointer.rb' - - 'app/form_pointers/form_financial_pointer.rb' - - 'app/models/assessor_assignment.rb' - - 'app/models/reports/discrepancies_between_primary_and_secondary_appraisals.rb' - -# Offense count: 41 -# Configuration parameters: Include. -# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb -Rails/Output: - Exclude: - - 'app/models/assessors_import/builder.rb' - - 'app/models/forms_lost_financial_data_detector.rb' - - 'app/models/users_import/builder.rb' - - 'app/services/notifiers/email_notification_service.rb' - - 'app/services/performance_platform_service.rb' - - 'app/tasks/manual_updaters/hard_copy_generation.rb' - - 'app/tasks/manual_updaters/submit_application.rb' - - 'app/tasks/manual_updaters/trade_award_downgrader.rb' - - 'app/tasks/useful_checkers/eligibility_checker.rb' - -# Offense count: 13 -Rails/OutputSafety: - Exclude: - - 'app/decorators/form_answer_decorator.rb' - - 'app/decorators/trigger_at_decorator.rb' - - 'app/helpers/application_helper.rb' - - 'app/helpers/appraisal_form_helper.rb' - - 'app/helpers/form_answer_helper.rb' - - 'spec/decorators/trigger_at_decorator_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Rails/Pluck: - Exclude: - - 'app/models/reports/csv_helper.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: conservative, aggressive -Rails/PluckInWhere: - Exclude: - - 'app/models/form_answer.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. -Rails/Present: - Exclude: - - 'app/pdf_generators/qae_pdf_forms/custom_questions/matrix.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Include. -# Include: **/Rakefile, **/*.rake -Rails/RakeEnvironment: - Exclude: - - 'lib/tasks/cf.rake' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/ReadWriteAttribute: - Exclude: - - 'app/models/form_answer_attachment.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/RedundantAllowNil: - Exclude: - - 'app/models/form_answer.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Rails/RedundantForeignKey: - Exclude: - - 'app/models/form_answer.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: conservative, aggressive -Rails/ShortI18n: - Exclude: - - 'app/models/audit_event.rb' - - 'spec/decorators/assessor_assignment_decorator_spec.rb' - -# Offense count: 57 -# Configuration parameters: ForbiddenMethods, AllowedMethods. -# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all -Rails/SkipsModelValidations: - Enabled: false - -# Offense count: 19 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: strict, flexible -Rails/TimeZone: - Exclude: - - 'app/models/form_answer_statistics/picker.rb' - - 'forms/award_years/v2025/innovation/innovation_step3.rb' - - 'spec/controllers/admin/assessment_submissions_controller_spec.rb' - - 'spec/controllers/admin/deadlines_controller_spec.rb' - - 'spec/decorators/assessor_assignment_decorator_spec.rb' - - 'spec/decorators/email_notification_decorator_spec.rb' - - 'spec/decorators/user_decorator_spec.rb' - - 'spec/features/admin/reports/assessors_progress_report_csv_spec.rb' - - 'spec/features/users/collaborator_registration_flow_spec.rb' - - 'spec/models/deadline_spec.rb' - - 'spec/services/notifiers/email_notification_service_spec.rb' - -# Offense count: 3 -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/UniqueValidationWithoutIndex: - Exclude: - - 'app/models/audit_certificate.rb' - - 'app/models/feedback.rb' - - 'app/models/palace_invite.rb' - -# Offense count: 1 -# Configuration parameters: Environments. -# Environments: development, test, production -Rails/UnknownEnv: - Exclude: - - 'config/initializers/pusher_init.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/Validation: - Exclude: - - 'app/models/form_answer.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -Rails/WhereEquals: - Exclude: - - 'app/models/form_answer_statistics/picker.rb' - - 'app/models/reports/reception_buckingham_palace_report.rb' - - 'app/pdf_generators/feedback_pdfs/base.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: exists, where -Rails/WhereExists: - Exclude: - - 'app/models/concerns/autosave_token_generation.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -Rails/WhereNot: - Exclude: - - 'app/models/user.rb' - - 'app/tasks/useful_checkers/eligibility_checker.rb' - - 'lib/tasks/temprary/fix_assessments.rake' - - 'lib/tasks/temprary/fix_sust_dev_assessments.rake' - - 'spec/models/user_spec.rb' - -# Offense count: 1 -Security/Eval: - Exclude: - - 'app/models/forms_lost_financial_data_detector.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: prefer_alias, prefer_alias_method -Style/Alias: - Exclude: - - 'app/policies/feedback_policy.rb' - - 'app/policies/press_summary_policy.rb' - - 'forms/qae_form_builder/subsidiaries_associates_plants_question.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: always, conditionals -Style/AndOr: - Exclude: - - 'app/helpers/application_helper.rb' - -# Offense count: 20 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames. -# RedundantRestArgumentNames: args, arguments -# RedundantKeywordRestArgumentNames: kwargs, options, opts -# RedundantBlockArgumentNames: blk, block, proc -Style/ArgumentsForwarding: - Exclude: - - 'app/helpers/application_helper.rb' - - 'app/mailers/devise/mailer.rb' - - 'app/workers/mail_delivery_worker.rb' - - 'forms/qae_form_builder.rb' - - 'forms/qae_form_builder/qae_decorator.rb' - - 'forms/qae_form_builder/qae_form.rb' - - 'forms/qae_form_builder/question.rb' - - 'forms/qae_form_builder/step.rb' - -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: percent_q, bare_percent -Style/BarePercentLiterals: - Exclude: - - 'app/models/form_answer.rb' - - 'app/models/reports/discrepancies_between_primary_and_secondary_appraisals.rb' - - 'forms/award_years/v2025/international_trade/international_trade_step4.rb' - - 'spec/services/company_registration_number_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/BlockComments: - Exclude: - - 'spec/spec_helper.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: is_a?, kind_of? -Style/ClassCheck: - Exclude: - - 'app/decorators/form_answer_decorator.rb' - - 'app/models/form_answer_state_transition.rb' - - 'lib/tasks/form_answers.rake' - -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowedMethods, AllowedPatterns. -# AllowedMethods: ==, equal?, eql? -Style/ClassEqualityComparison: - Exclude: - - 'app/models/audit_event.rb' - - 'app/pdf_generators/qae_pdf_forms/general/question_pointer.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/ColonMethodCall: - Exclude: - - 'app/controllers/assessor/form_answers_controller.rb' - -# Offense count: 15 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. -# SupportedStyles: assign_to_condition, assign_inside_condition -Style/ConditionalAssignment: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/decorators/assessor_assignment_decorator.rb' - - 'app/helpers/application_helper.rb' - - 'app/models/award_year.rb' - - 'app/models/form_answer.rb' - - 'app/pdf_generators/pdf_audit_certificates/general/guidance_elements.rb' - - 'app/pdf_generators/qae_pdf_forms/custom_questions/textarea.rb' - - 'app/pdf_generators/qae_pdf_forms/general/draw_elements.rb' - - 'app/pdf_generators/qae_pdf_forms/general/question_pointer.rb' - - 'app/search/search.rb' - - 'forms/appraisal_form.rb' - - 'forms/qae_form_builder/innovation_financial_year_date_question.rb' - - 'forms/qae_form_builder/matrix_question.rb' - - 'spec/support/shared_contexts/pdf_file_checks.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/EachWithObject: - Exclude: - - 'app/controllers/form_controller.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, EnforcedStyle, AllowComments. -# SupportedStyles: empty, nil, both -Style/EmptyElse: - Exclude: - - 'app/form_pointers/financial_summary_pointer.rb' - - 'app/services/form_answer_versions_dispatcher.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/EmptyLambdaParameter: - Exclude: - - 'app/models/user.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/EmptyLiteral: - Exclude: - - 'forms/appraisal_form.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Style/FileRead: - Exclude: - - 'app/models/assessors_import/builder.rb' - - 'app/models/users_import/builder.rb' - - 'lib/sic_code.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: each, for -Style/For: - Exclude: - - 'app/helpers/application_helper.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/GlobalStdStream: - Exclude: - - 'config/environments/production.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/HashExcept: - Exclude: - - 'app/models/form_answer.rb' - -# Offense count: 190 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent -Style/HashSyntax: - Exclude: - - 'Rakefile' - - 'config/routes.rb' - - 'forms/qae_form_builder/about_section_question.rb' - - 'forms/qae_form_builder/question.rb' - - 'lib/tasks/feedbacks.rake' - - 'spec/controllers/admin/audit_certificates_controller_spec.rb' - - 'spec/controllers/admin/form_answer_state_transitions_controller_spec.rb' - - 'spec/controllers/assessor/reports_controller_spec.rb' - - 'spec/features/non_js_form_dynamic_lists/subsidiaries_spec.rb' - - 'spec/form_pointers/financial_summary_pointer_spec.rb' - - 'spec/models/assessor_assignment_spec.rb' - -# Offense count: 18 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/IdenticalConditionalBranches: - Exclude: - - 'app/controllers/concerns/form_answer_mixin.rb' - - 'app/controllers/palace_invites_controller.rb' - - 'app/models/form_answer/award_eligibility_builder.rb' - - 'app/models/palace_invite.rb' - - 'app/pdf_generators/case_summary_pdfs/general/data_pointer.rb' - - 'app/tasks/manual_updaters/submit_application.rb' - - 'spec/models/form_answer_statistics/picker_spec.rb' - -# Offense count: 14 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowIfModifier. -Style/IfInsideElse: - Exclude: - - 'app/controllers/concerns/admin_shortlisted_docs_submission_context.rb' - - 'app/controllers/form_controller.rb' - - 'app/controllers/users/form_answers_controller.rb' - - 'app/form_pointers/form_financial_pointer.rb' - - 'app/helpers/application_helper.rb' - - 'app/helpers/form_answer_helper.rb' - - 'app/models/reports/data_pickers/form_document_picker.rb' - - 'app/pdf_generators/qae_pdf_forms/custom_questions/lists.rb' - - 'app/pdf_generators/qae_pdf_forms/general/question_pointer.rb' - - 'forms/qae_form_builder/award_holder_question.rb' - - 'forms/qae_form_builder/matrix_question.rb' - - 'forms/qae_form_builder/question.rb' - - 'lib/tasks/form_answers.rake' - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: call, braces -Style/LambdaCall: - Exclude: - - 'app/helpers/form_answer_helper.rb' - - 'app/services/utils/elapsed_time.rb' - - 'forms/qae_form_builder/by_years_question.rb' - - 'forms/qae_form_builder/question.rb' - - 'forms/qae_form_builder/turnover_exports_calculation_question.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/MapCompactWithConditionalBlock: - Exclude: - - 'app/models/assessor.rb' - -# Offense count: 7 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/MapIntoArray: - Exclude: - - 'app/form_pointers/financial_table.rb' - - 'app/form_pointers/form_financial_pointer.rb' - - 'forms/qae_form_builder/by_years_label_question.rb' - - 'forms/qae_form_builder/by_years_question.rb' - - 'forms/qae_form_builder/date_question.rb' - - 'forms/qae_form_builder/innovation_financial_year_date_question.rb' - - 'forms/qae_form_builder/turnover_exports_calculation_question.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedMethods, AllowedPatterns. -Style/MethodCallWithoutArgsParentheses: - Exclude: - - 'app/controllers/admin/users_reports_controller.rb' - - 'forms/qae_form_builder/question.rb' - - 'spec/features/admin/form_answers/collaborators_spec.rb' - - 'spec/features/admin/form_answers/remove_audit_certificate_spec.rb' - - 'spec/models/reports/admin/assessor_judge_admin_data_report_spec.rb' - -# Offense count: 2 -Style/MissingRespondToMissing: - Exclude: - - 'forms/qae_form_builder/qae_decorator.rb' - - 'forms/qae_form_builder/step.rb' - -# Offense count: 90 -Style/MixinUsage: - Enabled: false - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Style/MultilineIfModifier: - Exclude: - - 'app/form_pointers/financial_table.rb' - - 'app/models/eligibility/trade/not_a_last_year_winner_validator.rb' - - 'app/models/form_answer_state_machine.rb' - -# Offense count: 11 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedMethods. -# AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with -Style/NestedParenthesizedCalls: - Exclude: - - 'spec/controllers/form_controller_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/Not: - Exclude: - - 'app/validators/advanced_email_validator.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedOctalStyle. -# SupportedOctalStyles: zero_with_o, zero_only -Style/NumericLiteralPrefix: - Exclude: - - 'spec/features/palace_attendees_spec.rb' - - 'spec/mailers/account_mailers/buckingham_palace_invite_mailer_spec.rb' - -# Offense count: 211 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Enabled: false - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -Style/Proc: - Exclude: - - 'app/models/assessor_assignment.rb' - - 'app/models/feedback.rb' - - 'app/value_objects/subsidiary.rb' - - 'spec/lib/qae_form_builder_spec.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/RandomWithOffset: - Exclude: - - 'app/models/assessors_import/builder.rb' - - 'app/models/users_import/builder.rb' - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantAssignment: - Exclude: - - 'app/form_pointers/financial_summary_pointer.rb' - - 'app/helpers/case_summary_helper.rb' - - 'app/models/forms_lost_financial_data_detector.rb' - - 'app/pdf_generators/qae_pdf_forms/custom_questions/matrix.rb' - - 'app/services/company_registration_number.rb' - - 'forms/qae_form_builder/date_question.rb' - - 'forms/qae_form_builder/step.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantCondition: - Exclude: - - 'app/decorators/form_answer_decorator.rb' - - 'app/models/settings.rb' - - 'app/pdf_generators/qae_pdf_forms/general/draw_elements.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantFreeze: - Exclude: - - 'app/services/company_registration_number.rb' - - 'app/validators/company_registration_number_validator.rb' - -# Offense count: 23 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantPercentQ: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantRegexpArgument: - Exclude: - - 'app/validators/file_size_validator.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantRegexpEscape: - Exclude: - - 'app/models/concerns/formatted_time/date_time_for.rb' - - 'app/pdf_generators/qae_pdf_forms/custom_questions/textarea.rb' - -# Offense count: 24 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleReturnValues. -Style/RedundantReturn: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/controllers/concerns/form_answer_mixin.rb' - - 'app/controllers/concerns/support_letters_context.rb' - - 'app/controllers/form/materials_base_controller.rb' - - 'app/controllers/form_award_eligibilities_controller.rb' - - 'app/controllers/form_controller.rb' - - 'app/controllers/palace_invites_controller.rb' - - 'app/controllers/support_letters_controller.rb' - - 'app/controllers/users/audit_certificates_controller.rb' - - 'app/controllers/users/form_answer_feedbacks_controller.rb' - - 'app/controllers/users/press_summaries_controller.rb' - - 'app/helpers/partials_visibility_helper.rb' - - 'app/renderers/mail_renderer.rb' - - 'app/services/current_award_type_picker.rb' - - 'app/services/utils/date.rb' - -# Offense count: 18 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantSelf: - Exclude: - - 'app/controllers/form/form_attachments_controller.rb' - - 'app/models/assessor.rb' - - 'app/models/award_year.rb' - - 'app/models/concerns/formatted_time/date_time_for.rb' - - 'app/models/form_answer.rb' - - 'app/models/shortlisted_documents_wrapper.rb' - - 'app/models/supporter.rb' - - 'app/pdf_generators/shared_pdf_helpers/font_helper.rb' - - 'app/pdf_generators/shared_pdf_helpers/language_helper.rb' - - 'forms/declaration_of_responsibility_form.rb' - - 'forms/qae_form_builder/question.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/RedundantSort: - Exclude: - - 'app/controllers/form_controller.rb' - -# Offense count: 21 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantStringEscape: - Exclude: - - 'forms/award_years/v2022/social_mobility/social_mobility_step2.rb' - - 'forms/award_years/v2023/social_mobility/social_mobility_step2.rb' - - 'forms/award_years/v2024/social_mobility/social_mobility_step3.rb' - - 'forms/award_years/v2025/social_mobility/social_mobility_step3.rb' - -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -Style/RescueModifier: - Exclude: - - 'app/models/concerns/formatted_time/date_time_for.rb' - - 'app/models/reports/data_pickers/form_document_picker.rb' - - 'app/pdf_generators/qae_pdf_forms/general/question_pointer.rb' - - 'forms/qae_form_builder/by_years_label_question.rb' - - 'forms/qae_form_builder/by_years_question.rb' - - 'forms/qae_form_builder/date_question.rb' - - 'forms/qae_form_builder/innovation_financial_year_date_question.rb' - - 'forms/qae_form_builder/question.rb' - - 'forms/qae_form_builder/step.rb' - - 'forms/qae_form_builder/turnover_exports_calculation_question.rb' - -# Offense count: 27 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. -# AllowedMethods: present?, blank?, presence, try, try! -Style/SafeNavigation: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/SelfAssignment: - Exclude: - - 'app/decorators/trigger_at_decorator.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowAsExpressionSeparator. -Style/Semicolon: - Exclude: - - 'spec/models/reports/form_document_picker_spec.rb' - -# Offense count: 6 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/SlicingWithRange: - Exclude: - - 'app/form_pointers/financial_year_pointer.rb' - - 'app/models/urn_builder.rb' - - 'app/pdf_generators/pdf_audit_certificates/awards2016/innovation/base.rb' - - 'app/renderers/mail_renderer.rb' - - 'lib/sic_code.rb' - - 'spec/models/form_answer_spec.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/StringChars: - Exclude: - - 'app/validators/file_size_validator.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/SuperWithArgsParentheses: - Exclude: - - 'forms/qae_form_builder/number_question.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/UnlessElse: - Exclude: - - 'app/controllers/accounts_controller.rb' diff --git a/Rakefile b/Rakefile index 384703b79d..da6bf45182 100644 --- a/Rakefile +++ b/Rakefile @@ -6,4 +6,4 @@ require File.expand_path("../config/application", __FILE__) Rails.application.load_tasks task(:default).clear -task :default => %w(spec) +task default: %w[spec] diff --git a/app/controllers/account/base_controller.rb b/app/controllers/account/base_controller.rb index e8fb5bcb8e..49a9e0a5bb 100644 --- a/app/controllers/account/base_controller.rb +++ b/app/controllers/account/base_controller.rb @@ -2,7 +2,9 @@ class Account::BaseController < ApplicationController before_action :authenticate_user! before_action :restrict_access_if_admin_in_read_only_mode! + # rubocop:disable Rails/LexicallyScopedActionFilter before_action :require_to_be_account_admin!, only: [ :new, :create, :update, :destroy ] + # rubocop:enable Rails/LexicallyScopedActionFilter end diff --git a/app/controllers/account/collaborators_controller.rb b/app/controllers/account/collaborators_controller.rb index 81bea3e72c..a8313d4dbe 100644 --- a/app/controllers/account/collaborators_controller.rb +++ b/app/controllers/account/collaborators_controller.rb @@ -19,7 +19,7 @@ class Account::CollaboratorsController < Account::BaseController AddCollaborator.new( current_user, account, - {},) + {}) end def index @@ -40,7 +40,7 @@ def create self.add_collaborator_interactor = AddCollaborator.new( current_user, account, - create_params,).run + create_params).run self.collaborator = add_collaborator_interactor.collaborator if add_collaborator_interactor.success? @@ -65,8 +65,7 @@ def update end end - def confirm_deletion - end + def confirm_deletion; end def destroy form_id = params[:form_id].presence diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 0fa195bb2c..cec972ed35 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -2,8 +2,7 @@ class AccountsController < ApplicationController before_action :authenticate_user! before_action :restrict_access_if_admin_in_read_only_mode! - def additional_contact_preferences - end + def additional_contact_preferences; end def correspondent_details @active_step = 1 @@ -22,8 +21,7 @@ def password_settings @active_step = 5 end - def useful_information - end + def useful_information; end def update_correspondent_details current_user.set_step(1) @@ -75,13 +73,13 @@ def update_additional_contact_preferences end def complete_registration - unless current_user.completed_registration + if current_user.completed_registration? + redirect_to password_settings_account_path + else current_user.update_attribute(:completed_registration, true) flash.notice = "Your account details were successfully saved" redirect_to dashboard_path - else - redirect_to password_settings_account_path end end diff --git a/app/controllers/admin/admins_controller.rb b/app/controllers/admin/admins_controller.rb index f4c6f75a67..10cadf06f0 100644 --- a/app/controllers/admin/admins_controller.rb +++ b/app/controllers/admin/admins_controller.rb @@ -81,6 +81,6 @@ def resource_params :password, :password_confirmation, :first_name, - :last_name,) + :last_name) end end diff --git a/app/controllers/admin/assessors_controller.rb b/app/controllers/admin/assessors_controller.rb index ffe60f0412..b232f3ddf1 100644 --- a/app/controllers/admin/assessors_controller.rb +++ b/app/controllers/admin/assessors_controller.rb @@ -215,6 +215,6 @@ def resource_params :innovation_role, :development_role, :mobility_role, - :promotion_role,) + :promotion_role) end end diff --git a/app/controllers/admin/collaborator_deletion_controller.rb b/app/controllers/admin/collaborator_deletion_controller.rb index 924773f14b..502583f4c8 100644 --- a/app/controllers/admin/collaborator_deletion_controller.rb +++ b/app/controllers/admin/collaborator_deletion_controller.rb @@ -1,6 +1,5 @@ class Admin::CollaboratorDeletionController < Admin::BaseController def destroy - form_id = params[:form_id].presence collaborator = User.find(params[:id]) account = collaborator.account diff --git a/app/controllers/admin/custom_emails_controller.rb b/app/controllers/admin/custom_emails_controller.rb index 0ab2afcb92..7b539f55d0 100644 --- a/app/controllers/admin/custom_emails_controller.rb +++ b/app/controllers/admin/custom_emails_controller.rb @@ -7,9 +7,9 @@ def show def create authorize :custom_email, :create? custom_email_form_attributes = if params[:custom_email_form].present? - params[:custom_email_form].merge(admin_id: current_admin.id) + params[:custom_email_form].merge(admin_id: current_admin.id) else - {} + {} end @form = CustomEmailForm.new(custom_email_form_attributes) diff --git a/app/controllers/admin/dashboard_reports_controller.rb b/app/controllers/admin/dashboard_reports_controller.rb index 0cf13ad21a..5520421bfc 100644 --- a/app/controllers/admin/dashboard_reports_controller.rb +++ b/app/controllers/admin/dashboard_reports_controller.rb @@ -63,6 +63,6 @@ def render_or_download_report award_type, kind, format end def permitted_kind_value - params[:kind] if params[:kind].presence.in?(%w(by_month by_week by_day)) + params[:kind] if params[:kind].presence.in?(%w[by_month by_week by_day]) end end diff --git a/app/controllers/admin/form_answers_controller.rb b/app/controllers/admin/form_answers_controller.rb index 95bae38848..002c56c741 100644 --- a/app/controllers/admin/form_answers_controller.rb +++ b/app/controllers/admin/form_answers_controller.rb @@ -1,6 +1,7 @@ class Admin::FormAnswersController < Admin::BaseController include FormAnswerMixin + # rubocop:disable Rails/LexicallyScopedActionFilter before_action :load_resource, only: [ :review, :show, @@ -8,6 +9,7 @@ class Admin::FormAnswersController < Admin::BaseController :update_financials, :remove_audit_certificate, ] + # rubocop:enable Rails/LexicallyScopedActionFilter skip_after_action :verify_authorized, only: [:awarded_trade_applications] @@ -15,7 +17,7 @@ class Admin::FormAnswersController < Admin::BaseController FinancialSummaryPointer.new(@form_answer, { exclude_ignored_questions: true, financial_summary_view: true, - },) + }) end expose(:target_scope) do diff --git a/app/controllers/admin/judges_controller.rb b/app/controllers/admin/judges_controller.rb index a38f4f8d7f..558eeba3a4 100644 --- a/app/controllers/admin/judges_controller.rb +++ b/app/controllers/admin/judges_controller.rb @@ -61,6 +61,6 @@ def resource_params :innovation_role, :development_role, :mobility_role, - :promotion_role,) + :promotion_role) end end diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb index 1ccd2dbf0f..2590ce3510 100644 --- a/app/controllers/admin/reports_controller.rb +++ b/app/controllers/admin/reports_controller.rb @@ -1,6 +1,6 @@ class Admin::ReportsController < Admin::BaseController expose(:import_csv_pdf_guide) do - File.open("#{Rails.root}/lib/assets/IMPORT_CSV_INTO_MS_EXCEL_GUIDE.pdf") + File.open(Rails.root.join("lib/assets/IMPORT_CSV_INTO_MS_EXCEL_GUIDE.pdf")) end def show @@ -47,7 +47,7 @@ def import_csv_into_ms_excel_guide_pdf def stream_csv headers["Content-Type"] = "text/csv; charset=utf-8" # In Rails 5 it's set to HTML?? - headers["Content-Disposition"] = %{attachment; filename="#{csv_filename}"} + headers["Content-Disposition"] = %(attachment; filename="#{csv_filename}") headers["X-Accel-Buffering"] = "no" headers["Cache-Control"] = "no-cache" diff --git a/app/controllers/admin/session_checks_controller.rb b/app/controllers/admin/session_checks_controller.rb index 5ba9cc8679..3774a22c0b 100644 --- a/app/controllers/admin/session_checks_controller.rb +++ b/app/controllers/admin/session_checks_controller.rb @@ -1,3 +1,4 @@ +# rubocop:disable Rails/ApplicationController class Admin::SessionChecksController < ActionController::Base include SessionStatusCheckMixin @@ -19,3 +20,4 @@ def namespace ADMIN_NAMESPACE end end +# rubocop:enable Rails/ApplicationController diff --git a/app/controllers/admin/users_reports_controller.rb b/app/controllers/admin/users_reports_controller.rb index 6df8624404..bb4a67f420 100644 --- a/app/controllers/admin/users_reports_controller.rb +++ b/app/controllers/admin/users_reports_controller.rb @@ -2,7 +2,7 @@ class Admin::UsersReportsController < Admin::BaseController def assessors_judges_admins_data authorize :reports, :show? - @report = Reports::Admin::AssessorJudgeAdminDataReport.new() + @report = Reports::Admin::AssessorJudgeAdminDataReport.new respond_to do |format| format.csv do diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d9fb469b87..23d6199f50 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,8 @@ require "app_responder" -include AuditHelper class ApplicationController < ActionController::Base + include AuditHelper + # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception, prepend: true @@ -44,7 +45,7 @@ def restrict_access_if_admin_in_read_only_mode! else render text: "You have no permissions!" end - return + nil end end @@ -62,7 +63,7 @@ def allow_assessor_access!(fa) else render text: "You have no permissions!" end - return false + false end end end @@ -79,14 +80,14 @@ def should_enable_js? end helper_method :should_enable_js? - %w(innovation trade mobility development).each do |award| - define_method "#{award}_submission_started?" do - public_send("#{award}_submission_started_deadline").passed? + %w[innovation trade mobility development].each do |award| + define_method :"#{award}_submission_started?" do + public_send(:"#{award}_submission_started_deadline").passed? end helper_method "#{award}_submission_started?" - define_method "#{award}_submission_started_deadline" do - Settings.public_send("current_#{award}_submission_start_deadline") + define_method :"#{award}_submission_started_deadline" do + Settings.public_send(:"current_#{award}_submission_start_deadline") end helper_method "#{award}_submission_started_deadline" end @@ -140,7 +141,7 @@ def log_event subject: current_subject, auditable: form_answer, action_type: action_type, - ) + ) end def current_subject @@ -204,7 +205,7 @@ def configure_permitted_parameters def check_account_completion if !current_user.completed_registration? redirect_to correspondent_details_account_path - return + nil end end @@ -232,10 +233,10 @@ def require_to_be_account_admin! end def load_award_year_and_settings - if params[:year] && AwardYear::AVAILABLE_YEARS.include?(params[:year].to_i) - @award_year = AwardYear.for_year(params[:year].to_i).first_or_create + @award_year = if params[:year] && AwardYear::AVAILABLE_YEARS.include?(params[:year].to_i) + AwardYear.for_year(params[:year].to_i).first_or_create else - @award_year = AwardYear.current + AwardYear.current end @settings = @award_year.settings diff --git a/app/controllers/assessor/form_answers_controller.rb b/app/controllers/assessor/form_answers_controller.rb index ebbfb043e9..4f04d3376f 100644 --- a/app/controllers/assessor/form_answers_controller.rb +++ b/app/controllers/assessor/form_answers_controller.rb @@ -1,13 +1,15 @@ class Assessor::FormAnswersController < Assessor::BaseController include FormAnswerMixin + # rubocop:disable Rails/LexicallyScopedActionFilter before_action :load_resource, only: [:update_financials] + # rubocop:enable Rails/LexicallyScopedActionFilter expose(:financial_pointer) do FinancialSummaryPointer.new(@form_answer, { exclude_ignored_questions: true, financial_summary_view: true, - },) + }) end helper_method :resource, @@ -22,7 +24,7 @@ def index params[:search] ||= { sort: "company_or_nominee_name", search_filter: { - status: FormAnswerStatus::AssessorFilter::checked_options.invert.values, + status: FormAnswerStatus::AssessorFilter.checked_options.invert.values, }, } params[:search].permit! diff --git a/app/controllers/assessor/session_checks_controller.rb b/app/controllers/assessor/session_checks_controller.rb index 9f56f9fc43..e1007544df 100644 --- a/app/controllers/assessor/session_checks_controller.rb +++ b/app/controllers/assessor/session_checks_controller.rb @@ -1,3 +1,4 @@ +# rubocop:disable Rails/ApplicationController class Assessor::SessionChecksController < ActionController::Base include SessionStatusCheckMixin @@ -19,3 +20,4 @@ def namespace ASSESSOR_NAMESPACE end end +# rubocop:enable Rails/ApplicationController diff --git a/app/controllers/concerns/admin_shortlisted_docs_submission_context.rb b/app/controllers/concerns/admin_shortlisted_docs_submission_context.rb index e4338c5d5b..50046b4a79 100644 --- a/app/controllers/concerns/admin_shortlisted_docs_submission_context.rb +++ b/app/controllers/concerns/admin_shortlisted_docs_submission_context.rb @@ -4,14 +4,12 @@ def create if resource.submitted? resource.uncomplete - else - if resource.complete - if form_answer.assessors.primary.present? - Assessors::GeneralMailer.vat_returns_submitted(form_answer.id).deliver_later! - end - - Users::CommercialFiguresMailer.notify(form_answer.id, form_answer.account.owner_id).deliver_later! + elsif resource.complete + if form_answer.assessors.primary.present? + Assessors::GeneralMailer.vat_returns_submitted(form_answer.id).deliver_later! end + + Users::CommercialFiguresMailer.notify(form_answer.id, form_answer.account.owner_id).deliver_later! end respond_to do |format| diff --git a/app/controllers/concerns/assessment_submission_mixin.rb b/app/controllers/concerns/assessment_submission_mixin.rb index b73e1b9efc..c7951b0083 100644 --- a/app/controllers/concerns/assessment_submission_mixin.rb +++ b/app/controllers/concerns/assessment_submission_mixin.rb @@ -1,4 +1,6 @@ module AssessmentSubmissionMixin + delegate :form_answer, to: :resource + def create authorize resource, :submit? @service = AssessmentSubmissionService.new(resource, current_subject) @@ -30,10 +32,6 @@ def action_type "#{appraisal_type}_#{appraisal_action}" end - def form_answer - resource.form_answer - end - private def flash_message diff --git a/app/controllers/concerns/assessor_assignment_context.rb b/app/controllers/concerns/assessor_assignment_context.rb index 84b861f299..e31ca182c4 100644 --- a/app/controllers/concerns/assessor_assignment_context.rb +++ b/app/controllers/concerns/assessor_assignment_context.rb @@ -9,8 +9,8 @@ def update format.json { render json: { errors: [] } } else format.json { - render status: :unprocessable_entity, - json: { errors: assessment.resource.errors } } + render status: :unprocessable_entity, json: { errors: assessment.resource.errors } + } Appsignal.send_error(Exception.new("Failed to save `AssessorAssignment##{assessor_assignment.id}. \n #{assessment.resource.errors} \n #{params}")) end diff --git a/app/controllers/concerns/audit_certificate_context.rb b/app/controllers/concerns/audit_certificate_context.rb index fc9cb09b4b..ee9f3d9ecd 100644 --- a/app/controllers/concerns/audit_certificate_context.rb +++ b/app/controllers/concerns/audit_certificate_context.rb @@ -9,7 +9,7 @@ def create audit_certificate = form_answer.build_audit_certificate(audit_certificate_params) - if saved = audit_certificate.save + if (saved = audit_certificate.save) log_event if form_answer.assessors.primary.present? @@ -28,8 +28,8 @@ def create format.js do render partial: "admin/form_answers/docs/post_shortlisting_docs", locals: { - resource: form_answer.decorate, - }, + resource: form_answer.decorate, + }, content_type: "text/plain" end else @@ -69,11 +69,7 @@ def audit_certificate_params # This is fix of "missing 'audit_certificate' param" # if no any was selected in file input if params[:audit_certificate].blank? - params.merge!( - audit_certificate: { - attachment: "", - }, - ) + params[:audit_certificate] = { attachment: "" } end params.require(:audit_certificate).permit(:attachment) diff --git a/app/controllers/concerns/form_answer_mixin.rb b/app/controllers/concerns/form_answer_mixin.rb index 7c297f4c42..6c09234c43 100644 --- a/app/controllers/concerns/form_answer_mixin.rb +++ b/app/controllers/concerns/form_answer_mixin.rb @@ -37,12 +37,11 @@ def update_financials if request.xhr? || request.format.js? head :ok, content_type: "text/html" - return else flash.notice = "Financial data updated" redirect_to action: :show - return end + nil end def show diff --git a/app/controllers/concerns/password_settable.rb b/app/controllers/concerns/password_settable.rb index 4e5068a858..c9fe3b63ed 100644 --- a/app/controllers/concerns/password_settable.rb +++ b/app/controllers/concerns/password_settable.rb @@ -3,7 +3,7 @@ def after_confirmation_path_for(resource_name, resource) if resource.encrypted_password.blank? token, encoded_token = Devise.token_generator.generate(resource.class, :reset_password_token) resource.update(reset_password_token: encoded_token, - reset_password_sent_at: Time.current,) + reset_password_sent_at: Time.current) password_reset_path(token) else diff --git a/app/controllers/concerns/session_status_check_mixin.rb b/app/controllers/concerns/session_status_check_mixin.rb index 3defce94a3..1db74e7a74 100644 --- a/app/controllers/concerns/session_status_check_mixin.rb +++ b/app/controllers/concerns/session_status_check_mixin.rb @@ -45,11 +45,11 @@ def now def elapsed session = if namespace == ADMIN_NAMESPACE - admin_session + admin_session elsif namespace == ASSESSOR_NAMESPACE - assessor_session + assessor_session elsif namespace == JUDGE_NAMESPACE - judge_session + judge_session end (now - (session["last_request_at"] || params["__t"].to_i)).to_i / 1.minute end diff --git a/app/controllers/concerns/support_letters_context.rb b/app/controllers/concerns/support_letters_context.rb index 7a1a2e2f68..a01ac35c2e 100644 --- a/app/controllers/concerns/support_letters_context.rb +++ b/app/controllers/concerns/support_letters_context.rb @@ -6,7 +6,7 @@ def show send_data support_letter_attachment.attachment.read, filename: support_letter_attachment.original_filename, disposition: "attachment" - return + nil else render "admin/support_letters/show" end diff --git a/app/controllers/content_only_controller.rb b/app/controllers/content_only_controller.rb index 21b132e40c..f6f1ad44af 100644 --- a/app/controllers/content_only_controller.rb +++ b/app/controllers/content_only_controller.rb @@ -18,6 +18,7 @@ class ContentOnlyController < ApplicationController :submitted_nomination_successful, ] + # rubocop:disable Rails/LexicallyScopedActionFilter before_action :get_current_form, only: [ :award_info_innovation, @@ -25,7 +26,9 @@ class ContentOnlyController < ApplicationController :award_info_development, :award_info_mobility, ] + # rubocop:enable Rails/LexicallyScopedActionFilter + # rubocop:disable Rails/LexicallyScopedActionFilter before_action :get_collaborators, only: [ :award_info_innovation, @@ -33,14 +36,14 @@ class ContentOnlyController < ApplicationController :award_info_development, :award_info_mobility, ] + # rubocop:enable Rails/LexicallyScopedActionFilter - before_action :restrict_access_if_admin_in_read_only_mode!, - only: [:dashboard] - + # rubocop:disable Rails/LexicallyScopedActionFilter + before_action :restrict_access_if_admin_in_read_only_mode!, only: [:dashboard] before_action :clean_flash, only: [:sign_up_complete] - before_action :check_trade_count_limit, only: :apply_international_trade_award before_action :check_development_count_limit, only: :apply_sustainable_development_award + # rubocop:enable Rails/LexicallyScopedActionFilter expose(:form_answer) do current_user.form_answers.find(params[:id]) diff --git a/app/controllers/form/awards_controller.rb b/app/controllers/form/awards_controller.rb index d07959dfe7..892cdd899f 100644 --- a/app/controllers/form/awards_controller.rb +++ b/app/controllers/form/awards_controller.rb @@ -44,13 +44,12 @@ class Form::AwardsController < Form::NonJsDynamicListsFormSectionController ) end - def new - end + def new; end def create self.item = item_class.new(question, params[:holder], - item_params,) + item_params) if item.valid? @form_answer.document = add_result_doc @@ -69,7 +68,7 @@ def create def confirm_deletion self.item = item_class.new(question, params[:holder], - item_params,) + item_params) end def destroy @@ -86,13 +85,13 @@ def destroy def edit self.item = item_class.new(question, params[:holder], - item_params,) + item_params) end def update self.item = item_class.new(question, params[:holder], - item_params,) + item_params) if item.valid? @form_answer.document = update_result_doc diff --git a/app/controllers/form/base_controller.rb b/app/controllers/form/base_controller.rb index 2df44492dc..4f01657b36 100644 --- a/app/controllers/form/base_controller.rb +++ b/app/controllers/form/base_controller.rb @@ -1,9 +1,11 @@ class Form::BaseController < ApplicationController before_action :authenticate_user! + # rubocop:disable Rails/LexicallyScopedActionFilter before_action :restrict_access_if_admin_in_read_only_mode!, only: [ :new, :create, :update, :destroy ] + # rubocop:enable Rails/LexicallyScopedActionFilter before_action :load_form_answer diff --git a/app/controllers/form/current_queens_awards_controller.rb b/app/controllers/form/current_queens_awards_controller.rb index 9bcccff03f..99f6a839ba 100644 --- a/app/controllers/form/current_queens_awards_controller.rb +++ b/app/controllers/form/current_queens_awards_controller.rb @@ -57,14 +57,13 @@ class Form::CurrentQueensAwardsController < Form::NonJsDynamicListsFormSectionCo ) end - def new - end + def new; end def create self.item = item_class.new(categories, years, outcomes, - item_params,) + item_params) if item.valid? @form_answer.document = add_result_doc @@ -84,7 +83,7 @@ def confirm_deletion self.item = item_class.new(categories, years, [], - item_params,) + item_params) end def destroy @@ -102,14 +101,14 @@ def edit self.item = item_class.new(categories, years, outcomes, - item_params,) + item_params) end def update self.item = item_class.new(categories, years, outcomes, - item_params,) + item_params) if item.valid? @form_answer.document = update_result_doc diff --git a/app/controllers/form/form_attachments_controller.rb b/app/controllers/form/form_attachments_controller.rb index f2a28e4492..79f6d30bba 100644 --- a/app/controllers/form/form_attachments_controller.rb +++ b/app/controllers/form/form_attachments_controller.rb @@ -44,11 +44,9 @@ class Form::FormAttachmentsController < Form::MaterialsBaseController ) end - def index - end + def index; end - def new - end + def new; end def create self.form_answer_attachment = current_user.form_answer_attachments.new( @@ -70,7 +68,7 @@ def create end def confirm_deletion - self.form_answer_attachment = self.form_answer_attachments.find(params[:form_attachment_id]) + self.form_answer_attachment = form_answer_attachments.find(params[:form_attachment_id]) end def destroy diff --git a/app/controllers/form/form_links_controller.rb b/app/controllers/form/form_links_controller.rb index 3c6c888739..d46b95f42c 100644 --- a/app/controllers/form/form_links_controller.rb +++ b/app/controllers/form/form_links_controller.rb @@ -34,8 +34,7 @@ class Form::FormLinksController < Form::MaterialsBaseController ) end - def new - end + def new; end def create self.form_link = FormLink.new(link_params) diff --git a/app/controllers/form/materials_base_controller.rb b/app/controllers/form/materials_base_controller.rb index f98710d7dc..7192ea5b22 100644 --- a/app/controllers/form/materials_base_controller.rb +++ b/app/controllers/form/materials_base_controller.rb @@ -19,7 +19,9 @@ class Form::MaterialsBaseController < Form::BaseController existing_materials.keys.map(&:to_i).max.to_i + 1 end + # rubocop:disable Rails/LexicallyScopedActionFilter before_action :check_materials_limit, only: [:create] + # rubocop:enable Rails/LexicallyScopedActionFilter private @@ -27,7 +29,7 @@ def check_materials_limit if existing_materials.count >= MAX_ATTACHMENTS redirect_to form_form_answer_form_attachments_url(@form_answer), alert: "You can add up to #{MAX_ATTACHMENTS} files or website addresses as maximum!" - return + nil end end end diff --git a/app/controllers/form/organisational_charts_controller.rb b/app/controllers/form/organisational_charts_controller.rb index 2ff15d8b9d..7f8b97cc0f 100644 --- a/app/controllers/form/organisational_charts_controller.rb +++ b/app/controllers/form/organisational_charts_controller.rb @@ -49,8 +49,7 @@ class Form::OrganisationalChartsController < Form::MaterialsBaseController "header_org_chart" end - def new - end + def new; end def create self.form_answer_attachment = current_user.form_answer_attachments.new( diff --git a/app/controllers/form/positions_controller.rb b/app/controllers/form/positions_controller.rb index 9c466981b8..40006a5da2 100644 --- a/app/controllers/form/positions_controller.rb +++ b/app/controllers/form/positions_controller.rb @@ -38,11 +38,9 @@ class Form::PositionsController < Form::NonJsDynamicListsFormSectionController } end - def index - end + def index; end - def new - end + def new; end def create self.item = item_class.new(item_params) diff --git a/app/controllers/form/subsidiaries_controller.rb b/app/controllers/form/subsidiaries_controller.rb index 3adfe1f4ae..8b63e885ac 100644 --- a/app/controllers/form/subsidiaries_controller.rb +++ b/app/controllers/form/subsidiaries_controller.rb @@ -45,8 +45,7 @@ class Form::SubsidiariesController < Form::NonJsDynamicListsFormSectionControlle ) end - def new - end + def new; end def create self.item = item_class.new(item_params) diff --git a/app/controllers/form/support_letters_controller.rb b/app/controllers/form/support_letters_controller.rb index b9bfccc1c0..1c21e444ca 100644 --- a/app/controllers/form/support_letters_controller.rb +++ b/app/controllers/form/support_letters_controller.rb @@ -74,7 +74,7 @@ def add_support_letter_to_document! letters << new_letter @form_answer.document = @form_answer.document.merge(supporter_letters_list: letters, - manually_upload: "yes",) + manually_upload: "yes") end def remove_support_letter_from_document! diff --git a/app/controllers/form_award_eligibilities_controller.rb b/app/controllers/form_award_eligibilities_controller.rb index 244e80fa66..6ad0be2727 100644 --- a/app/controllers/form_award_eligibilities_controller.rb +++ b/app/controllers/form_award_eligibilities_controller.rb @@ -1,22 +1,23 @@ class FormAwardEligibilitiesController < ApplicationController include Wicked::Wizard - before_action :authenticate_user!, :check_account_completion, - :check_number_of_collaborators + before_action :authenticate_user!, :check_account_completion, :check_number_of_collaborators before_action :set_form_answer before_action :set_steps_and_eligibilities, :setup_wizard + + # rubocop:disable Rails/LexicallyScopedActionFilter before_action :restrict_access_if_admin_in_read_only_mode!, only: [ :new, :create, :update, :destroy ] + # rubocop:enable Rails/LexicallyScopedActionFilter + before_action do allow_assessor_access!(@form_answer) end def show - # if award eligibility is not passed - # and there's no basic eligibility - # or basic eligibility is not eligible - # and there's no step + # if award eligibility is not passed and there's no basic eligibility + # or basic eligibility is not eligible and there's no step if !params[:id] && (@form_answer.promotion? || @@ -81,7 +82,7 @@ def update redirect_to action: :show, form_id: @form_answer.id end - return + nil else render :show end @@ -91,10 +92,10 @@ def result if @form_answer.eligible? redirect_to edit_form_url(@form_answer) else - redirect_to public_send("#{@form_answer.award_type}_award_eligible_failure_path", form_id: @form_answer.id) + redirect_to public_send(:"#{@form_answer.award_type}_award_eligible_failure_path", form_id: @form_answer.id) end - return + nil end def warning diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index 6dc7b84c5c..e065082711 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -6,9 +6,12 @@ class FormController < ApplicationController before_action :authenticate_user! before_action :check_account_completion, :check_number_of_collaborators, unless: -> { admin_signed_in? || assessor_signed_in? } before_action :check_deadlines + + # rubocop:disable Rails/LexicallyScopedActionFilter before_action :restrict_access_if_admin_in_read_only_mode!, only: [ :new, :create, :update, :destroy, :submit_confirm, :save, :add_attachment ] + # rubocop:enable Rails/LexicallyScopedActionFilter before_action :check_trade_deadline, :check_trade_count_limit, only: :new_international_trade_form before_action :check_development_deadline, :check_development_count_limit, only: :new_sustainable_development_form @@ -22,11 +25,9 @@ class FormController < ApplicationController :new_social_mobility_form, ] - before_action :get_collaborators, only: [ - :submit_confirm, - ] + # rubocop:disable Rails/LexicallyScopedActionFilter + before_action :get_collaborators, only: [:submit_confirm] before_action :check_if_deadline_ended!, only: [:update, :save, :add_attachment] - before_action :check_eligibility!, only: [ :create, :destroy, @@ -35,16 +36,14 @@ class FormController < ApplicationController :add_attachment, :submit_confirm, ] + # rubocop:enable Rails/LexicallyScopedActionFilter before_action do allow_assessor_access!(@form_answer) end expose(:support_letter_attachments) do - @form_answer.support_letter_attachments.inject({}) do |r, attachment| - r[attachment.id] = attachment - r - end + @form_answer.support_letter_attachments.index_by(&:id) end expose(:all_form_questions) do @@ -149,28 +148,24 @@ def save if redirected @form_answer.save(validate: false) redirect_to(dashboard_url) - else - if submitted && saved - redirect_to submit_confirm_url(@form_answer) + elsif submitted && saved + redirect_to submit_confirm_url(@form_answer) + elsif saved + if @form_answer.halted? + params[:next_step] = params[:current_step] else - if saved - if @form_answer.halted? - params[:next_step] = params[:current_step] - else - params[:next_step] ||= @form.steps[1].title.parameterize - end - - redirect_to edit_form_url(@form_answer, step: params[:next_step]) - else - params[:step] = @form_answer.steps_with_errors.try(:first) - # avoid redirecting to supporters page - if !params[:step] || params[:step] == "letters-of-support" - params[:step] = @form.steps.first.title.parameterize - end - - render template: "qae_form/show" - end + params[:next_step] ||= @form.steps[1].title.parameterize end + + redirect_to edit_form_url(@form_answer, step: params[:next_step]) + else + params[:step] = @form_answer.steps_with_errors.try(:first) + # avoid redirecting to supporters page + if !params[:step] || params[:step] == "letters-of-support" + params[:step] = @form.steps.first.title.parameterize + end + + render template: "qae_form/show" end end @@ -201,9 +196,9 @@ def submit_confirm def add_attachment FormAnswer.transaction do attachment_params = params[:form] - attachment_params.merge!(form_answer_id: @form_answer.id) + attachment_params[:form_answer_id] = @form_answer.id - attachment_params.merge!(original_filename: attachment_params[:file].original_filename) if attachment_params[:file].respond_to?(:original_filename) + attachment_params[:original_filename] = attachment_params[:file].original_filename if attachment_params[:file].respond_to?(:original_filename) attachment_params = attachment_params.permit(:original_filename, :file, :description, :link, :form_answer_id) @@ -239,7 +234,7 @@ def get_collaborators def next_index(hash) return 0 if hash.empty? - return hash.keys.sort.last.to_i + 1 + hash.keys.max.to_i + 1 end def updating_step @@ -293,11 +288,7 @@ def build_new_form(award_type) def set_form_answer @form_answer = current_user.account.form_answers.find(params[:id]) - - @attachments = @form_answer.form_answer_attachments.inject({}) do |r, attachment| - r[attachment.id] = attachment - r - end + @attachments = @form_answer.form_answer_attachments.index_by(&:id) end def nickname @@ -313,11 +304,11 @@ def check_deadlines end end - %w(innovation trade mobility development).each do |award| - define_method "check_#{award}_deadline" do + %w[innovation trade mobility development].each do |award| + define_method :"check_#{award}_deadline" do return if admin_in_read_only_mode? - unless public_send("#{award}_submission_started?") + unless public_send(:"#{award}_submission_started?") flash.alert = "Sorry, submission is still closed" redirect_to dashboard_url end @@ -337,7 +328,7 @@ def check_if_deadline_ended! notice: "Form can't be updated as submission ended!" end - return false + false end end @@ -352,7 +343,7 @@ def humanized_upload_errors def check_eligibility! if @form_answer.eligibility.present? && !this_form_eligible? redirect_to form_award_eligibility_url(form_id: @form_answer.id, force_validate_now: true) - return false + false end end diff --git a/app/controllers/judge/session_checks_controller.rb b/app/controllers/judge/session_checks_controller.rb index ad9a5b962c..099bf7e884 100644 --- a/app/controllers/judge/session_checks_controller.rb +++ b/app/controllers/judge/session_checks_controller.rb @@ -1,3 +1,4 @@ +# rubocop:disable Rails/ApplicationController class Judge::SessionChecksController < ActionController::Base include SessionStatusCheckMixin @@ -19,3 +20,4 @@ def namespace JUDGE_NAMESPACE end end +# rubocop:enable Rails/ApplicationController diff --git a/app/controllers/palace_invites_controller.rb b/app/controllers/palace_invites_controller.rb index 7555534b94..321aa9dae3 100644 --- a/app/controllers/palace_invites_controller.rb +++ b/app/controllers/palace_invites_controller.rb @@ -7,13 +7,12 @@ def update if palace_invite_attributes.present? && @invite_form.update(palace_invite_attributes.to_h.merge({ submitted: params[:submit].present? })) log_event - if @invite.submitted? - flash.notice = "Windsor Castle Attendee details have been successfully submitted." - redirect_to edit_palace_invite_url(id: @invite.token) + flash.notice = if @invite.submitted? + "Windsor Castle Attendee details have been successfully submitted." else - flash.notice = "Windsor Castle Attendee details have been successfully updated." - redirect_to edit_palace_invite_url(id: @invite.token) + "Windsor Castle Attendee details have been successfully updated." end + redirect_to edit_palace_invite_url(id: @invite.token) else render :edit end @@ -58,7 +57,7 @@ def require_palace_invite_to_be_not_submitted_and_proper_stage! flash.notice = "Access denied!" redirect_to dashboard_url - return + nil end end @@ -68,7 +67,7 @@ def check_reception_attendee_information_deadline! redirect_to palace_invite_expired_url(id: @invite.token) - return + nil end def action_type diff --git a/app/controllers/support_letters_controller.rb b/app/controllers/support_letters_controller.rb index 5a8bfd02be..5066dc427e 100644 --- a/app/controllers/support_letters_controller.rb +++ b/app/controllers/support_letters_controller.rb @@ -32,7 +32,7 @@ def load_letter_and_check_access_key if supporter.support_letter && supporter.support_letter.persisted? && action_name != "show" redirect_to support_letter_path(access_key: supporter.access_key), notice: "Support Letter has been submitted already!" - return + nil end else head 404 diff --git a/app/controllers/users/actual_figures_controller.rb b/app/controllers/users/actual_figures_controller.rb index 0789062a2b..436038d147 100644 --- a/app/controllers/users/actual_figures_controller.rb +++ b/app/controllers/users/actual_figures_controller.rb @@ -11,7 +11,7 @@ def create @actual_figures = figures_wrapper.build_commercial_figures_file(commercial_figures_file_params) @actual_figures.form_answer = form_answer - if saved = @actual_figures.save + if (saved = @actual_figures.save) log_event end @@ -39,11 +39,7 @@ def commercial_figures_file_params # This is fix of "missing 'audit_certificate' param" # if no any was selected in file input if params[:commercial_figures_file].blank? - params.merge!( - commercial_figures_file: { - attachment: "", - }, - ) + params[:commercial_figures_file] = { attachment: "" } end params.require(:commercial_figures_file).permit(:attachment) diff --git a/app/controllers/users/audit_certificates_controller.rb b/app/controllers/users/audit_certificates_controller.rb index a9a00fcaae..fe6265054c 100644 --- a/app/controllers/users/audit_certificates_controller.rb +++ b/app/controllers/users/audit_certificates_controller.rb @@ -32,7 +32,7 @@ def show def create self.audit_certificate = form_answer.build_audit_certificate(audit_certificate_params) - if saved = audit_certificate.save + if (saved = audit_certificate.save) log_event if form_answer.assessors.primary.present? Assessors::GeneralMailer.audit_certificate_uploaded(form_answer.id).deliver_later! @@ -88,11 +88,7 @@ def audit_certificate_params # This is fix of "missing 'audit_certificate' param" # if no any was selected in file input if params[:audit_certificate].blank? - params.merge!( - audit_certificate: { - attachment: "", - }, - ) + params[:audit_certificate] = { attachment: "" } end params.require(:audit_certificate).permit(:attachment) @@ -109,14 +105,14 @@ def humanized_errors def check_if_audit_certificate_already_exist! if audit_certificate.present? && audit_certificate.persisted? head :ok - return + nil end end def check_if_vocf_is_required! unless form_answer.requires_vocf? redirect_to dashboard_url - return + nil end end end diff --git a/app/controllers/users/base_controller.rb b/app/controllers/users/base_controller.rb index 7b5e7646e8..4b9cfed391 100644 --- a/app/controllers/users/base_controller.rb +++ b/app/controllers/users/base_controller.rb @@ -1,7 +1,9 @@ class Users::BaseController < ApplicationController before_action :authenticate_user! + # rubocop:disable Rails/LexicallyScopedActionFilter before_action :restrict_access_if_admin_in_read_only_mode!, only: [ :new, :create, :update, :destroy ] + # rubocop:enable Rails/LexicallyScopedActionFilter end diff --git a/app/controllers/users/collaborator_access_controller.rb b/app/controllers/users/collaborator_access_controller.rb index c7e21ec834..52e78e4ce8 100644 --- a/app/controllers/users/collaborator_access_controller.rb +++ b/app/controllers/users/collaborator_access_controller.rb @@ -20,7 +20,7 @@ def auth section: params[:section], joined_at: params[:timestamp], }, - }, + } ) render( diff --git a/app/controllers/users/confirmations_controller.rb b/app/controllers/users/confirmations_controller.rb index 46850537e6..2bcffca536 100644 --- a/app/controllers/users/confirmations_controller.rb +++ b/app/controllers/users/confirmations_controller.rb @@ -10,9 +10,9 @@ def show if resource.errors.empty? set_flash_message!(:success, :confirmed) - respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) } + respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) } else - respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new } + respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new } end end diff --git a/app/controllers/users/form_answer_feedbacks_controller.rb b/app/controllers/users/form_answer_feedbacks_controller.rb index 2fffd5a9b0..6bd856f111 100644 --- a/app/controllers/users/form_answer_feedbacks_controller.rb +++ b/app/controllers/users/form_answer_feedbacks_controller.rb @@ -37,15 +37,15 @@ def require_logged_in_user! session[:custom_redirect] = users_form_answer_feedback_url(params[:id], format: :pdf) redirect_to new_user_session_url - return false + false end end def require_application_to_have_a_feedback! - unless form_answer.feedback.present? + if form_answer.feedback.blank? redirect_to dashboard_url, notice: "There are no any feedback for this application!" - return false + false end end end diff --git a/app/controllers/users/form_answers_controller.rb b/app/controllers/users/form_answers_controller.rb index caca1614a4..9fca28bb9f 100644 --- a/app/controllers/users/form_answers_controller.rb +++ b/app/controllers/users/form_answers_controller.rb @@ -72,14 +72,12 @@ def can_render_pdf_on_fly? def render_hard_copy_pdf if form_answer.pdf_version.present? redirect_to form_answer.pdf_version.url, allow_other_host: true + elsif !admin_in_read_only_mode? + redirect_to dashboard_path, + notice: "PDF version for your application is not available!" else - if !admin_in_read_only_mode? - redirect_to dashboard_path, - notice: "PDF version for your application is not available!" - else - flash[:notice] = "PDF version for your application is not available!" - redirect_back(fallback_location: root_path) - end + flash[:notice] = "PDF version for your application is not available!" + redirect_back(fallback_location: root_path) end end end diff --git a/app/controllers/users/press_summaries_controller.rb b/app/controllers/users/press_summaries_controller.rb index 0a04faa272..6f14fe4d04 100644 --- a/app/controllers/users/press_summaries_controller.rb +++ b/app/controllers/users/press_summaries_controller.rb @@ -2,10 +2,11 @@ class Users::PressSummariesController < Users::BaseController skip_before_action :authenticate_user!, raise: false before_action :check_deadline, :load_press_summary, except: [:success, :failure] - before_action :check_promotion_award_acceptance, - except: [:acceptance, :update_acceptance, :success, :failure] + # rubocop:disable Rails/LexicallyScopedActionFilter + before_action :check_promotion_award_acceptance, except: [:acceptance, :update_acceptance, :success, :failure] before_action :require_press_summary_to_be_valid!, only: [:show, :update] + # rubocop:enable Rails/LexicallyScopedActionFilter expose(:form_answer) do FormAnswer.find(params[:form_answer_id]) @@ -96,7 +97,7 @@ def require_press_summary_to_be_valid! if !@press_summary.submitted? || @press_summary.applicant_submitted? redirect_to dashboard_url, notice: "Press Summary can't be updated!" - return + nil end end end diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 9c5ecbfcc2..04a05f2aa6 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -1,7 +1,9 @@ class Users::RegistrationsController < Devise::RegistrationsController + # rubocop:disable Rails/LexicallyScopedActionFilter before_action :restrict_access_if_admin_in_read_only_mode!, only: [ :update, :destroy ] + # rubocop:enable Rails/LexicallyScopedActionFilter protected diff --git a/app/controllers/users/vat_returns_controller.rb b/app/controllers/users/vat_returns_controller.rb index 1a0fa3f12b..c9942bdf82 100644 --- a/app/controllers/users/vat_returns_controller.rb +++ b/app/controllers/users/vat_returns_controller.rb @@ -11,7 +11,7 @@ def create @vat_returns = figures_wrapper.vat_returns_files.new(vat_returns_file_params) @vat_returns.form_answer = form_answer - if saved = @vat_returns.save + if (saved = @vat_returns.save) log_event end @@ -39,11 +39,7 @@ def vat_returns_file_params # This is fix of "missing 'audit_certificate' param" # if no any was selected in file input if params[:vat_returns_file].blank? - params.merge!( - vat_returns_file: { - attachment: "", - }, - ) + params[:vat_returns_file] = { attachment: "" } end params.require(:vat_returns_file).permit(:attachment) diff --git a/app/decorators/assessor_assignment_decorator.rb b/app/decorators/assessor_assignment_decorator.rb index 641a330d65..e872afc7e6 100644 --- a/app/decorators/assessor_assignment_decorator.rb +++ b/app/decorators/assessor_assignment_decorator.rb @@ -3,10 +3,10 @@ def last_editor_info return unless object.assessed_at editor = object.editable if editor - if editor.first_name.present? && editor.last_name.present? - name = "#{editor.first_name} #{editor.last_name}" + name = if editor.first_name.present? && editor.last_name.present? + "#{editor.first_name} #{editor.last_name}" else - name = "Anonymous" + "Anonymous" end "Updated by #{name} - #{l object.assessed_at, format: :date_at_time}" diff --git a/app/decorators/form_answer_decorator.rb b/app/decorators/form_answer_decorator.rb index e1e8eba0f3..9e8aab9506 100644 --- a/app/decorators/form_answer_decorator.rb +++ b/app/decorators/form_answer_decorator.rb @@ -11,6 +11,8 @@ class FormAnswerDecorator < ApplicationDecorator NOT_ASSIGNED = "Not Assigned" ASSESSORS_NOT_ASSIGNED = "Assessors are not assigned" + delegate :company_or_nominee_name, to: :object + def pdf_generator(pdf_blank_mode = false) "QaePdfForms::Awards2016::#{object.award_type.capitalize}::Base".constantize.new(object, pdf_blank_mode) end @@ -40,7 +42,7 @@ def download_filename def pdf_filename timestamp = Time.zone.now.strftime("%d-%m-%Y_%-l-%M%P") - "#{object.award_type_full_name.gsub(" ", "_")}_Award_#{timestamp}.pdf" + "#{object.award_type_full_name.tr(" ", "_")}_Award_#{timestamp}.pdf" end def csv_filename @@ -67,16 +69,12 @@ def award_application_title_print "The King's Awards for Enterprise: #{object.award_type_full_name} #{object.award_year.try(:year)}" end - def company_or_nominee_name - object.company_or_nominee_name - end - def company_nominee_or_application_name company_or_nominee_name || application_name end def data - #object.document + # object.document OpenStruct.new(object.document.merge(persisted?: true)) end @@ -112,14 +110,14 @@ def data_attributes=(attributes) old_array << value end end - old_array.reject!{ |i| i.include? "_destroy" } + old_array.reject! { |i| i.include? "_destroy" } end end end end def array_keys - object.document.select{ |item, value| value.kind_of?(Array) }.keys + object.document.select { |item, value| value.is_a?(Array) }.keys end def company_name @@ -127,7 +125,7 @@ def company_name end def nominee_title - object.nominee_title ? object.nominee_title : document["nominee_title"] + object.nominee_title || document["nominee_title"] end def progress_class @@ -135,11 +133,11 @@ def progress_class end def state_text - I18n.t(object.state.to_s, scope: "form_answers.state") + h.t(object.state.to_s, scope: "form_answers.state") end def state_short_text - I18n.t(object.state.to_s, scope: "form_answers.state_short").html_safe + h.t("#{object.state}_html", scope: "form_answers.state_short") end def progress_text_short @@ -181,8 +179,7 @@ def corp_responsibility_required_keys step.short_title == "Declaration of Corporate Responsibility" end.questions.select do |q| q.is_a?(QaeFormBuilder::TextareaQuestion) && q.required - end.map(&:key) - .map(&:to_s) + end.map { |x| x.key.to_s } end def corp_responsibility_missing? @@ -398,7 +395,7 @@ def ultimate_control_company_country end def innovation_desc_short - sanitize_html document["innovation_desc_short"] + sanitize_html document["innovation_desc_short"] end def development_desc_short @@ -450,13 +447,13 @@ def goods_and_services def application_background app_background = case award_type when "trade" - document["trade_goods_briefly"] + document["trade_goods_briefly"] when "innovation" - document["innovation_desc_short"] + document["innovation_desc_short"] when "development" - document["development_management_approach_briefly"] + document["development_management_approach_briefly"] when "mobility" - document["mobility_desc_short"] + document["mobility_desc_short"] end sanitize_html app_background @@ -473,6 +470,7 @@ def show_this_entry_relates_to_question? (!development? || year < 2020) && (!mobility? || year < 2020) end + def this_entry_relates_to source_value = if document["application_relate_to"].present? document["application_relate_to"] diff --git a/app/decorators/paginating_decorator.rb b/app/decorators/paginating_decorator.rb index fe7f29d2ac..405e354de4 100644 --- a/app/decorators/paginating_decorator.rb +++ b/app/decorators/paginating_decorator.rb @@ -2,4 +2,4 @@ class PaginatingDecorator < Draper::CollectionDecorator delegate :current_page, :total_pages, :limit_value -end \ No newline at end of file +end diff --git a/app/decorators/trigger_at_decorator.rb b/app/decorators/trigger_at_decorator.rb index 35341672f9..1357635b80 100644 --- a/app/decorators/trigger_at_decorator.rb +++ b/app/decorators/trigger_at_decorator.rb @@ -9,7 +9,11 @@ def formatted_trigger_time(format = { bold: true }) trigger_at = "midday" if midday? if format[:bold] - h.tag.strong(trigger_on) + " at #{trigger_at}".html_safe + h.capture do + h.concat(h.tag.strong(trigger_on)) + h.concat(" at ") + h.concat(trigger_at) + end else "#{trigger_on} at #{trigger_at}" end @@ -25,7 +29,7 @@ def formatted_trigger_date(format = nil) return date_placeholder unless object.trigger_at str_format = "#{object.trigger_at.day.ordinalize} %B" - str_format = str_format + " %Y" if format.present? && format == "with_year" + str_format += " %Y" if format.present? && format == "with_year" object.trigger_at.strftime(str_format) end @@ -39,11 +43,14 @@ def formatted_trigger_day private def placeholder - "-- --- #{AwardYear.current.year} at --:--".html_safe + h.capture do + h.concat(h.tag.strong("-- --- #{AwardYear.current.year}")) + h.concat(" at --:--") + end end def date_placeholder - "-- --- #{AwardYear.current.year}".html_safe + h.tag.strong("-- --- #{AwardYear.current.year}") end def midday? diff --git a/app/form_pointers/financial_summary_pointer.rb b/app/form_pointers/financial_summary_pointer.rb index 08743c4f81..6afbc82a28 100644 --- a/app/form_pointers/financial_summary_pointer.rb +++ b/app/form_pointers/financial_summary_pointer.rb @@ -22,7 +22,7 @@ def fill_missing_fields(input) cloned = input.deep_dup - result = cloned.each_with_object([]) do |h, memo| + cloned.each_with_object([]) do |h, memo| key, values = h.keys[0], h.values[0] if values.length == minmax[:max] @@ -32,11 +32,9 @@ def fill_missing_fields(input) cloned = case values[0] when Hash - values[0].transform_values { |_v| nil } + values[0].transform_values { |_v| nil } when Array - [] - else - nil + [] end diff = ::Utils::Diff.calc(minmax[:min], minmax[:max]) @@ -44,16 +42,14 @@ def fill_missing_fields(input) memo << Hash[key, values] end - - result end def fill_missing_dates input = data.group_by do |x| - partitioned_hash.values.each_with_object(Hash[]).with_index do |(x, acc), idx| - x.each { |y| acc[y] = idx } - end.fetch(x.keys[0], 0) - end + partitioned_hash.values.each_with_object(Hash[]).with_index do |(x, acc), idx| + x.each { |y| acc[y] = idx } + end.fetch(x.keys[0], 0) + end dates, dates_changed = fetch_financial_year_dates @@ -102,9 +98,9 @@ def fill_missing_dates def fetch_financial_year_dates @_financial_year_dates ||= begin dates, changed = if data_values(:financial_year_changed_dates).present? - [financial_year_changed_dates, true] + [financial_year_changed_dates, true] else - [financial_year_dates, false] + [financial_year_dates, false] end [dates, changed] diff --git a/app/form_pointers/financial_table.rb b/app/form_pointers/financial_table.rb index 1e72652cdd..0a5ebcf72e 100644 --- a/app/form_pointers/financial_table.rb +++ b/app/form_pointers/financial_table.rb @@ -30,15 +30,17 @@ def financial_table_changed_dates_headers res.shift(diff.abs) if diff.negative? - diff.times do - date_to_calculate_from = res.first - if Utils::Date.valid?(date_to_calculate_from) - date = Date.parse(date_to_calculate_from).years_ago(1).strftime("%d/%m/%Y") - res.unshift(date) - else - res.unshift(nil) + if diff.positive? + diff.times do + date_to_calculate_from = res.first + if Utils::Date.valid?(date_to_calculate_from) + date = Date.parse(date_to_calculate_from).years_ago(1).strftime("%d/%m/%Y") + res.unshift(date) + else + res.unshift(nil) + end end - end if diff.positive? + end end if res.any?(&:present?) @@ -55,7 +57,7 @@ def correct_date_headers(res) # Probably better just to check if date is valid and only then push as correct one # Should help to avoid all that weirdness when trying to display invalid dates # - corrected_result = res.each_with_object([]) do |entry, memo| + res.each_with_object([]) do |entry, memo| memo << if ::Utils::Date.valid?(entry) Date.parse(entry).strftime("%d/%m/%Y") else @@ -141,18 +143,18 @@ def financial_date_pointer_value def financial_years_number @financial_years_number ||= if financial_date_selector_value.present? - if one_option_question_or_development? - "3" - elsif form_answer.innovation? - innovation_years_number - else - financial_date_selector.ops_values[financial_date_selector_value] - end + if one_option_question_or_development? + "3" + elsif form_answer.innovation? + innovation_years_number + else + financial_date_selector.ops_values[financial_date_selector_value] + end elsif financial_pointer.period_length.present? && financial_pointer.period_length > 0 - financial_pointer.period_length + financial_pointer.period_length else - # If not selected yet, render last option as default - financial_date_selector.ops_values.values.last + # If not selected yet, render last option as default + financial_date_selector.ops_values.values.last end end @@ -173,13 +175,13 @@ def innovation_years_number form = question.form years = 5 + # rubocop:disable Lint/EnsureReturn begin result = question.by_year_conditions.find do |c| - date = [] q = form[c.question_key] - q.required_sub_fields.each do |sub| - date << doc.dig("#{q.key}_#{sub.keys[0]}") + date = q.required_sub_fields.map do |sub| + doc.dig("#{q.key}_#{sub.keys[0]}") end date = Date.parse(date.join("/")) @@ -193,5 +195,6 @@ def innovation_years_number ensure return years.to_s end + # rubocop:enable Lint/EnsureReturn end end diff --git a/app/form_pointers/financial_year_pointer.rb b/app/form_pointers/financial_year_pointer.rb index 0b2725b51a..789e1102d4 100644 --- a/app/form_pointers/financial_year_pointer.rb +++ b/app/form_pointers/financial_year_pointer.rb @@ -7,7 +7,7 @@ class FinancialYearPointer def initialize(ops = {}) ops.each do |k, v| - instance_variable_set("@#{k}", v) + instance_variable_set(:"@#{k}", v) end @key = question.key @@ -70,7 +70,7 @@ def active_fields end def entries - question.active_fields[0..-1].map do |field| + question.active_fields.map do |field| FormFinancialPointer::YEAR_LABELS.map do |year_label| entry(field, year_label) end diff --git a/app/form_pointers/form_answers_base_pointer.rb b/app/form_pointers/form_answers_base_pointer.rb index 7be6a47449..7953ba4d80 100644 --- a/app/form_pointers/form_answers_base_pointer.rb +++ b/app/form_pointers/form_answers_base_pointer.rb @@ -17,7 +17,7 @@ module FormAnswersBasePointer def fetch_answers(pdf_blank_mode = false) doc = pdf_blank_mode.present? ? {} : form_answer.document ActiveSupport::HashWithIndifferentAccess.new(doc).select do |key, _value| - !HIDDEN_QUESTIONS.include?(key.to_s) + HIDDEN_QUESTIONS.exclude?(key.to_s) end.merge(ActiveSupport::HashWithIndifferentAccess.new(form_answer.financial_data)) end diff --git a/app/form_pointers/form_financial_pointer.rb b/app/form_pointers/form_financial_pointer.rb index f87df08c9c..63bc53e00d 100644 --- a/app/form_pointers/form_financial_pointer.rb +++ b/app/form_pointers/form_financial_pointer.rb @@ -18,11 +18,10 @@ class FormFinancialPointer QaeFormBuilder::OneOptionByYearsLabelQuestion, QaeFormBuilder::OneOptionByYearsQuestion, ] - YEAR_LABELS = %w(day month year) + YEAR_LABELS = %w[day month year] IN_PROGRESS = "-" - TRADE_AUTOEXCLUDED_QUESTION_KEYS = [ - ] + TRADE_AUTOEXCLUDED_QUESTION_KEYS = [] UK_SALES_EXCLUDED_FORM_TYPES = [ :trade, @@ -56,10 +55,10 @@ def data unless UK_SALES_EXCLUDED_FORM_TYPES.include?(form_answer.object.award_type.to_sym) uk_sales_data = UkSalesCalculator.new(fetched).data - if index = fetched.index { |data| data[:exports].present? } + if (index = fetched.index { |data| data[:exports].present? }) fetched.insert(index + 1, uk_sales_data) if uk_sales_data.present? - else - fetched += [uk_sales_data] if uk_sales_data.present? + elsif uk_sales_data.present? + fetched += [uk_sales_data] end end @@ -151,7 +150,7 @@ def overall_growth_in_percents def fetch_financial_questions financial_step.questions.select do |question| - !FormPdf::HIDDEN_QUESTIONS.include?(question.key.to_s) && + FormPdf::HIDDEN_QUESTIONS.exclude?(question.key.to_s) && TARGET_FINANCIAL_DATA_QUESTION_TYPES.include?(question.delegate_obj.class) && award_form[question.key].visible? && !excluded_by_ignored_questions_list?(question) @@ -203,14 +202,9 @@ def financial_year_changed_dates dates_by_years = data_values(:financial_year_changed_dates) if dates_by_years.present? - res = [] - last_year = dates_by_years.last.split("/")[-1][-1].to_i - - dates_by_years.each do |date| - res << date.join("/") + dates_by_years.each_with_object([]) do |date, memo| + memo << date.join("/") end - - res else [] end diff --git a/app/form_pointers/latest_year_generator.rb b/app/form_pointers/latest_year_generator.rb index c9019e9e35..e3016a9050 100644 --- a/app/form_pointers/latest_year_generator.rb +++ b/app/form_pointers/latest_year_generator.rb @@ -5,7 +5,7 @@ def calculate_last_year(form_answer, day, month) # If from January to 6th of September -> then current year # - @form_answer_award_year = form_answer.award_year.year unless @form_answer_award_year.present? + @form_answer_award_year = form_answer.award_year.year if @form_answer_award_year.blank? if form_answer.financial_year_changeable? || (month.to_i == 9 && day.to_i > 6) || month.to_i > 9 @form_answer_award_year - 2 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8930c3e664..30b56915ff 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -7,32 +7,36 @@ def step_link_to(name, url, opts = {}) opts[:class] ||= "govuk-body" step_status = "" - if opts[:index] + index_step_text = if opts[:index] if opts[:index_name] - index_step_text = "#{opts[:index_name]} #{name}".html_safe + capture do + concat(tag.span(opts[:index_name], class: "step-number")) + concat(name) + end else - index_step_text = "#{opts[:index]}. #{name}".html_safe + capture do + concat(tag.span(opts[:index], class: "step-number")) + concat(name) + end end else - index_step_text = name + name end if opts[:index] && opts[:active] if opts[:index] == opts[:active] step_status = "current" opts[:class] += " step-current" - else - if opts[:disable_progression].present? && opts[:disable_progression] - opts[:class] += " step-regular" - elsif opts[:index] < opts[:active] - step_status = "past" - opts[:class] += " step-past" - end + elsif opts[:disable_progression].present? && opts[:disable_progression] + opts[:class] += " step-regular" + elsif opts[:index] < opts[:active] + step_status = "past" + opts[:class] += " step-past" end end tag.li(**opts) do - if step_status == "current" or (step_status != "past" && opts[:cant_access_future]) + if (step_status == "current") || (step_status != "past" && opts[:cant_access_future]) tag.span(class: "govuk-body") do index_step_text end @@ -49,7 +53,7 @@ def condition_divs(question, &block) return inner if question.conditions.empty? current = inner - for condition in question.conditions + question.conditions.each do |condition| dep = question.form[condition.question_key] raise "Can't find parent question for conditional #{question.key} -> #{condition.question_key}" unless dep @@ -122,23 +126,23 @@ def qae_simple_format(text) text = sanitize(text) paragraphs = split_paragraphs(text) + # rubocop:disable Rails/OutputSafety if paragraphs.present? - paragraphs.map! { |paragraph| - raw(paragraph) - }.join("

").html_safe + paragraphs.map! { |paragraph| raw(paragraph) }.join("

").html_safe end + # rubocop:enable Rails/OutputSafety end def ordinal(n) ending = case n % 100 when 11, 12, 13 then "th" else - case n % 10 - when 1 then "st" - when 2 then "nd" - when 3 then "rd" - else "th" - end + case n % 10 + when 1 then "st" + when 2 then "nd" + when 3 then "rd" + else "th" + end end n.to_s + ending end diff --git a/app/helpers/appraisal_form_helper.rb b/app/helpers/appraisal_form_helper.rb index 9b8677d11a..a0110b6e2e 100644 --- a/app/helpers/appraisal_form_helper.rb +++ b/app/helpers/appraisal_form_helper.rb @@ -22,25 +22,28 @@ module AppraisalFormHelper ENTRY_RELATES_TO_MOBILITY_OPS = ["mentoring", "career_opportunities_accessibility", "workplace_fostering"] def options_available(options) - @check_options = ENTRY_RELATES_TO_OPTIONS.select do |i| + ENTRY_RELATES_TO_OPTIONS.select do |i| options.include?(i.keys.first) end.map do |el| - [ - el.keys.first, - el.values.first, - ] + [ + el.keys.first, + el.values.first, + ] end end def render_section(form_answer, f) section_odd_even = false - AppraisalForm.struct(form_answer, f).map do |k, section| + + output = AppraisalForm.struct(form_answer, f).map do |k, section| section_obj = OpenStruct.new(section.merge(desc: "#{k}_desc", rate: "#{k}_rate")) partial = "admin/form_answers/appraisal_form_components/#{section[:type]}_section" section_odd_even = !section_odd_even render partial: partial, locals: { section: section_obj, f: f, section_odd_even: section_odd_even } - end.join.html_safe + end + + safe_join(output) end end diff --git a/app/helpers/audit_helper.rb b/app/helpers/audit_helper.rb index 77795af605..721ef21328 100644 --- a/app/helpers/audit_helper.rb +++ b/app/helpers/audit_helper.rb @@ -6,13 +6,13 @@ def dummy_user private def dummy_user_params - { - email: "dummy_user@example.com", - password: SecureRandom.base64(16), - agreed_with_privacy_policy: "1", - role: "regular", - first_name: "Unknown", - last_name: "User", - } + { + email: "dummy_user@example.com", + password: SecureRandom.base64(16), + agreed_with_privacy_policy: "1", + role: "regular", + first_name: "Unknown", + last_name: "User", + } end end diff --git a/app/helpers/case_summary_helper.rb b/app/helpers/case_summary_helper.rb index c9e0d5f58d..6dc02241da 100644 --- a/app/helpers/case_summary_helper.rb +++ b/app/helpers/case_summary_helper.rb @@ -8,12 +8,9 @@ def visible_case_summaries(subject, form_answer) lead = subject.lead?(form_answer) primary = subject.primary?(form_answer) - assessments = if lead || primary all end - - assessments end def wrap_case_summary(summary, title = "Case Summary") diff --git a/app/helpers/form_answer_helper.rb b/app/helpers/form_answer_helper.rb index 56ec7dcb8b..d8587d4494 100644 --- a/app/helpers/form_answer_helper.rb +++ b/app/helpers/form_answer_helper.rb @@ -19,12 +19,10 @@ def application_flags(fa, subject = nil) else fa.flagged_critical_comments_count end + elsif current_subject.is_a?(Admin) + fa.flagged_critical_comments_count else - if current_subject.is_a?(Admin) - fa.flagged_critical_comments_count - else - fa.flagged_admin_comments_count - end + fa.flagged_admin_comments_count end current_user_class = current_subject.model_name.to_s.parameterize @@ -37,10 +35,8 @@ def application_flags(fa, subject = nil) if comments_count > 0 tag.span(class: "icon-flagged #{flag_type}") do - "#{current_user_class} flags: ".html_safe + - tag.span(class: "flag-count") do - comments_count.to_s - end + concat("#{current_user_class} flags: ") + concat(tag.span(comments_count.to_s, class: "flag-count")) end end end @@ -56,10 +52,10 @@ def user_can_edit_company(form) def application_comments(comments_count) return unless comments_count > 0 - output = "Comments: " - output += comments_count.to_s - output += "" - output.html_safe + tag.span(class: "icon-comment") do + concat("Comments: ") + concat(tag.span(comments_count.to_s, class: "comment-count")) + end end def award_types_collection(year) @@ -74,9 +70,9 @@ def award_types_collection(year) def each_index_or_empty(collection, attrs, &block) if collection.any? - collection.each_with_index &block + collection.each_with_index(&block) else - block.(attrs, 0) + yield(attrs, 0) end end diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index 3037f436e7..298f800c3d 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -41,8 +41,8 @@ def text_words_count(text) text.to_s.split.count end - def application_collaborator_group_mode? + def application_collaborator_group_mode?(application) current_form_is_editable? && - @form_answer.has_more_than_one_contributor? + application.has_more_than_one_contributor? end end diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index 2246349f62..fdd0355419 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -1,6 +1,6 @@ module MailerHelper def formatted_deadline_time deadline - #govuk suggested format is 12-hour clock with meridian indicator + # govuk suggested format is 12-hour clock with meridian indicator time = deadline.trigger_at.try :strftime, "%-I:%M %P" if time == "12:00 pm" "noon" diff --git a/app/helpers/partials_visibility_helper.rb b/app/helpers/partials_visibility_helper.rb index 1f5f54986f..a7eb05bafb 100644 --- a/app/helpers/partials_visibility_helper.rb +++ b/app/helpers/partials_visibility_helper.rb @@ -1,33 +1,24 @@ module PartialsVisibilityHelper - def show_section_case_summary? - return false unless moderated_assessment.submitted? - return true if current_subject.lead?(@form_answer) || current_subject.primary?(@form_answer) + def show_winners_section?(application) + application.awarded? || application.recommended? || application.reserved? end - def show_section_appraisal_moderated? - policy(@form_answer).show_section_appraisal_moderated? + def show_case_summary_section?(application) + admin_lead_or_primary?(application) end - def show_winners_section? - @form_answer.awarded? || @form_answer.recommended? || @form_answer.reserved? + def show_feedback_section?(application) + !application.promotion? && + admin_lead_or_primary?(application) end - def show_case_summary_section? - admin_lead_or_primary? + def show_press_summary_subsection?(application) + (application.awarded? || application.recommended? || application.reserved?) && + admin_lead_or_primary?(application) end - def show_feedback_section? - !@form_answer.promotion? && - admin_lead_or_primary? - end - - def show_press_summary_subsection? - (@form_answer.awarded? || @form_answer.recommended? || @form_answer.reserved?) && - admin_lead_or_primary? - end - - def show_palace_attendees_subsection? - @form_answer.awarded? && admin_lead_or_primary? + def show_palace_attendees_subsection?(application) + application.awarded? && admin_lead_or_primary?(application) end def show_bulk_assignment? @@ -49,9 +40,9 @@ def show_shortlisted_document?(attachment) private - def admin_lead_or_primary? + def admin_lead_or_primary?(application) current_subject.is_a?(Admin) || - current_subject.lead?(@form_answer) || - current_subject.primary?(@form_answer) + current_subject.lead?(application) || + current_subject.primary?(application) end end diff --git a/app/helpers/region_helper.rb b/app/helpers/region_helper.rb index 27bc5279aa..da0dea2757 100644 --- a/app/helpers/region_helper.rb +++ b/app/helpers/region_helper.rb @@ -1,21 +1,21 @@ module RegionHelper COUNTY_REGION_MAPPINGS = { - "Aberdeenshire": "Scotland", - "Angus": "Scotland", + Aberdeenshire: "Scotland", + Angus: "Scotland", "Argyll and Bute": "Scotland", - "Bedfordshire": "East of England", - "Berkshire": "South East", - "Bristol": "South West", - "Buckinghamshire": "South East", - "Cambridgeshire": "East of England", - "Cheshire": "North West", + Bedfordshire: "East of England", + Berkshire: "South East", + Bristol: "South West", + Buckinghamshire: "South East", + Cambridgeshire: "East of England", + Cheshire: "North West", "City of Aberdeen": "Scotland", "City of Dundee": "Scotland", "City of Edinburgh": "Scotland", "City of Glasgow": "Scotland", - "Clackmannanshire": "Scotland", - "Clwyd": "Wales", - "Cornwall": "South West", + Clackmannanshire: "Scotland", + Clwyd: "Wales", + Cornwall: "South West", "County Antrim": "Northern Ireland", "County Armagh": "Northern Ireland", "County Down": "Northern Ireland", @@ -23,79 +23,79 @@ module RegionHelper "County Fermanagh": "Northern Ireland", "County Londonderry": "Northern Ireland", "County Tyrone": "Northern Ireland", - "Cumbria": "North West", - "Derbyshire": "East Midlands", - "Devon": "South West", - "Dorset": "South West", + Cumbria: "North West", + Derbyshire: "East Midlands", + Devon: "South West", + Dorset: "South West", "Dumfries and Galloway": "Scotland", - "Dyfed": "Wales", + Dyfed: "Wales", "East Ayrshire": "Scotland", "East Dunbartonshire": "Scotland", "East Lothian": "Scotland", "East Renfrewshire": "Scotland", "East Riding of Yorkshire": "Yorkshire & The Humber", "East Sussex": "South East", - "Essex": "East of England", - "Falkirk": "Scotland", - "Fife": "Scotland", - "Gloucestershire": "South West", + Essex: "East of England", + Falkirk: "Scotland", + Fife: "Scotland", + Gloucestershire: "South West", "Greater London": "Greater London", - "Gwynedd": "Wales", - "Hampshire": "South East", - "Herefordshire": "West Midlands", - "Hertfordshire": "East of England", - "Highland": "Scotland", - "Inverclyde": "Scotland", + Gwynedd: "Wales", + Hampshire: "South East", + Herefordshire: "West Midlands", + Hertfordshire: "East of England", + Highland: "Scotland", + Inverclyde: "Scotland", "Isle of Wight": "South East", "Isles of Scilly": "South West", - "Kent": "South East", - "Lancashire": "North West", - "Leicestershire": "East Midlands", + Kent: "South East", + Lancashire: "North West", + Leicestershire: "East Midlands", "Lincolnshire - East Midlands region (includes Boston, East Lindsey, Lincoln, North Kesteven, South Holland, South Kesteven, West Lindsey)": "East Midlands", "Lincolnshire - Yorkshire & The Humber region (includes North East Lincolnshire, North Lincolnshire)": "Yorkshire & The Humber", - "Manchester": "North West", - "Merseyside": "North West", + Manchester: "North West", + Merseyside: "North West", "Mid Glamorgan": "Wales", - "Midlothian": "Scotland", + Midlothian: "Scotland", "Gwent - Blaenau Gwent, Caerphilly, Monmouthshire, Newport, Torfaen": "Wales", - "Moray": "Scotland", + Moray: "Scotland", "Na h-Eileanan Siar - Western Isles": "Scotland", - "Norfolk": "East of England", + Norfolk: "East of England", "North Ayrshire": "Scotland", "North Lanarkshire": "Scotland", "North Yorkshire - Yorkshire & The Humber region (includes Craven, Hambleton, Harrogate, Richmondshire, Ryedale, Scarborough, Selby, York)": "Yorkshire & The Humber", "North Yorkshire - North East England region (includes Middlesbrough, Redcar and Cleveland, Stockton-on-Tees)": "North East", - "Northamptonshire": "East Midlands", - "Northumberland": "North East", - "Nottinghamshire": "East Midlands", + Northamptonshire: "East Midlands", + Northumberland: "North East", + Nottinghamshire: "East Midlands", "Orkney Islands": "Scotland", - "Oxfordshire": "South East", + Oxfordshire: "South East", "Perth and Kinross": "Scotland", - "Powys": "Wales", - "Renfrewshire": "Scotland", - "Rutland": "East Midlands", + Powys: "Wales", + Renfrewshire: "Scotland", + Rutland: "East Midlands", "Scottish Borders": "Scotland", "Shetland Islands": "Scotland", - "Shropshire": "West Midlands", - "Somerset": "South West", + Shropshire: "West Midlands", + Somerset: "South West", "South Ayrshire": "Scotland", "South Glamorgan": "Wales", "South Lanarkshire": "Scotland", "South Yorkshire": "Yorkshire & The Humber", - "Staffordshire": "West Midlands", - "Stirling": "Scotland", - "Suffolk": "East of England", - "Surrey": "South East", + Staffordshire: "West Midlands", + Stirling: "Scotland", + Suffolk: "East of England", + Surrey: "South East", "Tyne and Wear": "North East", - "Warwickshire": "West Midlands", + Warwickshire: "West Midlands", "West Dunbartonshire": "Scotland", "West Glamorgan": "Wales", "West Lothian": "Scotland", "West Midlands": "West Midlands", "West Sussex": "South East", "West Yorkshire": "Yorkshire & The Humber", - "Wiltshire": "South West", - "Worcestershire": "West Midlands", + Wiltshire: "South West", + Worcestershire: "West Midlands", "Bailiwick of Guernsey": "Channel Islands", "Bailiwick of Jersey": "Channel Islands", "Isle of Man": "Isle of Man", diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 99dc5e45a7..54a98ed9f5 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -5,7 +5,7 @@ def sort_link(f, name, search, field, options = {}) h = "".html_safe h << link_to(name, { search: { sort: sort_link_param(search, field) } }, { class: sort_link_class(search, field) }) - h << f.input(:sort, as: :hidden, input_html: { id:"search_sort_#{field}", value: sort_link_param(search, field), disabled: true }) + h << f.input(:sort, as: :hidden, input_html: { id: "search_sort_#{field}", value: sort_link_param(search, field), disabled: true }) h end diff --git a/app/helpers/user_devise_helper.rb b/app/helpers/user_devise_helper.rb index 7df7105bc3..79b1d6fd92 100644 --- a/app/helpers/user_devise_helper.rb +++ b/app/helpers/user_devise_helper.rb @@ -26,6 +26,6 @@ def login_unconfirmed_message end def parsed_flash_alert - message = flash.alert.to_s.strip + flash.alert.to_s.strip end end diff --git a/app/helpers/winners_awards_helper.rb b/app/helpers/winners_awards_helper.rb index 1baad0e05a..0e1c1e78df 100644 --- a/app/helpers/winners_awards_helper.rb +++ b/app/helpers/winners_awards_helper.rb @@ -5,4 +5,3 @@ def static_s3_asset_path(year, file_name) "https://s3-eu-west-1.amazonaws.com/qae-winners-assets/#{CGI.escape(file_path)}" end end - diff --git a/app/inputs/separated_date_time_input.rb b/app/inputs/separated_date_time_input.rb index f08c6087f3..389478be7e 100644 --- a/app/inputs/separated_date_time_input.rb +++ b/app/inputs/separated_date_time_input.rb @@ -5,11 +5,11 @@ def input(wrapper_options) out << @builder.text_field("formatted_#{attribute_name}_date", input_html_options.merge(class: "form-control datepicker", placeholder: "dd/mm/yyyy", - aria: { label: "formatted_#{attribute_name}_date" },),) + aria: { label: "formatted_#{attribute_name}_date" })) out << @builder.text_field("formatted_#{attribute_name}_time", input_html_options.merge(class: "form-control timepicker", placeholder: "hh:mm", - aria: { label: "formatted_#{attribute_name}_time" },),) + aria: { label: "formatted_#{attribute_name}_time" })) out end diff --git a/app/mailers/users/custom_mailer.rb b/app/mailers/users/custom_mailer.rb index b67ff42ad7..129f0426b1 100644 --- a/app/mailers/users/custom_mailer.rb +++ b/app/mailers/users/custom_mailer.rb @@ -1,6 +1,6 @@ class Users::CustomMailer < ApplicationMailer def notify(user_id, user_class, body, subject) - if %w(Admin User Assessor).include?(user_class) + if %w[Admin User Assessor].include?(user_class) @user = user_class.constantize.find(user_id).decorate @body = body diff --git a/app/models/aggregated_award_year_pdf.rb b/app/models/aggregated_award_year_pdf.rb index 3fa79f51f7..599ec4a445 100644 --- a/app/models/aggregated_award_year_pdf.rb +++ b/app/models/aggregated_award_year_pdf.rb @@ -1,5 +1,5 @@ class AggregatedAwardYearPdf < ApplicationRecord - TYPES = %w(case_summary feedback) + TYPES = %w[case_summary feedback] belongs_to :award_year, optional: true diff --git a/app/models/assessor.rb b/app/models/assessor.rb index 722f973e77..195dbdebfc 100644 --- a/app/models/assessor.rb +++ b/app/models/assessor.rb @@ -93,7 +93,7 @@ def self.role_meth(category) end def applications_scope(award_year = nil) - c = assigned_categories_as(%w(lead)) + c = assigned_categories_as(%w[lead]) join = "LEFT OUTER JOIN assessor_assignments ON assessor_assignments.form_answer_id = form_answers.id" @@ -108,7 +108,7 @@ def applications_scope(award_year = nil) (form_answers.award_type in (?) OR (assessor_assignments.position in (?) AND assessor_assignments.assessor_id = ?)) AND form_answers.state NOT IN (?) - ", c, [0, 1], id, "withdrawn",) + ", c, [0, 1], id, "withdrawn") end # we're using extended scope on the resource page @@ -116,12 +116,9 @@ def applications_scope(award_year = nil) # with account's other applications # they were not assigned to def extended_applications_scope - c = assigned_categories_as(%w(lead regular)) + c = assigned_categories_as(%w[lead regular]) - out = FormAnswer.where(" - form_answers.award_type in (?) - AND form_answers.state NOT IN (?) - ", c, "withdrawn",) + FormAnswer.where(award_type: c).where.not(state: "withdrawn") end def full_name @@ -191,7 +188,7 @@ def has_access_to_award_type?(award_type) end def all_assigned_award_types - assigned_categories_as(%w(lead regular)).map do |cat| + assigned_categories_as(%w[lead regular]).map do |cat| FormAnswer::AWARD_TYPE_FULL_NAMES[cat] end.join(", ") end @@ -212,18 +209,12 @@ def get_role(category) end def assigned_categories_as(roles) - FormAnswer::POSSIBLE_AWARDS.map do |award| - award if roles.include?(get_role(award).to_s) - end.compact + FormAnswer::POSSIBLE_AWARDS.select { |award| roles.include?(get_role(award).to_s) } end def nil_if_blank FormAnswer::POSSIBLE_AWARDS.each do |award| - self.public_send("#{award}_role=", nil) if get_role(award).blank? + public_send(:"#{award}_role=", nil) if get_role(award).blank? end end - - def self.leads_for(category) - where(role_meth(category) => "lead") - end end diff --git a/app/models/assessor_assignment.rb b/app/models/assessor_assignment.rb index a315e07d2e..e072e34376 100644 --- a/app/models/assessor_assignment.rb +++ b/app/models/assessor_assignment.rb @@ -1,5 +1,5 @@ class AssessorAssignment < ApplicationRecord - has_paper_trail unless: Proc.new { |t| Rails.env.test? } + has_paper_trail unless: proc { |t| Rails.env.test? } enum position: { primary: 0, @@ -8,40 +8,36 @@ class AssessorAssignment < ApplicationRecord case_summary: 4, } - begin :validations - validates :form_answer_id, - :position, - presence: true + # validations + validates :form_answer_id, + :position, + presence: true - validate :award_specific_attributes - validate :mandatory_fields_for_submitted + validate :award_specific_attributes + validate :mandatory_fields_for_submitted - validate do - validate_rate :rag - validate_rate :strengths - validate_rate :verdict - end - - validate :assessor_existence - validate :assessor_assignment_to_category - validates :assessor_id, - uniqueness: { scope: [:form_answer_id] }, - allow_nil: true + validate do + validate_rate :rag + validate_rate :strengths + validate_rate :verdict end - begin :associations - 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 + validate :assessor_existence + validate :assessor_assignment_to_category + validates :assessor_id, + uniqueness: { scope: [:form_answer_id] }, + allow_nil: true - begin :scopes - scope :submitted, -> { where.not(submitted_at: nil) } - end + # associations + belongs_to :assessor, optional: true + belongs_to :form_answer, optional: true + belongs_to :editable, polymorphic: true, optional: true + belongs_to :award_year, optional: true - around_save :notify_form_answer + # scopes + scope :submitted, -> { where.not(submitted_at: nil) } + around_save :notify_form_answer before_create :set_award_year! store_accessor :document, *AppraisalForm.all @@ -183,7 +179,7 @@ def validate_rate(rate_type) struct.rates(form_answer, rate_type).each do |section, _| val = section_rate(section) c = "#{rate_type.upcase}_ALLOWED_VALUES" - if val && !struct.const_get(c).include?(val) + if val && struct.const_get(c).exclude?(val) sect_name = struct.rate(section) message = "#{rate_type} field for '#{section_name(section)}' has not permitted value." errors.add(sect_name, message: message) @@ -198,7 +194,7 @@ def section_rate(section) def section_name(key) @_sections ||= struct.struct(form_answer).to_h section_key = key.to_s.gsub(/_desc$/, "").gsub(/_rate$/, "") - if section = @_sections.dig(section_key.to_sym) + if (section = @_sections.dig(section_key.to_sym)) section[:label].gsub(/:$/, "") end end diff --git a/app/models/assessors_import/builder.rb b/app/models/assessors_import/builder.rb index 8569809574..210258c3bf 100644 --- a/app/models/assessors_import/builder.rb +++ b/app/models/assessors_import/builder.rb @@ -3,8 +3,10 @@ class AssessorsImport::Builder attr_reader :csv + FIELDS = %w[first_name last_name company trade_role innovation_role promotion_role development_role] + def initialize(filepath) - file = File.open(filepath).read + file = File.read(filepath) @csv = CSV.parse(file, headers: true) end @@ -17,8 +19,8 @@ def process if a.new_record? && email.present? log "saving: #{email}" - ["first_name", "last_name", "company", "trade_role", "innovation_role", "promotion_role", "development_role"].each do |db_h| - a.send("#{db_h}=", row[db_h]) + FIELDS.each do |db_h| + a.send(:"#{db_h}=", row[db_h]) end a = assign_password(a) @@ -40,11 +42,11 @@ def process private def log(msg) - puts msg unless Rails.env.test? + Rails.logger.debug msg unless Rails.env.test? end def assign_password(user) - passw = (0...15).map { (65 + rand(26)).chr }.join + passw = (0...15).map { rand(65..90).chr }.join user.password = passw user.password_confirmation = passw user diff --git a/app/models/audit_certificate.rb b/app/models/audit_certificate.rb index 6aff5e4f6e..c6d58d1adf 100644 --- a/app/models/audit_certificate.rb +++ b/app/models/audit_certificate.rb @@ -1,17 +1,14 @@ -class AuditCertificate < ActiveRecord::Base +class AuditCertificate < ApplicationRecord include ShortlistedDocument include Reviewable - begin :validations - validates :attachment, presence: true, - on: :create, - file_size: { - maximum: 15.megabytes.to_i, - } + validates :attachment, presence: true, + on: :create, + file_size: { + maximum: 15.megabytes.to_i, + } - validates :form_answer_id, uniqueness: true, - presence: true - end + validates :form_answer_id, uniqueness: true, presence: true # rubocop:disable Rails/UniqueValidationWithoutIndex before_save :clean_changes_description diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb index 25e7646cfe..307c98d762 100644 --- a/app/models/audit_event.rb +++ b/app/models/audit_event.rb @@ -23,11 +23,11 @@ def time_string end def description_for_action_type(action_type) - I18n.translate("audit_logs.action_types.#{action_type}") + I18n.t("audit_logs.action_types.#{action_type}") end def user_string - user_type = (subject.class.name == "User") ? "Applicant" : subject.class.name + user_type = subject.instance_of?(::User) ? "Applicant" : subject.class.name "#{subject.full_name} (#{user_type})" end end diff --git a/app/models/audit_log.rb b/app/models/audit_log.rb index 96c322693d..a9dbc13391 100644 --- a/app/models/audit_log.rb +++ b/app/models/audit_log.rb @@ -1,5 +1,5 @@ class AuditLog < ApplicationRecord - validates :subject_type, inclusion: { in: %w(Admin User Assessor Judge) }, presence: true + validates :subject_type, inclusion: { in: %w[Admin User Assessor Judge] }, presence: true validates :subject_id, presence: true validates :action_type, presence: true diff --git a/app/models/award_year.rb b/app/models/award_year.rb index 5d056d9a34..2ea6788a4d 100644 --- a/app/models/award_year.rb +++ b/app/models/award_year.rb @@ -6,6 +6,7 @@ class AwardYear < ApplicationRecord has_many :feedbacks has_one :settings, inverse_of: :award_year, autosave: true + # rubocop:disable Rails/InverseOf has_many :aggregated_case_summary_hard_copies, -> { where(type_of_report: "case_summary") }, class_name: "AggregatedAwardYearPdf", dependent: :destroy @@ -13,6 +14,7 @@ class AwardYear < ApplicationRecord has_many :aggregated_feedback_hard_copies, -> { where(type_of_report: "feedback") }, class_name: "AggregatedAwardYearPdf", dependent: :destroy + # rubocop:enable Rails/InverseOf after_create :create_settings @@ -41,7 +43,7 @@ class AwardYear < ApplicationRecord ] def current? - self.year == self.class.current.year + year == self.class.current.year end # @@ -50,8 +52,8 @@ def current? # FormAnswer::POSSIBLE_AWARDS.each do |award_category| AggregatedAwardYearPdf::TYPES.each do |pdf_type| - define_method("#{pdf_type}_#{award_category}_hard_copy_pdf") do - send("aggregated_#{pdf_type}_hard_copies").find_by(award_category: award_category) + define_method(:"#{pdf_type}_#{award_category}_hard_copy_pdf") do + send(:"aggregated_#{pdf_type}_hard_copies").find_by(award_category: award_category) end end end @@ -61,8 +63,8 @@ def current? # for '3 to 5' and '6 plus' years # CASE_SUMMARY_YEAR_MODES.map do |i| - define_method("case_summary_trade_#{i}_hard_copy_pdf") do - send("aggregated_case_summary_hard_copies").find_by( + define_method(:"case_summary_trade_#{i}_hard_copy_pdf") do + send(:aggregated_case_summary_hard_copies).find_by( award_category: "trade", sub_type: i, ) @@ -101,12 +103,12 @@ def aggregated_feedback_generation_can_be_started? def aggregated_hard_copies_completed?(type) CURRENT_YEAR_AWARDS.all? do |award_category| if award_category == "trade" && type == "case_summary" - ["3", "6"].all? do |i| - copy_record = send("#{type}_#{award_category}_#{i}_hard_copy_pdf") + CASE_SUMMARY_YEAR_MODES.all? do |i| + copy_record = send(:"#{type}_#{award_category}_#{i}_hard_copy_pdf") copy_record.present? && copy_record.file.present? end else - copy_record = send("#{type}_#{award_category}_hard_copy_pdf") + copy_record = send(:"#{type}_#{award_category}_hard_copy_pdf") copy_record.present? && copy_record.file.present? end end @@ -121,7 +123,7 @@ def check_aggregated_hard_copy_pdf_generation_status!(type) end def check_hard_copy_pdf_generation_status!(type) - scope = send("hard_copy_#{type}_scope") + scope = send(:"hard_copy_#{type}_scope") condition_rule = if type == "form_data" scope.count == scope.hard_copy_generated(type).count @@ -174,10 +176,10 @@ def self.current .try(:trigger_at) deadline ||= Date.new(now.year, 4, 21) - if now >= deadline.to_datetime - y = now.year + 1 + y = if now >= deadline.to_datetime + now.year + 1 else - y = now.year + now.year end where(year: y).first_or_create @@ -226,8 +228,7 @@ def self.past_years end def fetch_deadline(title) - res = settings - .deadlines + settings.deadlines .where(kind: title) .first end diff --git a/app/models/commercial_figures_file.rb b/app/models/commercial_figures_file.rb index c853dd4fc9..3186787ef1 100644 --- a/app/models/commercial_figures_file.rb +++ b/app/models/commercial_figures_file.rb @@ -1,4 +1,4 @@ -class CommercialFiguresFile < ActiveRecord::Base +class CommercialFiguresFile < ApplicationRecord include ShortlistedDocument validates :attachment, presence: true, diff --git a/app/models/concerns/autosave_token_generation.rb b/app/models/concerns/autosave_token_generation.rb index c4b8b56bea..82e7c490e5 100644 --- a/app/models/concerns/autosave_token_generation.rb +++ b/app/models/concerns/autosave_token_generation.rb @@ -16,7 +16,7 @@ def set_autosave_token def generate_token loop do token = SecureRandom.hex(10) - break token unless self.class.where(autosave_token: token).exists? + break token unless self.class.exists?(autosave_token: token) end end end diff --git a/app/models/concerns/formatted_time/date_time_for.rb b/app/models/concerns/formatted_time/date_time_for.rb index d4a3a67cbe..eb05459b4b 100644 --- a/app/models/concerns/formatted_time/date_time_for.rb +++ b/app/models/concerns/formatted_time/date_time_for.rb @@ -5,17 +5,17 @@ module ClassMethods def formatted_time_for(*attrs) mod = Module.new do attrs.each do |attr| - define_method("formatted_#{attr}=") do |value| - hours, min = value.match(/(\d{2})\:(\d{2})/).try(:captures) + define_method(:"formatted_#{attr}=") do |value| + hours, min = value.match(/(\d{2}):(\d{2})/).try(:captures) seconds = if hours && min hours.to_i * 3600 + min.to_i * 60 end - self.public_send("#{attr}=", seconds) + public_send(:"#{attr}=", seconds) end - define_method("formatted_#{attr}") do + define_method(:"formatted_#{attr}") do seconds = public_send(attr) if seconds @@ -34,12 +34,16 @@ def formatted_date_for(*attrs) attrs.each do |attr| attr_accessible "formatted_#{attr}" if respond_to?(:attr_accessible) - define_method("formatted_#{attr}=") do |value| - date = Date.strptime(value, "%d/%m/%Y") rescue nil - self.public_send("#{attr}=", date) + define_method(:"formatted_#{attr}=") do |value| + date = begin + Date.strptime(value, "%d/%m/%Y") + rescue + nil + end + public_send(:"#{attr}=", date) end - define_method("formatted_#{attr}") do + define_method(:"formatted_#{attr}") do date = public_send(attr) date && date.strftime("%d/%m/%Y") end diff --git a/app/models/concerns/mailgun_helper.rb b/app/models/concerns/mailgun_helper.rb index bd52ac0071..b75d8e9f87 100644 --- a/app/models/concerns/mailgun_helper.rb +++ b/app/models/concerns/mailgun_helper.rb @@ -32,11 +32,11 @@ def valid?(email) return true if Rails.env.test? body = Curl::Easy.perform(url(email)).body - if response = JSON.parse(body) + if (response = JSON.parse(body)) return false if response.is_a?(Hash) && response["is_valid"].to_s == "false" response.size > 0 end - rescue Exception => e + rescue false end end diff --git a/app/models/deadline.rb b/app/models/deadline.rb index 678d3c9f8f..14887c2cd6 100644 --- a/app/models/deadline.rb +++ b/app/models/deadline.rb @@ -54,8 +54,8 @@ def submission_start where(kind: "submission_start").first end - %w(innovation trade mobility development).each do |award| - define_method "#{award}_submission_start" do + %w[innovation trade mobility development].each do |award| + define_method :"#{award}_submission_start" do where(kind: "#{award}_submission_start").first end end diff --git a/app/models/eligibility.rb b/app/models/eligibility.rb index b83d731f96..54c8be57cf 100644 --- a/app/models/eligibility.rb +++ b/app/models/eligibility.rb @@ -71,7 +71,7 @@ def self.property(name, options = {}) end if options[:boolean] || options[:acts_like_boolean] - define_method "#{name}?" do + define_method :"#{name}?" do ["1", "true", "yes", true].include?(public_send(name)) end end @@ -133,7 +133,7 @@ def skipped? end def any_error_yet? - answers.any?{ |answer| !answer_valid?(answer[0], answer[1]) } + answers.any? { |answer| !answer_valid?(answer[0], answer[1]) } end def answer_valid?(question, answer) diff --git a/app/models/eligibility/trade/not_a_last_year_winner_validator.rb b/app/models/eligibility/trade/not_a_last_year_winner_validator.rb index 0b0cf0fc02..a851e7c49a 100644 --- a/app/models/eligibility/trade/not_a_last_year_winner_validator.rb +++ b/app/models/eligibility/trade/not_a_last_year_winner_validator.rb @@ -1,9 +1,11 @@ class Eligibility::Trade::NotALastYearWinnerValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) - record.errors.add( - attribute, - "Not eligible to apply this year", - ) unless self.class.valid_year?(value) + unless self.class.valid_year?(value) + record.errors.add( + attribute, + "Not eligible to apply this year", + ) + end end # must not be winner last year diff --git a/app/models/eligibility/validation/false_validation.rb b/app/models/eligibility/validation/false_validation.rb index 606bde8c5a..caf79d541e 100644 --- a/app/models/eligibility/validation/false_validation.rb +++ b/app/models/eligibility/validation/false_validation.rb @@ -1,5 +1,5 @@ class Eligibility::Validation::FalseValidation < Eligibility::Validation::Base def valid? - !eligibility.public_send("#{question}?") + !eligibility.public_send(:"#{question}?") end end diff --git a/app/models/eligibility/validation/true_validation.rb b/app/models/eligibility/validation/true_validation.rb index 7a9123b43f..4f68ccde66 100644 --- a/app/models/eligibility/validation/true_validation.rb +++ b/app/models/eligibility/validation/true_validation.rb @@ -1,5 +1,5 @@ class Eligibility::Validation::TrueValidation < Eligibility::Validation::Base def valid? - eligibility.public_send("#{question}?") + eligibility.public_send(:"#{question}?") end end diff --git a/app/models/feedback.rb b/app/models/feedback.rb index baad89cf3b..76921cf77f 100644 --- a/app/models/feedback.rb +++ b/app/models/feedback.rb @@ -1,5 +1,5 @@ class Feedback < ApplicationRecord - has_paper_trail unless: Proc.new { |t| Rails.env.test? } + has_paper_trail unless: proc { |t| Rails.env.test? } belongs_to :form_answer, optional: true @@ -9,7 +9,7 @@ class Feedback < ApplicationRecord belongs_to :authorable, polymorphic: true, optional: true belongs_to :award_year, optional: true - validates :form_answer_id, uniqueness: true + validates :form_answer_id, uniqueness: true # rubocop:disable Rails/UniqueValidationWithoutIndex before_create :set_award_year! diff --git a/app/models/form_answer.rb b/app/models/form_answer.rb index 8820bfaa14..3bff42fbf6 100644 --- a/app/models/form_answer.rb +++ b/app/models/form_answer.rb @@ -42,7 +42,7 @@ class FormAnswer < ApplicationRecord "promotion", # Enterprise Promotion Award ] - BUSINESS_AWARD_TYPES = %w(trade innovation development mobility) + BUSINESS_AWARD_TYPES = %w[trade innovation development mobility] AWARD_TYPE_FULL_NAMES = { "trade" => "International Trade", @@ -51,9 +51,7 @@ class FormAnswer < ApplicationRecord "mobility" => "Promoting Opportunity", "promotion" => "Enterprise Promotion", } - CURRENT_AWARD_TYPE_FULL_NAMES = AWARD_TYPE_FULL_NAMES.reject do |k, _| - k == "promotion" - end + CURRENT_AWARD_TYPE_FULL_NAMES = AWARD_TYPE_FULL_NAMES.except("promotion") FINANCIAL_STEPS = { ..2023 => { @@ -75,154 +73,140 @@ class FormAnswer < ApplicationRecord mount_uploader :pdf_version, FormAnswerPdfVersionUploader - begin :associations - belongs_to :user, optional: true - belongs_to :account, optional: true - belongs_to :award_year, optional: true - belongs_to :company_details_editable, polymorphic: true, optional: true - - has_one :form_basic_eligibility, class_name: "Eligibility::Basic", dependent: :destroy - has_one :trade_eligibility, class_name: "Eligibility::Trade", dependent: :destroy - has_one :innovation_eligibility, class_name: "Eligibility::Innovation", dependent: :destroy - has_one :development_eligibility, class_name: "Eligibility::Development", dependent: :destroy - has_one :mobility_eligibility, class_name: "Eligibility::Mobility", dependent: :destroy - has_one :promotion_eligibility, class_name: "Eligibility::Promotion", dependent: :destroy - has_one :audit_certificate, dependent: :destroy - has_one :feedback, dependent: :destroy - has_one :press_summary, dependent: :destroy - has_one :draft_note, as: :notable, dependent: :destroy - has_one :palace_invite, dependent: :destroy - has_one :form_answer_progress, dependent: :destroy - has_one :shortlisted_documents_wrapper, dependent: :destroy - - # PDF Hard Copies - # - has_one :case_summary_hard_copy_pdf, dependent: :destroy - has_one :feedback_hard_copy_pdf, dependent: :destroy - - belongs_to :primary_assessor, optional: true, class_name: "Assessor", foreign_key: :primary_assessor_id - belongs_to :secondary_assessor, optional: true, class_name: "Assessor", foreign_key: :secondary_assessor_id - has_many :form_answer_attachments, dependent: :destroy - has_many :support_letter_attachments, dependent: :destroy - has_many :commercial_figures_files, dependent: :destroy - has_many :vat_returns_files, dependent: :destroy - - has_many :audit_logs, as: :auditable - has_many :supporters, dependent: :destroy, autosave: true - has_many :support_letters, dependent: :destroy - has_many :comments, as: :commentable, dependent: :destroy - has_many :form_answer_transitions, autosave: false - has_many :assessor_assignments, dependent: :destroy - has_many :lead_or_primary_assessor_assignments, - -> { - where.not(submitted_at: nil) - .where(position: [3, 4]) - .order(position: :desc) }, - class_name: "AssessorAssignment", - foreign_key: :form_answer_id - has_many :assessors, through: :assessor_assignments do - def primary - where(assessor_assignments: - { - position: 0, - }, - ).first - end - - def secondary - where(assessor_assignments: - { - position: 1, - }, - ).first - end - end - end + # associations + belongs_to :user, optional: true + belongs_to :account, optional: true + belongs_to :award_year, optional: true + belongs_to :company_details_editable, polymorphic: true, optional: true + + has_one :form_basic_eligibility, class_name: "Eligibility::Basic", dependent: :destroy + has_one :trade_eligibility, class_name: "Eligibility::Trade", dependent: :destroy + has_one :innovation_eligibility, class_name: "Eligibility::Innovation", dependent: :destroy + has_one :development_eligibility, class_name: "Eligibility::Development", dependent: :destroy + has_one :mobility_eligibility, class_name: "Eligibility::Mobility", dependent: :destroy + has_one :promotion_eligibility, class_name: "Eligibility::Promotion", dependent: :destroy + has_one :audit_certificate, dependent: :destroy + has_one :feedback, dependent: :destroy + has_one :press_summary, dependent: :destroy + has_one :draft_note, as: :notable, dependent: :destroy + has_one :palace_invite, dependent: :destroy + has_one :form_answer_progress, dependent: :destroy + has_one :shortlisted_documents_wrapper, dependent: :destroy + + # PDF Hard Copies + # + has_one :case_summary_hard_copy_pdf, dependent: :destroy + has_one :feedback_hard_copy_pdf, dependent: :destroy + + belongs_to :primary_assessor, optional: true, class_name: "Assessor" + belongs_to :secondary_assessor, optional: true, class_name: "Assessor" + has_many :form_answer_attachments, dependent: :destroy + has_many :support_letter_attachments, dependent: :destroy + has_many :commercial_figures_files, dependent: :destroy + has_many :vat_returns_files, dependent: :destroy + + has_many :audit_logs, as: :auditable + has_many :supporters, dependent: :destroy, autosave: true + has_many :support_letters, dependent: :destroy + has_many :comments, as: :commentable, dependent: :destroy + has_many :form_answer_transitions, autosave: false + has_many :assessor_assignments, dependent: :destroy + # rubocop:disable Rails/InverseOf + has_many :lead_or_primary_assessor_assignments, + -> { where.not(submitted_at: nil).where(position: [3, 4]).order(position: :desc) }, + class_name: "AssessorAssignment", + foreign_key: :form_answer_id + # rubocop:enable Rails/InverseOf + has_many :assessors, through: :assessor_assignments do + def primary + where(assessor_assignments: { position: 0 }).first + end - begin :validations - validates :user, presence: true - validates :award_type, presence: true, - inclusion: { - in: POSSIBLE_AWARDS, - } - validates_uniqueness_of :urn, allow_nil: true, allow_blank: true - validates :sic_code, format: { with: SicCode::REGEX }, allow_nil: true, allow_blank: true - validate :validate_answers - end - - begin :scopes - scope :for_award_type, -> (award_type) { where(award_type: award_type) } - scope :for_year, -> (year) { joins(:award_year).where(award_years: { year: year }) } - scope :shortlisted, -> { where(state: %w(reserved recommended)) } - scope :not_shortlisted, -> { where(state: "not_recommended") } - scope :winners, -> { where(state: "awarded") } - scope :unsuccessful_applications, -> { submitted.where("state not in ('awarded', 'withdrawn')") } - scope :submitted, -> { where.not(submitted_at: nil) } - scope :positive, -> { where(state: FormAnswerStateMachine::POSITIVE_STATES) } - scope :at_post_submission_stage, -> { where(state: FormAnswerStateMachine::POST_SUBMISSION_STATES) } - scope :not_positive, -> { where(state: FormAnswerStateMachine::NOT_POSITIVE_STATES) } - scope :business, -> { where(award_type: BUSINESS_AWARD_TYPES) } - scope :promotion, -> { where(award_type: "promotion") } - scope :in_progress, -> { where(state: ["eligibility_in_progress", "application_in_progress"]) } - scope :without_product_figures, ->(condition) { - where(%Q{(#{FormAnswer.table_name}.metadata::JSONB->>'product_estimated_figures')::boolean is #{condition}}) - } - scope :with_estimated_figures_provided, -> { without_product_figures(true) } - scope :with_actual_figures_provided, -> { without_product_figures(false) } - scope :by_registration_numbers, ->(*numbers) { - query = numbers.join("|") - - where( - %Q{#{table_name}.metadata::JSONB @? '$.registration_number ? (@.type() == "string" && @ like_regex "[[:<:]](#{query})[[:>:]]" flag "i")'}, - ) - } - - scope :past, -> { - where(award_year_id: AwardYear.past.pluck(:id)).order("award_type") - } - - scope :hard_copy_generated, -> (mode) { - submitted.where("#{mode}_hard_copy_generated" => true) - } - - scope :with_comments_counters, -> { - select("form_answers.*, COUNT(DISTINCT(comments.id)) AS comments_count, COUNT(DISTINCT(flagged_admin_comments.id)) AS flagged_admin_comments_count, COUNT(DISTINCT(flagged_critical_comments.id)) AS flagged_critical_comments_count") - .joins("LEFT OUTER JOIN comments ON comments.commentable_id = form_answers.id AND comments.commentable_type = 'FormAnswer'") - .joins("LEFT OUTER JOIN comments AS flagged_admin_comments ON flagged_admin_comments.commentable_id = form_answers.id AND flagged_admin_comments.commentable_type = 'FormAnswer' AND flagged_admin_comments.flagged IS true AND flagged_admin_comments.section = 0") - .joins("LEFT OUTER JOIN comments AS flagged_critical_comments ON flagged_critical_comments.commentable_id = form_answers.id AND flagged_critical_comments.commentable_type = 'FormAnswer' AND flagged_critical_comments.flagged IS true AND flagged_critical_comments.section = 1") - } - - scope :primary_and_secondary_appraisals_are_not_match, -> { - where("discrepancies_between_primary_and_secondary_appraisals::text <> '{}'::text") - } - - scope :require_vocf, -> { where(award_type: %w[trade innovation]) } - scope :vocf_free, -> { where(award_type: %w[mobility development]) } - scope :provided_estimates, -> { where("document #>> '{product_estimated_figures}' = 'yes'") } - end - - begin :callbacks - before_save :set_award_year, unless: :award_year - before_save :set_urn - before_save :set_progress - before_save :set_region - before_save :assign_searching_attributes - - before_create :set_account - before_create :set_user_info + def secondary + where(assessor_assignments: { position: 1 }).first + end end + # validations + validates :user, presence: true + validates :award_type, presence: true, + inclusion: { + in: POSSIBLE_AWARDS, + } + validates :urn, uniqueness: { allow_blank: true } # rubocop:disable Rails/UniqueValidationWithoutIndex + validates :sic_code, format: { with: SicCode::REGEX }, allow_blank: true + validate :validate_answers + + # scopes + scope :for_award_type, ->(award_type) { where(award_type: award_type) } + scope :for_year, ->(year) { joins(:award_year).where(award_years: { year: year }) } + scope :shortlisted, -> { where(state: %w[reserved recommended]) } + scope :not_shortlisted, -> { where(state: "not_recommended") } + scope :winners, -> { where(state: "awarded") } + scope :unsuccessful_applications, -> { submitted.where("state not in ('awarded', 'withdrawn')") } + scope :submitted, -> { where.not(submitted_at: nil) } + scope :positive, -> { where(state: FormAnswerStateMachine::POSITIVE_STATES) } + scope :at_post_submission_stage, -> { where(state: FormAnswerStateMachine::POST_SUBMISSION_STATES) } + scope :not_positive, -> { where(state: FormAnswerStateMachine::NOT_POSITIVE_STATES) } + scope :business, -> { where(award_type: BUSINESS_AWARD_TYPES) } + scope :promotion, -> { where(award_type: "promotion") } + scope :in_progress, -> { where(state: ["eligibility_in_progress", "application_in_progress"]) } + scope :without_product_figures, ->(condition) { + where(%{(#{FormAnswer.table_name}.metadata::JSONB->>'product_estimated_figures')::boolean is #{condition}}) + } + scope :with_estimated_figures_provided, -> { without_product_figures(true) } + scope :with_actual_figures_provided, -> { without_product_figures(false) } + scope :by_registration_numbers, ->(*numbers) { + query = numbers.join("|") + + where( + %{#{table_name}.metadata::JSONB @? '$.registration_number ? (@.type() == "string" && @ like_regex "[[:<:]](#{query})[[:>:]]" flag "i")'}, + ) + } + + scope :past, -> { + where(award_year_id: AwardYear.past.select(:id)).order("award_type") + } + + scope :hard_copy_generated, ->(mode) { + submitted.where("#{mode}_hard_copy_generated" => true) + } + + scope :with_comments_counters, -> { + select("form_answers.*, COUNT(DISTINCT(comments.id)) AS comments_count, COUNT(DISTINCT(flagged_admin_comments.id)) AS flagged_admin_comments_count, COUNT(DISTINCT(flagged_critical_comments.id)) AS flagged_critical_comments_count") + .joins("LEFT OUTER JOIN comments ON comments.commentable_id = form_answers.id AND comments.commentable_type = 'FormAnswer'") + .joins("LEFT OUTER JOIN comments AS flagged_admin_comments ON flagged_admin_comments.commentable_id = form_answers.id AND flagged_admin_comments.commentable_type = 'FormAnswer' AND flagged_admin_comments.flagged IS true AND flagged_admin_comments.section = 0") + .joins("LEFT OUTER JOIN comments AS flagged_critical_comments ON flagged_critical_comments.commentable_id = form_answers.id AND flagged_critical_comments.commentable_type = 'FormAnswer' AND flagged_critical_comments.flagged IS true AND flagged_critical_comments.section = 1") + } + + scope :primary_and_secondary_appraisals_are_not_match, -> { + where("discrepancies_between_primary_and_secondary_appraisals::text <> '{}'::text") + } + + scope :require_vocf, -> { where(award_type: %w[trade innovation]) } + scope :vocf_free, -> { where(award_type: %w[mobility development]) } + scope :provided_estimates, -> { where("document #>> '{product_estimated_figures}' = 'yes'") } + + # callbacks + before_save :set_award_year, unless: :award_year + before_save :set_urn + before_save :set_progress + before_save :set_region + before_save :assign_searching_attributes + + before_create :set_account + before_create :set_user_info + store_accessor :document store_accessor :financial_data - begin :state_machine - delegate :current_state, :trigger!, :available_events, to: :state_machine - delegate :can_transition_to?, :transition_to!, :transition_to, :current_state, - to: :state_machine + # state_machine + delegate :current_state, :trigger!, :available_events, to: :state_machine + delegate :can_transition_to?, :transition_to!, :transition_to, :current_state, + to: :state_machine - def state_machine - @state_machine ||= FormAnswerStateMachine.new(self, transition_class: FormAnswerTransition) - end + def state_machine + @state_machine ||= FormAnswerStateMachine.new(self, transition_class: FormAnswerTransition) end # FormAnswer#award_form @@ -262,7 +246,7 @@ def award_form end def eligibility - public_send("#{award_type}_eligibility") + public_send(:"#{award_type}_eligibility") end def eligibility_class @@ -286,7 +270,7 @@ def document end def disabled_questions_hash(flatten: false) - ivar = flatten ? :"@_disabled_questions_flat_map" : :"@_disabled_questions_map" + ivar = flatten ? :@_disabled_questions_flat_map : :@_disabled_questions_map if instance_variable_defined?(ivar) return instance_variable_get(ivar) @@ -296,45 +280,46 @@ def disabled_questions_hash(flatten: false) form = award_form.decorate(answers: progress_hash) res = form.steps.each_with_object(Hash[:halted, Hash[:step, nil]]) do |step, memo| - memo[step.index] = Hash[].tap do |hash| - s_idx = memo.dig(:halted, :step) - q_idx = nil + memo[step.index] = Hash[].tap do |hash| + s_idx = memo.dig(:halted, :step) + q_idx = nil - hash[:disabled] = !!(s_idx && step.index > s_idx) - step.questions.each_with_index do |question, idx| - memo[:halted][:step] ||= step.index if question.halted? - q_idx ||= idx if question.halted? + hash[:disabled] = !!(s_idx && step.index > s_idx) + step.questions.each_with_index do |question, idx| + memo[:halted][:step] ||= step.index if question.halted? + q_idx ||= idx if question.halted? - hash[question.key] = !!(hash[:disabled] || q_idx && idx > q_idx) - end - end - end + hash[question.key] = !!(hash[:disabled] || q_idx && idx > q_idx) + end + end + end - instance_variable_set(:"@_disabled_questions_map", res) - instance_variable_set(:"@_disabled_questions_flat_map", res.values.reduce({}, :merge)) + instance_variable_set(:@_disabled_questions_map, res) + instance_variable_set(:@_disabled_questions_flat_map, res.values.reduce({}, :merge)) instance_variable_get(ivar) end def halted? - if instance_variable_defined?(:"@_form_halted") - return instance_variable_get(:"@_form_halted") + if instance_variable_defined?(:@_form_halted) + return instance_variable_get(:@_form_halted) end progress_hash = HashWithIndifferentAccess.new(document || {}) form = award_form.decorate(answers: progress_hash) value = form.steps.any? do |step| - step.questions.any?(&:halted?) - end + step.questions.any?(&:halted?) + end - instance_variable_set(:"@_form_halted", value) + instance_variable_set(:@_form_halted, value) end def head_of_business - head_of_business = document["head_of_business_first_name"].to_s - head_of_business += " " - head_of_business += document["head_of_business_last_name"].to_s + [ + document["head_of_business_first_name"].to_s, + document["head_of_business_last_name"].to_s, + ].compact_blank.join(" ") end def company_or_nominee_from_document @@ -393,8 +378,8 @@ def business? end def financial_step - h = FINANCIAL_STEPS.select { |y| y === self.award_year.year } - h.values[0][self.award_type] - 1 + h = FINANCIAL_STEPS.select { |y| y === award_year.year } + h.values[0][award_type] - 1 end # @@ -418,9 +403,9 @@ def generate_feedback_hard_copy_pdf! end def hard_copy_ready_for?(mode) - send("#{mode}_hard_copy_generated?") && - send("#{mode}_hard_copy_pdf").present? && - send("#{mode}_hard_copy_pdf").file.present? + send(:"#{mode}_hard_copy_generated?") && + send(:"#{mode}_hard_copy_pdf").present? && + send(:"#{mode}_hard_copy_pdf").file.present? end # @@ -493,13 +478,13 @@ def requires_vocf? return false if !business? return true if award_year && award_year.before_vocf_switch? - %w(trade innovation).include?(award_type) + %w[trade innovation].include?(award_type) end def financial_year_changeable? key = :most_recent_financial_year selected = %i[most_recent_financial_year financial_year_date_day financial_year_date_month] - self.award_form + award_form .questions_by_key[key] &.decorate(answers: HashWithIndifferentAccess.new(document || {}).slice(*selected)) &.year_changeable? @@ -514,18 +499,26 @@ def shortlisted_documents_submitted? end def other_applications_from_same_entity - content = self.document.dig("registration_number") + content = document.dig("registration_number") extracted_numbers = ::CompanyRegistrationNumber.extract_from(content) return [] if extracted_numbers.empty? self.class.submitted - .where.not(id: self.id) + .where.not(id: id) .by_registration_numbers(*extracted_numbers) .joins(:award_year) .order("award_years.year DESC") end + def self.transition_class + FormAnswerTransition + end + + def self.initial_state + FormAnswerStateMachine.initial_state + end + private def nominator_full_name_from_document @@ -550,11 +543,11 @@ def set_award_year end def set_progress - #TODO: move this logic to it's specific class when you create one class per document type. - if award_type == "promotion" - questions_that_dont_count = [] + # TODO: move this logic to it's specific class when you create one class per document type. + questions_that_dont_count = if award_type == "promotion" + [] else - questions_that_dont_count = [:company_name] + [:company_name] end ## questions that don't count are excluded to show 0% progress for applications not started @@ -619,12 +612,4 @@ def validate_answers def award_form_class_name(year) "::AwardYears::V#{year}::QaeForms" end - - def self.transition_class - FormAnswerTransition - end - - def self.initial_state - FormAnswerStateMachine.initial_state - end end diff --git a/app/models/form_answer/award_eligibility_builder.rb b/app/models/form_answer/award_eligibility_builder.rb index 75887435fc..5aee1022ce 100644 --- a/app/models/form_answer/award_eligibility_builder.rb +++ b/app/models/form_answer/award_eligibility_builder.rb @@ -11,7 +11,7 @@ def eligibility method = "#{form_answer.award_type}_eligibility" unless form_answer.public_send(method) - form_answer.public_send("build_#{method}", account_id: account.id).save! + form_answer.public_send(:"build_#{method}", account_id: account.id).save! end form_answer.public_send(method) @@ -22,11 +22,10 @@ def basic_eligibility return nil if form_answer.promotion? if form_answer.form_basic_eligibility.try(:persisted?) - form_answer.form_basic_eligibility else form_answer.build_form_basic_eligibility(filter(account.basic_eligibility.try(:attributes) || {}).merge(account_id: account.id)).save! - form_answer.form_basic_eligibility end + form_answer.form_basic_eligibility end end diff --git a/app/models/form_answer_attachment.rb b/app/models/form_answer_attachment.rb index 45fcca38f0..9f6d2e07c4 100644 --- a/app/models/form_answer_attachment.rb +++ b/app/models/form_answer_attachment.rb @@ -24,17 +24,13 @@ class FormAnswerAttachment < ApplicationRecord validate :question_key_correctness # Used for NON JS implementation - end - begin :validations - validates :form_answer_id, presence: true - validates :file, presence: true, - on: :create, - file_size: { - maximum: 5.megabytes.to_i, - } - end + validates :form_answer_id, presence: true + validates :file, presence: true, + on: :create, + file_size: { maximum: 5.megabytes.to_i } def filename - read_attribute(:file) + self[:file] end def created_by_admin? diff --git a/app/models/form_answer_state_machine.rb b/app/models/form_answer_state_machine.rb index a4545b44bd..afdd074bb8 100644 --- a/app/models/form_answer_state_machine.rb +++ b/app/models/form_answer_state_machine.rb @@ -160,10 +160,12 @@ def after_eligibility_step_failure private def get_metadata(subject) - meta = { - transitable_id: subject.id, - transitable_type: subject.class.to_s, - } if subject.present? + if subject.present? + meta = { + transitable_id: subject.id, + transitable_type: subject.class.to_s, + } + end meta ||= {} meta end diff --git a/app/models/form_answer_state_transition.rb b/app/models/form_answer_state_transition.rb index 74b166f340..4c90bed40d 100644 --- a/app/models/form_answer_state_transition.rb +++ b/app/models/form_answer_state_transition.rb @@ -23,7 +23,7 @@ def save def collection states = form_answer.state_machine.collection(subject) - if !subject.kind_of?(Admin) && subject.lead?(form_answer) + if !subject.is_a?(Admin) && subject.lead?(form_answer) states - [:not_awarded, :withdrawn] else states diff --git a/app/models/form_answer_states_helper.rb b/app/models/form_answer_states_helper.rb index abf295cf2b..dcfa4b294b 100644 --- a/app/models/form_answer_states_helper.rb +++ b/app/models/form_answer_states_helper.rb @@ -8,7 +8,7 @@ def submitted_and_after_the_deadline? end (FormAnswerStateMachine::STATES - [:submitted]).each do |permitted_state| - define_method("#{permitted_state}?") do + define_method(:"#{permitted_state}?") do state == permitted_state.to_s end end diff --git a/app/models/form_answer_statistics/picker.rb b/app/models/form_answer_statistics/picker.rb index 24a663c0b8..2c9b1e2298 100644 --- a/app/models/form_answer_statistics/picker.rb +++ b/app/models/form_answer_statistics/picker.rb @@ -8,10 +8,10 @@ def initialize(year) def applications_table out = {} registered_users = [] - c = count_with_year(User.where(created_at: (Time.now - 24.hours)..Time.now)) + c = count_with_year(User.where(created_at: (Time.current - 24.hours)..Time.current)) registered_users << c - c = count_with_year(User.where(created_at: (Time.now - 7.days)..Time.now)) + c = count_with_year(User.where(created_at: (Time.current - 7.days)..Time.current)) registered_users << c registered_users << User.where(created_at: year.user_creation_range).count @@ -30,8 +30,8 @@ def applications_table out[:eligibility_in_progress] = { name: "Applications with eligibility in progress", counters: eligibility_in_progress } in_progress = [] - in_progress << count_with_year(application_in_progress(Time.now - 1.day).count) - in_progress << count_with_year(application_in_progress(Time.now - 7.days).count) + in_progress << count_with_year(application_in_progress(Time.current - 1.day).count) + in_progress << count_with_year(application_in_progress(Time.current - 7.days).count) in_progress << fa_year_scope.where(state: "application_in_progress").count out[:applications_in_progress] = { name: "Applications in progress", counters: in_progress } @@ -47,7 +47,7 @@ def applications_completions out = {} out["total"] = [0, 0, 0, 0, 0, 0, 0, 0] klass::POSSIBLE_AWARDS.each do |aw| - scope = fa_year_scope.where(award_type: aw).where(state: %w(application_in_progress eligibility_in_progress not_eligible)) + scope = fa_year_scope.where(award_type: aw).where(state: %w[application_in_progress eligibility_in_progress not_eligible]) out[aw] = collect_completion_ranges(scope) unless aw == "promotion" @@ -96,7 +96,7 @@ def application_in_progress(time_range) .where(state: "application_in_progress") .where("(form_answer_transitions.to_state = ? AND form_answer_transitions.created_at > ?) OR (form_answers.created_at > ?)", - "application_in_progress", time_range, time_range,) + "application_in_progress", time_range, time_range) .group("form_answers.id") end @@ -104,7 +104,7 @@ def eligibility_in_progress(time_range) fa_year_scope.joins(:form_answer_transitions) .where(state: "eligibility_in_progress") .where("form_answer_transitions.to_state = ? AND - form_answer_transitions.created_at > ?", "eligibility_in_progress", time_range,) + form_answer_transitions.created_at > ?", "eligibility_in_progress", time_range) .group("form_answers.id") end @@ -112,14 +112,14 @@ def not_eligible(time_range) fa_year_scope.joins(:form_answer_transitions) .where(state: "not_eligible") .where("form_answer_transitions.to_state = ? AND - form_answer_transitions.created_at > ?", "not_eligible", time_range,) + form_answer_transitions.created_at > ?", "not_eligible", time_range) .group("form_answers.id") end def submissions_query(scope, time_range) out = scope.joins(:form_answer_transitions) out = out.at_post_submission_stage - out = out.where("form_answer_transitions.to_state = ?", "submitted") + out = out.where(form_answer_transitions: { to_state: "submitted" }) out = out.where("form_answer_transitions.created_at > ?", time_range) if time_range out.group("form_answers.id") end diff --git a/app/models/forms_lost_financial_data_detector.rb b/app/models/forms_lost_financial_data_detector.rb index 35c36ae128..2ebd6345b4 100644 --- a/app/models/forms_lost_financial_data_detector.rb +++ b/app/models/forms_lost_financial_data_detector.rb @@ -4,22 +4,25 @@ # [1925, 2569, 998, 2582, 551, 2580, 2570, 2584, 2395, 2583, 1993, 2595, 2270, 2304, 750, 2596, 2572, 1572, 251, 2539, 2589, 26, 443, 2558, 2531, 2511, 2559, 564, 2555, 2532, 2561, 2601, 2602, 1333, 2600, 2593, 2594, 2548, 2535, 2536, 1705, 429, 1768, 1391, 2574, 2341, 677, 1406, 2547, 2560, 2348, 2162, 2240, 2302, 2314, 1945, 1714, 2206, 2543, 2494, 2553, 2578, 1117, 2352, 1584, 2549, 1371, 2250, 2211, 1161, 292, 1118, 2344, 1474, 1795, 2196, 2214, 2563] class FormsLostFinancialDataDetector - QUESTIONS = [ - "employees_", - "total_turnover_", - "exports_", - "uk_sales_", - "net_profit_", - "total_net_assets_", - "units_sold_", - "sales_", - "sales_exports_", - "sales_royalties_", - "avg_unit_cost_self_", - "overseas_sales_", - "avg_unit_price_", + QUESTIONS = %w[ + employees_ + total_turnover_ + exports_ + uk_sales_ + net_profit_ + total_net_assets_ + units_sold_ + sales_ + sales_exports_ + sales_royalties_ + avg_unit_cost_self_ + overseas_sales_ + avg_unit_price_ ] + RANGE_OPTIONS = %w[day month year] + THRESHOLD_OPTIONS = [2, 3, 5, 6] + attr_accessor :forms, :date_of_update def initialize @@ -27,12 +30,11 @@ def initialize self.forms = fetch_forms end - def restore - end + def restore; end def possible_question_keys QUESTIONS.map do |q| - [2, 3, 5, 6].map do |i| + THRESHOLD_OPTIONS.map do |i| (1..i).to_a.map do |y| "#{q}#{y}of#{i}" end @@ -42,8 +44,8 @@ def possible_question_keys end def financial_dates - ["day", "month", "year"].map do |i| - [2, 3, 5, 6].map do |z| + RANGE_OPTIONS.map do |i| + THRESHOLD_OPTIONS.map do |z| (1..z).to_a.map do |y| "financial_year_changed_dates_#{y}of#{z}#{i}" end @@ -53,9 +55,9 @@ def financial_dates def set_form(f, doc) possible_question_keys.each do |k| - puts "[#{f.id}] #{k}: #{doc[k]}" + Rails.logger.debug "[#{f.id}] #{k}: #{doc[k]}" if doc[k].present? - puts "[#{f.id}] #{k}: #{doc[k]} --------------- ADDED" + Rails.logger.debug "[#{f.id}] #{k}: #{doc[k]} --------------- ADDED" f.document[k] = doc[k] end end @@ -83,13 +85,13 @@ def fetch_forms end def get_target_requests_from_logfile - content = File.read("#{Rails.root}/logfile.log") + content = File.read(Rails.root.join("logfile.log")) entries = content.scan(/^(.*)Parameters: (.*)$/).select do |entry| entry[1].include?("current_step_id") end - res = entries.map do |entry| - hash_of_params = eval(entry[1]) + entries.map do |entry| + hash_of_params = JSON.parse(entry[1].gsub!("=>", ":")) id = hash_of_params["id"] form = hash_of_params["form"] @@ -101,15 +103,13 @@ def get_target_requests_from_logfile date, ] end.select do |item| - #ids.include?(item[0].to_s) && + # ids.include?(item[0].to_s) && possible_question_keys.any? do |k| item[1][k.to_s].present? end end.sort do |a, b| b[2] <=> a[2] end - - res end def fetch_date(str) diff --git a/app/models/judge.rb b/app/models/judge.rb index 12907e90ae..2f542182d0 100644 --- a/app/models/judge.rb +++ b/app/models/judge.rb @@ -52,7 +52,7 @@ def self.roles def assigned_award_types FormAnswer::POSSIBLE_AWARDS.select do |category| - public_send("#{category}_role").present? + public_send(:"#{category}_role").present? end end diff --git a/app/models/palace_attendee.rb b/app/models/palace_attendee.rb index c46d9f526a..3d0a8e99ec 100644 --- a/app/models/palace_attendee.rb +++ b/app/models/palace_attendee.rb @@ -11,8 +11,8 @@ class PalaceAttendee < ApplicationRecord :postcode, presence: true - validates :disabled_access, inclusion: { in: [ true, false ], message: "This field cannot be blank" } - validates :has_royal_family_connections, inclusion: { in: [ true, false ], message: "This field cannot be blank" } + validates :disabled_access, inclusion: { in: [true, false], message: "This field cannot be blank" } + validates :has_royal_family_connections, inclusion: { in: [true, false], message: "This field cannot be blank" } validates :royal_family_connection_details, presence: true, if: :has_royal_family_connections? validate :royal_family_connection_details_length diff --git a/app/models/palace_invite.rb b/app/models/palace_invite.rb index d0f6d1c37e..1a70e7129c 100644 --- a/app/models/palace_invite.rb +++ b/app/models/palace_invite.rb @@ -3,8 +3,7 @@ class PalaceInvite < ApplicationRecord has_many :palace_attendees, dependent: :destroy, autosave: true - validates :form_answer_id, presence: true, - uniqueness: true + validates :form_answer_id, presence: true, uniqueness: true # rubocop:disable Rails/UniqueValidationWithoutIndex before_create :set_token @@ -26,11 +25,7 @@ def submit! end def attendees_limit - if form_answer.promotion? - 1 # nominator - else - 1 # 2020 COVID inspired rules - end + 1 end private diff --git a/app/models/permitted_params.rb b/app/models/permitted_params.rb index db39c9a1d8..cdbab66654 100644 --- a/app/models/permitted_params.rb +++ b/app/models/permitted_params.rb @@ -330,5 +330,3 @@ module PermittedParams data_attributes: {}, ] end - - diff --git a/app/models/reports/admin_report.rb b/app/models/reports/admin_report.rb index 371baad54d..9565d3e5a0 100644 --- a/app/models/reports/admin_report.rb +++ b/app/models/reports/admin_report.rb @@ -51,7 +51,7 @@ def csv_filename if category == "trade" && id == "case-index" && year.year != 2016 - # For 2016 we use one report for both trade years modes ('3 to 5' and '6 plus') + # For 2016 we use one report for both trade years modes ('3 to 5' and '6 plus') sub_type = "_#{years_mode}" end @@ -83,13 +83,13 @@ def as_pdf if category == "trade" && id == "case_summaries" && year.year != 2016 - # For 2016 we use one report for both trade years modes ('3 to 5' and '6 plus') + # For 2016 we use one report for both trade years modes ('3 to 5' and '6 plus') sub_type = "_#{years_mode}" end - attachment = year.send("#{id.singularize}_#{category}#{sub_type}_hard_copy_pdf") + attachment = year.send(:"#{id.singularize}_#{category}#{sub_type}_hard_copy_pdf") - if year.send("aggregated_#{id.singularize}_hard_copy_state").to_s == "completed" && + if year.send(:"aggregated_#{id.singularize}_hard_copy_state").to_s == "completed" && attachment.present? && attachment.file.present? # Render Hard Copy if it's generated for this year @@ -125,7 +125,7 @@ def valid_identifier(identifier) end def category - params[:category] if ::FormAnswer::AWARD_TYPE_FULL_NAMES.keys.include?(params[:category]) + params[:category] if ::FormAnswer::AWARD_TYPE_FULL_NAMES.key?(params[:category]) end def years_mode diff --git a/app/models/reports/assessor_report.rb b/app/models/reports/assessor_report.rb index 49923e1493..30bfe0888f 100644 --- a/app/models/reports/assessor_report.rb +++ b/app/models/reports/assessor_report.rb @@ -15,7 +15,7 @@ def as_csv when "discrepancies_between_primary_and_secondary_appraisals" Reports::DiscrepanciesBetweenPrimaryAndSecondaryAppraisals.new(year, params[:category], @current_subject).build when /assessors-progress/ - if FormAnswer::AWARD_TYPE_FULL_NAMES.keys.include?(params[:category]) + if FormAnswer::AWARD_TYPE_FULL_NAMES.key?(params[:category]) Reports::AssessorsProgressReport.new(year, params[:category]).build else raise ArgumentError, "Invalid category" diff --git a/app/models/reports/cases_status_report.rb b/app/models/reports/cases_status_report.rb index b304831587..d02939d298 100644 --- a/app/models/reports/cases_status_report.rb +++ b/app/models/reports/cases_status_report.rb @@ -128,7 +128,7 @@ def scoped_collection :audit_certificate, :feedback, :primary_assessor, - :secondary_assessor,) + :secondary_assessor) end def mapping diff --git a/app/models/reports/compiled_press_book.rb b/app/models/reports/compiled_press_book.rb index bcedd1a13b..dccd00d1a3 100644 --- a/app/models/reports/compiled_press_book.rb +++ b/app/models/reports/compiled_press_book.rb @@ -275,7 +275,7 @@ def render_total_cell(worksheet, row_i, column_i, category) end def group_form_answers(form_answers) - groupped = form_answers.group_by do |fa| + form_answers.group_by do |fa| fa.document["organization_address_region"] end end diff --git a/app/models/reports/csv_helper.rb b/app/models/reports/csv_helper.rb index 57349fbc72..f9ef6e8d3a 100644 --- a/app/models/reports/csv_helper.rb +++ b/app/models/reports/csv_helper.rb @@ -56,7 +56,7 @@ def prepare_stream(scope, limited_access = false) private def headers - mapping.map { |m| m[:label] } + mapping.pluck(:label) end def sanitize_string(string) diff --git a/app/models/reports/dashboard/applications_report.rb b/app/models/reports/dashboard/applications_report.rb index 7b7f2fe7ae..0782d5e362 100644 --- a/app/models/reports/dashboard/applications_report.rb +++ b/app/models/reports/dashboard/applications_report.rb @@ -2,12 +2,12 @@ class Reports::Dashboard::ApplicationsReport < Reports::Dashboard::Base attr_reader :award_type def initialize(kind:, award_type: nil) - @kind = kind + @kind = valid_kind(kind) @award_type = award_type end def stats - public_send("stats_#{kind}") + public_send(:"stats_#{kind}") end def scope(award_year) @@ -92,15 +92,15 @@ def as_csv when "by_day" columns = ["6 days before deadline", "5 days before deadline", "4 days before deadline", "3 days before deadline", "2 days before deadline", "1 day before deadline", "Totals on deadline"] end - csv << (headers + columns.map{ |c| [c] << nil }).flatten + csv << (headers + columns.map { |c| [c] << nil }).flatten subheaders = [""] - columns.each{ subheaders << ["In progress", "Submitted"] } + columns.each { subheaders << ["In progress", "Submitted"] } csv << subheaders.flatten stats.each do |row| content = [] content << row.label - row.content.each{ |c| content << ((c == " ") ? nil : c) } + row.content.each { |c| content << ((c == " ") ? nil : c) } csv << content end end @@ -109,4 +109,8 @@ def as_csv def csv_filename "#{award_type || "all"}_applications_report_#{kind}.csv" end + + def valid_kind(value) + value if value.presence.in?(%w[by_month by_week by_day]) + end end diff --git a/app/models/reports/dashboard/base.rb b/app/models/reports/dashboard/base.rb index 72aedc9587..f860f437c4 100644 --- a/app/models/reports/dashboard/base.rb +++ b/app/models/reports/dashboard/base.rb @@ -10,7 +10,7 @@ def label(award_year) end def submission_deadline_label(award_year) - if deadline = submission_deadline(award_year) + if (deadline = submission_deadline(award_year)) "(#{deadline.strftime("%m/%d/%Y")})" else "" diff --git a/app/models/reports/dashboard/users_report.rb b/app/models/reports/dashboard/users_report.rb index 31927254b8..eb848febf6 100644 --- a/app/models/reports/dashboard/users_report.rb +++ b/app/models/reports/dashboard/users_report.rb @@ -1,10 +1,10 @@ class Reports::Dashboard::UsersReport < Reports::Dashboard::Base def initialize(kind:) - @kind = kind + @kind = valid_kind(kind) end def stats - public_send("stats_#{kind}") + public_send(:"stats_#{kind}") end def scope(award_year) @@ -85,7 +85,7 @@ def as_csv stats.each do |row| content = [] content << row.label - row.content.each{ |c| content << ((c == " ") ? nil : c) } + row.content.each { |c| content << ((c == " ") ? nil : c) } csv << content end end @@ -94,4 +94,8 @@ def as_csv def csv_filename "account_registrations_#{kind}.csv" end + + def valid_kind(value) + value if value.presence.in?(%w[by_month by_week by_day]) + end end diff --git a/app/models/reports/data_pickers/form_document_picker.rb b/app/models/reports/data_pickers/form_document_picker.rb index 3828a84a37..f1f0000e1d 100644 --- a/app/models/reports/data_pickers/form_document_picker.rb +++ b/app/models/reports/data_pickers/form_document_picker.rb @@ -73,7 +73,7 @@ def head_title def innovation_type if innovation? && doc("application_relate_to_header") - types = doc("application_relate_to_header").map{ |hash| hash["type"] } + types = doc("application_relate_to_header").map { |hash| hash["type"] } types.join(",") else "" @@ -91,7 +91,7 @@ def innovation_description def current_queens_award_holder awards = obj.previous_wins - return if !awards || awards.empty? + return if awards.blank? categories = PreviousWin::CATEGORIES.invert @@ -140,7 +140,7 @@ def principal_address3 def principal_county if business_form? - if county = doc("organization_address_county") + if (county = doc("organization_address_county")) county.split(" - ").first else "" @@ -295,12 +295,10 @@ def product_service elsif mobility? if obj.award_year.year <= 2020 doc("mobility_desc_short") + elsif obj.award_year.year <= 2023 + (doc("application_category") == "initiative") ? doc("initiative_desc_short") : doc("organisation_desc_short") else - if obj.award_year.year <= 2023 - (doc("application_category") == "initiative") ? doc("initiative_desc_short") : doc("organisation_desc_short") - else - doc("initiative_desc_short") - end + doc("initiative_desc_short") end else (obj.award_year.year <= 2023) ? doc("trade_goods_briefly") : doc("trade_description_short") @@ -315,7 +313,11 @@ def date_started_trading year = doc("started_trading_year") if year && month && day - Date.new(year.to_i, month.to_i, day.to_i).strftime("%m/%d/%Y") rescue nil + begin + Date.new(year.to_i, month.to_i, day.to_i).strftime("%m/%d/%Y") + rescue + nil + end end end @@ -331,9 +333,9 @@ def collect_final_value_from_doc(meth) question = questions[meth.keys.first.to_sym]&.decorate(answers: answers) range = if question.respond_to?(:active_by_year_condition) - question.active_by_year_condition&.options&.dig(:data, :identifier) + question.active_by_year_condition&.options&.dig(:data, :identifier) else - doc(meth.keys.first) + doc(meth.keys.first) end target_key = meth.values.first[range] diff --git a/app/models/reports/data_pickers/user_picker.rb b/app/models/reports/data_pickers/user_picker.rb index 87f71afbea..e06b3aadf5 100644 --- a/app/models/reports/data_pickers/user_picker.rb +++ b/app/models/reports/data_pickers/user_picker.rb @@ -1,7 +1,5 @@ module Reports::DataPickers::UserPicker - def user - obj.user - end + delegate :user, to: :obj def contact_title user.try(:title) diff --git a/app/models/reports/discrepancies_between_primary_and_secondary_appraisals.rb b/app/models/reports/discrepancies_between_primary_and_secondary_appraisals.rb index 26774429f9..e8faed3058 100644 --- a/app/models/reports/discrepancies_between_primary_and_secondary_appraisals.rb +++ b/app/models/reports/discrepancies_between_primary_and_secondary_appraisals.rb @@ -41,16 +41,16 @@ def initialize(year, award_type, current_subject = nil) @award_type = award_type if current_subject.is_a?(Assessor) && - !current_subject.lead_roles.include?(@award_type) + current_subject.lead_roles.exclude?(@award_type) raise "Access Denied!" end @scope = @year.form_answers.order(:id) - .joins(%Q{ + .joins(%( JOIN assessor_assignments primary_assignments ON primary_assignments.form_answer_id = form_answers.id JOIN assessor_assignments secondary_assignments ON secondary_assignments.form_answer_id = form_answers.id - }) + )) .where(primary_assignments: { position: AssessorAssignment.positions[:primary] }) .where.not(primary_assignments: { position: nil }) .where(secondary_assignments: { position: AssessorAssignment.positions[:secondary] }) diff --git a/app/models/reports/reception_buckingham_palace_report.rb b/app/models/reports/reception_buckingham_palace_report.rb index 6e3cbe86bf..fb15b54a78 100644 --- a/app/models/reports/reception_buckingham_palace_report.rb +++ b/app/models/reports/reception_buckingham_palace_report.rb @@ -109,8 +109,8 @@ def stream def scoped_collection PalaceAttendee.includes(palace_invite: :form_answer) - .where("form_answers.award_year_id = ?", @year.id) - .where("palace_invites.submitted = ?", true) + .where(form_answers: { award_year_id: @year.id }) + .where(palace_invites: { submitted: true }) .order("palace_invites.form_answer_id ASC, palace_attendees.id ASC") end diff --git a/app/models/reports/registered_users.rb b/app/models/reports/registered_users.rb index c6bdb3ab7b..4570320adf 100644 --- a/app/models/reports/registered_users.rb +++ b/app/models/reports/registered_users.rb @@ -123,7 +123,7 @@ def scoped_collection :assessor_assignments, :primary_assessor, :secondary_assessor, - :form_answer_progress,) + :form_answer_progress) end def mapping diff --git a/app/models/reports/user.rb b/app/models/reports/user.rb index 7b25d33d78..862a5cd092 100644 --- a/app/models/reports/user.rb +++ b/app/models/reports/user.rb @@ -24,8 +24,8 @@ def user_type def awards_assigned if @user.is_a?(Assessor) || @user.is_a?(Judge) @user.roles - .reject{ |role| role =~ /promotion/ } - .map{ |role| FormAnswer::AWARD_TYPE_FULL_NAMES[role] } + .reject { |role| role.include?("promotion") } + .map { |role| FormAnswer::AWARD_TYPE_FULL_NAMES[role] } .join(", ") else "N/A" diff --git a/app/models/settings.rb b/app/models/settings.rb index 6e5cb9efe3..8434ece35f 100644 --- a/app/models/settings.rb +++ b/app/models/settings.rb @@ -27,11 +27,7 @@ def current_award_year_switch_date def current_award_year_switch_date_or_default_trigger_at Rails.cache.fetch("award_year_switch_deadline_or_default_trigger_at", expires_in: 1.minute) do - if current.deadlines.award_year_switch.trigger_at - current.deadlines.award_year_switch.trigger_at - else - Date.new(current.award_year.year - 1, AwardYear::DEFAULT_FINANCIAL_SWITCH_MONTH, AwardYear::DEFAULT_FINANCIAL_SWITCH_DAY) - end + current.deadlines.award_year_switch.trigger_at || Date.new(current.award_year.year - 1, AwardYear::DEFAULT_FINANCIAL_SWITCH_MONTH, AwardYear::DEFAULT_FINANCIAL_SWITCH_DAY) end end @@ -51,10 +47,10 @@ def current_submission_start_deadline end end - %w(innovation trade mobility development).each do |award| - define_method "current_#{award}_submission_start_deadline" do + %w[innovation trade mobility development].each do |award| + define_method :"current_#{award}_submission_start_deadline" do Rails.cache.fetch("#{award}_submission_start_deadline", expires_in: 1.minute) do - current.deadlines.public_send("#{award}_submission_start") + current.deadlines.public_send(:"#{award}_submission_start") end end end diff --git a/app/models/shortlisted_documents_wrapper.rb b/app/models/shortlisted_documents_wrapper.rb index 28acfab628..eea91ae542 100644 --- a/app/models/shortlisted_documents_wrapper.rb +++ b/app/models/shortlisted_documents_wrapper.rb @@ -1,4 +1,4 @@ -class ShortlistedDocumentsWrapper < ActiveRecord::Base +class ShortlistedDocumentsWrapper < ApplicationRecord include Reviewable has_one :commercial_figures_file @@ -35,7 +35,7 @@ def confirmed_changes? private def set_submission_date(timestamp = Time.zone.now) - self.update(submitted_at: timestamp) + update(submitted_at: timestamp) end def requirements_fulfilled? diff --git a/app/models/site_feedback.rb b/app/models/site_feedback.rb index c41c6d2be8..8baeabfcc8 100644 --- a/app/models/site_feedback.rb +++ b/app/models/site_feedback.rb @@ -5,7 +5,7 @@ class SiteFeedback < ApplicationRecord satisfied: 4, neither_satisfied_or_dissatisfied: 3, dissatisfied: 2, - very_dissatisfied: 1, } + very_dissatisfied: 1 } validates :rating, presence: true end diff --git a/app/models/support_letter.rb b/app/models/support_letter.rb index b4846f8b4b..e62d2a3b8a 100644 --- a/app/models/support_letter.rb +++ b/app/models/support_letter.rb @@ -1,27 +1,24 @@ class SupportLetter < ApplicationRecord - begin :associations - belongs_to :supporter, optional: true - belongs_to :form_answer, optional: true - belongs_to :user, optional: true + # associations + belongs_to :supporter, optional: true + belongs_to :form_answer, optional: true + belongs_to :user, optional: true - has_one :support_letter_attachment, autosave: true, dependent: :destroy - end + has_one :support_letter_attachment, autosave: true, dependent: :destroy - begin :validations - validates :first_name, - :last_name, - :user, - :form_answer, - :relationship_to_nominee, presence: true - validates :attachment, presence: true, if: proc { manual? && !support_letter_attachment } - validates :body, presence: true, unless: :manual? - validates :support_letter_attachment, presence: true, if: proc { manual? } - end + # validations + validates :first_name, + :last_name, + :user, + :form_answer, + :relationship_to_nominee, presence: true + validates :attachment, presence: true, if: proc { manual? && !support_letter_attachment } + validates :body, presence: true, unless: :manual? + validates :support_letter_attachment, presence: true, if: proc { manual? } - begin :scopes - scope :manual, -> { where(manual: true) } - scope :not_manual, -> { where(manual: false) } - end + # scopes + scope :manual, -> { where(manual: true) } + scope :not_manual, -> { where(manual: false) } attr_accessor :attachment diff --git a/app/models/support_letter_attachment.rb b/app/models/support_letter_attachment.rb index f49faa8ce3..3fa95dae42 100644 --- a/app/models/support_letter_attachment.rb +++ b/app/models/support_letter_attachment.rb @@ -5,18 +5,16 @@ class SupportLetterAttachment < ApplicationRecord include ::InfectedFileCleaner clean_after_scan :attachment - begin :associations - belongs_to :user, optional: true - belongs_to :form_answer, optional: true - belongs_to :support_letter, optional: true - end + # associations + belongs_to :user, optional: true + belongs_to :form_answer, optional: true + belongs_to :support_letter, optional: true - begin :validations - validates :form_answer, :user, presence: true - validates :attachment, presence: true, - on: :create, - file_size: { - maximum: 5.megabytes.to_i, - } - end + # validations + validates :form_answer, :user, presence: true + validates :attachment, presence: true, + on: :create, + file_size: { + maximum: 5.megabytes.to_i, + } end diff --git a/app/models/supporter.rb b/app/models/supporter.rb index d2fc6bf507..ea82aa687b 100644 --- a/app/models/supporter.rb +++ b/app/models/supporter.rb @@ -1,26 +1,20 @@ require "securerandom" class Supporter < ApplicationRecord - begin :associations - belongs_to :form_answer, optional: true - belongs_to :user, optional: true + # associations + belongs_to :form_answer, optional: true + belongs_to :user, optional: true - has_one :support_letter, dependent: :destroy - end - - begin :associations - validates :email, :form_answer, presence: true - end + has_one :support_letter, dependent: :destroy - begin :validations - validates :email, email: true - - validates :first_name, - :last_name, - :user, - :form_answer, - :relationship_to_nominee, presence: true - end + # validations + validates :email, email: true + validates :email, + :first_name, + :last_name, + :user, + :form_answer, + :relationship_to_nominee, presence: true before_create :generate_access_key after_create :notify!, unless: proc { Rails.env.test? } @@ -32,6 +26,6 @@ def generate_access_key end def notify! - Users::SupporterMailer.success(self.id, form_answer.user.id).deliver_later! + Users::SupporterMailer.success(id, form_answer.user.id).deliver_later! end end diff --git a/app/models/urn_builder.rb b/app/models/urn_builder.rb index 7311219f88..f1f47de765 100644 --- a/app/models/urn_builder.rb +++ b/app/models/urn_builder.rb @@ -28,7 +28,7 @@ def generate_urn "mobility" => "P", "trade" => "T", }[fa.award_type] - generated_urn += "#{award_year.year.to_s[2..-1]}#{suffix}" + generated_urn += "#{award_year.year.to_s[2..]}#{suffix}" generated_urn end diff --git a/app/models/user.rb b/app/models/user.rb index 5cb44aa085..2e946b64d0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,8 +2,8 @@ class User < ApplicationRecord include PgSearch::Model extend Enumerize - POSSIBLE_ROLES = %w(account_admin regular) - POSSIBLE_TITLES = %w(Mr Mrs Miss Ms Mx Dr Professor Reverend Sir Baron Baroness Dame Lady Lord) + POSSIBLE_ROLES = %w[account_admin regular] + POSSIBLE_TITLES = %w[Mr Mrs Miss Ms Mx Dr Professor Reverend Sir Baron Baroness Dame Lady Lord] devise :database_authenticatable, :registerable, :recoverable, :trackable, :validatable, :confirmable, @@ -39,71 +39,57 @@ class User < ApplicationRecord validates_with AdvancedEmailValidator - begin :associations - has_many :form_answers - has_many :feedbacks, through: :form_answers, - class_name: "Feedback", - source: :feedback - has_one :owned_account, foreign_key: :owner_id, class_name: "Account" - - belongs_to :account, optional: true - has_many :form_answer_attachments, as: :attachable - has_many :support_letter_attachments, dependent: :destroy - has_many :supporters, dependent: :destroy - end - - begin :scopes - scope :not_including, -> (user) { - where.not(id: user.id) - } - scope :by_email, -> { order(:email) } - scope :qae_opt_in_group, -> { where(subscribed_to_emails: true) } - scope :bit_opt_in, -> { where(agree_being_contacted_by_department_of_business: true) } - scope :confirmed, -> { - where("confirmed_at IS NOT NULL") - } - scope :by_query_part, -> (email) { - where("email ilike ? OR first_name ilike ? OR last_name ilike ?", - "%#{email}%", "%#{email}%", "%#{email}%",) - } - scope :not_in_ids, -> (ids) { - where.not(id: ids) - } - scope :bounced_emails, -> { - where(marked_at_bounces_email: true) - } - scope :not_bounced_emails, -> { - where( - "marked_at_bounces_email IS FALSE OR marked_at_bounces_email IS NULL", - ) - } - scope :allowed_to_get_award_open_notification, -> (award_type) { - if FormAnswer::BUSINESS_AWARD_TYPES.index(award_type) - where("notification_when_#{award_type}_award_open" => true) - else - none - end - } - scope :debounce_scan_candidates, -> () { - order(id: :asc).where( - "debounce_api_latest_check_at IS NULL OR debounce_api_latest_check_at < ?", 6.months.ago, - ) - } - scope :want_to_receive_opening_notification_for_at_least_one_award, -> () { - where(" - notification_when_innovation_award_open IS TRUE OR - notification_when_trade_award_open IS TRUE OR - notification_when_development_award_open IS TRUE OR - notification_when_mobility_award_open IS TRUE - ") - } - end + # associations + has_many :form_answers + has_many :feedbacks, through: :form_answers, class_name: "Feedback", source: :feedback + has_many :form_answer_attachments, as: :attachable + has_many :support_letter_attachments, dependent: :destroy + has_many :supporters, dependent: :destroy + + has_one :owned_account, foreign_key: :owner_id, class_name: "Account", inverse_of: :owner + + belongs_to :account, optional: true + + # scopes + scope :not_including, ->(user) { where.not(id: user.id) } + scope :by_email, -> { order(:email) } + scope :qae_opt_in_group, -> { where(subscribed_to_emails: true) } + scope :bit_opt_in, -> { where(agree_being_contacted_by_department_of_business: true) } + scope :confirmed, -> { where.not(confirmed_at: nil) } + scope :by_query_part, ->(email) { + where("email ilike ? OR first_name ilike ? OR last_name ilike ?", + "%#{email}%", "%#{email}%", "%#{email}%") + } + scope :not_in_ids, ->(ids) { where.not(id: ids) } + scope :bounced_emails, -> { where(marked_at_bounces_email: true) } + scope :not_bounced_emails, -> { + where("marked_at_bounces_email IS FALSE OR marked_at_bounces_email IS NULL") + } + scope :allowed_to_get_award_open_notification, ->(award_type) { + if FormAnswer::BUSINESS_AWARD_TYPES.index(award_type) + where("notification_when_#{award_type}_award_open" => true) + else + none + end + } + scope :debounce_scan_candidates, -> { + where("debounce_api_latest_check_at IS NULL OR debounce_api_latest_check_at < ?", 6.months.ago) + .order(id: :asc) + } + scope :want_to_receive_opening_notification_for_at_least_one_award, -> { + where(%( + notification_when_innovation_award_open IS TRUE OR + notification_when_trade_award_open IS TRUE OR + notification_when_development_award_open IS TRUE OR + notification_when_mobility_award_open IS TRUE + ).squish) + } before_validation :create_account, on: :create around_save :update_user_full_name - enumerize :prefered_method_of_contact, in: %w(phone email) - enumerize :qae_info_source, in: %w( + enumerize :prefered_method_of_contact, in: %w[phone email] + enumerize :qae_info_source, in: %w[ govuk competitor business_event @@ -115,32 +101,31 @@ class User < ApplicationRecord mail_from_qae word_of_mouth other - ) + ] enumerize :role, in: POSSIBLE_ROLES, predicates: true - begin :searching - pg_search_scope :basic_search, - against: [ - :email, - :first_name, - :last_name, - :company_name, - ], - using: { - tsearch: { - prefix: true, - }, - } - # TODO: take into consideration forcing NULL for all attributes. - nilify_blanks only: [ - :title, - :first_name, - :last_name, - :company_name, - ] - end - - def set_step (step) + # searching + pg_search_scope :basic_search, + against: [ + :email, + :first_name, + :last_name, + :company_name, + ], + using: { + tsearch: { + prefix: true, + }, + } + # TODO: take into consideration forcing NULL for all attributes. + nilify_blanks only: [ + :title, + :first_name, + :last_name, + :company_name, + ] + + def set_step(step) @current_step = step end diff --git a/app/models/users_import/builder.rb b/app/models/users_import/builder.rb index 361afe5580..a6edc12f26 100644 --- a/app/models/users_import/builder.rb +++ b/app/models/users_import/builder.rb @@ -4,7 +4,7 @@ class UsersImport::Builder attr_reader :csv def initialize(filepath) - file = File.open(filepath).read + file = File.read(filepath) @csv = CSV.parse(file, headers: true) end @@ -19,7 +19,7 @@ def process u.imported = true map.each do |csv_h, db_h| - u.send("#{db_h}=", user[csv_h]) + u.send(:"#{db_h}=", user[csv_h]) end u.role = "account_admin" u = assign_password(u) @@ -56,7 +56,7 @@ def process private def log(msg) - puts msg unless Rails.env.test? + Rails.logger.debug msg unless Rails.env.test? end def map @@ -76,7 +76,7 @@ def map end def assign_password(user) - passw = (0...15).map { (65 + rand(26)).chr }.join + passw = (0...15).map { rand(65..90).chr }.join user.password = passw user.password_confirmation = passw user diff --git a/app/models/vat_returns_file.rb b/app/models/vat_returns_file.rb index 7342245243..dd9e33a756 100644 --- a/app/models/vat_returns_file.rb +++ b/app/models/vat_returns_file.rb @@ -1,4 +1,4 @@ -class VatReturnsFile < ActiveRecord::Base +class VatReturnsFile < ApplicationRecord include ShortlistedDocument validates :attachment, presence: true, diff --git a/app/pdf_generators/audit_certificate_pdf.rb b/app/pdf_generators/audit_certificate_pdf.rb index 36594d8393..12b1ecf076 100644 --- a/app/pdf_generators/audit_certificate_pdf.rb +++ b/app/pdf_generators/audit_certificate_pdf.rb @@ -27,7 +27,7 @@ def initialize(form_answer) @financial_pointer = FinancialSummaryPointer.new(@form_answer, { exclude_ignored_questions: true, financial_summary_view: true, - },) + }) @audit_data = financial_pointer.data @step_questions = financial_pointer.financial_step.questions @filled_answers = financial_pointer.filled_answers diff --git a/app/pdf_generators/case_summary_pdfs/general/data_pointer.rb b/app/pdf_generators/case_summary_pdfs/general/data_pointer.rb index 8563aba8e2..f2e02e0943 100644 --- a/app/pdf_generators/case_summary_pdfs/general/data_pointer.rb +++ b/app/pdf_generators/case_summary_pdfs/general/data_pointer.rb @@ -1,9 +1,9 @@ module CaseSummaryPdfs::General::DataPointer PREVIOUS_AWARDS = { "innovation" => "Innovation", "international_trade" => "International Trade", - "sustainable_development" => "Sustainable Development", } + "sustainable_development" => "Sustainable Development" } - COLOR_LABELS = %w(positive average negative neutral) + COLOR_LABELS = %w[positive average negative neutral] POSITIVE_COLOR = "6B8E23" AVERAGE_COLOR = "DAA520" NEGATIVE_COLOR = "FF0000" @@ -13,12 +13,6 @@ def undefined_value FeedbackPdfs::Pointer::UNDEFINED_VALUE end - def current_awards_question - all_questions.detect do |q| - q.delegate_obj.is_a?(QaeFormBuilder::QueenAwardHolderQuestion) - end - end - def organisation_type filled_answers["organisation_type"].capitalize end @@ -46,13 +40,6 @@ def sic_code form_answer.decorate.sic_code_name || undefined_value end - def current_awards_question - all_questions.detect do |q| - q.delegate_obj.is_a?(QaeFormBuilder::QueenAwardHolderQuestion) || - q.delegate_obj.is_a?(QaeFormBuilder::QueenAwardApplicationsQuestion) - end - end - def current_awards awarded_applications = form_answer.account.form_answers.winners.where.not(id: form_answer.id) @@ -119,7 +106,6 @@ def render_data! render_financial_block(true) pdf_doc.move_down 10.mm - render_application_background else # type and sub category Qs are missing for SD2020+, so need to move up if form_answer.development? && form_answer.award_year.year >= 2020 @@ -127,8 +113,8 @@ def render_data! end pdf_doc.move_down y_coord("general_block").mm - render_application_background end + render_application_background pdf_doc.move_down 7.mm render_case_summary_comments @@ -173,7 +159,7 @@ def render_case_summaries_header # so, that we are setting them here COLOR_LABELS.each do |label| AppraisalForm::SUPPORTED_YEARS.each do |year| - const_set("#{label.upcase}_LABELS_#{year}", AppraisalForm.group_labels_by(year, label)) + const_set(:"#{label.upcase}_LABELS_#{year}", AppraisalForm.group_labels_by(year, label)) end end @@ -221,7 +207,7 @@ def render_financial_section_header end def render_financial_table_header - pdf_doc.table [year_rows], row_colors: %w(FFFFFF), + pdf_doc.table [year_rows], row_colors: %w[FFFFFF], cell_style: { size: 12, font_style: :bold }, column_widths: column_widths end @@ -230,7 +216,7 @@ def render_financials financial_metrics_by_years.each do |row| if row[0] == CaseSummaryPdfs::Pointer::DATE_LABEL pdf_doc.table([row], - row_colors: %w(FFFFFF), + row_colors: %w[FFFFFF], cell_style: { size: 12, font_style: :bold }, column_widths: column_widths, ) @@ -251,15 +237,15 @@ def column_widths period_length = financial_pointer.period_length(exclude_innovation_years) first_row_width = case period_length when 2 - first_row_width = 607 + 607 when 3 - first_row_width = 527 + 527 when 4 - first_row_width = 447 + 447 when 5 - first_row_width = 367 + 367 when 6 - first_row_width = 287 + 287 end res = { 0 => first_row_width } @@ -277,7 +263,7 @@ def column_widths # and less space we need for the data (column 1), since it's only one column # for the overall growth table def benchmarks_column_widths - first_row_width = case financial_pointer.period_length + case financial_pointer.period_length when 2 { 0 => 607, diff --git a/app/pdf_generators/case_summary_pdfs/general/draw_elements.rb b/app/pdf_generators/case_summary_pdfs/general/draw_elements.rb index 20051b9d73..69f9772212 100644 --- a/app/pdf_generators/case_summary_pdfs/general/draw_elements.rb +++ b/app/pdf_generators/case_summary_pdfs/general/draw_elements.rb @@ -48,7 +48,7 @@ def render_type(offset: 0.mm) header_text_properties.merge( at: [0.mm, 97.mm + default_offset + offset], width: 272.mm, - ) + ) end def y_coord(mode) diff --git a/app/pdf_generators/case_summary_pdfs/pointer.rb b/app/pdf_generators/case_summary_pdfs/pointer.rb index cad569ea01..f25eaf2fb5 100644 --- a/app/pdf_generators/case_summary_pdfs/pointer.rb +++ b/app/pdf_generators/case_summary_pdfs/pointer.rb @@ -43,7 +43,7 @@ def fetch_financial_data @financial_pointer = FinancialSummaryPointer.new(form_answer.decorate, { exclude_ignored_questions: true, award_year: @award_year, - },) + }) @financial_data = financial_pointer.summary_data diff --git a/app/pdf_generators/feedback_pdfs/base.rb b/app/pdf_generators/feedback_pdfs/base.rb index 166600f1ad..b610216c0c 100644 --- a/app/pdf_generators/feedback_pdfs/base.rb +++ b/app/pdf_generators/feedback_pdfs/base.rb @@ -18,8 +18,8 @@ def set_feedbacks @feedbacks = Feedback.submitted .includes(:form_answer) .joins(form_answer: :award_year) - .where("form_answers.award_type = ?", options[:category]) - .where("form_answers.award_year_id = ?", award_year.id) + .where(form_answers: { award_type: options[:category] }) + .where(form_answers: { award_year_id: award_year.id }) end def render_item(form_answer) diff --git a/app/pdf_generators/feedback_pdfs/general/data_pointer.rb b/app/pdf_generators/feedback_pdfs/general/data_pointer.rb index e0b54f9414..b9c015cfd0 100644 --- a/app/pdf_generators/feedback_pdfs/general/data_pointer.rb +++ b/app/pdf_generators/feedback_pdfs/general/data_pointer.rb @@ -1,5 +1,5 @@ module FeedbackPdfs::General::DataPointer - COLOR_LABELS = %w(positive average negative neutral) + COLOR_LABELS = %w[positive average negative neutral] POSITIVE_COLOR = "6B8E23" AVERAGE_COLOR = "DAA520" @@ -8,7 +8,7 @@ module FeedbackPdfs::General::DataPointer COLOR_LABELS.each do |label| AppraisalForm::SUPPORTED_YEARS.each do |year| - const_set("#{label.upcase}_LABELS_#{year}", AppraisalForm.group_labels_by(year, label)) + const_set(:"#{label.upcase}_LABELS_#{year}", AppraisalForm.group_labels_by(year, label)) end end @@ -57,12 +57,12 @@ def render_data! 0 => 130, 1 => 300, 2 => 337, - },) + }) render_table(table_items, { 0 => 130, 1 => 300, 2 => 337, - },) + }) if form_answer.development? && strengths_entries.present? year = form_answer.award_year.year @@ -72,7 +72,7 @@ def render_data! column_widths: { 0 => 130, 1 => 637, - },) do + }) do values = cells.columns(1).rows(0..-1) green_rags = values.filter do |cell| @@ -103,12 +103,12 @@ def render_overall_summary! render_table([["Overall Summary", data["overall_summary"]]], { 0 => 130, 1 => 637, - },) + }) end def render_headers(table_lines, column_widths) pdf_doc.move_down 10.mm - pdf_doc.table table_lines, row_colors: %w(F0F0F0), + pdf_doc.table table_lines, row_colors: %w[F0F0F0], cell_style: { size: 12, font_style: :bold }, column_widths: column_widths end diff --git a/app/pdf_generators/form_pdf.rb b/app/pdf_generators/form_pdf.rb index 3d257c250f..10279a14b6 100644 --- a/app/pdf_generators/form_pdf.rb +++ b/app/pdf_generators/form_pdf.rb @@ -9,14 +9,14 @@ class FormPdf < Prawn::Document UNDEFINED_TITLE = "No answer ..." NOTHING_SELECTED = "Nothing selected" UNDEFINED_TYPE = "undefined type UNDEFINED" - TABLE_WITH_COMMENT_QUESTION = %w(financial_year_dates total_turnover exports net_profit total_net_assets) - INLINE_DATE_QUESTION = %w( + TABLE_WITH_COMMENT_QUESTION = %w[financial_year_dates total_turnover exports net_profit total_net_assets] + INLINE_DATE_QUESTION = %w[ started_trading financial_year_date nominee_date_of_birth innovation_was_launched_in_the_market development_was_launched_since - ) + ] JUST_NOTES = [ "QaeFormBuilder::HeaderQuestion", ] @@ -61,7 +61,7 @@ def generate! steps.each do |step| QaePdfForms::General::StepPointer.new(award_form: award_form, form_pdf: self, - step: step,).render! + step: step).render! end render_submission_deadline_block(32) diff --git a/app/pdf_generators/hard_copy_generators/aggregated_base.rb b/app/pdf_generators/hard_copy_generators/aggregated_base.rb index bc6ca461b2..27e8dff399 100644 --- a/app/pdf_generators/hard_copy_generators/aggregated_base.rb +++ b/app/pdf_generators/hard_copy_generators/aggregated_base.rb @@ -15,7 +15,7 @@ def initialize(award_category, award_year, type_of_report) private def attach_generated_file! - pdf_record = award_year.send("aggregated_#{type_of_report}_hard_copies").new( + pdf_record = award_year.send(:"aggregated_#{type_of_report}_hard_copies").new( file: tmpfile, type_of_report: type_of_report, award_category: award_category, @@ -36,6 +36,6 @@ def file_prefix end def tempfile_name - "#{file_prefix}_#{timestamp}_SEPARATOR".gsub("/", "_") + "#{file_prefix}_#{timestamp}_SEPARATOR".tr("/", "_") end end diff --git a/app/pdf_generators/hard_copy_generators/aggregated_case_summary_generator.rb b/app/pdf_generators/hard_copy_generators/aggregated_case_summary_generator.rb index 07676fc1f0..4591ad5ea3 100644 --- a/app/pdf_generators/hard_copy_generators/aggregated_case_summary_generator.rb +++ b/app/pdf_generators/hard_copy_generators/aggregated_case_summary_generator.rb @@ -22,7 +22,7 @@ def initialize(award_category, award_year, type_of_report, sub_type = nil) private def attach_generated_file! - pdf_record = award_year.send("aggregated_#{type_of_report}_hard_copies").new( + pdf_record = award_year.send(:"aggregated_#{type_of_report}_hard_copies").new( file: tmpfile, type_of_report: type_of_report, sub_type: sub_type, @@ -51,7 +51,7 @@ def set_pdf! ops[:years_mode] = sub_type if award_category == "trade" @pdf = CaseSummaryPdfs::Base.new( - "all", nil, ops, + "all", nil, ops ) end end diff --git a/app/pdf_generators/hard_copy_generators/aggregated_feedback_generator.rb b/app/pdf_generators/hard_copy_generators/aggregated_feedback_generator.rb index 236be26f40..f28ca1a97d 100644 --- a/app/pdf_generators/hard_copy_generators/aggregated_feedback_generator.rb +++ b/app/pdf_generators/hard_copy_generators/aggregated_feedback_generator.rb @@ -17,7 +17,7 @@ def run(award_year) def set_pdf! @pdf = FeedbackPdfs::Base.new( - "all", nil, category: award_category, award_year: award_year, + "all", nil, category: award_category, award_year: award_year ) end end diff --git a/app/pdf_generators/hard_copy_generators/base.rb b/app/pdf_generators/hard_copy_generators/base.rb index 230fbfee41..a2e0801002 100644 --- a/app/pdf_generators/hard_copy_generators/base.rb +++ b/app/pdf_generators/hard_copy_generators/base.rb @@ -1,7 +1,6 @@ class HardCopyGenerators::Base attr_reader :form_answer, :pdf, - :tempfile_name, :timestamp, :tmpfile, :use_latest_version @@ -37,7 +36,7 @@ def run private def tempfile_name - "#{file_prefix}_#{form_answer.urn}_#{timestamp}_SEPARATOR".gsub("/", "_") + "#{file_prefix}_#{form_answer.urn}_#{timestamp}_SEPARATOR".tr("/", "_") end def original_filename diff --git a/app/pdf_generators/pdf_audit_certificates/awards2016/innovation/base.rb b/app/pdf_generators/pdf_audit_certificates/awards2016/innovation/base.rb index 6338313783..fd2d911641 100644 --- a/app/pdf_generators/pdf_audit_certificates/awards2016/innovation/base.rb +++ b/app/pdf_generators/pdf_audit_certificates/awards2016/innovation/base.rb @@ -15,7 +15,7 @@ def partitioned_rows return formatted_data unless indexes.size > 1 first = formatted_data[0...(indexes[-1])] - last = formatted_data[indexes[-1]..-1] + last = formatted_data[indexes[-1]..] [first, last] end diff --git a/app/pdf_generators/pdf_audit_certificates/base.rb b/app/pdf_generators/pdf_audit_certificates/base.rb index f2116c1efd..18afea5704 100644 --- a/app/pdf_generators/pdf_audit_certificates/base.rb +++ b/app/pdf_generators/pdf_audit_certificates/base.rb @@ -2,7 +2,14 @@ class PdfAuditCertificates::Base < AuditCertificatePdf private def initialize_form_answer(form) - if notification = form.award_year.settings.email_notifications.where(kind: "shortlisted_notifier").order(:trigger_at).first + notification = form.award_year + .settings + .email_notifications + .where(kind: "shortlisted_notifier") + .order(:trigger_at) + .first + + if notification.present? form.paper_trail.version_at(notification.trigger_at).decorate else super diff --git a/app/pdf_generators/pdf_audit_certificates/general/guidance_elements.rb b/app/pdf_generators/pdf_audit_certificates/general/guidance_elements.rb index f8c8463994..887a599851 100644 --- a/app/pdf_generators/pdf_audit_certificates/general/guidance_elements.rb +++ b/app/pdf_generators/pdf_audit_certificates/general/guidance_elements.rb @@ -33,10 +33,10 @@ def render_accountant_guidance_intro render_text_line(header, 3, style: :bold) - if form_answer.innovation? - table = "tables" + table = if form_answer.innovation? + "tables" else - table = "table" + "table" end ps = [] diff --git a/app/pdf_generators/pdf_audit_certificates/general/shared_elements.rb b/app/pdf_generators/pdf_audit_certificates/general/shared_elements.rb index 77ff0ac836..bcc73427e6 100644 --- a/app/pdf_generators/pdf_audit_certificates/general/shared_elements.rb +++ b/app/pdf_generators/pdf_audit_certificates/general/shared_elements.rb @@ -1,6 +1,6 @@ module PdfAuditCertificates::General::SharedElements DEFAULT_OFFSET = 110.mm - NOT_CURRENCY_QUESTION_KEYS = %w(employees) + NOT_CURRENCY_QUESTION_KEYS = %w[employees] def render_main_header render_certificate_info @@ -29,7 +29,7 @@ def render_urn end def render_base_paragraph - p1 = %{We have performed the work agreed with #{form_answer.company_name} in line with the requirements set out in the document “King’s Awards for Enterprise: #{form_answer.award_type_full_name} #{form_answer.award_year.year}” which constitutes the application form for the award.} + p1 = %(We have performed the work agreed with #{form_answer.company_name} in line with the requirements set out in the document “King’s Awards for Enterprise: #{form_answer.award_type_full_name} #{form_answer.award_year.year}” which constitutes the application form for the award.) render_text_line(p1, 2, { leading: 2 }) p2 = "Our work was carried out solely to assist your process for considering #{form_answer.company_name} for a King’s Awards for Enterprise. We have reviewed the figures provided by #{form_answer.company_name} in section C of the application form. We have used the guidance in section C of the application form of the as our own guidance in terms of the information that #{form_answer.company_name} should have provided. " @@ -173,7 +173,7 @@ def financial_table_year_and_date_data def benchmarks_row(metric) res = [I18n.t("#{financials_i18_prefix}.benchmarks.#{metric}")] - res += financial_pointer.send("#{metric}_list").map do |entry| + res += financial_pointer.send(:"#{metric}_list").map do |entry| formatted_uk_sales_value(entry) end @@ -200,31 +200,31 @@ def render_financial_overall_benchmarks ################################### def render_user_filling_block - dotted_line = %{...............................................................................................................................} + dotted_line = %(...............................................................................................................................) b1 = %{Signed (External Accountant) ............................................................................} render_text_line(b1, 1) render_text_line(dotted_line, 1) - b2 = %{Company partnership name: ............................................................................} + b2 = %(Company partnership name: ............................................................................) render_text_line(b2, 1) render_text_line(dotted_line, 1) - b3 = %{Company registration number/Professional body practising certificate number: } + b3 = %(Company registration number/Professional body practising certificate number: ) render_text_line(b3, 1) render_text_line(dotted_line, 1) render_text_line(dotted_line, 1) - b4 = %{Address: ..............................................................................................................} + b4 = %(Address: ..............................................................................................................) render_text_line(b4, 1) - b5 = %{Telephone number: ...........................................................................................} + b5 = %(Telephone number: ...........................................................................................) render_text_line(b5, 1) - b6 = %{Email: ...................................................................................................................} + b6 = %(Email: ...................................................................................................................) render_text_line(b6, 1) - b7 = %{Date: ....................................................................................................................} + b7 = %(Date: ....................................................................................................................) render_text_line(b7, 5) end @@ -235,13 +235,13 @@ def render_applicants_management_statement line = "We confirm we have updated the figures originally submitted in our application to The King’s Award for Enterprise. The revised figures should be used as the basis of our application." render_text_line(line, 2, default_text_ops) - b1 = %{Signed ................................................................................................................} + b1 = %(Signed ................................................................................................................) render_text_line(b1, 1) - b2 = %{Job title: ..............................................................................................................} + b2 = %(Job title: ..............................................................................................................) render_text_line(b2, 1) - b3 = %{Company: ..........................................................................................................} + b3 = %(Company: ..........................................................................................................) render_text_line(b3, 1) move_down 6.mm @@ -424,7 +424,7 @@ def default_text_ops def table_default_ops(table_type) { - column_widths: send("#{table_type}_column_widths"), + column_widths: send(:"#{table_type}_column_widths"), cell_style: { size: 10, padding: [3, 3, 3, 3], diff --git a/app/pdf_generators/qae_pdf_forms/custom_questions/by_year.rb b/app/pdf_generators/qae_pdf_forms/custom_questions/by_year.rb index 8807a6cd4a..e576db602a 100644 --- a/app/pdf_generators/qae_pdf_forms/custom_questions/by_year.rb +++ b/app/pdf_generators/qae_pdf_forms/custom_questions/by_year.rb @@ -1,6 +1,6 @@ module QaePdfForms::CustomQuestions::ByYear EMPTY_STRING = "".freeze - YEAR_LABELS = %w(day month year).freeze + YEAR_LABELS = %w[day month year].freeze FORMATTED_FINANCIAL_YEAR_WITH_DATE = "Financial year ended %s".freeze FORMATTED_FINANCIAL_YEAR_WITHOUT_DATE = "Financial year %d".freeze ANSWER_FONT_START = "".freeze @@ -18,9 +18,9 @@ def render_years_labels_table financial_dates_year_headers(format: FORMATTED_FINANCIAL_YEAR_WITHOUT_DATE).each_with_index do |header_item, placement| form_pdf.default_bottom_margin title = if OMIT_COLON_KEYS.include?(question.key) - "#{header_item} #{ANSWER_FONT_START}#{rows[placement].join("/")}#{ANSWER_FONT_END}" + "#{header_item} #{ANSWER_FONT_START}#{rows[placement].join("/")}#{ANSWER_FONT_END}" else - "#{header_item}: #{ANSWER_FONT_START}#{rows[placement].join(" ")}#{ANSWER_FONT_END}" + "#{header_item}: #{ANSWER_FONT_START}#{rows[placement].join(" ")}#{ANSWER_FONT_END}" end form_pdf.text title, inline_format: true @@ -33,7 +33,7 @@ def render_years_table ApplicationController.helpers.formatted_uk_sales_value(field) end - (res.all? { |el| el == {} }) ? [] : res + res.all?({}) ? [] : res else active_fields.map do |field| entry = year_entry(field).to_s.delete(",") @@ -59,9 +59,9 @@ def financial_dates_year_headers(**opts) financial_table_headers.each.with_index(1) do |item, idx| frmt = if !::Utils::Date.valid?(item) - FORMATTED_FINANCIAL_YEAR_WITHOUT_DATE + FORMATTED_FINANCIAL_YEAR_WITHOUT_DATE else - opts.dig(:format) + opts.dig(:format) end frmt ||= FORMATTED_FINANCIAL_YEAR_WITH_DATE diff --git a/app/pdf_generators/qae_pdf_forms/custom_questions/financial_table_summary.rb b/app/pdf_generators/qae_pdf_forms/custom_questions/financial_table_summary.rb index 8f84374356..90b228eb36 100644 --- a/app/pdf_generators/qae_pdf_forms/custom_questions/financial_table_summary.rb +++ b/app/pdf_generators/qae_pdf_forms/custom_questions/financial_table_summary.rb @@ -370,11 +370,11 @@ def fs_number_of_years def fs_financial_table_headers_filled_in @financial_table_headers_filled_in ||= if financial_year_changed_dates? - financial_table_changed_dates_headers + financial_table_changed_dates_headers elsif financial_date_day.to_i > 0 && financial_date_month.to_i > 0 - financial_table_pointer_headers + financial_table_pointer_headers else - [] + [] end end diff --git a/app/pdf_generators/qae_pdf_forms/custom_questions/lists.rb b/app/pdf_generators/qae_pdf_forms/custom_questions/lists.rb index 0c08545568..5b5e271821 100644 --- a/app/pdf_generators/qae_pdf_forms/custom_questions/lists.rb +++ b/app/pdf_generators/qae_pdf_forms/custom_questions/lists.rb @@ -40,12 +40,10 @@ def render_list form_pdf.default_bottom_margin render_word_limit end + elsif question.delegate_obj.is_a?(QaeFormBuilder::ByTradeGoodsAndServicesLabelQuestion) + render_by_trade_goods_question else - if question.delegate_obj.is_a?(QaeFormBuilder::ByTradeGoodsAndServicesLabelQuestion) - render_by_trade_goods_question - else - render_word_limit - end + render_word_limit end end @@ -95,9 +93,6 @@ def queen_award_holder_query_conditions(prepared_item) end def award_applications_query_conditions(item) - category = item["category"].presence && QaePdfForms::General::QuestionPointer::PREVIOUS_AWARDS[item["category"]] - outcome = item["outcome"].presence && question.outcomes.detect { |o| o.value == item["outcome"] }.try(:text) - [ item["category"], item["year"], diff --git a/app/pdf_generators/qae_pdf_forms/custom_questions/matrix.rb b/app/pdf_generators/qae_pdf_forms/custom_questions/matrix.rb index 7779bf65a5..b433edaea3 100644 --- a/app/pdf_generators/qae_pdf_forms/custom_questions/matrix.rb +++ b/app/pdf_generators/qae_pdf_forms/custom_questions/matrix.rb @@ -4,7 +4,7 @@ def matrix_headers end def matrix_rows - y_headings = if question.required_row_parent.present? && !question.required_row_options.blank? + y_headings = if question.required_row_parent.present? && question.required_row_options.present? checked_options = form_pdf.filled_answers.fetch(question.required_row_parent, []).map(&:values).flatten if checked_options.size.zero? question.y_headings @@ -15,7 +15,7 @@ def matrix_rows question.y_headings end - rows = y_headings.map do |y_heading| + y_headings.map do |y_heading| columns = [y_heading.label.to_s] question.x_headings.each do |x_heading| columns << form_pdf.filled_answers[question.key.to_s + "_#{x_heading.key}_#{y_heading.key}"] @@ -23,8 +23,6 @@ def matrix_rows columns end - - rows end def millimeterized_column_widths diff --git a/app/pdf_generators/qae_pdf_forms/custom_questions/textarea.rb b/app/pdf_generators/qae_pdf_forms/custom_questions/textarea.rb index d471732bd4..87db654470 100644 --- a/app/pdf_generators/qae_pdf_forms/custom_questions/textarea.rb +++ b/app/pdf_generators/qae_pdf_forms/custom_questions/textarea.rb @@ -73,7 +73,7 @@ def render_wysywyg_line(line) end def wysywyg_list_leading_tag?(tag_abbr) - LIST_TAGS.include?(tag_abbr.gsub(/(\<|\>)/, "")) + LIST_TAGS.include?(tag_abbr.gsub(/(<|>)/, "")) end def wysywyg_list_ending_tag?(tag_abbr) @@ -83,7 +83,7 @@ def wysywyg_list_ending_tag?(tag_abbr) def wysywyg_print_lists(key, line) wysywyg_list_content_generator(wysywyg_prepare_list_content(line), wysywyg_get_list_left_margin(line), - key,) + key) end def wysywyg_get_list_left_margin(line) @@ -107,7 +107,7 @@ def wysywyg_prepare_list_content(line) content.map! do |el| if el.include?("\r\n") - element = el.gsub!("\r", "").gsub!("\n", "").gsub!("\t", "") + el.delete!("\r").delete!("\n").delete!("\t") end el end.reject!(&:blank?) @@ -192,7 +192,6 @@ def wysywyg_handle_ul_tag(key, i) li_style = styles_picker(@styles) print_pdf(@string.join(""), li_style) - key = "
    " @keys_history << key @ns_history << @counter @string = [] @@ -213,10 +212,10 @@ def wysywyg_handle_ol_tag(i) end def marker_of_list(string, key, n) - if key == "
      " - string << "• " + string << if key == "
        " + "• " else - string << "#{n}. " + "#{n}. " end end @@ -241,10 +240,10 @@ def styles_picker(style_options) if style_options.to_s.include?(";") style_options = style_options[0].split(";").map(&:strip) end + style_options = Array.wrap(style_options) + styles = { inline_format: true, color: FormPdf::DEFAULT_ANSWER_COLOR } - styles = { inline_format: true, - color: FormPdf::DEFAULT_ANSWER_COLOR, } if style_options.present? margin_list = style_options.select do |el| el.include?("margin-left") diff --git a/app/pdf_generators/qae_pdf_forms/general/draw_elements.rb b/app/pdf_generators/qae_pdf_forms/general/draw_elements.rb index de1f557631..eeba908b85 100644 --- a/app/pdf_generators/qae_pdf_forms/general/draw_elements.rb +++ b/app/pdf_generators/qae_pdf_forms/general/draw_elements.rb @@ -2,7 +2,7 @@ module QaePdfForms::General::DrawElements DEFAULT_OFFSET = 110.mm - IMAGES_PATH = "#{Rails.root}/app/assets/images/".freeze + IMAGES_PATH = Rails.root.join("app/assets/images/").freeze LOGO_ICON = "logo-pdf.png".freeze ATTACHMENT_ICON = "icon-attachment.png".freeze ALERT_ICON = "icon-important-print.png".freeze @@ -14,7 +14,7 @@ def attachment_path(attachment_file, link = false) elsif link "#{current_host}#{attachment_file.url}" else - "#{Rails.root}/public#{attachment_file.url}" + Rails.root.join("public#{attachment_file.url}") end end @@ -54,7 +54,7 @@ def draw_link_with_file_attachment(attachment, description) base_link_sceleton( attachment_path(attachment.file, true), attachment.original_filename.truncate(60), - description ? description : nil,) + description || nil) move_down 5.mm end @@ -64,17 +64,17 @@ def draw_link(v) base_link_sceleton( v["link"], v["link"], - v["description"] ? v["description"] : v["link"], - {},) + v["description"] || v["link"], + {}) end def base_link_sceleton(url, filename, description = nil, ops = {}) - indent (ops[:description_left_margin] || 0) do + indent(ops[:description_left_margin] || 0) do formatted_text [{ - text: filename, - link: url, - styles: [:underline], - }] + text: filename, + link: url, + styles: [:underline], + }] move_down 3.mm @@ -91,10 +91,10 @@ def main_header indent 32.mm do render_urn if pdf_blank_mode.blank? render_award_information - render_company_name unless pdf_blank_mode.present? + render_company_name if pdf_blank_mode.blank? end - if !form_answer.urn.present? || pdf_blank_mode + if form_answer.urn.blank? || pdf_blank_mode move_down 6.mm render_intro_text move_down 2.mm @@ -178,10 +178,10 @@ def render_urn end def render_award_information - if form_answer.promotion? - award_title = "King's Award for Enterprise Promotion #{form_answer.award_year.year}" + award_title = if form_answer.promotion? + "King's Award for Enterprise Promotion #{form_answer.award_year.year}" else - award_title = form_answer.decorate.award_application_title_print + form_answer.decorate.award_application_title_print end text award_title.upcase, header_text_properties.merge(style: :bold) @@ -233,7 +233,7 @@ def render_text(title, ops = {}) def render_table(table_lines, ops = {}) default_options = { - row_colors: %w(F0F0F0 FFFFFF), + row_colors: %w[F0F0F0 FFFFFF], cell_style: { size: 10, font_style: :bold }, } @@ -247,7 +247,7 @@ def render_header(title) text title, style: :bold, size: 16, align: :left - stroke_color = "999999" + move_down 4.mm stroke_horizontal_line 0, 192.mm default_bottom_margin diff --git a/app/pdf_generators/qae_pdf_forms/general/question_pointer.rb b/app/pdf_generators/qae_pdf_forms/general/question_pointer.rb index 448ff8cf3e..6869b08efe 100644 --- a/app/pdf_generators/qae_pdf_forms/general/question_pointer.rb +++ b/app/pdf_generators/qae_pdf_forms/general/question_pointer.rb @@ -9,9 +9,9 @@ class QaePdfForms::General::QuestionPointer include FinancialTable include QuestionTextHelper - NOT_CURRENCY_QUESTION_KEYS = %w(employees).freeze - SKIP_HEADER_HINT_KEYS = %w(head_of_business_header).freeze - RENDER_INLINE_KEYS = %w(head_of_business_title).freeze + NOT_CURRENCY_QUESTION_KEYS = %w[employees].freeze + SKIP_HEADER_HINT_KEYS = %w[head_of_business_header].freeze + RENDER_INLINE_KEYS = %w[head_of_business_title].freeze attr_reader :form_pdf, :form_answer, @@ -58,7 +58,7 @@ class QaePdfForms::General::QuestionPointer def initialize(ops = {}) ops.each do |k, v| - instance_variable_set("@#{k}", v) + instance_variable_set(:"@#{k}", v) end @key = question.key @@ -117,8 +117,16 @@ def answer_by_key def fetch_sub_answers res = [] - required_sub_fields = question.required_sub_fields rescue [] - sub_fields = question.sub_fields rescue [] + required_sub_fields = begin + question.required_sub_fields + rescue + [] + end + sub_fields = begin + question.sub_fields + rescue + [] + end merged_sub_fields = (required_sub_fields + sub_fields).flatten.uniq merged_sub_fields.each do |sub_field| @@ -300,7 +308,7 @@ def render_question_hints def render_context_or_help_block(context) if question.classes == "application-notice help-notice" - form_pdf.image "#{Rails.root}/app/assets/images/icon-important-print.png", + form_pdf.image Rails.root.join("app/assets/images/icon-important-print.png"), at: [-10.mm, form_pdf.cursor - 3.5.mm], width: 6.5.mm, height: 6.5.mm @@ -312,20 +320,22 @@ def render_context_or_help_block(context) end def render_validation_block + # rubocop:disable Lint/LiteralAsCondition # Valid/pending icon - # TODO If it has validation + # TODO: If it has validation if false - # TODO If it is valid - if false - valid_icon = "icon-valid-pdf.png" + # TODO: If it is valid + valid_icon = if false + "icon-valid-pdf.png" else - valid_icon = "icon-pending-pdf.png" + "icon-pending-pdf.png" end - form_pdf.image "#{Rails.root}/app/assets/images/#{valid_icon}", + form_pdf.image Rails.root.join("app/assets/images/#{valid_icon}"), at: [0, form_pdf.cursor - 4.mm], width: 7.mm end + # rubocop:enable Lint/LiteralAsCondition end def render_question_sub_title @@ -373,7 +383,7 @@ def question_answer(question) end when QaeFormBuilder::TradeMostRecentFinancialYearOptionsQuestion, QaeFormBuilder::OptionsQuestion if q_visible? && humanized_answer.present? - chosen_option = question.options.detect{ |option| option.value.to_s == humanized_answer.to_s } + chosen_option = question.options.detect { |option| option.value.to_s == humanized_answer.to_s } form_pdf.render_standart_answer_block(question_option_title) if chosen_option render_context_for_option(question, chosen_option) @@ -425,8 +435,6 @@ def question_answer(question) render_supporters end when QaeFormBuilder::TextareaQuestion - title = (q_visible? && humanized_answer.present?) ? humanized_answer : "" - form_pdf.default_bottom_margin render_word_limit render_wysywyg_content @@ -542,7 +550,7 @@ def render_attachments end def attachment_by_type(_k, v) - if v.keys.include?("file") + if v.key?("file") attachment = form_pdf.form_answer_attachments.detect do |a| a.id.to_s == v["file"] end @@ -550,7 +558,7 @@ def attachment_by_type(_k, v) if attachment.present? form_pdf.draw_link_with_file_attachment(attachment, v["description"]) end - elsif v.keys.include?("link") + elsif v.key?("link") if v["link"].present? form_pdf.draw_link(v) end @@ -562,11 +570,11 @@ def attachment_by_type(_k, v) def complex_question render_question_title_with_ref_or_not - if question.delegate_obj.class.to_s == "QaeFormBuilder::AddressQuestion" + if question.delegate_obj.instance_of?(::QaeFormBuilder::AddressQuestion) render_context_and_answer_blocks end - if question.delegate_obj.class.to_s == "QaeFormBuilder::PressContactDetailsQuestion" + if question.delegate_obj.instance_of?(::QaeFormBuilder::PressContactDetailsQuestion) render_context_and_answer_blocks end @@ -594,7 +602,7 @@ def sub_answers_by_type def render_table_with_optional_extra cells = sub_answers.select do |a| a[0].match(/\/{1}[0-9]{2}\/{1}/).present? || - a[0].match(/Year/).present? + a[0].include?("Year").present? end if cells.present? @@ -630,7 +638,6 @@ def render_single_row_list(headers, row) end def render_inline_date - headers = sub_answers.map { |a| a[0] } row = sub_answers.map { |a| a[1] } row[1] = to_month(row[1]) if row[1].present? empty_date = false @@ -673,7 +680,7 @@ def sub_question_block(sub_question, sub_answer) def sub_question_block_without_title(sub_answer) if question.can_have_parent_conditional_hints? && question.have_conditional_parent? - form_pdf.indent -25.mm do # compensating 25mm indent for subquestion + form_pdf.indent(-25.mm) do # compensating 25mm indent for subquestion render_info_about_conditional_parent end end @@ -734,8 +741,8 @@ def data_by_type(question_key, entry) if entry[:value].present? if NOT_CURRENCY_QUESTION_KEYS.include?(question_key) entry[:value] - else - "£#{entry[:value]}" if entry[:value] != "-" + elsif entry[:value] != "-" + "£#{entry[:value]}" end end end diff --git a/app/pdf_generators/qae_pdf_forms/general/step_pointer.rb b/app/pdf_generators/qae_pdf_forms/general/step_pointer.rb index a1610b8e02..8492184a49 100644 --- a/app/pdf_generators/qae_pdf_forms/general/step_pointer.rb +++ b/app/pdf_generators/qae_pdf_forms/general/step_pointer.rb @@ -7,7 +7,7 @@ class QaePdfForms::General::StepPointer def initialize(ops = {}) ops.each do |k, v| - instance_variable_set("@#{k}", v) + instance_variable_set(:"@#{k}", v) end @step_questions = step.questions.reject do |question| @@ -33,7 +33,7 @@ def render! filtered_questions.each do |question| QaePdfForms::General::QuestionPointer.new(form_pdf: form_pdf, step: self, - question: question.decorate,).render! + question: question.decorate).render! end end end diff --git a/app/pdf_generators/shared_pdf_helpers/draw_elements.rb b/app/pdf_generators/shared_pdf_helpers/draw_elements.rb index b2a75fed4e..013247dfeb 100644 --- a/app/pdf_generators/shared_pdf_helpers/draw_elements.rb +++ b/app/pdf_generators/shared_pdf_helpers/draw_elements.rb @@ -1,6 +1,6 @@ module SharedPdfHelpers::DrawElements DEFAULT_OFFSET = 50.mm - IMAGES_PATH = "#{Rails.root}/app/assets/images/" + IMAGES_PATH = Rails.root.join("app/assets/images/") LOGO_ICON = "logo-pdf.png" AWARD_GENERAL_INFO_PREFIX = "The King's Awards for Enterprise" @@ -42,13 +42,13 @@ def render_award_title(x_coord, y_coord) def render_headers(table_lines, column_widths) pdf_doc.move_down 30.mm - pdf_doc.table table_lines, row_colors: %w(F0F0F0), + pdf_doc.table table_lines, row_colors: %w[F0F0F0], cell_style: { size: 12, font_style: :bold }, column_widths: column_widths end def render_table(table_lines, column_widths = {}) - pdf_doc.table table_lines, row_colors: %w(FFFFFF), + pdf_doc.table table_lines, row_colors: %w[FFFFFF], cell_style: { size: 12 }, column_widths: column_widths end diff --git a/app/pdf_generators/shared_pdf_helpers/font_helper.rb b/app/pdf_generators/shared_pdf_helpers/font_helper.rb index 6767dfcbaf..d229a45249 100644 --- a/app/pdf_generators/shared_pdf_helpers/font_helper.rb +++ b/app/pdf_generators/shared_pdf_helpers/font_helper.rb @@ -1,6 +1,6 @@ module SharedPdfHelpers::FontHelper def set_fonts! - self.font_families.update( + font_families.update( "OpenSans" => { normal: font_path("OpenSans-Regular.ttf"), bold: font_path("OpenSans-Bold.ttf"), @@ -9,7 +9,7 @@ def set_fonts! }, ) - self.font("OpenSans") + font("OpenSans") end private diff --git a/app/pdf_generators/shared_pdf_helpers/language_helper.rb b/app/pdf_generators/shared_pdf_helpers/language_helper.rb index fc4b1bcf27..508ae10405 100644 --- a/app/pdf_generators/shared_pdf_helpers/language_helper.rb +++ b/app/pdf_generators/shared_pdf_helpers/language_helper.rb @@ -1,5 +1,5 @@ module SharedPdfHelpers::LanguageHelper def set_language! - self.state.store.root.data[:Lang] = "en-UK" + state.store.root.data[:Lang] = "en-UK" end end diff --git a/app/policies/feedback_policy.rb b/app/policies/feedback_policy.rb index e4d2348ecb..a1ad0bc396 100644 --- a/app/policies/feedback_policy.rb +++ b/app/policies/feedback_policy.rb @@ -1,9 +1,4 @@ class FeedbackPolicy < ApplicationPolicy - def create? - admin? || (assessor? && subject.assigned?(form_answer)) && - form_answer.reload.feedback.blank? - end - def update? return @can_update unless @can_update.nil? return false if record.locked? @@ -14,7 +9,7 @@ def update? admin? end end - alias :create? :update? + alias_method :create?, :update? def submit? return @can_submit unless @can_submit.nil? diff --git a/app/policies/form_answer_policy.rb b/app/policies/form_answer_policy.rb index 58069b4cbf..d64ea16eaf 100644 --- a/app/policies/form_answer_policy.rb +++ b/app/policies/form_answer_policy.rb @@ -31,7 +31,7 @@ def show? def edit? deadline = record.award_year.settings.winners_email_notification.try(:trigger_at) - admin? && subject.superadmin? && (!deadline.present? || DateTime.now <= deadline) + admin? && subject.superadmin? && (deadline.blank? || DateTime.now <= deadline) end def update? diff --git a/app/policies/press_summary_policy.rb b/app/policies/press_summary_policy.rb index a2453c0066..935ca194e8 100644 --- a/app/policies/press_summary_policy.rb +++ b/app/policies/press_summary_policy.rb @@ -1,13 +1,8 @@ class PressSummaryPolicy < ApplicationPolicy - def create? - subject.lead_or_assigned?(form_answer) - end - def update? (!record.submitted? && subject.lead_or_assigned?(form_answer)) || admin? end - - alias :create? :update? + alias_method :create?, :update? def approve? !record.approved? && subject.lead?(form_answer) @@ -26,7 +21,7 @@ def admin_signoff? end def can_update_contact_details? - ( !deadline_passed? && update? ) || admin? + (!deadline_passed? && update?) || admin? end def deadline_passed? diff --git a/app/renderers/mail_renderer.rb b/app/renderers/mail_renderer.rb index 781991ba90..5d2e4177ea 100644 --- a/app/renderers/mail_renderer.rb +++ b/app/renderers/mail_renderer.rb @@ -11,7 +11,7 @@ def default_url_options end def compiled_method_container - return self.class + self.class end end @@ -220,7 +220,7 @@ def winners_head_of_organisation_notification assigns[:name] = "Mr Smith" assigns[:form_answer] = form assigns[:award_year] = form.award_year.year - assigns[:urn] = "QAXXXX/#{assigns[:award_year].to_s[2..-1]}I" + assigns[:urn] = "QAXXXX/#{assigns[:award_year].to_s[2..]}I" assigns[:award_category_title] = form.award_type_full_name assigns[:head_email] = "john@example.com" assigns[:head_of_business_full_name] = "Jon Doe" diff --git a/app/search/form_answer_search.rb b/app/search/form_answer_search.rb index 41b0b40386..1146dadc89 100644 --- a/app/search/form_answer_search.rb +++ b/app/search/form_answer_search.rb @@ -91,7 +91,7 @@ def filter_by_sub_status(scoped_results, value) ) OR (awd_yrs.year < 2023 AND audit_certificates.id IS NULL))") when "additional_finances_not_reviewed" - out = out.joins( + out = out.joins( "LEFT OUTER JOIN audit_certificates ON audit_certificates.form_answer_id=form_answers.id", ).joins( "LEFT OUTER JOIN shortlisted_documents_wrappers ON shortlisted_documents_wrappers.form_answer_id = form_answers.id", diff --git a/app/search/search.rb b/app/search/search.rb index 68e04dcef3..4ea8885a83 100644 --- a/app/search/search.rb +++ b/app/search/search.rb @@ -4,6 +4,16 @@ class Search extend ActiveModel::Naming include ActiveModel::Conversion + VALID_SORT_OPTIONS = %w[ + applied_before + audit_updated_at + flag + full_name + primary_assessor_name + secondary_assessor_name + sic_code + ] + attr_reader :scope, :params, :ordered_desc, :filter_params, :query attr_accessor :ordered_by @@ -48,12 +58,12 @@ def results @search_results = scope filter_params.each do |column, value| - next unless value.present? + next if value.blank? - if included_in_model_columns?(column) - @search_results = @search_results.where(column => value) + @search_results = if included_in_model_columns?(column) + @search_results.where(column => value) else - @search_results = apply_custom_filter(@search_results, column, value) + apply_custom_filter(@search_results, column, value) end end @@ -62,14 +72,14 @@ def results end if ordered_by - if included_in_model_columns?(ordered_by) + @search_results = if included_in_model_columns?(ordered_by) if ordered_desc - @search_results = @search_results.order("#{ordered_by} DESC") + @search_results.order("#{ordered_by} DESC") else - @search_results = @search_results.order(ordered_by) + @search_results.order(ordered_by) end else - @search_results = apply_custom_sort(@search_results, params[:sort]) + apply_custom_sort(@search_results, params[:sort]) end end @@ -96,12 +106,17 @@ def included_in_model_columns?(column) def apply_custom_sort(scoped_results, sort_value) column, order = sort_value.split(".") + + unless VALID_SORT_OPTIONS.include?(column) + raise ArgumentError, "The :column option must be one of #{VALID_SORT_OPTIONS}, but is \"#{column}\"" + end + desc = order == "desc" - public_send("sort_by_#{column}", scoped_results, desc) + public_send(:"sort_by_#{column}", scoped_results, desc) end def apply_custom_filter(scoped_results, column, value) - public_send("filter_by_#{column}", scoped_results, value) + public_send(:"filter_by_#{column}", scoped_results, value) end class Filter < OpenStruct diff --git a/app/services/assessment_submission_service.rb b/app/services/assessment_submission_service.rb index a50dc7e0e4..22fdd04684 100644 --- a/app/services/assessment_submission_service.rb +++ b/app/services/assessment_submission_service.rb @@ -165,7 +165,7 @@ def check_if_there_are_any_discrepancies_between_primary_and_secondary_appraisal } form_answer.update_column( - :discrepancies_between_primary_and_secondary_appraisals, res, + :discrepancies_between_primary_and_secondary_appraisals, res ) end end diff --git a/app/services/assessor_assignment_service.rb b/app/services/assessor_assignment_service.rb index 51386deca6..4965a9d0cf 100644 --- a/app/services/assessor_assignment_service.rb +++ b/app/services/assessor_assignment_service.rb @@ -41,9 +41,9 @@ def normalize_params # but there is only single huge form for all of the descriptions # it's needed to updated only description marked explicitly by the admin # to achieve data other description fields should be removed from params - if updated_section =~ DESC_REGEX + if DESC_REGEX.match?(updated_section) p.delete_if { |k, _| k =~ DESC_REGEX && k != updated_section } - elsif updated_section =~ RATE_REGEX + elsif RATE_REGEX.match?(updated_section) p.delete_if { |k, _| k != updated_section && (k =~ DESC_REGEX || k =~ RATE_REGEX) } end end diff --git a/app/services/check_account_on_bounces_email.rb b/app/services/check_account_on_bounces_email.rb index efe264ceb0..c7a2374986 100644 --- a/app/services/check_account_on_bounces_email.rb +++ b/app/services/check_account_on_bounces_email.rb @@ -10,7 +10,7 @@ class CheckAccountOnBouncesEmail "8" => "Role. Role accounts such as info, support, etc.", } - VALID_DEBOUNCE_API_CODES = [ 4, 5, 7, 8 ] + VALID_DEBOUNCE_API_CODES = [4, 5, 7, 8] attr_accessor :user, :email, @@ -48,22 +48,22 @@ def bounce_reason(code) private def debounce_api_says_it_is_valid?(email) - res = RestClient.get( - "https://api.debounce.io/v1/?api=#{ENV["DEBOUNCE_API_KEY"]}&email=#{email}", - { accept: :json }, - ) - @code = JSON.parse(res.body)["debounce"]["code"] + res = RestClient.get( + "https://api.debounce.io/v1/?api=#{ENV["DEBOUNCE_API_KEY"]}&email=#{email}", + { accept: :json }, + ) + @code = JSON.parse(res.body)["debounce"]["code"] - VALID_DEBOUNCE_API_CODES.include?(code.to_i) - rescue RestClient::Exceptions::ReadTimeout => e - # - # RARE CASE: - # - # Mark email as valid in case of getting Timeout error - # as Debounce API sometimes returns Timeout error - # for valid emails. - # + VALID_DEBOUNCE_API_CODES.include?(code.to_i) + rescue RestClient::Exceptions::ReadTimeout + # + # RARE CASE: + # + # Mark email as valid in case of getting Timeout error + # as Debounce API sometimes returns Timeout error + # for valid emails. + # - true + true end -end \ No newline at end of file +end diff --git a/app/services/company_registration_number.rb b/app/services/company_registration_number.rb index 575ca84fb9..d2597d19eb 100644 --- a/app/services/company_registration_number.rb +++ b/app/services/company_registration_number.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class CompanyRegistrationNumber - COMPANY_REGISTRATION_NUMBER_REGEX = %r{(?!\s)((AC|ZC|FC|GE|LP|OC|SE|SA|SZ|SF|GS|SL|SO|SC|ES|NA|NZ|NF|GN|NL|NC|R0|NI|EN|\d{0,2}|SG|FE(\s?))\d{5}(\d|C|R))|((RS|SO)\d{3}(\d{3}|\d{2}[WSRCZF]|\d(FI|RS|SA|IP|US|EN|AS)|CUS))|((NI|SL)\d{5}[\dA])|(OC(([\dP]{5}[CWERTB])|([\dP]{4}(OC|CU))))}i.freeze + COMPANY_REGISTRATION_NUMBER_REGEX = %r{(?!\s)((AC|ZC|FC|GE|LP|OC|SE|SA|SZ|SF|GS|SL|SO|SC|ES|NA|NZ|NF|GN|NL|NC|R0|NI|EN|\d{0,2}|SG|FE(\s?))\d{5}(\d|C|R))|((RS|SO)\d{3}(\d{3}|\d{2}[WSRCZF]|\d(FI|RS|SA|IP|US|EN|AS)|CUS))|((NI|SL)\d{5}[\dA])|(OC(([\dP]{5}[CWERTB])|([\dP]{4}(OC|CU))))}i def self.extract_from(content) new(content).extract @@ -18,12 +18,10 @@ def extract return [] if content.blank? sanitized = sanitize(content).strip - parts = tokenize(content) - numbers = parts.each_with_object([]) do |part, memo| - memo << part if part =~ COMPANY_REGISTRATION_NUMBER_REGEX + parts = tokenize(sanitized) + parts.each_with_object([]) do |part, memo| + memo << part if COMPANY_REGISTRATION_NUMBER_REGEX.match?(part) end - - numbers end private diff --git a/app/services/current_award_type_picker.rb b/app/services/current_award_type_picker.rb index 8760734fbb..6d4df0817b 100644 --- a/app/services/current_award_type_picker.rb +++ b/app/services/current_award_type_picker.rb @@ -28,7 +28,7 @@ def visible_categories categories = lead_categories + regular_categories - if !params[:year].present? || params[:year].to_i > 2016 + if params[:year].blank? || params[:year].to_i > 2016 categories -= ["promotion"] end @@ -38,9 +38,7 @@ def visible_categories end def show_award_tabs_for_assessor? - if current_subject.categories_as_lead.size > 0 - return true if visible_categories.size > 1 - end + current_subject.categories_as_lead.size > 0 && visible_categories.size > 1 end class AwardCategory < OpenStruct diff --git a/app/services/form_answer_auditor.rb b/app/services/form_answer_auditor.rb index 5e60a4cee3..e6fef10c3a 100644 --- a/app/services/form_answer_auditor.rb +++ b/app/services/form_answer_auditor.rb @@ -19,7 +19,7 @@ def create_events_from_audit_logs(form_answer) action_type: audit_log.action_type, subject: audit_log.subject || dummy_user, created_at: audit_log.created_at, - ) + ) end end @@ -30,7 +30,7 @@ def create_events_from_papertrail_versions(form_answer) action_type: "application_#{version.event}", subject: get_user_from_papertrail_version(version), created_at: version.created_at, - ) + ) end end diff --git a/app/services/form_answer_versions_dispatcher.rb b/app/services/form_answer_versions_dispatcher.rb index 81ab826ac9..ee714060e6 100644 --- a/app/services/form_answer_versions_dispatcher.rb +++ b/app/services/form_answer_versions_dispatcher.rb @@ -14,7 +14,7 @@ def versions def whodunnit_hash @whodunnit_hash ||= begin keys = @form_answer.versions.map(&:whodunnit).uniq.compact - Hash[keys.map { |key| [key, get_full_name(key)] }] + keys.index_with { |key| get_full_name(key) } end end @@ -27,8 +27,6 @@ def get_full_name(whodunnit_key) # and display "N/A" for such users if user user.decorate.full_name - else - nil end end diff --git a/app/services/notifiers/account_notifier.rb b/app/services/notifiers/account_notifier.rb index 3e74854069..e14a53ae38 100644 --- a/app/services/notifiers/account_notifier.rb +++ b/app/services/notifiers/account_notifier.rb @@ -1,5 +1,5 @@ class Notifiers::AccountNotifier - attr_reader :account, :form_answer, :recipients + attr_reader :account, :form_answer def form_owner @form_owner ||= form_answer.user diff --git a/app/services/notifiers/email_notification_service.rb b/app/services/notifiers/email_notification_service.rb index 30b25b5a76..4d59bf8d8e 100644 --- a/app/services/notifiers/email_notification_service.rb +++ b/app/services/notifiers/email_notification_service.rb @@ -24,8 +24,8 @@ def run end end - %w(innovation trade mobility development).each do |award| - define_method "#{award}_submission_started_notification" do |award_year| + %w[innovation trade mobility development].each do |award| + define_method :"#{award}_submission_started_notification" do |award_year| submission_started_notification(award_year, award) end end @@ -75,20 +75,20 @@ def reminder_to_submit(award_year) end send_emails_to_collaborators!( - collaborator_data, AccountMailers::ReminderToSubmitMailer, + collaborator_data, AccountMailers::ReminderToSubmitMailer ) end def shortlisted_notifier(award_year) gather_data_and_send_emails!( - award_year.form_answers.shortlisted.where(award_type: %w(innovation trade)), + award_year.form_answers.shortlisted.where(award_type: %w[innovation trade]), AccountMailers::NotifyShortlistedMailer, ) end def shortlisted_po_sd_notifier(award_year) gather_data_and_send_emails!( - award_year.form_answers.shortlisted.with_estimated_figures_provided.where(award_type: %w(mobility development)), + award_year.form_answers.shortlisted.with_estimated_figures_provided.where(award_type: %w[mobility development]), AccountMailers::NotifyShortlistedMailer, :notify_po_sd, ) @@ -96,7 +96,7 @@ def shortlisted_po_sd_notifier(award_year) def shortlisted_po_sd_with_actual_figures_notifier(award_year) gather_data_and_send_emails!( - award_year.form_answers.shortlisted.with_actual_figures_provided.where(award_type: %w(mobility development)), + award_year.form_answers.shortlisted.with_actual_figures_provided.where(award_type: %w[mobility development]), AccountMailers::NotifyShortlistedMailer, :notify_po_sd_with_actual_figures, ) @@ -112,7 +112,7 @@ def not_shortlisted_notifier(award_year) def shortlisted_audit_certificate_reminder(award_year) collaborator_data = [] - award_year.form_answers.where(award_type: %w(innovation trade)).shortlisted.each do |form_answer| + award_year.form_answers.where(award_type: %w[innovation trade]).shortlisted.each do |form_answer| next if form_answer.audit_certificate form_answer.collaborators.each do |collaborator| @@ -126,7 +126,7 @@ def shortlisted_audit_certificate_reminder(award_year) def shortlisted_po_sd_reminder(award_year) collaborator_data = [] - award_year.form_answers.where(award_type: %w(mobility development)).shortlisted.provided_estimates.each do |form_answer| + award_year.form_answers.where(award_type: %w[mobility development]).shortlisted.provided_estimates.each do |form_answer| next if form_answer.shortlisted_documents_wrapper.try(:submitted?) form_answer.collaborators.each do |collaborator| @@ -193,7 +193,7 @@ def buckingham_palace_invite(award_year) class << self def log_this(message) - p "[EmailNotificationService] #{Time.zone.now} #{message}" + Rails.logger.debug "[EmailNotificationService] #{Time.zone.now} #{message}" end end diff --git a/app/services/performance_platform_service.rb b/app/services/performance_platform_service.rb index 275fa6760c..c173628f7e 100644 --- a/app/services/performance_platform_service.rb +++ b/app/services/performance_platform_service.rb @@ -31,7 +31,7 @@ def self.run log_this("completed") unless Rails.env.test? end - #[ + # [ # { # "_id": "23456780", # "_timestamp": "2015-03-10T00:00:00Z", @@ -40,7 +40,7 @@ def self.run # "channel_type": "digital", # "count": 42 # } - #] + # ] def self.perform_transactions_by_channel timestamp = (Time.current - 1.week).beginning_of_day.utc @@ -59,7 +59,7 @@ def self.perform_transactions_by_channel perform_request(TRANSACTIONS_BY_CHANNEL_URL, [result]) end - #[ + # [ # { # "_id": "23456789", # "_timestamp": "2015-03-18T00:00:00Z", @@ -78,7 +78,7 @@ def self.perform_transactions_by_channel # "count": 42, # "cumulative_count": 72 # } - #] + # ] def self.perform_applications_by_stage payload = fetch_applications_data @@ -105,7 +105,7 @@ def self.perform_request(url, payload) http.request req end - puts res.body + Rails.logger.debug res.body nil end @@ -199,7 +199,7 @@ def self.fetch_applications_data def self.generate_transactions_id(data) string = "" - %w(_timestamp period channel channel_type).each do |attr| + %w[_timestamp period channel channel_type].each do |attr| string << data[attr] end @@ -210,7 +210,7 @@ def self.generate_transactions_id(data) def self.generate_applications_id(data) string = "" - %w(_timestamp period award stage).each do |attr| + %w[_timestamp period award stage].each do |attr| string << data[attr] end @@ -236,7 +236,7 @@ def self.md5(string) class << self def log_this(message) - p "[PerformancePlatformService] #{Time.zone.now} #{message}" + Rails.logger.debug "[PerformancePlatformService] #{Time.zone.now} #{message}" end end end diff --git a/app/services/rescan_service.rb b/app/services/rescan_service.rb index 476e729f02..985704de0d 100644 --- a/app/services/rescan_service.rb +++ b/app/services/rescan_service.rb @@ -7,7 +7,7 @@ def self.perform def self.rescan_model(attachment_class, attachment_column) attachment_class.where.not("#{attachment_column}_scan_results" => %w[infected clean]).each do |record| - record.public_send("scan_#{attachment_column}!") + record.public_send(:"scan_#{attachment_column}!") end end end diff --git a/app/services/utils/date.rb b/app/services/utils/date.rb index 7f7a2ba28a..005236df66 100644 --- a/app/services/utils/date.rb +++ b/app/services/utils/date.rb @@ -12,7 +12,7 @@ def self.within_range?(value, range) end min, max = range.minmax - return date >= min && date <= max + date >= min && date <= max rescue false end diff --git a/app/services/utils/elapsed_time.rb b/app/services/utils/elapsed_time.rb index 608a3f5971..9eb3f3744b 100644 --- a/app/services/utils/elapsed_time.rb +++ b/app/services/utils/elapsed_time.rb @@ -9,7 +9,7 @@ class ElapsedTime end.freeze def self.call - @clock.() + @clock.call end end end diff --git a/app/tasks/manual_updaters/hard_copy_generation.rb b/app/tasks/manual_updaters/hard_copy_generation.rb index e3f955c0ca..dd0ed52fe6 100644 --- a/app/tasks/manual_updaters/hard_copy_generation.rb +++ b/app/tasks/manual_updaters/hard_copy_generation.rb @@ -47,15 +47,15 @@ def case_summary_individual not_updated_entries_cs_individual = [] year.hard_copy_case_summary_scope.find_each do |form_answer| - form_answer.generate_case_summary_hard_copy_pdf! + form_answer.generate_case_summary_hard_copy_pdf! - sleep 3 + sleep 3 - logy "[#{ENV["MAILER_HOST"]} | CS IND | #{form_answer.id}] -------------------------------- updated" + logy "[#{ENV["MAILER_HOST"]} | CS IND | #{form_answer.id}] -------------------------------- updated" rescue => e - not_updated_entries_cs_individual << form_answer.id + not_updated_entries_cs_individual << form_answer.id - logy "[#{ENV["MAILER_HOST"]} | CS IND | #{form_answer.id} | ERROR] --------------------------------- #{e.message}" + logy "[#{ENV["MAILER_HOST"]} | CS IND | #{form_answer.id} | ERROR] --------------------------------- #{e.message}" end if not_updated_entries_cs_individual.present? @@ -80,15 +80,15 @@ def feedback_individual not_updated_entries_feed_individual = [] year.hard_copy_feedback_scope.find_each do |form_answer| - form_answer.generate_feedback_hard_copy_pdf! + form_answer.generate_feedback_hard_copy_pdf! - sleep 3 + sleep 3 - logy "[#{ENV["MAILER_HOST"]} | FEED IND | #{form_answer.id}] -------------------------------- updated" + logy "[#{ENV["MAILER_HOST"]} | FEED IND | #{form_answer.id}] -------------------------------- updated" rescue => e - not_updated_entries_feed_individual << form_answer.id + not_updated_entries_feed_individual << form_answer.id - logy "[#{ENV["MAILER_HOST"]} | FEED IND | #{form_answer.id} | ERROR] --------------------------------- #{e.message}" + logy "[#{ENV["MAILER_HOST"]} | FEED IND | #{form_answer.id} | ERROR] --------------------------------- #{e.message}" end if not_updated_entries_feed_individual.present? @@ -129,8 +129,7 @@ def feedback_aggregated end def logy(m) - puts m - Rails.logger.info m + Rails.logger.debug m end end end diff --git a/app/tasks/manual_updaters/submit_application.rb b/app/tasks/manual_updaters/submit_application.rb index 8be17be15a..9dd5bcab33 100644 --- a/app/tasks/manual_updaters/submit_application.rb +++ b/app/tasks/manual_updaters/submit_application.rb @@ -43,14 +43,13 @@ def run! # HardCopyPdfGenerators::FormDataWorker.perform_async(form_answer.id, true) - p "" - p "[MANUAL SUBMISSION | SUCCESS] DONE! Check it at https://www.kings-awards-enterprise.service.gov.uk/admin/form_answers/#{form_answer.id}" - p "" + Rails.logger.debug "" + Rails.logger.debug "[MANUAL SUBMISSION | SUCCESS] DONE! Check it at https://www.kings-awards-enterprise.service.gov.uk/admin/form_answers/#{form_answer.id}" else - p "" - p "[MANUAL SUBMISSION | ERROR] seems URN is not generated! Please, check why!" - p "" + Rails.logger.debug "" + Rails.logger.debug "[MANUAL SUBMISSION | ERROR] seems URN is not generated! Please, check why!" end + Rails.logger.debug "" end end end diff --git a/app/tasks/manual_updaters/trade_award_downgrader.rb b/app/tasks/manual_updaters/trade_award_downgrader.rb index faf112afa1..a59260a986 100644 --- a/app/tasks/manual_updaters/trade_award_downgrader.rb +++ b/app/tasks/manual_updaters/trade_award_downgrader.rb @@ -13,17 +13,17 @@ def run! raise ArgumentError, "Application is already 3 to 5 years" if document["trade_commercial_success"] != "6 plus" - puts "Downgrading Trade Application ##{form_answer.id}" + Rails.logger.debug "Downgrading Trade Application ##{form_answer.id}" # financial year changed dates - %w(day month).each do |attr| + %w[day month].each do |attr| # two times since the last date is already set 2.times do |i| document["financial_year_changed_dates_#{i + 1}of3#{attr}"] = document["financial_year_changed_dates_#{i + 4}of6#{attr}"] end end - %w(employees overseas_sales total_turnover net_profit).each do |attr| + %w[employees overseas_sales total_turnover net_profit].each do |attr| 3.times do |i| document["#{attr}_#{i + 1}of3"] = document["#{attr}_#{i + 4}of6"] end @@ -34,6 +34,6 @@ def run! form_answer.document = document form_answer.save! - puts "Sucess!" + Rails.logger.debug "Sucess!" end end diff --git a/app/tasks/useful_checkers/eligibility_checker.rb b/app/tasks/useful_checkers/eligibility_checker.rb index f9b6506cfd..3f207dbe77 100644 --- a/app/tasks/useful_checkers/eligibility_checker.rb +++ b/app/tasks/useful_checkers/eligibility_checker.rb @@ -19,7 +19,7 @@ def initialize ActiveRecord::Base.logger.level = Logger::INFO self.year = AwardYear.current - self.all_apps = year.form_answers.where("state NOT IN (?)", ["eligibility_in_progress", "not_eligible", "not_submitted"]) + self.all_apps = year.form_answers.where.not(state: ["eligibility_in_progress", "not_eligible", "not_submitted"]) self.trade_apps = all_apps.where(award_type: "trade") self.innovation_apps = all_apps.where(award_type: "innovation") @@ -28,7 +28,7 @@ def initialize end def run - puts "" + Rails.logger.debug "" self.wrong_trade_apps = trade_apps.select do |app| e = app.eligibility @@ -37,14 +37,14 @@ def run !e.valid? end - puts "[TRADE] #{wrong_trade_apps.count} entries" - puts "" + Rails.logger.debug "[TRADE] #{wrong_trade_apps.count} entries" + Rails.logger.debug "" wrong_trade_apps.map do |app| details(app) end - puts "" + Rails.logger.debug "" self.wrong_innovation_apps = innovation_apps.select do |app| e = app.eligibility @@ -53,14 +53,14 @@ def run !e.valid? end - puts "[INNOVATION] #{wrong_innovation_apps.count} entries" - puts "" + Rails.logger.debug "[INNOVATION] #{wrong_innovation_apps.count} entries" + Rails.logger.debug "" wrong_innovation_apps.map do |app| details(app) end - puts "" + Rails.logger.debug "" self.wrong_development_apps = development_apps.select do |app| e = app.eligibility @@ -69,13 +69,13 @@ def run !e.valid? end - puts "[DEVELOPMENT] #{wrong_development_apps.count} entries" - puts "" + Rails.logger.debug "[DEVELOPMENT] #{wrong_development_apps.count} entries" + Rails.logger.debug "" wrong_development_apps.map do |app| details(app) end - puts "" + Rails.logger.debug "" self.wrong_mobility_apps = mobility_apps.select do |app| e = app.eligibility @@ -84,13 +84,13 @@ def run !e.valid? end - puts "[MOBILITY] #{wrong_mobility_apps.count} entries" - puts "" + Rails.logger.debug "[MOBILITY] #{wrong_mobility_apps.count} entries" + Rails.logger.debug "" wrong_mobility_apps.map do |app| details(app) end - puts "" + Rails.logger.debug "" end def details(app) @@ -99,22 +99,22 @@ def details(app) e.force_validate_now = true e.valid? - puts " [#{app.id} | #{app.award_type}] STATE: #{app.state}" - puts "" - puts " BASIC ELIGIBILITY" - puts "" + Rails.logger.debug " [#{app.id} | #{app.award_type}] STATE: #{app.state}" + Rails.logger.debug "" + Rails.logger.debug " BASIC ELIGIBILITY" + Rails.logger.debug "" b.answers.map do |k, v| - puts " #{k}: #{v}" + Rails.logger.debug " #{k}: #{v}" end - puts "" - puts " #{app.award_type.upcase} ELIGIBILITY" - puts "" + Rails.logger.debug "" + Rails.logger.debug " #{app.award_type.upcase} ELIGIBILITY" + Rails.logger.debug "" e.answers.map do |k, v| - puts " #{k}: #{v}" + Rails.logger.debug " #{k}: #{v}" end - puts "" - puts " #{e.errors.full_messages.join(", ")}" - puts "" + Rails.logger.debug "" + Rails.logger.debug " #{e.errors.full_messages.join(", ")}" + Rails.logger.debug "" end end end diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index 315945bfcf..bf112d380a 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -1,6 +1,6 @@ class FileUploader < CarrierWave::Uploader::Base - POSSIBLE_IMG_EXTENSIONS = %w(jpg jpeg gif png) - POSSIBLE_DOC_EXTENSIONS = %w(chm csv diff doc docx dot dxf eps gml ics kml odp ods odt pdf ppt pptx ps rdf rtf sch txt wsdl xls xlsm xlsx xlt xsd xslt zip msg) + POSSIBLE_IMG_EXTENSIONS = %w[jpg jpeg gif png] + POSSIBLE_DOC_EXTENSIONS = %w[chm csv diff doc docx dot dxf eps gml ics kml odp ods odt pdf ppt pptx ps rdf rtf sch txt wsdl xls xlsm xlsx xlt xsd xslt zip msg] def extension_allowlist POSSIBLE_IMG_EXTENSIONS + POSSIBLE_DOC_EXTENSIONS diff --git a/app/uploaders/form_answer_pdf_version_uploader.rb b/app/uploaders/form_answer_pdf_version_uploader.rb index e8dfb63fe0..190fa4c3ec 100644 --- a/app/uploaders/form_answer_pdf_version_uploader.rb +++ b/app/uploaders/form_answer_pdf_version_uploader.rb @@ -6,7 +6,7 @@ def filename end def extension_allowlist - %w(pdf) + %w[pdf] end def store_dir diff --git a/app/validators/advanced_email_validator.rb b/app/validators/advanced_email_validator.rb index 1b8a9c8a3e..6febb5f660 100644 --- a/app/validators/advanced_email_validator.rb +++ b/app/validators/advanced_email_validator.rb @@ -25,7 +25,7 @@ def validate_address_domain(record, parsed) def validate_address_well_formed(record, parsed) maybe_set_error(record, "is not a valid address") do - not (parsed.local && + !(parsed.local && parsed.domain && parsed.address == record.email && parsed.local != record.email) diff --git a/app/validators/company_registration_number_validator.rb b/app/validators/company_registration_number_validator.rb index 1f155421e9..95c3d637f4 100644 --- a/app/validators/company_registration_number_validator.rb +++ b/app/validators/company_registration_number_validator.rb @@ -3,7 +3,7 @@ # Based on: https://gist.github.com/rob-murray/01d43581114a6b319034732bcbda29e1 class CompanyRegistrationNumberValidator < ActiveModel::EachValidator - VALID_CRN_REGEX = %r{\A(?!.{9})((AC|ZC|FC|GE|LP|OC|SE|SA|SZ|SF|GS|SL|SO|SC|ES|NA|NZ|NF|GN|NL|NC|R0|NI|EN|\d{0,2}|SG|FE)\d{5}(\d|C|R))|((RS|SO)\d{3}(\d{3}|\d{2}[WSRCZF]|\d(FI|RS|SA|IP|US|EN|AS)|CUS))|((NI|SL)\d{5}[\dA])|(OC(([\dP]{5}[CWERTB])|([\dP]{4}(OC|CU))))\z}i.freeze + VALID_CRN_REGEX = %r{\A(?!.{9})((AC|ZC|FC|GE|LP|OC|SE|SA|SZ|SF|GS|SL|SO|SC|ES|NA|NZ|NF|GN|NL|NC|R0|NI|EN|\d{0,2}|SG|FE)\d{5}(\d|C|R))|((RS|SO)\d{3}(\d{3}|\d{2}[WSRCZF]|\d(FI|RS|SA|IP|US|EN|AS)|CUS))|((NI|SL)\d{5}[\dA])|(OC(([\dP]{5}[CWERTB])|([\dP]{4}(OC|CU))))\z}i def self.regexp VALID_CRN_REGEX diff --git a/app/validators/file_size_validator.rb b/app/validators/file_size_validator.rb index eac9102393..272d2c0e7d 100644 --- a/app/validators/file_size_validator.rb +++ b/app/validators/file_size_validator.rb @@ -5,11 +5,11 @@ class FileSizeValidator < ActiveModel::EachValidator MESSAGES = { is: :wrong_size, minimum: :size_too_small, maximum: :size_too_big }.freeze CHECKS = { is: :==, minimum: :>=, maximum: :<= }.freeze - DEFAULT_TOKENIZER = lambda { |value| value.split(//) } + DEFAULT_TOKENIZER = lambda { |value| value.chars } RESERVED_OPTIONS = [:minimum, :maximum, :within, :is, :tokenizer, :too_short, :too_long] def initialize(options) - if range = options.delete(:in) || options.delete(:within) + if (range = options.delete(:in) || options.delete(:within)) raise ArgumentError, ":in and :within must be a Range" unless range.is_a?(Range) options[:minimum], options[:maximum] = range.begin, range.end options[:maximum] -= 1 if range.exclude_end? @@ -43,7 +43,7 @@ def validate_each(record, attribute, value) value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.is_a?(String) CHECKS.each do |key, validity_check| - next unless check_value = options[key] + next unless (check_value = options[key]) value ||= [] if key == :maximum diff --git a/app/value_objects/award.rb b/app/value_objects/award.rb index 49be3c5921..3601447daf 100644 --- a/app/value_objects/award.rb +++ b/app/value_objects/award.rb @@ -19,7 +19,7 @@ def initialize(question, holder = false, attrs = {}) @holder = holder attrs.each do |key, value| - instance_variable_set("@#{key}", value.to_s.strip) + instance_variable_set(:"@#{key}", value.to_s.strip) end end diff --git a/app/value_objects/current_queens_award.rb b/app/value_objects/current_queens_award.rb index f23973f81e..d08c815e53 100644 --- a/app/value_objects/current_queens_award.rb +++ b/app/value_objects/current_queens_award.rb @@ -12,12 +12,12 @@ class CurrentQueensAward validates :category, length: { maximum: 100 }, inclusion: { - in: -> (record) { record.categories }, + in: ->(record) { record.categories }, } validates :year, length: { maximum: 4 }, inclusion: { - in: -> (record) { record.years }, + in: ->(record) { record.years }, } def initialize(categories, years, outcomes, attrs = {}) @@ -26,7 +26,7 @@ def initialize(categories, years, outcomes, attrs = {}) @outcomes = outcomes.map { |o| [o.value, o.text] } attrs.each do |key, value| - instance_variable_set("@#{key}", value.to_s.strip) + instance_variable_set(:"@#{key}", value.to_s.strip) end end end diff --git a/app/value_objects/form_answer_appraisal_form_helpers.rb b/app/value_objects/form_answer_appraisal_form_helpers.rb index a5f5fbdfd4..29f5872de9 100644 --- a/app/value_objects/form_answer_appraisal_form_helpers.rb +++ b/app/value_objects/form_answer_appraisal_form_helpers.rb @@ -25,7 +25,6 @@ def secondary_assessor_submitted_at def discrepancies_between_primary_and_secondary_appraisals_details list = discrepancies_source["discrepancies"] - total_number_of_keys = list.count list.map.with_index do |discrepancy, index| "#{discrepancy[1]} (#{discrepancy[2]} - #{discrepancy[3]})" @@ -35,4 +34,4 @@ def discrepancies_between_primary_and_secondary_appraisals_details def discrepancies_source discrepancies_between_primary_and_secondary_appraisals end -end \ No newline at end of file +end diff --git a/app/value_objects/form_link.rb b/app/value_objects/form_link.rb index 2d544b2b92..fa20ae8188 100644 --- a/app/value_objects/form_link.rb +++ b/app/value_objects/form_link.rb @@ -12,13 +12,13 @@ class FormLink # Should be 100 words maximum (limit + 10%).to_i + 1) validates :description, length: { maximum: 111, - tokenizer: -> (str) { str.split }, + tokenizer: ->(str) { str.split }, message: "is too long (maximum is 100 words)", } def initialize(attrs = {}) attrs.each do |key, value| - instance_variable_set("@#{key}", value.to_s.strip) + instance_variable_set(:"@#{key}", value.to_s.strip) end end end diff --git a/app/value_objects/position.rb b/app/value_objects/position.rb index 51a72aec1c..326de95b55 100644 --- a/app/value_objects/position.rb +++ b/app/value_objects/position.rb @@ -21,13 +21,13 @@ class Position # Should be 100 words maximum (limit + 10%).to_i + 1) validates :details, length: { maximum: 111, - tokenizer: -> (str) { str.split }, + tokenizer: ->(str) { str.split }, message: "is too long (maximum is 100 words)", } def initialize(attrs = {}) attrs.each do |key, value| - instance_variable_set("@#{key}", value.to_s.strip) + instance_variable_set(:"@#{key}", value.to_s.strip) end end end diff --git a/app/value_objects/subsidiary.rb b/app/value_objects/subsidiary.rb index 501b19ae3c..925a5b6892 100644 --- a/app/value_objects/subsidiary.rb +++ b/app/value_objects/subsidiary.rb @@ -12,11 +12,11 @@ class Subsidiary validates :description, presence: true # Should be 100 words maximum (limit + 10%).to_i + 1) - validate :words_in_description, if: Proc.new { |m| m.description.present? } + validate :words_in_description, if: proc { |m| m.description.present? } def initialize(attrs = {}) attrs.each do |key, value| - instance_variable_set("@#{key}", value.to_s.strip) + instance_variable_set(:"@#{key}", value.to_s.strip) end end diff --git a/app/views/admin/form_answers/_states_list.html.slim b/app/views/admin/form_answers/_states_list.html.slim index ab7a3c3bea..9441c04a0f 100644 --- a/app/views/admin/form_answers/_states_list.html.slim +++ b/app/views/admin/form_answers/_states_list.html.slim @@ -2,4 +2,4 @@ ul.dropdown-menu.pull-right role="menu" - collection.each do |state| li.checkbox role="presentation" - = link_to I18n.t(state, scope: "form_answers.state"), "#", "data-state" => state.to_s, "data-label" => I18n.t(state, scope: "form_answers.state_short").html_safe + = link_to t(state, scope: "form_answers.state"), "#", "data-state" => state.to_s, "data-label" => t("#{state}_html", scope: "form_answers.state_short") diff --git a/app/views/admin/form_answers/_submitted_view.html.slim b/app/views/admin/form_answers/_submitted_view.html.slim index 56fda0ce76..e0519670d1 100644 --- a/app/views/admin/form_answers/_submitted_view.html.slim +++ b/app/views/admin/form_answers/_submitted_view.html.slim @@ -27,10 +27,10 @@ = render "admin/form_answers/section_appraisal_form_secondary" = render "section_appraisal_form_moderated" - - if show_case_summary_section? + - if show_case_summary_section?(@form_answer) = render "section_case_summary" - - if show_feedback_section? + - if show_feedback_section?(@form_answer) .panel.panel-default.panel-parent[data-controller="element-focus" data-element-focus-selector-value="input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [href='#']"] .panel-heading#feedback-heading h2.panel-title @@ -47,7 +47,7 @@ .panel-body[data-controller="inline-flash"] = render "admin/feedbacks/section", form_answer: @form_answer - - if show_winners_section? + - if show_winners_section?(@form_answer) .panel.panel-default.panel-parent[data-controller="element-focus" data-element-focus-selector-value="input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [href='#']"] .panel-heading#winners-heading h2.panel-title @@ -56,9 +56,9 @@ #section-winners.section-application-info.panel-collapse.collapse.in aria-labelledby="winners-heading" .panel-body .panel-group#panel-winners-parent - - if show_press_summary_subsection? + - if show_press_summary_subsection?(@form_answer) = render "section_press_summary" - - if show_palace_attendees_subsection? + - if show_palace_attendees_subsection?(@form_answer) = render "section_palace_attendees" .panel.panel-default.panel-parent[data-controller="element-focus" data-element-focus-selector-value="input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [href='#']"] diff --git a/app/views/admin/form_answers/company_details/_entry_relates_to_checkboxes.html.slim b/app/views/admin/form_answers/company_details/_entry_relates_to_checkboxes.html.slim index 6daa99b58b..99bb80b933 100644 --- a/app/views/admin/form_answers/company_details/_entry_relates_to_checkboxes.html.slim +++ b/app/views/admin/form_answers/company_details/_entry_relates_to_checkboxes.html.slim @@ -1,8 +1,10 @@ -- if @form_answer.send("#{awards[0]}?") && options_available(AppraisalFormHelper.const_get("ENTRY_RELATES_TO_#{awards[0].upcase}_OPS")) || @form_answer.send("#{awards[1]}?") && options_available(AppraisalFormHelper.const_get("ENTRY_RELATES_TO_#{awards[1].upcase}_OPS")) +- check_options = (@form_answer.send("#{awards[0]}?") && options_available(AppraisalFormHelper.const_get("ENTRY_RELATES_TO_#{awards[0].upcase}_OPS"))) || (@form_answer.send("#{awards[1]}?") && options_available(AppraisalFormHelper.const_get("ENTRY_RELATES_TO_#{awards[1].upcase}_OPS"))) + +- unless check_options.blank? - name = awards[0] == "innovation" ? "application_relate_to_header" : "application_relate_to" - values = awards[0] == "innovation" ? @form_answer.document["application_relate_to_header"] : @form_answer.document["application_relate_to"] - - @check_options.each_with_index do |check_option, placement| + - check_options.each_with_index do |check_option, placement| - value_selected = values.is_a?(Array) && values.detect { |el| el['type'].to_s == check_option[0].to_s } .form-control diff --git a/app/views/assessor/form_answers/_submitted_view.html.slim b/app/views/assessor/form_answers/_submitted_view.html.slim index 5558e72290..c7131ab22d 100644 --- a/app/views/assessor/form_answers/_submitted_view.html.slim +++ b/app/views/assessor/form_answers/_submitted_view.html.slim @@ -25,13 +25,13 @@ = render "admin/form_answers/section_appraisal_form_primary" - if secondary_assessment.visible_for?(current_subject) = render "admin/form_answers/section_appraisal_form_secondary" - - if show_section_appraisal_moderated? + - if policy(@form_answer).show_section_appraisal_moderated? = render "admin/form_answers/section_appraisal_form_moderated" - - if show_case_summary_section? + - if show_case_summary_section?(@form_answer) = render "admin/form_answers/section_case_summary" - - if show_feedback_section? + - if show_feedback_section?(@form_answer) .panel.panel-default.panel-parent[data-controller="element-focus" data-element-focus-selector-value="input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [href='#']"] .panel-heading#feedback-heading h2.panel-title @@ -48,7 +48,7 @@ .panel-body[data-controller="inline-flash"] = render "admin/feedbacks/section", form_answer: @form_answer - - if show_winners_section? + - if show_winners_section?(@form_answer) .panel.panel-default.panel-parent .panel-heading#winners-heading[data-controller="element-focus" data-element-focus-selector-value="input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [href='#']"] h2.panel-title @@ -57,9 +57,9 @@ #section-winners.section-application-info.panel-collapse.collapse.in aria-labelledby="winners-heading" .panel-body .panel-group#panel-winners-parent - - if show_press_summary_subsection? + - if show_press_summary_subsection?(@form_answer) = render "admin/form_answers/section_press_summary" - - if show_palace_attendees_subsection? + - if show_palace_attendees_subsection?(@form_answer) = render "admin/form_answers/section_palace_attendees" .panel.panel-default.panel-parent diff --git a/app/views/qae_form/show.html.slim b/app/views/qae_form/show.html.slim index 5f74e0a3e3..6c57016de5 100644 --- a/app/views/qae_form/show.html.slim +++ b/app/views/qae_form/show.html.slim @@ -2,7 +2,7 @@ - provide(:page_wrapper_class, "page-award-form #{'page-read-only-form' if current_form_is_not_editable?}") -- if application_collaborator_group_mode? +- if application_collaborator_group_mode?(@form_answer) - provide(:body_end) do .js-collaborators-bar.hidden @@ -34,6 +34,6 @@ form.qae-form.award-form data-autosave-url=save_form_url(@form_answer) action=sa = render "qae_form/step_error" -- if application_collaborator_group_mode? +- if application_collaborator_group_mode?(@form_answer) = content_for(:javascript_code) do | ApplicationCollaboratorsConnectionManager.init('#{@form_answer.id}', '#{Pusher.host}', #{Pusher.port}, '#{Pusher.key}', '#{Rails.env}', #{Time.now.utc.to_i}); diff --git a/config/application.rb b/config/application.rb index 7aad9ce305..4514995ae2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,9 +11,9 @@ module Qae class Application < Rails::Application config.load_defaults 7.0 - #initializer :regenerate_require_cache, before: :load_environment_config do + # initializer :regenerate_require_cache, before: :load_environment_config do # Bootscale.regenerate - #end + # end # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. @@ -41,7 +41,7 @@ class Application < Rails::Application # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - #NOTE: This works like Rails 4. For Rails 5, we can use + # 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 diff --git a/config/environments/production.rb b/config/environments/production.rb index c05eead8cb..ad5ae448f2 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -62,7 +62,7 @@ config.log_level = ENV["LOG_LEVEL"].presence || :debug # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -93,7 +93,7 @@ "rails", format: Appsignal::Logger::LOGFMT, ) - config.logger = ActiveSupport::Logger.new(STDOUT) # Lograge-formatted logs to STDOUT + config.logger = ActiveSupport::Logger.new($stdout) # Lograge-formatted logs to STDOUT # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 6e44e403e6..32636d78c4 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -18,9 +18,9 @@ "twofactor.js", ] -Rails.application.config.assets.precompile += %w( ckeditor/* ) -Rails.application.config.assets.precompile += %w( favicon.ico ) -Rails.application.config.assets.precompile += %w( *.png ) +Rails.application.config.assets.precompile += %w[ckeditor/*] +Rails.application.config.assets.precompile += %w[favicon.ico] +Rails.application.config.assets.precompile += %w[*.png] # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 3a365d5610..5b426f8fab 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -8,7 +8,7 @@ config.mailer_sender = ENV["MAILER_FROM"] || "no-reply@kings-awards-enterprise.service.gov.uk" # Configure the class responsible to send e-mails. - #config.mailer = "Devise::Mailer" + # config.mailer = "Devise::Mailer" require "devise/orm/active_record" @@ -32,12 +32,12 @@ # Configure which authentication keys should be case-insensitive. # These keys will be downcased upon creating or modifying a user and when used # to authenticate or find a user. Default is :email. - config.case_insensitive_keys = [ :email ] + config.case_insensitive_keys = [:email] # Configure which authentication keys should have whitespace stripped. # These keys will have whitespace before and after removed upon creating or # modifying a user and when used to authenticate or find a user. Default is :email. - config.strip_whitespace_keys = [ :email ] + config.strip_whitespace_keys = [:email] # Tell if authentication through request.params is enabled. True by default. # config.params_authenticatable = true @@ -119,7 +119,7 @@ config.lock_strategy = :failed_attempts # Defines which key will be used when locking and unlocking an account - config.unlock_keys = [ :email ] + config.unlock_keys = [:email] # Defines which strategy will be used to unlock an account. # :email = Sends an unlock link to the user email @@ -138,7 +138,7 @@ # ==> Configuration for :recoverable # # Defines which key will be used when recovering the password for an account - config.reset_password_keys = [ :email ] + config.reset_password_keys = [:email] # Time interval you can reset your password with a reset password key. # Don't put a too small interval or your users won't have the time to diff --git a/config/initializers/rack_key_space.rb b/config/initializers/rack_key_space.rb index 1eb4421cb8..7c59c53fa2 100644 --- a/config/initializers/rack_key_space.rb +++ b/config/initializers/rack_key_space.rb @@ -1,3 +1,3 @@ -if Rack::Utils.respond_to?("key_space_limit=") +if Rack::Utils.respond_to?(:key_space_limit=) Rack::Utils.key_space_limit = 131072 end diff --git a/config/initializers/statesman.rb b/config/initializers/statesman.rb index 4c2ac22b55..852d061fb8 100644 --- a/config/initializers/statesman.rb +++ b/config/initializers/statesman.rb @@ -1,3 +1,3 @@ Statesman.configure do storage_adapter(Statesman::Adapters::ActiveRecord) -end \ No newline at end of file +end diff --git a/config/locales/en.yml b/config/locales/en.yml index d0f8bd6176..d8178e322e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -354,19 +354,19 @@ en: awarded: Awarded not_awarded: Not awarded state_short: - eligibility_in_progress: Eligibility in progress - application_in_progress: Application in progress - submitted: Submitted - withdrawn: Withdrawn/Ineligible - not_eligible: Not eligible - not_submitted: Not submitted - assessment_in_progress: Assessment in progress - disqualified: Disqualified -
        no additional
        financials - recommended: Recommended - reserved: Reserved - not_recommended: Not recommended - awarded: Awarded - not_awarded: Not awarded + eligibility_in_progress_html: Eligibility in progress + application_in_progress_html: Application in progress + submitted_html: Submitted + withdrawn_html: Withdrawn/Ineligible + not_eligible_html: Not eligible + not_submitted_html: Not submitted + assessment_in_progress_html: Assessment in progress + disqualified_html: Disqualified -
        no additional
        financials + recommended_html: Recommended + reserved_html: Reserved + not_recommended_html: Not recommended + awarded_html: Awarded + not_awarded_html: Not awarded confirmation_form: errors: activate_assessor: "You must select whether you want to activate this assessor or not." diff --git a/config/routes.rb b/config/routes.rb index 59ac2ca36c..24d182d4ea 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -41,34 +41,34 @@ get "/additional_information_and_contact" => redirect("https://www.gov.uk/kings-awards-for-enterprise/how-to-apply") get "/apply-for-kings-award-for-enterprise" => redirect("https://www.gov.uk/kings-awards-for-enterprise/how-to-apply") - get "/sign_up_complete" => "content_only#sign_up_complete", as: "sign_up_complete" - get "/privacy" => "content_only#privacy", as: "privacy" - get "/cookies" => "content_only#cookies", as: "cookies" - get "/accessibility-statement" => "content_only#accessibility_statement", as: "accessibility_statement" + get "/sign_up_complete" => "content_only#sign_up_complete", :as => "sign_up_complete" + get "/privacy" => "content_only#privacy", :as => "privacy" + get "/cookies" => "content_only#cookies", :as => "cookies" + get "/accessibility-statement" => "content_only#accessibility_statement", :as => "accessibility_statement" - get "/new_innovation_form" => "form#new_innovation_form", as: "new_innovation_form" - get "/new_international_trade_form" => "form#new_international_trade_form", as: "new_international_trade_form" - get "/new_sustainable_development_form" => "form#new_sustainable_development_form", as: "new_sustainable_development_form" - get "/new_social_mobility_form" => "form#new_social_mobility_form", as: "new_social_mobility_form" + get "/new_innovation_form" => "form#new_innovation_form", :as => "new_innovation_form" + get "/new_international_trade_form" => "form#new_international_trade_form", :as => "new_international_trade_form" + get "/new_sustainable_development_form" => "form#new_sustainable_development_form", :as => "new_sustainable_development_form" + get "/new_social_mobility_form" => "form#new_social_mobility_form", :as => "new_social_mobility_form" - get "/form/:id" => "form#edit_form", as: "edit_form" - post "/form/:id" => "form#save", as: "save_form" - post "/form/:id/attachments" => "form#add_attachment", as: "attachments" - get "/form/:id/confirmation" => "form#submit_confirm", as: "submit_confirm" - get "/dashboard" => "content_only#dashboard", as: "dashboard" + get "/form/:id" => "form#edit_form", :as => "edit_form" + post "/form/:id" => "form#save", :as => "save_form" + post "/form/:id/attachments" => "form#add_attachment", :as => "attachments" + get "/form/:id/confirmation" => "form#submit_confirm", :as => "submit_confirm" + get "/dashboard" => "content_only#dashboard", :as => "dashboard" - get "/apply_innovation_award" => "content_only#apply_innovation_award", as: "apply_innovation_award" - get "/award_info_innovation" => "content_only#award_info_innovation", as: "award_info_innovation" + get "/apply_innovation_award" => "content_only#apply_innovation_award", :as => "apply_innovation_award" + get "/award_info_innovation" => "content_only#award_info_innovation", :as => "award_info_innovation" - get "/apply_international_trade_award" => "content_only#apply_international_trade_award", as: "apply_international_trade_award" - get "/award_info_trade" => "content_only#award_info_trade", as: "award_info_trade" + get "/apply_international_trade_award" => "content_only#apply_international_trade_award", :as => "apply_international_trade_award" + get "/award_info_trade" => "content_only#award_info_trade", :as => "award_info_trade" - get "/apply_sustainable_development_award" => "content_only#apply_sustainable_development_award", as: "apply_sustainable_development_award" - get "/award_info_development" => "content_only#award_info_development", as: "award_info_development" - get "/apply_social_mobility_award" => "content_only#apply_social_mobility_award", as: "apply_social_mobility_award" - get "/award_info_mobility" => "content_only#award_info_mobility", as: "award_info_mobility" + get "/apply_sustainable_development_award" => "content_only#apply_sustainable_development_award", :as => "apply_sustainable_development_award" + get "/award_info_development" => "content_only#award_info_development", :as => "award_info_development" + get "/apply_social_mobility_award" => "content_only#apply_social_mobility_award", :as => "apply_social_mobility_award" + get "/award_info_mobility" => "content_only#award_info_mobility", :as => "award_info_mobility" - get "/award_winners_section" => "content_only#award_winners_section", as: "award_winners_section" + get "/award_winners_section" => "content_only#award_winners_section", :as => "award_winners_section" root to: QAE.production? ? redirect("https://www.gov.uk/kings-awards-for-enterprise/how-to-apply") : "content_only#dashboard" @@ -91,7 +91,7 @@ end resource :form_award_eligibility, only: [:show, :update] do - collection do + collection do get :warning get :result end diff --git a/config/spring.rb b/config/spring.rb index c9119b40c0..9fa7863f99 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,6 +1,6 @@ -%w( +%w[ .ruby-version .rbenv-vars tmp/restart.txt tmp/caching-dev.txt -).each { |path| Spring.watch(path) } +].each { |path| Spring.watch(path) } diff --git a/forms/appraisal_form.rb b/forms/appraisal_form.rb index 03f03195d4..03fee18eb2 100644 --- a/forms/appraisal_form.rb +++ b/forms/appraisal_form.rb @@ -5,63 +5,63 @@ class AppraisalForm SUPPORTED_YEARS = [2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025] RAG_OPTIONS_2016 = [ - %w(Red negative), - %w(Amber average), - %w(Green positive), + %w[Red negative], + %w[Amber average], + %w[Green positive], ] RAG_OPTIONS_2017 = [ - %w(Red negative), - %w(Amber average), - %w(Green positive), + %w[Red negative], + %w[Amber average], + %w[Green positive], ] RAG_OPTIONS_2018 = [ - %w(Red negative), - %w(Amber average), - %w(Green positive), + %w[Red negative], + %w[Amber average], + %w[Green positive], ] RAG_OPTIONS_2019 = [ - %w(Red negative), - %w(Amber average), - %w(Green positive), + %w[Red negative], + %w[Amber average], + %w[Green positive], ] RAG_OPTIONS_2020 = [ - %w(Red negative), - %w(Amber average), - %w(Green positive), + %w[Red negative], + %w[Amber average], + %w[Green positive], ] RAG_OPTIONS_2021 = [ - %w(Red negative), - %w(Amber average), - %w(Green positive), + %w[Red negative], + %w[Amber average], + %w[Green positive], ] RAG_OPTIONS_2022 = [ - %w(Red negative), - %w(Amber average), - %w(Green positive), + %w[Red negative], + %w[Amber average], + %w[Green positive], ] RAG_OPTIONS_2023 = [ - %w(Red negative), - %w(Amber average), - %w(Green positive), + %w[Red negative], + %w[Amber average], + %w[Green positive], ] RAG_OPTIONS_2024 = [ - %w(Red negative), - %w(Amber average), - %w(Green positive), + %w[Red negative], + %w[Amber average], + %w[Green positive], ] RAG_OPTIONS_2025 = [ - %w(Red negative), - %w(Amber average), - %w(Green positive), + %w[Red negative], + %w[Amber average], + %w[Green positive], ] CSR_RAG_OPTIONS_2016 = [ @@ -271,8 +271,7 @@ def self.rag_options_for(object, section) ) end - def self.non_rag_options_for(object, section) - end + def self.non_rag_options_for(object, section); end def self.strength_options_for(object, section) year = object.award_year.year @@ -1920,13 +1919,13 @@ def self.meths_for_award_type(form_answer, moderated = false) award_type = form_answer.award_type award_year = form_answer.award_year - if moderated - assessment_types = [:verdict] + assessment_types = if moderated + [:verdict] else - assessment_types = [:rag, :non_rag, :verdict] + [:rag, :non_rag, :verdict] end const_get("#{award_type.upcase}_#{award_year.year}").map do |k, obj| - methods = Array.new + methods = [] methods << Array(rate(k)) if (!moderated && (obj[:type] != :non_rag)) || (moderated && obj[:type] == :verdict) methods << desc(k) if assessment_types.include?(obj[:type]) methods @@ -1941,12 +1940,15 @@ def self.diff(form_answer, moderated = false) def self.all out = [] + assessment_types_with_description = %i[strengths rag non_rag verdict] + assessment_types = %i[rag non_rag verdict] + AppraisalForm::SUPPORTED_YEARS.map do |year| const_get("ALL_FORMS_#{year}").each do |form| form.each do |k, obj| - out << rate(k).to_sym if [:strengths, :rag, :non_rag, :verdict].include?(obj[:type]) + out << rate(k).to_sym if assessment_types_with_description.include?(obj[:type]) # strengths doesn't have description - out << desc(k).to_sym if [:rag, :non_rag, :verdict].include?(obj[:type]) + out << desc(k).to_sym if assessment_types.include?(obj[:type]) end end @@ -1978,7 +1980,7 @@ def self.rates(form_answer, type) class << self def group_labels_by(year, type) - %w(rag csr_rag strength verdict).map do |label_type| + %w[rag csr_rag strength verdict].map do |label_type| const_get("#{label_type.upcase}_OPTIONS_#{year}").detect do |el| el[1] == type end diff --git a/forms/award_years/v2018/social_mobility/social_mobility_step3.rb b/forms/award_years/v2018/social_mobility/social_mobility_step3.rb index 17c9a3e4fe..7bab2fcf9f 100644 --- a/forms/award_years/v2018/social_mobility/social_mobility_step3.rb +++ b/forms/award_years/v2018/social_mobility/social_mobility_step3.rb @@ -1,6 +1,3 @@ - -# -*- coding: utf-8 -*- - class AwardYears::V2018::QaeForms class << self def mobility_step3 diff --git a/forms/award_years/v2020/innovation/innovation_step1.rb b/forms/award_years/v2020/innovation/innovation_step1.rb index 6d819ef85f..6e5ba2e635 100644 --- a/forms/award_years/v2020/innovation/innovation_step1.rb +++ b/forms/award_years/v2020/innovation/innovation_step1.rb @@ -68,59 +68,56 @@ def innovation_step1 pdf_context_with_header_blocks [ [:bold, "About this section"], [:normal, %( - We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. - ) - ], + We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. + )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( - Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. - ) - ], + Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. + )], ] end diff --git a/forms/award_years/v2020/international_trade/international_trade_step1.rb b/forms/award_years/v2020/international_trade/international_trade_step1.rb index 64fc47c86d..678f2677cf 100644 --- a/forms/award_years/v2020/international_trade/international_trade_step1.rb +++ b/forms/award_years/v2020/international_trade/international_trade_step1.rb @@ -68,59 +68,56 @@ def trade_step1 pdf_context_with_header_blocks [ [:bold, "About this section"], [:normal, %( - We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. - ) - ], + We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. + )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( - Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. - ) - ], + Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. + )], ] end diff --git a/forms/award_years/v2020/social_mobility/social_mobility_step1.rb b/forms/award_years/v2020/social_mobility/social_mobility_step1.rb index 77683dc336..7a818349c9 100644 --- a/forms/award_years/v2020/social_mobility/social_mobility_step1.rb +++ b/forms/award_years/v2020/social_mobility/social_mobility_step1.rb @@ -68,59 +68,56 @@ def mobility_step1 pdf_context_with_header_blocks [ [:bold, "About this section"], [:normal, %( - We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. - ) - ], + We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. + )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( - Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. - ) - ], + Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. + )], ] end diff --git a/forms/award_years/v2020/sustainable_development/sustainable_development_step2.rb b/forms/award_years/v2020/sustainable_development/sustainable_development_step2.rb index db828bc743..47840e7163 100644 --- a/forms/award_years/v2020/sustainable_development/sustainable_development_step2.rb +++ b/forms/award_years/v2020/sustainable_development/sustainable_development_step2.rb @@ -210,9 +210,9 @@ def development_step2 classes "word-max-strict" ref "B 2" required - question_sub_title %{ + question_sub_title %( Briefly describe your core business and what factors or issues motivated your organisation to develop sustainable ways of doing business. - } + ) context %{

        Please include: @@ -269,9 +269,9 @@ def development_step2 classes "word-max-strict" ref "B 4" required - question_sub_title %{ + question_sub_title %( Please describe the driving force of your organisation’s sustainability. - } + ) context %{

        a) Who is ultimately responsible for the organisation’s sustainability interventions and their success? @@ -307,9 +307,9 @@ def development_step2 classes "word-max-strict" ref "B 5" required - question_sub_title %{ + question_sub_title %( Describe how your organisation’s culture fosters and supports sustainability. - } + ) context %{

        Please include: diff --git a/forms/award_years/v2021/innovation/innovation_step1.rb b/forms/award_years/v2021/innovation/innovation_step1.rb index 503e70b913..0a0fa2e3c7 100644 --- a/forms/award_years/v2021/innovation/innovation_step1.rb +++ b/forms/award_years/v2021/innovation/innovation_step1.rb @@ -68,59 +68,56 @@ def innovation_step1 pdf_context_with_header_blocks [ [:bold, "About this section"], [:normal, %( - We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. - ) - ], + We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. + )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( - Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. - ) - ], + Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. + )], ] end diff --git a/forms/award_years/v2021/international_trade/international_trade_step1.rb b/forms/award_years/v2021/international_trade/international_trade_step1.rb index ab43583280..0034e1aa78 100644 --- a/forms/award_years/v2021/international_trade/international_trade_step1.rb +++ b/forms/award_years/v2021/international_trade/international_trade_step1.rb @@ -68,59 +68,56 @@ def trade_step1 pdf_context_with_header_blocks [ [:bold, "About this section"], [:normal, %( - We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. - ) - ], + We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. + )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( - Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. - ) - ], + Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. + )], ] end diff --git a/forms/award_years/v2021/social_mobility/social_mobility_step1.rb b/forms/award_years/v2021/social_mobility/social_mobility_step1.rb index 7bd9a82a46..11ccb9596b 100644 --- a/forms/award_years/v2021/social_mobility/social_mobility_step1.rb +++ b/forms/award_years/v2021/social_mobility/social_mobility_step1.rb @@ -68,59 +68,56 @@ def mobility_step1 pdf_context_with_header_blocks [ [:bold, "About this section"], [:normal, %( - We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. - ) - ], + We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. + )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( - Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. - ) - ], + Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. + )], ] end diff --git a/forms/award_years/v2021/social_mobility/social_mobility_step2.rb b/forms/award_years/v2021/social_mobility/social_mobility_step2.rb index d4309475c7..b4bf3da366 100644 --- a/forms/award_years/v2021/social_mobility/social_mobility_step2.rb +++ b/forms/award_years/v2021/social_mobility/social_mobility_step2.rb @@ -543,9 +543,9 @@ def mobility_step2 textarea :initiative_community_society_impact, "Impact on community and society." do sub_ref "B 7a" required - question_sub_title %{ + question_sub_title %( What is the impact of your initiative on the local community and at a regional and national level; and how is this exemplary? - } + ) context %(

        For example, has your initiative led to there being more people from disadvantaged backgrounds being in employment in your area that is higher than the national average? Has it increased recognition and awareness of these initiatives as being a valid route to employment? Has it led to higher employment outcomes regionally?

        ) @@ -907,9 +907,9 @@ def mobility_step2 textarea :organisation_community_society_impact, "Impact on community and society." do sub_ref "B 7b" required - question_sub_title %{ + question_sub_title %( What is the impact of your organisation on the local community and at a regional and national level; and how is this exemplary? - } + ) context %(

        For example, has your organisation’s activities led to there being more people from disadvantaged backgrounds being in employment in your area that is higher than the national average? Has it increased recognition and awareness of these initiatives as being a valid route to employment? Has it led to higher employment outcomes regionally?

        ) diff --git a/forms/award_years/v2021/sustainable_development/sustainable_development_step2.rb b/forms/award_years/v2021/sustainable_development/sustainable_development_step2.rb index 8c283b25ac..788421b40d 100644 --- a/forms/award_years/v2021/sustainable_development/sustainable_development_step2.rb +++ b/forms/award_years/v2021/sustainable_development/sustainable_development_step2.rb @@ -210,9 +210,9 @@ def development_step2 classes "word-max-strict" ref "B 2" required - question_sub_title %{ + question_sub_title %( Briefly describe your core business and what factors or issues motivated your organisation to develop sustainable ways of doing business. - } + ) context %{

        Please include: @@ -241,9 +241,9 @@ def development_step2 classes "word-max-strict" ref "B 3" required - question_sub_title %{ + question_sub_title %( Please describe the impact. Focus on what impact your activities have achieved to date but include the longer-term outcomes as well. - } + ) context %{

        Wherever possible, use a balance of quantitative (for example, numbers and figures) and qualitative (for example, comments, feedback from people, main stakeholders) evidence to support your application. @@ -275,9 +275,9 @@ def development_step2 classes "word-max-strict" ref "B 4" required - question_sub_title %{ + question_sub_title %( Please describe the driving force of your organisation’s sustainability. - } + ) context %{

        a) Who is ultimately responsible for the organisation’s sustainability interventions and their success? @@ -313,9 +313,9 @@ def development_step2 classes "word-max-strict" ref "B 5" required - question_sub_title %{ + question_sub_title %( Describe how your organisation’s culture fosters and supports sustainability. - } + ) context %{

        Please include: diff --git a/forms/award_years/v2022/innovation/innovation_step1.rb b/forms/award_years/v2022/innovation/innovation_step1.rb index 7eb77a2892..46c25693ca 100644 --- a/forms/award_years/v2022/innovation/innovation_step1.rb +++ b/forms/award_years/v2022/innovation/innovation_step1.rb @@ -69,59 +69,56 @@ def innovation_step1 pdf_context_with_header_blocks [ [:bold, "About this section"], [:normal, %( - We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. - ) - ], + We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. + )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( - Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. - ) - ], + Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. + )], ] end diff --git a/forms/award_years/v2022/international_trade/international_trade_step1.rb b/forms/award_years/v2022/international_trade/international_trade_step1.rb index 0158cf7f33..146f7fad8f 100644 --- a/forms/award_years/v2022/international_trade/international_trade_step1.rb +++ b/forms/award_years/v2022/international_trade/international_trade_step1.rb @@ -69,59 +69,56 @@ def trade_step1 pdf_context_with_header_blocks [ [:bold, "About this section"], [:normal, %( - We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. - ) - ], + We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. + )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( - Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. - ) - ], + Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. + )], ] end diff --git a/forms/award_years/v2022/social_mobility/social_mobility_step1.rb b/forms/award_years/v2022/social_mobility/social_mobility_step1.rb index 5a01289c51..c74e985368 100644 --- a/forms/award_years/v2022/social_mobility/social_mobility_step1.rb +++ b/forms/award_years/v2022/social_mobility/social_mobility_step1.rb @@ -69,59 +69,56 @@ def mobility_step1 pdf_context_with_header_blocks [ [:bold, "About this section"], [:normal, %( - We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. - ) - ], + We need some essential information about your organisation so that we can undertake due diligence checks with various agencies if your application is shortlisted. + )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( - Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. - ) - ], + Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer them to a degree you can. + )], ] end diff --git a/forms/award_years/v2022/social_mobility/social_mobility_step2.rb b/forms/award_years/v2022/social_mobility/social_mobility_step2.rb index 97144c6d83..83cb88c827 100644 --- a/forms/award_years/v2022/social_mobility/social_mobility_step2.rb +++ b/forms/award_years/v2022/social_mobility/social_mobility_step2.rb @@ -255,14 +255,14 @@ def mobility_step2 y_headings [ ["careers_advice", "Careers advice"], - [ "fairer_recruitment", "Fairer recruitment"], - [ "skills_development", "Skills development"], - [ "work_placements", "Work placements"], - [ "early_careers", "Early careers"], - [ "job_opportunities", "Job opportunities"], - [ "advancement", "Advancement"], - [ "advocacy_and_leadership", "Advocacy and leadership"], - [ "other_activity_types", "Other activity types"], + ["fairer_recruitment", "Fairer recruitment"], + ["skills_development", "Skills development"], + ["work_placements", "Work placements"], + ["early_careers", "Early careers"], + ["job_opportunities", "Job opportunities"], + ["advancement", "Advancement"], + ["advocacy_and_leadership", "Advocacy and leadership"], + ["other_activity_types", "Other activity types"], ] conditional :application_category, "initiative" column_widths({ 1 => 16, 2 => 16, 3 => 16, 4 => 16, 5 => 16 }) @@ -419,15 +419,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -465,15 +465,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -511,15 +511,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -557,15 +557,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -695,9 +695,9 @@ def mobility_step2 textarea :initiative_community_society_impact, "Impact on community and society." do sub_ref "B 7a" required - question_sub_title %{ + question_sub_title %( What is the impact of your initiative on the local community and at a regional and national level; and how is this exemplary? - } + ) context %(

        For example, has your initiative led to there being more people from disadvantaged backgrounds being in employment in your area that is higher than the national average? Has it increased recognition and awareness of these initiatives as being a valid route to employment? Has it led to higher employment outcomes regionally?

        ) @@ -777,14 +777,14 @@ def mobility_step2 y_headings [ ["careers_advice", "Careers advice"], - [ "fairer_recruitment", "Fairer recruitment"], - [ "skills_development", "Skills development"], - [ "work_placements", "Work placements"], - [ "early_careers", "Early careers"], - [ "job_opportunities", "Job opportunities"], - [ "advancement", "Advancement"], - [ "advocacy_and_leadership", "Advocacy and leadership"], - [ "other_activity_types", "Other activity types"], + ["fairer_recruitment", "Fairer recruitment"], + ["skills_development", "Skills development"], + ["work_placements", "Work placements"], + ["early_careers", "Early careers"], + ["job_opportunities", "Job opportunities"], + ["advancement", "Advancement"], + ["advocacy_and_leadership", "Advocacy and leadership"], + ["other_activity_types", "Other activity types"], ] conditional :application_category, "organisation" column_widths({ 1 => 16, 2 => 16, 3 => 16, 4 => 16, 5 => 16 }) @@ -923,15 +923,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -969,15 +969,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -1015,15 +1015,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -1061,15 +1061,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -1180,9 +1180,9 @@ def mobility_step2 textarea :organisation_community_society_impact, "Impact on community and society." do sub_ref "B 7b" required - question_sub_title %{ + question_sub_title %( What is the impact of your organisation on the local community and at a regional and national level; and how is this exemplary? - } + ) context %(

        For example, has your organisation’s activities led to there being more people from disadvantaged backgrounds being in employment in your area that is higher than the national average? Has it increased recognition and awareness of these initiatives as being a valid route to employment? Has it led to higher employment outcomes regionally?

        ) diff --git a/forms/award_years/v2022/sustainable_development/sustainable_development_step2.rb b/forms/award_years/v2022/sustainable_development/sustainable_development_step2.rb index 1d85bfdb3d..30715b6cdb 100644 --- a/forms/award_years/v2022/sustainable_development/sustainable_development_step2.rb +++ b/forms/award_years/v2022/sustainable_development/sustainable_development_step2.rb @@ -224,9 +224,9 @@ def development_step2 classes "word-max-strict" ref "B 2" required - question_sub_title %{ + question_sub_title %( Briefly describe your core business and what factors or issues motivated your organisation to develop sustainable ways of doing business. - } + ) context %{

        Please include: @@ -255,9 +255,9 @@ def development_step2 classes "word-max-strict" ref "B 3" required - question_sub_title %{ + question_sub_title %( Please describe the impact. Focus on what impact your activities have achieved to date but include the longer-term outcomes as well. - } + ) context %{

        Wherever possible, use a balance of quantitative (for example, numbers and figures) and qualitative (for example, comments, feedback from people, main stakeholders) evidence to support your application. @@ -292,9 +292,9 @@ def development_step2 classes "word-max-strict" ref "B 4" required - question_sub_title %{ + question_sub_title %( Please describe the driving force of your organisation’s sustainability. - } + ) context %{

        a) Who is ultimately responsible for the organisation’s sustainability interventions and their success? @@ -330,9 +330,9 @@ def development_step2 classes "word-max-strict" ref "B 5" required - question_sub_title %{ + question_sub_title %( Describe how your organisation’s culture fosters and supports sustainability. - } + ) context %{

        Please include: diff --git a/forms/award_years/v2023/innovation/innovation_step1.rb b/forms/award_years/v2023/innovation/innovation_step1.rb index c3224daa16..d660f21454 100644 --- a/forms/award_years/v2023/innovation/innovation_step1.rb +++ b/forms/award_years/v2023/innovation/innovation_step1.rb @@ -83,63 +83,62 @@ def innovation_step1 pdf_context_with_header_blocks [ [:bold, "About section A"], [:normal, %( - The purpose of this section is to collect all vital information about your company. For example, your company's registration number and address. It is important for the details provided to be accurate as it cannot be changed later. This information will also be used to enable us to undertake due diligence checks with other government departments and agencies if your application is shortlisted. Please be aware due diligence checks inform the decision to confer an award. + The purpose of this section is to collect all vital information about your company. For example, your company's registration number and address. It is important for the details provided to be accurate as it cannot be changed later. This information will also be used to enable us to undertake due diligence checks with other government departments and agencies if your application is shortlisted. Please be aware due diligence checks inform the decision to confer an award. - Before you apply, please consider any issues that may prevent your application from receiving routine clearance as part of the due diligence we undertake with a number of Government Departments and Agencies. For example, this may be fines or penalties you have received or non-compliance with regulations. + Before you apply, please consider any issues that may prevent your application from receiving routine clearance as part of the due diligence we undertake with a number of Government Departments and Agencies. For example, this may be fines or penalties you have received or non-compliance with regulations. - Please check with your accountant and legal representatives if there are any outstanding or recent issues, as The Queen's Awards for Enterprise Office are unable to perform due diligence again once it has been completed. + Please check with your accountant and legal representatives if there are any outstanding or recent issues, as The Queen's Awards for Enterprise Office are unable to perform due diligence again once it has been completed. - Some examples of issues that may prevent your organisation from receiving clearance for The Queen's Awards for Enterprise Award: + Some examples of issues that may prevent your organisation from receiving clearance for The Queen's Awards for Enterprise Award: - \u2022 A failure to pay staff the minimum wage; - \u2022 An accident within the workplace, which has resulted in harm being caused to the environment or employees; - \u2022 A failure to fully comply with administrative filing requirements as stipulated by any Government Department or Agency. - )], + \u2022 A failure to pay staff the minimum wage; + \u2022 An accident within the workplace, which has resulted in harm being caused to the environment or employees; + \u2022 A failure to fully comply with administrative filing requirements as stipulated by any Government Department or Agency. + )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( The Queen's Awards for Enterprise is committed to acknowledging the efforts of organisations of all sizes. When assessing, we consider what is a reasonable performance, given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer all of the questions to the degree you can. diff --git a/forms/award_years/v2023/international_trade/international_trade_step1.rb b/forms/award_years/v2023/international_trade/international_trade_step1.rb index 56731d6583..cf13602397 100644 --- a/forms/award_years/v2023/international_trade/international_trade_step1.rb +++ b/forms/award_years/v2023/international_trade/international_trade_step1.rb @@ -97,54 +97,52 @@ def trade_step1 )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( - Queen's Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer all of the questions to a degree you can. - ) - ], + Queen's Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer all of the questions to a degree you can. + )], ] end diff --git a/forms/award_years/v2023/social_mobility/social_mobility_step1.rb b/forms/award_years/v2023/social_mobility/social_mobility_step1.rb index b2d96b6545..a502c92252 100644 --- a/forms/award_years/v2023/social_mobility/social_mobility_step1.rb +++ b/forms/award_years/v2023/social_mobility/social_mobility_step1.rb @@ -97,54 +97,52 @@ def mobility_step1 )], [:bold, "Government Departments and Agencies we undertake due diligence checks with:"], [:normal, %( - \u2022 Biotechnology & Biological Sciences Research Council - \u2022 Charity Commission - \u2022 Companies House - \u2022 Competition and Markets Authority - \u2022 Crown Commercial Service - \u2022 Department for Business, Energy and Industrial Strategy - \u2022 Department for Communities and Local Government - \u2022 Department for Culture Media & Sport - \u2022 Department for Education - \u2022 Department for Environment, Food & Rural Affairs - \u2022 Department for International Trade - \u2022 Department for Transport - \u2022 Department of Economic Development, Isle of Man - \u2022 Department for the Economy NI - \u2022 Department of Health - \u2022 Environment Agency - \u2022 Financial Conduct Authority - \u2022 Food Standards Agency - \u2022 Forestry Commission - \u2022 Guernsey Government - \u2022 Health and Safety Executive - \u2022 HM Courts & Tribunals Service - \u2022 HM Revenue & Customs - \u2022 Home Office - \u2022 Insolvency Service - \u2022 Intellectual Property Office - \u2022 Invest NI - \u2022 Jersey Government - \u2022 Ministry of Defence - \u2022 Ministry of Justice - \u2022 Medical Research Council Technology - \u2022 National Measurement Office - \u2022 Natural England - \u2022 Natural Environment Research Council - \u2022 Office of the Scottish Charity Regulator - \u2022 Scottish Government - \u2022 Scottish Environment Protection Agency - \u2022 Scottish Funding Council - \u2022 Serious Fraud Office - \u2022 UK Export Finance - \u2022 Wales Government - ) - ], + \u2022 Biotechnology & Biological Sciences Research Council + \u2022 Charity Commission + \u2022 Companies House + \u2022 Competition and Markets Authority + \u2022 Crown Commercial Service + \u2022 Department for Business, Energy and Industrial Strategy + \u2022 Department for Communities and Local Government + \u2022 Department for Culture Media & Sport + \u2022 Department for Education + \u2022 Department for Environment, Food & Rural Affairs + \u2022 Department for International Trade + \u2022 Department for Transport + \u2022 Department of Economic Development, Isle of Man + \u2022 Department for the Economy NI + \u2022 Department of Health + \u2022 Environment Agency + \u2022 Financial Conduct Authority + \u2022 Food Standards Agency + \u2022 Forestry Commission + \u2022 Guernsey Government + \u2022 Health and Safety Executive + \u2022 HM Courts & Tribunals Service + \u2022 HM Revenue & Customs + \u2022 Home Office + \u2022 Insolvency Service + \u2022 Intellectual Property Office + \u2022 Invest NI + \u2022 Jersey Government + \u2022 Ministry of Defence + \u2022 Ministry of Justice + \u2022 Medical Research Council Technology + \u2022 National Measurement Office + \u2022 Natural England + \u2022 Natural Environment Research Council + \u2022 Office of the Scottish Charity Regulator + \u2022 Scottish Government + \u2022 Scottish Environment Protection Agency + \u2022 Scottish Funding Council + \u2022 Serious Fraud Office + \u2022 UK Export Finance + \u2022 Wales Government + )], [:bold, "Small organisations"], [:normal, %( - Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer all of the questions to a degree you can. - ) - ], + Queen’s Awards for Enterprise is committed to acknowledging efforts of organisations of all sizes. When assessing we consider what is reasonable performance given the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer all of the questions to a degree you can. + )], ] end diff --git a/forms/award_years/v2023/social_mobility/social_mobility_step2.rb b/forms/award_years/v2023/social_mobility/social_mobility_step2.rb index 62aa42d1b2..6af1a4788b 100644 --- a/forms/award_years/v2023/social_mobility/social_mobility_step2.rb +++ b/forms/award_years/v2023/social_mobility/social_mobility_step2.rb @@ -267,14 +267,14 @@ def mobility_step2 y_headings [ ["careers_advice", "Careers advice"], - [ "fairer_recruitment", "Fairer recruitment"], - [ "skills_development", "Skills development"], - [ "work_placements", "Work placements"], - [ "early_careers", "Early careers"], - [ "job_opportunities", "Job opportunities"], - [ "advancement", "Advancement"], - [ "advocacy_and_leadership", "Advocacy and leadership"], - [ "other_activity_types", "Other activity types"], + ["fairer_recruitment", "Fairer recruitment"], + ["skills_development", "Skills development"], + ["work_placements", "Work placements"], + ["early_careers", "Early careers"], + ["job_opportunities", "Job opportunities"], + ["advancement", "Advancement"], + ["advocacy_and_leadership", "Advocacy and leadership"], + ["other_activity_types", "Other activity types"], ] conditional :application_category, "initiative" column_widths({ 1 => 16, 2 => 16, 3 => 16, 4 => 16, 5 => 16 }) @@ -431,15 +431,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -477,15 +477,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -523,15 +523,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -569,15 +569,15 @@ def mobility_step2 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower than average attainment or if there are children in the person’s current household who attend school with lower than average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -707,9 +707,9 @@ def mobility_step2 textarea :initiative_community_society_impact, "Impact on community and society." do sub_ref "B 7a" required - question_sub_title %{ + question_sub_title %( What is the impact of your initiative on the local community and at a regional and national level; and how is this exemplary? - } + ) context %(

        For example, has your initiative led to there being more people from disadvantaged backgrounds being in employment in your area that is higher than the national average? Has it increased recognition and awareness of these initiatives as being a valid route to employment? Has it led to higher employment outcomes regionally?

        ) diff --git a/forms/award_years/v2023/sustainable_development/sustainable_development_step2.rb b/forms/award_years/v2023/sustainable_development/sustainable_development_step2.rb index 79f096c4fb..1c04efe94b 100644 --- a/forms/award_years/v2023/sustainable_development/sustainable_development_step2.rb +++ b/forms/award_years/v2023/sustainable_development/sustainable_development_step2.rb @@ -224,9 +224,9 @@ def development_step2 classes "word-max-strict" ref "B 2" required - question_sub_title %{ + question_sub_title %( Briefly describe your core business and what factors or issues motivated your organisation to develop sustainable ways of doing business. - } + ) context %{

        Please include: @@ -255,9 +255,9 @@ def development_step2 classes "word-max-strict" ref "B 3" required - question_sub_title %{ + question_sub_title %( Please describe the impact. Focus on what impact your activities have achieved to date but include the longer-term outcomes as well. - } + ) context %{

        Wherever possible, use a balance of quantitative (for example, numbers and figures) and qualitative (for example, comments, feedback from people, main stakeholders) evidence to support your application. @@ -292,9 +292,9 @@ def development_step2 classes "word-max-strict" ref "B 4" required - question_sub_title %{ + question_sub_title %( Please describe the driving force of your organisation’s sustainability. - } + ) context %{

        a) Who is ultimately responsible for the organisation’s sustainability interventions and their success? @@ -330,9 +330,9 @@ def development_step2 classes "word-max-strict" ref "B 5" required - question_sub_title %{ + question_sub_title %( Describe how your organisation’s culture fosters and supports sustainability. - } + ) context %{

        Please include: diff --git a/forms/award_years/v2024/innovation/innovation_step1.rb b/forms/award_years/v2024/innovation/innovation_step1.rb index 167e05b4c5..b09c104c10 100644 --- a/forms/award_years/v2024/innovation/innovation_step1.rb +++ b/forms/award_years/v2024/innovation/innovation_step1.rb @@ -29,7 +29,7 @@ def innovation_step1 header :due_diligence_header, "Organisation's conduct & due diligence checks" do ref "A 2" - context %{ + context %(

        Please be aware that due diligence checks inform the decision to grant an award.

        Before you apply, please consider any issues that may prevent your application from receiving routine clearance as part of the due diligence process that we undertake with a number of Government Departments and Agencies.

        Therefore, please check with your accountant and legal representatives if there are any outstanding or recent issues, as The King's Awards for Enterprise Office starts the due diligence process immediately after the submission and is unable to repeat the due diligence process.

        @@ -96,7 +96,7 @@ def innovation_step1
      - } + ) pdf_context_with_header_blocks [ [:normal, %( Please be aware that due diligence checks inform the decision to grant an award. diff --git a/forms/award_years/v2024/innovation/innovation_step2.rb b/forms/award_years/v2024/innovation/innovation_step2.rb index 26090fac2f..dac71b1d33 100644 --- a/forms/award_years/v2024/innovation/innovation_step2.rb +++ b/forms/award_years/v2024/innovation/innovation_step2.rb @@ -67,12 +67,12 @@ def innovation_step2 text :other_organisation_type, "" do classes "text-words-max" - context %{ + context %(

      Please specify

      - } - pdf_context %{ + ) + pdf_context %(

      Please specify if selected Other

      - } + ) conditional :organisation_type, :other text_words_max 50 end diff --git a/forms/award_years/v2024/innovation/innovation_step3.rb b/forms/award_years/v2024/innovation/innovation_step3.rb index f62da2f0f1..52cf35a527 100644 --- a/forms/award_years/v2024/innovation/innovation_step3.rb +++ b/forms/award_years/v2024/innovation/innovation_step3.rb @@ -265,10 +265,10 @@ def innovation_step3 header :innovation_timeline_header, "Innovation development" do ref "C 2" linkable true - context %{ + context %(

      The questions in subsection C2 help the assessors understand the development of your innovation. - } + ) end year :innovation_developing_started_year, "Please provide the year when your innovation started to be developed." do @@ -447,7 +447,7 @@ def innovation_step3 header :innovation_value_add_header, "Innovation value-add" do ref "C 3" linkable true - context %{ + context %(

      The questions in subsection C3 give you the opportunity to describe how your innovation adds value beyond the direct financial impact.

      @@ -457,7 +457,7 @@ def innovation_step3

      You can add testimonials using quotation marks within the answer. Alternatively, if you have them in a letter or email format, consider joining them into one PDF and uploading it in section F - if you do so, please reference it in your answer.

      - } + ) pdf_context_with_header_blocks [ [:normal, %( The questions in subsection C3 give you the opportunity to describe how your innovation adds value beyond the direct financial impact. diff --git a/forms/award_years/v2024/international_trade/international_trade_step1.rb b/forms/award_years/v2024/international_trade/international_trade_step1.rb index dadd5b5a90..fc7a801765 100644 --- a/forms/award_years/v2024/international_trade/international_trade_step1.rb +++ b/forms/award_years/v2024/international_trade/international_trade_step1.rb @@ -31,7 +31,7 @@ def trade_step1 header :due_diligence_header, "Organisation's conduct & due diligence checks" do ref "A 2" - context %{ + context %(

      Please be aware that due diligence checks inform the decision to grant an award.

      Before you apply, please consider any issues that may prevent your application from receiving routine clearance as part of the due diligence process that we undertake with a number of Government Departments and Agencies.

      Therefore, please check with your accountant and legal representatives if there are any outstanding or recent issues, as The King's Awards for Enterprise Office starts the due diligence process immediately after the submission and is unable to repeat the due diligence process.

      @@ -98,7 +98,7 @@ def trade_step1
    - } + ) pdf_context_with_header_blocks [ [:normal, %( Please be aware that due diligence checks inform the decision to grant an award. diff --git a/forms/award_years/v2024/international_trade/international_trade_step2.rb b/forms/award_years/v2024/international_trade/international_trade_step2.rb index 089f9d3f50..95d59b494f 100644 --- a/forms/award_years/v2024/international_trade/international_trade_step2.rb +++ b/forms/award_years/v2024/international_trade/international_trade_step2.rb @@ -62,12 +62,12 @@ def trade_step2 text :other_organisation_type, "" do classes "text-words-max" - context %{ + context %(

    Please specify

    - } - pdf_context %{ + ) + pdf_context %(

    Please specify if selected Other

    - } + ) conditional :organisation_type, :other text_words_max 50 end diff --git a/forms/award_years/v2024/social_mobility/social_mobility_step1.rb b/forms/award_years/v2024/social_mobility/social_mobility_step1.rb index af8e125860..e6402e8762 100644 --- a/forms/award_years/v2024/social_mobility/social_mobility_step1.rb +++ b/forms/award_years/v2024/social_mobility/social_mobility_step1.rb @@ -29,7 +29,7 @@ def mobility_step1 header :due_diligence_header, "Organisation's conduct & due diligence checks" do ref "A 2" - context %{ + context %(

    Please be aware that due diligence checks inform the decision to grant an award.

    Before you apply, please consider any issues that may prevent your application from receiving routine clearance as part of the due diligence process that we undertake with a number of Government Departments and Agencies.

    Therefore, please check with your accountant and legal representatives if there are any outstanding or recent issues, as The King's Awards for Enterprise Office starts the due diligence process immediately after the submission and is unable to repeat the due diligence process.

    @@ -96,7 +96,7 @@ def mobility_step1
- } + ) pdf_context_with_header_blocks [ [:normal, %( Please be aware that due diligence checks inform the decision to grant an award. diff --git a/forms/award_years/v2024/social_mobility/social_mobility_step3.rb b/forms/award_years/v2024/social_mobility/social_mobility_step3.rb index bfb87209df..24f5e3049d 100644 --- a/forms/award_years/v2024/social_mobility/social_mobility_step3.rb +++ b/forms/award_years/v2024/social_mobility/social_mobility_step3.rb @@ -584,7 +584,7 @@ def mobility_step3 ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower-than-average attainment or if there are children in the person’s current household who attend school with lower-than-average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was a secondary school"], @@ -636,7 +636,7 @@ def mobility_step3 ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower-than-average attainment or if there are children in the person’s current household who attend school with lower-than-average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was a secondary school"], @@ -678,15 +678,15 @@ def mobility_step3 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower-than-average attainment or if there are children in the person’s current household who attend school with lower-than-average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was a secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -720,15 +720,15 @@ def mobility_step3 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower-than-average attainment or if there are children in the person’s current household who attend school with lower-than-average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was a secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], diff --git a/forms/award_years/v2024/sustainable_development/sustainable_development_step1.rb b/forms/award_years/v2024/sustainable_development/sustainable_development_step1.rb index 0288895d2c..897b766630 100644 --- a/forms/award_years/v2024/sustainable_development/sustainable_development_step1.rb +++ b/forms/award_years/v2024/sustainable_development/sustainable_development_step1.rb @@ -29,7 +29,7 @@ def development_step1 header :due_diligence_checks, "Organisation's conduct & due diligence checks" do ref "A 2" - context %{ + context %(

Please be aware that due diligence checks inform the decision to grant an award.

Before you apply, please consider any issues that may prevent your application from receiving routine clearance as part of the due diligence process that we undertake with a number of Government Departments and Agencies.

Therefore, please check with your accountant and legal representatives if there are any outstanding or recent issues, as The King's Awards for Enterprise Office starts the due diligence process immediately after the submission and is unable to repeat the due diligence process.

@@ -96,7 +96,7 @@ def development_step1 - } + ) pdf_context_with_header_blocks [ [:normal, %( Please be aware that due diligence checks inform the decision to grant an award. diff --git a/forms/award_years/v2024/sustainable_development/sustainable_development_step2.rb b/forms/award_years/v2024/sustainable_development/sustainable_development_step2.rb index d2b6d5fff2..6c386d30b8 100644 --- a/forms/award_years/v2024/sustainable_development/sustainable_development_step2.rb +++ b/forms/award_years/v2024/sustainable_development/sustainable_development_step2.rb @@ -62,12 +62,12 @@ def development_step2 text :other_organisation_type, "" do classes "text-words-max" - context %{ + context %(

Please specify

- } - pdf_context %{ + ) + pdf_context %(

Please specify if selected Other

- } + ) conditional :organisation_type, :other text_words_max 50 end @@ -114,10 +114,10 @@ def development_step2 classes "sub-question text-words-max" sub_ref "B 4.1" required - context %{ + context %(

Usually, this is the same name as your organisation's full legal name.

However, you may choose to include the name you are trading as or a brand name. If you do so, you may be asked to provide evidence that the legal entity uses the trading name or owns the brand. Also, the evidence in the application form must be clearly linked to the provided trading name or brand.

- } + ) text_words_max 50 end @@ -199,9 +199,9 @@ def development_step2 textarea :social_media_links, "Links to social media accounts, for example, LinkedIn, Twitter, Instagram (optional)." do classes "sub-question" sub_ref "B 8.1" - context %{ + context %(

Please note, when evaluating your application, the assessors may check your organisation's online presence.

- } + ) end sic_code_dropdown :sic_code, "The Standard Industrial Classification (SIC) code." do diff --git a/forms/award_years/v2024/sustainable_development/sustainable_development_step3.rb b/forms/award_years/v2024/sustainable_development/sustainable_development_step3.rb index 2c7693d2d6..1e65ee1e4d 100644 --- a/forms/award_years/v2024/sustainable_development/sustainable_development_step3.rb +++ b/forms/award_years/v2024/sustainable_development/sustainable_development_step3.rb @@ -23,7 +23,7 @@ def development_step3
  • Our IT Disposal and Gifting service transforms waste for the benefit of people and the planet.
  • ) - pdf_context %{ + pdf_context %(

    If your application is successful, this description will appear in the London Gazette.

    Some good examples from previously shortlisted organisations:

    @@ -31,7 +31,7 @@ def development_step3 \u2022 Manufacturer of environmentally friendly cleaning products since 2007. Loved by professionals, approved by the planet. \u2022 Our IT Disposal and Gifting service transforms waste for the benefit of people and the planet.

    - } + ) rows 2 words_max 15 end @@ -49,11 +49,11 @@ def development_step3 header :sustainable_development_core_business_header, "Core business and your approach to sustainability" do ref "C 2" - context %{ + context %(

    In questions C2.1 to C2.7, describe your core business and what factors or issues motivated your organisation to develop sustainable ways of doing business.

    - } + ) end textarea :briefly_describe_your_core_business, "A brief summary of your organisation." do @@ -136,22 +136,22 @@ def development_step3 classes "word-max-strict sub-question" ref "C 2.7" required - context %{ + context %(

    For example, how are you changing your business to respond to future sustainability challenges in your business or sector?

    - } + ) rows 2 words_max 200 end header :leadership_and_management, "Leadership and management" do ref "C 3" - context %{ + context %(

    In questions C3.1 to C3.8, describe the driving force of your organisation's sustainability.

    - } + ) end textarea :describe_the_driving_force_of_your_organisation, "Who is ultimately responsible for the organisation's sustainability interventions and their success?" do @@ -166,9 +166,9 @@ def development_step3 classes "word-max-strict sub-question" ref "C 3.2" required - context %{ + context %(

    You may include flow charts to make it easier for assessors to understand how your programme is managed in section E of this form.

    - } + ) rows 2 words_max 200 end @@ -185,11 +185,11 @@ def development_step3 classes "word-max-strict sub-question" ref "C 3.4" required - context %{ + context %(

    For example, businesses in your supply chain, stakeholders, customers, local communities or even competitors.

    - } + ) rows 4 words_max 400 end @@ -206,11 +206,11 @@ def development_step3 classes "word-max-strict sub-question" ref "C 3.6" required - context %{ + context %(

    Describe your organisation's diversity and inclusion strategy and any policies. Provide evidence that these are effective.

    - } + ) rows 5 words_max 500 end @@ -225,11 +225,11 @@ def development_step3 header :culture_and_values, "Culture and values regarding sustainability" do ref "C 4" - context %{ + context %(

    In questions C4.1 to C4.4, describe how your organisation's culture fosters and supports sustainability.

    - } + ) end textarea :culture_and_values_regarding_sustainability, "How is sustainability embedded in your organisation's culture and values?" do @@ -269,25 +269,25 @@ def development_step3 header :sustainable_development_interventions_header, "Your sustainable development interventions in detail" do ref "C 5" - context %{ + context %(

    In questions C5.1 to C5.4, describe your interventions using the UN SDGs to structure your answer to each section, but only where relevant.

    You need to summarise your interventions for sustainable development and demonstrate a sustainable strategy across the business.

    - } + ) end textarea :describe_your_interventions_using_un, "Which UN SDGs are your efforts targeted towards?" do required classes "word-max-strict sub-question" sub_ref "C 5.1" - context %{ + context %(

    Please note, you do not need to address each UN SDG, only the ones that are most applicable to your sustainable development interventions.

    - } + ) rows 2 words_max 200 end @@ -296,11 +296,11 @@ def development_step3 classes "word-max-strict sub-question" ref "C 5.2" required - context %{ + context %(

    For example, this could be, to regenerate, to restore, to reduce emissions or to promote good health and wellbeing within the local community and society in general.

    - } + ) rows 2 words_max 200 end @@ -322,7 +322,7 @@ def development_step3 classes "word-max-strict sub-question" ref "C 5.4" required - context %{ + context %(

    For example, they may be exemplary as a result of:

    @@ -335,7 +335,7 @@ def development_step3

    If you have any external documents or other media to support your answer, please add these in Section E and reference them by their names in your answers.

    - } + ) pdf_context %( For example, it may be exemplary as a result of: @@ -385,11 +385,11 @@ def development_step3 classes "word-max-strict sub-question" ref "C 6.3" required - context %{ + context %(

    Describe the impact on your organisation, workforce, customers, stakeholders, supply chain, communities, regions or others, such as overseas clients or markets and how you are part of the circular economy.

    - } + ) rows 3 words_max 300 end @@ -398,14 +398,14 @@ def development_step3 classes "word-max-strict sub-question" ref "C 6.4" required - context %{ + context %(

    Explain and, if possible, provide evidence or research on how you have compared your organisation to others in your sector, including a web link if available.

    Explain how you know that your sustainability performance is exemplary compared with the sector in general.

    - } + ) rows 3 words_max 300 end @@ -434,11 +434,11 @@ def development_step3 textarea :governance, "Additional information about your Environmental, Social, and Corporate Governance (ESG). (optional)" do classes "word-max-strict sub-question" ref "C 6.7" - context %{ + context %(

    Please highlight your responsible business conduct and its impact within your organisation, supply chain and the wider community, if not already covered.

    - } + ) rows 2 words_max 200 end diff --git a/forms/award_years/v2025/innovation/innovation_step2.rb b/forms/award_years/v2025/innovation/innovation_step2.rb index e89be2f0cd..0c7c6a44da 100644 --- a/forms/award_years/v2025/innovation/innovation_step2.rb +++ b/forms/award_years/v2025/innovation/innovation_step2.rb @@ -67,12 +67,12 @@ def innovation_step2 text :other_organisation_type, "" do classes "text-words-max" - context %{ + context %(

    Please specify

    - } - pdf_context %{ + ) + pdf_context %(

    Please specify if selected Other

    - } + ) conditional :organisation_type, :other text_words_max 50 end diff --git a/forms/award_years/v2025/innovation/innovation_step3.rb b/forms/award_years/v2025/innovation/innovation_step3.rb index 5d6a60950d..6fa436ae33 100644 --- a/forms/award_years/v2025/innovation/innovation_step3.rb +++ b/forms/award_years/v2025/innovation/innovation_step3.rb @@ -245,10 +245,10 @@ def innovation_step3 header :innovation_timeline_header, "Innovation development" do ref "C 2" linkable true - context %{ + context %(

    The questions in subsection C2 help the assessors understand the development of your innovation. - } + ) end year :innovation_developing_started_year, "Please provide the year when your innovation started to be developed." do @@ -257,7 +257,7 @@ def innovation_step3 sub_ref "C 2.1" required min 2000 - max -> { Time.now.year } + max -> { Time.current.year } end date :innovation_was_launched_in_the_market, "Select the date when your innovation was launched in the market." do @@ -427,7 +427,7 @@ def innovation_step3 header :innovation_value_add_header, "Innovation value-add" do ref "C 3" linkable true - context %{ + context %(

    The questions in subsection C3 give you the opportunity to describe how your innovation adds value beyond the direct financial impact.

    @@ -437,7 +437,7 @@ def innovation_step3

    You can add testimonials using quotation marks within the answer. Alternatively, if you have them in a letter or email format, consider joining them into one PDF and uploading it in section F - if you do so, please reference it in your answer.

    - } + ) pdf_context_with_header_blocks [ [:normal, %( The questions in subsection C3 give you the opportunity to describe how your innovation adds value beyond the direct financial impact. diff --git a/forms/award_years/v2025/international_trade/international_trade_step2.rb b/forms/award_years/v2025/international_trade/international_trade_step2.rb index 6e809f178d..6f159eaddf 100644 --- a/forms/award_years/v2025/international_trade/international_trade_step2.rb +++ b/forms/award_years/v2025/international_trade/international_trade_step2.rb @@ -62,12 +62,12 @@ def trade_step2 text :other_organisation_type, "" do classes "text-words-max" - context %{ + context %(

    Please specify

    - } - pdf_context %{ + ) + pdf_context %(

    Please specify if selected Other

    - } + ) conditional :organisation_type, :other text_words_max 50 end diff --git a/forms/award_years/v2025/international_trade/international_trade_step4.rb b/forms/award_years/v2025/international_trade/international_trade_step4.rb index d8631e838d..d2177b2b0b 100644 --- a/forms/award_years/v2025/international_trade/international_trade_step4.rb +++ b/forms/award_years/v2025/international_trade/international_trade_step4.rb @@ -217,9 +217,9 @@ def trade_step4 title: "You do not meet the eligibility criteria for this award.", message: ->(resource) do value = resource.respond_to?(:fields_count) ? resource.fields_count : resource - (value == 3) ? %Q{ + (value == 3) ? %( Your total overseas sales are showing dips during the period of your entry. Therefore, you do not meet eligibility for the award and cannot proceed. - } : %Q{ + ) : %{ Your total overseas sales are showing dips during the period of our entry. If you had a steep year-on-year growth (without dips) over the three most recent financial years, consider applying on an "Outstanding Short-Term Growth" basis by changing your answer in D1. If you had dips in total overseas sales during that period, you do not meet eligibility for the award and cannot proceed. } end diff --git a/forms/award_years/v2025/social_mobility/social_mobility_step3.rb b/forms/award_years/v2025/social_mobility/social_mobility_step3.rb index 08fef8ac3c..ea31762c0d 100644 --- a/forms/award_years/v2025/social_mobility/social_mobility_step3.rb +++ b/forms/award_years/v2025/social_mobility/social_mobility_step3.rb @@ -604,7 +604,7 @@ def mobility_step3 ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower-than-average attainment or if there are children in the person’s current household who attend school with lower-than-average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was a secondary school"], @@ -646,7 +646,7 @@ def mobility_step3 ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower-than-average attainment or if there are children in the person’s current household who attend school with lower-than-average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was a secondary school"], @@ -703,7 +703,7 @@ def mobility_step3 ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower-than-average attainment or if there are children in the person’s current household who attend school with lower-than-average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was a secondary school"], @@ -750,15 +750,15 @@ def mobility_step3 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower-than-average attainment or if there are children in the person’s current household who attend school with lower-than-average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was a secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], @@ -797,15 +797,15 @@ def mobility_step3 y_headings [ ["ethnic", "Black, Asian and minority ethnic people, including Gypsy and Traveller people"], - [ "refugees", "Asylum seekers and refugees or children of refugees"], - [ "young_language", "Young people (over 16 years old) with English as a second language"], - [ "living_situation", "Long-term unemployed or people who grew up in workless households"], + ["refugees", "Asylum seekers and refugees or children of refugees"], + ["young_language", "Young people (over 16 years old) with English as a second language"], + ["living_situation", "Long-term unemployed or people who grew up in workless households"], ["people_low_incomes", "People on low incomes"], - [ "lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], - [ "free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], - [ "homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], - [ "care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children\'s homes, or other arrangements outside the immediate or extended family"], - [ "young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], + ["lone_parents", "Lone parents - single adult heads of a household who are responsible for at least one dependent child, who normally lives with them"], + ["free_meals", "People who received free school meals or if there are children in the person’s current household who receive free school meals"], + ["homeless_insecurely_housed", "Homeless and insecurely housed, including those at risk of becoming homeless and those in overcrowded or substandard housing"], + ["care_leavers", "Care leavers - people who spent time in care before the age of 18. Such care could be in foster care, children's homes, or other arrangements outside the immediate or extended family"], + ["young_education", "Young people (over 16 years old) who are not in education, employment or training (NEET) or are at risk of that"], ["school_attainment", "People who attended schools with lower-than-average attainment or if there are children in the person’s current household who attend school with lower-than-average attainment"], ["parents_qualification", "People whose parents’ or guardians’ highest level of qualifications by the time the person was 18 was a secondary school"], ["mental_disability", "People with a physical or mental disability that has a substantial and adverse long- term effect on a person’s ability to do normal daily activities"], diff --git a/forms/award_years/v2025/sustainable_development/sustainable_development_step2.rb b/forms/award_years/v2025/sustainable_development/sustainable_development_step2.rb index 606c49d640..058fbacbff 100644 --- a/forms/award_years/v2025/sustainable_development/sustainable_development_step2.rb +++ b/forms/award_years/v2025/sustainable_development/sustainable_development_step2.rb @@ -62,12 +62,12 @@ def development_step2 text :other_organisation_type, "" do classes "text-words-max" - context %{ + context %(

    Please specify

    - } - pdf_context %{ + ) + pdf_context %(

    Please specify if selected Other

    - } + ) conditional :organisation_type, :other text_words_max 50 end @@ -207,9 +207,9 @@ def development_step2 textarea :social_media_links, "Links to social media accounts, for example, LinkedIn, Twitter, Instagram (optional)." do classes "sub-question" sub_ref "B 8.1" - context %{ + context %(

    Please note, when evaluating your application, the assessors may check your organisation's online presence.

    - } + ) end sic_code_dropdown :sic_code, "The Standard Industrial Classification (SIC) code." do diff --git a/forms/award_years/v2025/sustainable_development/sustainable_development_step3.rb b/forms/award_years/v2025/sustainable_development/sustainable_development_step3.rb index 5b25378ce1..1f8399bb96 100644 --- a/forms/award_years/v2025/sustainable_development/sustainable_development_step3.rb +++ b/forms/award_years/v2025/sustainable_development/sustainable_development_step3.rb @@ -23,7 +23,7 @@ def development_step3
  • Our IT Disposal and Gifting service transforms waste for the benefit of people and the planet.
  • ) - pdf_context %{ + pdf_context %(

    If your application is successful, this description will appear in the London Gazette.

    Some good examples from previously shortlisted organisations:

    @@ -31,7 +31,7 @@ def development_step3 \u2022 Manufacturer of environmentally friendly cleaning products since 2007. Loved by professionals, approved by the planet. \u2022 Our IT Disposal and Gifting service transforms waste for the benefit of people and the planet.

    - } + ) rows 2 words_max 15 end @@ -49,11 +49,11 @@ def development_step3 header :sustainable_development_core_business_header, "Core business and your approach to sustainability" do ref "C 2" - context %{ + context %(

    In questions C2.1 to C2.7, describe your core business and what factors or issues motivated your organisation to develop sustainable ways of doing business.

    - } + ) end textarea :briefly_describe_your_core_business, "A brief summary of your organisation." do @@ -157,22 +157,22 @@ def development_step3 classes "word-max-strict sub-question" ref "C 2.7" required - context %{ + context %(

    For example, how are you changing your business to respond to future sustainability challenges in your business or sector?

    - } + ) rows 2 words_max 200 end header :leadership_and_management, "Leadership and management" do ref "C 3" - context %{ + context %(

    In questions C3.1 to C3.8, describe the driving force of your organisation's sustainability.

    - } + ) end textarea :describe_the_driving_force_of_your_organisation, "Who is ultimately responsible for the organisation's sustainability interventions and their success?" do @@ -187,9 +187,9 @@ def development_step3 classes "word-max-strict sub-question" ref "C 3.2" required - context %{ + context %(

    You may include flow charts to make it easier for assessors to understand how your programme is managed in section E of this form.

    - } + ) rows 2 words_max 200 end @@ -206,11 +206,11 @@ def development_step3 classes "word-max-strict sub-question" ref "C 3.4" required - context %{ + context %(

    For example, businesses in your supply chain, stakeholders, customers, local communities or even competitors.

    - } + ) rows 4 words_max 400 end @@ -227,11 +227,11 @@ def development_step3 classes "word-max-strict sub-question" ref "C 3.6" required - context %{ + context %(

    Describe your organisation's diversity and inclusion strategy and any policies, and provide evidence that they are effective. Include data on how employees with protected characteristics are represented in your workforce.

    - } + ) rows 5 words_max 500 end @@ -246,11 +246,11 @@ def development_step3 header :culture_and_values, "Culture and values regarding sustainability" do ref "C 4" - context %{ + context %(

    In questions C4.1 to C4.4, describe how your organisation's culture fosters and supports sustainability.

    - } + ) end textarea :culture_and_values_regarding_sustainability, "How is sustainability embedded in your organisation's culture and values?" do @@ -290,25 +290,25 @@ def development_step3 header :sustainable_development_interventions_header, "Your sustainable development interventions in detail" do ref "C 5" - context %{ + context %(

    In questions C5.1 to C5.4, describe your interventions using the UN SDGs to structure your answer to each section, but only where relevant.

    You need to summarise your interventions for sustainable development and demonstrate a sustainable strategy across the business.

    - } + ) end textarea :describe_your_interventions_using_un, "Which UN SDGs are your efforts targeted towards?" do required classes "word-max-strict sub-question" sub_ref "C 5.1" - context %{ + context %(

    Please note, you do not need to address each UN SDG, only the ones that are most applicable to your sustainable development interventions.

    - } + ) rows 2 words_max 200 end @@ -317,11 +317,11 @@ def development_step3 classes "word-max-strict sub-question" ref "C 5.2" required - context %{ + context %(

    For example, this could be, to regenerate, to restore, to reduce emissions or to promote good health and wellbeing within the local community and society in general.

    - } + ) rows 2 words_max 200 end @@ -343,7 +343,7 @@ def development_step3 classes "word-max-strict sub-question" ref "C 5.4" required - context %{ + context %(

    For example, they may be exemplary as a result of:

    @@ -356,7 +356,7 @@ def development_step3

    If you have any external documents or other media to support your answer, please add these in Section E and reference them by their names in your answers.

    - } + ) pdf_context %( For example, it may be exemplary as a result of: @@ -406,11 +406,11 @@ def development_step3 classes "word-max-strict sub-question" ref "C 6.3" required - context %{ + context %(

    Describe the impact on your organisation, workforce, customers, stakeholders, supply chain, communities, regions or others, such as overseas clients or markets and how you are part of the circular economy.

    - } + ) rows 3 words_max 300 end @@ -419,14 +419,14 @@ def development_step3 classes "word-max-strict sub-question" ref "C 6.4" required - context %{ + context %(

    Explain and, if possible, provide evidence or research on how you have compared your organisation to others in your sector, including a web link if available.

    Explain how you know that your sustainability performance is exemplary compared with the sector in general.

    - } + ) rows 3 words_max 300 end @@ -455,11 +455,11 @@ def development_step3 textarea :governance, "Additional information about your Environmental, Social, and Corporate Governance (ESG). (optional)" do classes "word-max-strict sub-question" ref "C 6.7" - context %{ + context %(

    Please highlight your responsible business conduct and its impact within your organisation, supply chain and the wider community, if not already covered.

    - } + ) rows 2 words_max 200 end diff --git a/forms/custom_email_form.rb b/forms/custom_email_form.rb index 9758bcc25a..40befd25b4 100644 --- a/forms/custom_email_form.rb +++ b/forms/custom_email_form.rb @@ -4,7 +4,7 @@ class CustomEmailForm include ActiveModel::Validations extend Enumerize - SCOPES = %w(myself qae_opt_in_group bis_opt_in assessors all_users) + SCOPES = %w[myself qae_opt_in_group bis_opt_in assessors all_users] attr_reader :scope, :message, :admin_id, :subject validates :message, :scope, :subject, presence: true @@ -24,10 +24,10 @@ def persisted? def send! users.each do |user| - Users::CustomMailer.notify(user.id, user.class.name, message, subject).deliver_later! + Users::CustomMailer.notify(user.id, user.class.name, message, subject).deliver_later! rescue => e - puts "Error: #{e}" - Appsignal.send_error(e) + Rails.logger.debug "Error: #{e}" + Appsignal.send_error(e) end end diff --git a/forms/declaration_of_responsibility_form.rb b/forms/declaration_of_responsibility_form.rb index e90736b9bd..9a3d209094 100644 --- a/forms/declaration_of_responsibility_form.rb +++ b/forms/declaration_of_responsibility_form.rb @@ -14,7 +14,7 @@ class DeclarationOfResponsibilityForm attr_reader :form_answer - attr_accessor *ATTRIBUTES + attr_accessor(*ATTRIBUTES) ATTRIBUTES.each do |attr_name| class_eval <<-EVAL, __FILE__, __LINE__ + 1 @@ -25,13 +25,13 @@ class DeclarationOfResponsibilityForm def initialize(form_answer) @form_answer = form_answer ATTRIBUTES.each do |attr_name| - public_send("#{attr_name}=", form_answer.document[attr_name.to_s]) + public_send(:"#{attr_name}=", form_answer.document[attr_name.to_s]) end end def update(attrs = {}) ATTRIBUTES.each do |attr_name| - self.public_send("#{attr_name}=", attrs[attr_name]) + public_send(:"#{attr_name}=", attrs[attr_name]) end return false unless valid? @@ -52,7 +52,7 @@ def persisted? private ATTRIBUTES.each do |attr_name| - define_method("words_in_#{attr_name}") do + define_method(:"words_in_#{attr_name}") do if public_send(attr_name.to_s).split.size > 500 errors.add(attr_name, "is too long (maximum is 500 words)") end diff --git a/forms/eligibility_form.rb b/forms/eligibility_form.rb index 1628731abc..4ac9cd5283 100644 --- a/forms/eligibility_form.rb +++ b/forms/eligibility_form.rb @@ -10,14 +10,14 @@ def initialize(form_answer) end def eligibility - @eligibility ||= form_answer.public_send("#{form_answer.award_type}_eligibility") || form_answer.public_send("build_#{form_answer.award_type}_eligibility", filter(form_answer.user.public_send("#{form_answer.award_type}_eligibility").try(:attributes) || {})) + @eligibility ||= form_answer.public_send(:"#{form_answer.award_type}_eligibility") || form_answer.public_send(:"build_#{form_answer.award_type}_eligibility", filter(form_answer.user.public_send(:"#{form_answer.award_type}_eligibility").try(:attributes) || {})) end def basic_eligibility @basic_eligibility ||= if form_answer.basic_eligibility.try(:persisted?) - form_answer.basic_eligibility + form_answer.basic_eligibility else - form_answer.build_basic_eligibility(filter(form_answer.user.basic_eligibility.try(:attributes) || {})) + form_answer.build_basic_eligibility(filter(form_answer.user.basic_eligibility.try(:attributes) || {})) end end diff --git a/forms/palace_invite_form.rb b/forms/palace_invite_form.rb index ae495c3146..366b7896a6 100644 --- a/forms/palace_invite_form.rb +++ b/forms/palace_invite_form.rb @@ -11,7 +11,7 @@ def initialize(invite) def update(attributes = {}) attributes.each do |k, v| - public_send("#{k}=", v) if respond_to?("#{k}=") + public_send(:"#{k}=", v) if respond_to?(:"#{k}=") end if attributes[:submitted].present? diff --git a/forms/qae_form_builder.rb b/forms/qae_form_builder.rb index 1b9de3fdf3..1d2d6c3b9c 100644 --- a/forms/qae_form_builder.rb +++ b/forms/qae_form_builder.rb @@ -61,7 +61,7 @@ class QaeFormBuilder class << self def build title, &block form = QaeForm.new title - form.instance_eval &block if block_given? + form.instance_eval(&block) if block form end end diff --git a/forms/qae_form_builder/about_section_question.rb b/forms/qae_form_builder/about_section_question.rb index d0e6783ae6..848aefa30a 100644 --- a/forms/qae_form_builder/about_section_question.rb +++ b/forms/qae_form_builder/about_section_question.rb @@ -8,7 +8,7 @@ def section ref @q.context = data.map { |d| form_context(d) }.join - @q.pdf_context_with_header_blocks = data.map { |d| pdf_context(d) }.flatten(1) + @q.pdf_context_with_header_blocks = data.flat_map { |d| pdf_context(d) } end private @@ -17,9 +17,7 @@ def form_context(data) @link = data.link %(

    #{data.header}

    - #{data.context.map { |c| - "

    #{c}

    "}.join - } + #{data.context.map { |c| "

    #{c}

    " }.join} ) end @@ -72,8 +70,8 @@ def section_data(ref) ######## Section A ######## def about_section_A OpenStruct.new( - :header => "About section A", - :context => [ + header: "About section A", + context: [ "This section is to confirm that you have the authorisation to apply, that your organisation's past and present conduct would not cause reputational damage to the Awards, and what will happen after you apply in terms of due diligence and verification of commercial figures. We recommend you carefully answer section A questions before proceeding with the rest of the application.", ], ) @@ -83,8 +81,8 @@ def about_section_A ######## Section B ######## def about_section_B OpenStruct.new( - :header => "About section B", - :context => [ + header: "About section B", + context: [ "The purpose of this section is to collect specific information about your organisation. It is important that the details are accurate as they cannot be changed after the submission deadline.", "This information will help us to identify your organisation and will also enable us to undertake due diligence checks with other Government Departments and Agencies if your application is shortlisted.", ], @@ -93,8 +91,8 @@ def about_section_B def small_organisations OpenStruct.new( - :header => "Small organisations", - :context => [ + header: "Small organisations", + context: [ "The King's Awards for Enterprise is committed to acknowledging the efforts of organisations of all sizes. When assessing, we consider the size and sector of your organisation. If you are a small organisation, do not be intimidated by the questions that are less relevant to you - answer all questions to the degree you can.", ], ) @@ -107,8 +105,8 @@ def small_organisations # About Section C def about_section_C_innovation OpenStruct.new( - :header => "About section C", - :context => [ + header: "About section C", + context: [ "This section is structured to enable you to tell your success story of the innovation's development, implementation and impact, enabling the assessing team to understand the role innovation plays within your overall business and how this impacts the performance of your business.", ], ) @@ -116,8 +114,8 @@ def about_section_C_innovation def about_section_C_international_trade OpenStruct.new( - :header => "About section C", - :context => [ + header: "About section C", + context: [ "The purpose of this section is to enable the assessing team to understand your company, its product, services, and the role exporting plays within your overall business. We need to understand how this impacts the overall performance of your business.", ], ) @@ -125,8 +123,8 @@ def about_section_C_international_trade def about_section_C_sustainable_development OpenStruct.new( - :header => "About section C", - :context => [ + header: "About section C", + context: [ "Read this section before planning the answers. Try not to repeat points: instead, you can say that you are referring to a previous answer to another question and include that question number.", "Avoid using technical jargon.", ], @@ -136,8 +134,8 @@ def about_section_C_sustainable_development # Covid impact def covid_impact OpenStruct.new( - :header => "Impact of COVID-19 and other adverse events", - :context => [ + header: "Impact of COVID-19 and other adverse events", + context: [ "If your growth was affected by adverse national and global events - such as COVID-19, the war in Ukraine, flooding, and wildfires - this will be taken into consideration during the assessment process. Question C6 allows you to explain how your organisation was affected and how you responded to these challenges.", ], ) @@ -145,8 +143,8 @@ def covid_impact def covid_impact_development OpenStruct.new( - :header => "Impact of COVID-19 and other adverse events", - :context => [ + header: "Impact of COVID-19 and other adverse events", + context: [ "If your growth was affected by adverse national and global events - such as COVID-19, the war in Ukraine, flooding, and wildfires - this will be taken into consideration during the assessment process. Question D6 allows you to explain how your organisation was affected and how you responded to these challenges.", ], ) @@ -155,8 +153,8 @@ def covid_impact_development # Word limits def word_limits OpenStruct.new( - :header => "Word limits", - :context => [ + header: "Word limits", + context: [ "What matters most is the quality of the information and insight you provide. The word limits for each question are just there to stop your application from becoming overlong and give an idea of the relative level of detail the assessors are looking for.", ], ) @@ -165,8 +163,8 @@ def word_limits # Technical language def technical_language OpenStruct.new( - :header => "Technical language", - :context => [ + header: "Technical language", + context: [ "Please avoid using technical language - we need to understand your answers without having specific knowledge of your industry. If you use acronyms, please define them when you use them for the first time.", ], ) @@ -175,8 +173,8 @@ def technical_language # Supplementary materials def supplementary_materials OpenStruct.new( - :header => "Supplementary materials", - :context => [ + header: "Supplementary materials", + context: [ "To support your answers in this section, you can add up to three materials (documents or online links) in Section F. For assessors to review them, you must reference them by their names in your answers.", "Please do not combine documents and do not link to folders. Assessors have limited time to evaluate your application, so any additional documents should be kept short and relevant. Do not use them as a substitute for providing narrative answers to the questions.", ], @@ -185,8 +183,8 @@ def supplementary_materials def supplementary_materials_development OpenStruct.new( - :header => "Supplementary materials", - :context => [ + header: "Supplementary materials", + context: [ "To support your answers in this section, you can add up to three materials (documents or online links) in Section E. For assessors to review them, you must reference them by their names in your answers.", "Please do not combine documents and do not link to folders. Assessors have limited time to evaluate your application, so any additional documents should be kept short and relevant. Do not use them as a substitute for providing narrative answers to the questions.", ], @@ -196,8 +194,8 @@ def supplementary_materials_development # UN SDGs def un_sdgs OpenStruct.new( - :header => "United Nations Sustainable Development Goals (UN SDGs)", - :context => [ + header: "United Nations Sustainable Development Goals (UN SDGs)", + context: [ "You may find it helpful to familiarise yourself with the United Nations 17 Sustainable Development Goals (UN SDGs). While they include impacts at a national level, you may want to reference the real positive impact your organisation contributes towards them.", "You do not need to show impact in each of these areas, only the ones that are most applicable to your sustainable development interventions.", "You can find more information about each goal on the United Nations (UN) website.", @@ -212,8 +210,8 @@ def un_sdgs # About Section D def about_section_D_innovation OpenStruct.new( - :header => "About section D", - :context => [ + header: "About section D", + context: [ "All applicants must demonstrate a certain level of financial performance. This section enables you to show the impact that your innovation has had on your organisation's financial performance. Financial information must be supplied so your organisation's commercial performance can be evaluated. It is important that these details are accurate, as you will need to verify them if shortlisted.", "We recommend you get your accountant to assist you with this section.", ], @@ -222,8 +220,8 @@ def about_section_D_innovation def about_section_D_trade OpenStruct.new( - :header => "About section D", - :context => [ + header: "About section D", + context: [ "All applicants must demonstrate a certain level of financial performance. This section enables you to show the impact that your international trade has had on your organisation's financial performance. Financial information must be supplied so your organisation's commercial performance can be evaluated. It is important that these details are accurate, as you will need to verify them if shortlisted.", "We recommend you get your accountant to assist you with this section.", ], @@ -232,8 +230,8 @@ def about_section_D_trade def about_section_D OpenStruct.new( - :header => "About section D", - :context => [ + header: "About section D", + context: [ "You must demonstrate that your organisation is financially viable. You will also need to upload your financial statements to provide evidence of this.", "We recommend you get your accountant to assist you with this section.", ], @@ -243,8 +241,8 @@ def about_section_D # Financial periods def financial_periods_innovation OpenStruct.new( - :header => "Periods the figures are required for", - :context => [ + header: "Periods the figures are required for", + context: [ "We ask you to provide figures for your five most recent financial years. If you started trading within the last five years, you only need to provide figures for the years you have been trading. However, to meet minimum eligibility requirements, you must be able to provide figures for at least your two most recent financial years, covering the full 24 months.", ], ) @@ -252,8 +250,8 @@ def financial_periods_innovation def financial_periods_trade OpenStruct.new( - :header => "Periods the figures are required for", - :context => [ + header: "Periods the figures are required for", + context: [ "Depending on which award you are applying for, you must be able to provide financial figures for your three most recent financial years, covering exactly 36 consecutive months; or if you are applying for a 6-year award (see question D1), you must provide figures for the last six financial years, covering exactly 72 consecutive months.", "If you have changed your year-end during the period of your application, see D3.2 for an explanation of how this must be dealt with.", ], @@ -262,8 +260,8 @@ def financial_periods_trade def financial_periods OpenStruct.new( - :header => "Periods the figures are required for", - :context => [ + header: "Periods the figures are required for", + context: [ "You must provide financial figures for your three most recent financial years, covering 36 months.", "If you have changed your year-end during the period of your application, see D2.3 for an explanation of how this must be dealt with.", "For the purpose of this application, your most recent financial year is your last financial year ending before the #{Settings.current.deadlines.where(kind: "submission_end").first.decorate.formatted_trigger_date("with_year")} - the application submission deadline.", @@ -274,8 +272,8 @@ def financial_periods # Estimated figures def estimated_figures OpenStruct.new( - :header => "Estimated figures", - :context => [ + header: "Estimated figures", + context: [ "If you haven't reached or finalised accounts for your most recent financial year, you can provide estimated figures for now.", "If you are shortlisted, you will have to provide the actual figures that have been verified before the specified November deadline (the exact date will be provided in the shortlisting email). Typically, the verification is done by an external accountant who prepares your annual accounts or returns or, in the case of a larger organisation, who conducts your financial audit.", ], @@ -284,8 +282,8 @@ def estimated_figures def estimated_figures_development OpenStruct.new( - :header => "Estimated figures", - :context => [ + header: "Estimated figures", + context: [ "If you haven't reached or finalised accounts for your most recent financial year, you can provide estimated figures for now.", "If you are shortlisted, you will have to provide the actual figures and the related VAT returns before the specified November deadline (the exact date will be provided in the shortlisting email).", ], @@ -295,8 +293,8 @@ def estimated_figures_development # Group entries def group_entries OpenStruct.new( - :header => "Group entries", - :context => [ + header: "Group entries", + context: [ "A parent company making a group entry should include the trading figures of all UK members of the group.", "If your organisation is based in the Channel Islands or Isle of Man, you should include only the subsidiaries that are located there (do not include subsidiaries that are in the UK).", ], @@ -306,8 +304,8 @@ def group_entries # Required figures def required_figures_company OpenStruct.new( - :header => "Required figures", - :context => [ + header: "Required figures", + context: [ "We ask you to provide figures for your five most recent financial years. If you started trading within the last five years, you only need to provide figures for the years you have been trading. However, to meet minimum eligibility requirements, you must be able to provide figures for at least your two most recent financial years, covering the full 24 months.", "If you haven't reached your latest year-end, please use estimates to complete these questions.", ], @@ -316,8 +314,8 @@ def required_figures_company def required_figures_innovation OpenStruct.new( - :header => "Required figures", - :context => [ + header: "Required figures", + context: [ "We ask you to provide figures for your five most recent financial years. If the innovation has been in the market for less than five years, you only need to provide figures for the years it was in the market. However, to meet minimum eligibility requirements, you must be able to provide figures for at least your two most recent financial years, covering the full 24 months.", "If you haven't reached your latest year-end, please use estimates to complete these questions.", ], @@ -326,8 +324,8 @@ def required_figures_innovation def required_figures_trade OpenStruct.new( - :header => "Required figures", - :context => [ + header: "Required figures", + context: [ "If you have selected “Outstanding Short-Term Growth” in D1, you will only need to provide information for the last three years.", "If you haven't reached your latest year-end, please use estimates to complete these questions.", ], @@ -337,8 +335,8 @@ def required_figures_trade # Figures format def figures_format OpenStruct.new( - :header => "Figures - format", - :context => [ + header: "Figures - format", + context: [ "You must enter financial figures in pounds sterling (£).
    Round the figures to the nearest pound (do not enter pennies).
    Do not separate your figures with commas.
    @@ -351,8 +349,8 @@ def figures_format # D6 def about_D6 OpenStruct.new( - :header => "About D6 questions", - :context => [ + header: "About D6 questions", + context: [ "Some of the details may not apply to your innovation. Answer the questions that are relevant to help us understand the financial value of your innovation.", ], ) @@ -363,8 +361,8 @@ def about_D6 def about_section_E OpenStruct.new( - :header => "About section E", - :context => [ + header: "About section E", + context: [ "The environmental, social, and corporate governance (ESG) section is an opportunity for you to highlight your responsible business conduct and its impact within your organisation, supply chain and the wider community.", "We expect all King's Award for Enterprise applicants to adhere to commonly accepted standards for environmentally and socially responsible corporate governance. Failure to demonstrate that will result in your application not being successful.", ], @@ -374,8 +372,8 @@ def about_section_E # Answering questions def answering_questions OpenStruct.new( - :header => "Answering questions", - :context => [ + header: "Answering questions", + context: [ "Provide examples for each question relative to the size and scale of your business.", "The word limits are a guide. You do not need to maximise the word limit if there is no reason to - we suggest you focus on your strongest examples in each case.", "Furthermore, you may have already answered some of the questions in this section in other parts of the form. If you believe this is the case, you do not need to repeat the information but make it clear by referencing the questions in other parts of the form.", diff --git a/forms/qae_form_builder/address_question.rb b/forms/qae_form_builder/address_question.rb index 5367bf3428..c02ab7040e 100644 --- a/forms/qae_form_builder/address_question.rb +++ b/forms/qae_form_builder/address_question.rb @@ -27,7 +27,7 @@ def rendering_sub_fields # are rendering together in same block # and the :building is the first one sub_fields.reject do |f| - f.keys.include?(:street) + f.key?(:street) end.map do |f| [f.keys.first, f.values.first] end diff --git a/forms/qae_form_builder/award_holder_question.rb b/forms/qae_form_builder/award_holder_question.rb index f0af28a554..9db82f9d19 100644 --- a/forms/qae_form_builder/award_holder_question.rb +++ b/forms/qae_form_builder/award_holder_question.rb @@ -5,19 +5,17 @@ def errors question.entities.each_with_index do |award, index| question.required_sub_fields_list.each do |attr| - if !award[attr].present? + if award[attr].blank? result[question.key] ||= {} result[question.key][index] ||= "" result[question.key][index] << " #{attr.humanize.capitalize} can't be blank." - else - if attr == "details" - limit = question.delegate_obj.details_words_max - length = award[attr].split(" ").length + elsif attr == "details" + limit = question.delegate_obj.details_words_max + length = award[attr].split(" ").length - if limit && limit_with_buffer(limit) && length && length > limit_with_buffer(limit) - result[question.key][index] ||= "" - result[question.key][index] << " #{attr.humanize.capitalize} exeeded #{limit} words limit." - end + if limit && limit_with_buffer(limit) && length && length > limit_with_buffer(limit) + result[question.key][index] ||= "" + result[question.key][index] << " #{attr.humanize.capitalize} exeeded #{limit} words limit." end end end @@ -44,9 +42,9 @@ class AwardHolderQuestion < Question class AwardHolderQuestionDecorator < MultiQuestionDecorator def required_sub_fields_list if delegate_obj.award_years_present - %w(title year details) + %w[title year details] else - %w(title details) + %w[title details] end end end diff --git a/forms/qae_form_builder/by_trade_goods_and_services_label_question.rb b/forms/qae_form_builder/by_trade_goods_and_services_label_question.rb index 099357569f..789b634693 100644 --- a/forms/qae_form_builder/by_trade_goods_and_services_label_question.rb +++ b/forms/qae_form_builder/by_trade_goods_and_services_label_question.rb @@ -15,7 +15,7 @@ def errors # only validate the first product or at least one field is filled in if product_number == 1 || !entity.values.all?(&:blank?) question.required_sub_fields_list.each do |attr| - if !entity[attr].present? + if entity[attr].blank? result[question.key] ||= {} result[question.key][product_number] ||= {} result[question.key][product_number][attr] ||= "" @@ -50,7 +50,7 @@ def trade_goods_and_services end def required_sub_fields_list - %w(desc_short total_overseas_trade) + %w[desc_short total_overseas_trade] end end diff --git a/forms/qae_form_builder/by_years_label_question.rb b/forms/qae_form_builder/by_years_label_question.rb index a9aab80b7d..d87b5392d1 100644 --- a/forms/qae_form_builder/by_years_label_question.rb +++ b/forms/qae_form_builder/by_years_label_question.rb @@ -8,19 +8,19 @@ def errors return result unless question.visible? dates = question.active_fields.each_with_object(Hash[]) do |field, outer| - suffix = "#{question.key}_#{field}" - parts = REQUIRED_SUB_FIELDS.each_with_object([]) do |sub, inner| - key = "#{suffix}#{sub}" - inner << answers[key] - end - - if parts.any?(&:blank?) - outer[suffix] = :blank - else - date = parts.join("/") - outer[suffix] = ::Utils::Date.valid?(date) ? Date.parse(date) : :invalid - end - end + suffix = "#{question.key}_#{field}" + parts = REQUIRED_SUB_FIELDS.each_with_object([]) do |sub, inner| + key = "#{suffix}#{sub}" + inner << answers[key] + end + + if parts.any?(&:blank?) + outer[suffix] = :blank + else + date = parts.join("/") + outer[suffix] = ::Utils::Date.valid?(date) ? Date.parse(date) : :invalid + end + end required = question.required? @@ -92,7 +92,7 @@ def has_drops? def active_fields return [] unless fields_count - (1..fields_count).map{ |y| "#{y}of#{fields_count}" } + (1..fields_count).map { |y| "#{y}of#{fields_count}" } end def fields_count @@ -108,12 +108,15 @@ def active_by_year_condition q = form[c.question_key] if q.is_a?(QaeFormBuilder::DateQuestion) || q.is_a?(QaeFormBuilder::DateQuestionDecorator) - date = [] - q.required_sub_fields.each do |sub| - date << q.input_value(suffix: sub.keys[0]) + date = q.required_sub_fields.map do |sub| + q.input_value(suffix: sub.keys[0]) end - date = Date.parse(date.join("/")) rescue nil + date = begin + Date.parse(date.join("/")) + rescue + nil + end c.question_value.call(date) else diff --git a/forms/qae_form_builder/by_years_question.rb b/forms/qae_form_builder/by_years_question.rb index bf6001bab6..7846d8499d 100644 --- a/forms/qae_form_builder/by_years_question.rb +++ b/forms/qae_form_builder/by_years_question.rb @@ -7,7 +7,7 @@ def errors if question.required? question.active_fields.each.with_index(1) do |suffix, idx| - if !question.input_value(suffix: suffix).present? + if question.input_value(suffix: suffix).blank? result[question.hash_key(suffix: suffix)] ||= "" result[question.hash_key(suffix: suffix)] << "Question #{question.ref || question.sub_ref} is incomplete. Financial year #{idx} is required and must be filled in. Enter '0' if none" end @@ -63,7 +63,7 @@ def has_drops? def active_fields return [] unless fields_count - (1..fields_count).map{ |y| "#{y}of#{fields_count}" } + (1..fields_count).map { |y| "#{y}of#{fields_count}" } end def fields_count @@ -78,16 +78,19 @@ def active_by_year_condition if c.question_value.respond_to?(:call) q = form[c.question_key] if q.is_a?(QaeFormBuilder::DateQuestion) || q.is_a?(QaeFormBuilder::DateQuestionDecorator) - date = [] - q.required_sub_fields.each do |sub| - date << q.input_value(suffix: sub.keys[0]) + date = q.required_sub_fields.map do |sub| + q.input_value(suffix: sub.keys[0]) end - date = Date.parse(date.join("/")) rescue nil + date = begin + Date.parse(date.join("/")) + rescue + nil + end - c.question_value.(date) + c.question_value.call(date) else - c.question_value.(form[c.question_key].input_value) + c.question_value.call(form[c.question_key].input_value) end else form[c.question_key].input_value == c.question_value diff --git a/forms/qae_form_builder/checkbox_seria_question.rb b/forms/qae_form_builder/checkbox_seria_question.rb index 615e946a9f..d73377ce62 100644 --- a/forms/qae_form_builder/checkbox_seria_question.rb +++ b/forms/qae_form_builder/checkbox_seria_question.rb @@ -6,7 +6,7 @@ def errors return {} if skip_base_validation? if question.required? - if !question.input_value.present? + if question.input_value.blank? result[question.hash_key] = "Question #{question.ref || question.sub_ref} is incomplete. It is required and at least one option must be chosen from the following list." end end diff --git a/forms/qae_form_builder/confirm_question.rb b/forms/qae_form_builder/confirm_question.rb index 98d6d31012..0774730b4e 100644 --- a/forms/qae_form_builder/confirm_question.rb +++ b/forms/qae_form_builder/confirm_question.rb @@ -6,7 +6,7 @@ def errors return {} if skip_base_validation? if question.required? - if !question.input_value.present? + if question.input_value.blank? result[question.hash_key] = "Question #{question.ref || question.sub_ref} is incomplete. It is required and confirmation must be given by ticking the checkbox." end end diff --git a/forms/qae_form_builder/date_question.rb b/forms/qae_form_builder/date_question.rb index cedcf13d3f..ef2b7c062a 100644 --- a/forms/qae_form_builder/date_question.rb +++ b/forms/qae_form_builder/date_question.rb @@ -3,15 +3,26 @@ class DateQuestionValidator < QuestionValidator def errors result = super - date_max = Date.parse(question.delegate_obj.date_max) rescue nil - date_min = Date.parse(question.delegate_obj.date_min) rescue nil + date_max = begin + Date.parse(question.delegate_obj.date_max) + rescue + nil + end + date_min = begin + Date.parse(question.delegate_obj.date_min) + rescue + nil + end - date = [] - question.required_sub_fields.each do |sub_field| - date << question.input_value(suffix: sub_field.keys[0]) + date = question.required_sub_fields.map do |sub_field| + question.input_value(suffix: sub_field.keys[0]) end - date = Date.parse(date.join("/")) rescue nil + date = begin + Date.parse(date.join("/")) + rescue + nil + end if !date if question.required? @@ -30,9 +41,7 @@ def errors end end - result = process_dynamic_dates(date, result) - - result + process_dynamic_dates(date, result) end def process_dynamic_dates(date, result) @@ -41,7 +50,11 @@ def process_dynamic_dates(date, result) settings = question.delegate_obj.dynamic_date_max if (key = answers[settings[:conditional].to_s]).present? - date_max = Date.parse(settings[:dates][key]) rescue nil + date_max = begin + Date.parse(settings[:dates][key]) + rescue + nil + end if date_max && date > date_max result[question.hash_key] ||= "" diff --git a/forms/qae_form_builder/innovation_financial_year_date_question.rb b/forms/qae_form_builder/innovation_financial_year_date_question.rb index 892329279d..7205498ede 100644 --- a/forms/qae_form_builder/innovation_financial_year_date_question.rb +++ b/forms/qae_form_builder/innovation_financial_year_date_question.rb @@ -3,19 +3,22 @@ class InnovationFinancialYearDateQuestionValidator < QuestionValidator def errors result = super - date = [] - question.required_sub_fields.each do |sub_field| - date << question.input_value(suffix: sub_field.keys[0]) + date = question.required_sub_fields.map do |sub_field| + question.input_value(suffix: sub_field.keys[0]) end date << Date.current.year.to_s day = question.input_value(suffix: "day") month = question.input_value(suffix: "month") - if day.blank? || month.blank? - date = nil + date = if day.blank? || month.blank? + nil else - date = Date.parse(date.join("/")) rescue nil + begin + Date.parse(date.join("/")) + rescue + nil + end end if question.required? && !date diff --git a/forms/qae_form_builder/matrix_question.rb b/forms/qae_form_builder/matrix_question.rb index f168ba0158..20635e6010 100644 --- a/forms/qae_form_builder/matrix_question.rb +++ b/forms/qae_form_builder/matrix_question.rb @@ -1,6 +1,6 @@ class QaeFormBuilder - AUTO_CALCULATED_HEADINGS = %w(total_system_calculated calculated_total calculated_proportion calculated_sub_total).freeze - EXCLUDED_HEADINGS = %w(calculated_sub_total others calculated_total calculated_proportion).freeze + AUTO_CALCULATED_HEADINGS = %w[total_system_calculated calculated_total calculated_proportion calculated_sub_total].freeze + EXCLUDED_HEADINGS = %w[calculated_sub_total others calculated_total calculated_proportion].freeze class MatrixQuestionValidator < QuestionValidator def errors result = super @@ -9,16 +9,14 @@ def errors question.x_headings.each do |x_heading| suffix = "#{x_heading.key}_#{y_heading.key}" if !AUTO_CALCULATED_HEADINGS.any? { |excluded| question.input_name(suffix: suffix).include?(excluded) } - if !question.input_value(suffix: suffix).present? + if question.input_value(suffix: suffix).blank? if (question.required_row_parent && question.required_rows.include?(y_heading.key)) || !question.required_row_parent result[question.hash_key(suffix: suffix)] ||= "" result[question.hash_key(suffix: suffix)] << "Must be filled in. Enter '0' if none" end - else - if !/\A\d+\z/.match(question.input_value(suffix: suffix).to_s) - result[question.hash_key(suffix: suffix)] ||= "" - result[question.hash_key(suffix: suffix)] << "Must be a whole number" - end + elsif !/\A\d+\z/.match(question.input_value(suffix: suffix).to_s) + result[question.hash_key(suffix: suffix)] ||= "" + result[question.hash_key(suffix: suffix)] << "Must be a whole number" end end end @@ -96,10 +94,10 @@ def calculate_col_subtotal(question_key, x_headings, y_headings, answers) end def calculate_proportion(question_key, answers, x_heading, y_heading) - if y_headings.any? { |heading| heading.key == "calculated_sub_total" } - disadvantaged = answers["#{question_key}_#{x_heading}_calculated_sub_total"].to_f + disadvantaged = if y_headings.any? { |heading| heading.key == "calculated_sub_total" } + answers["#{question_key}_#{x_heading}_calculated_sub_total"].to_f else - disadvantaged = answers["#{question_key}_#{x_heading}_total_disadvantaged"].to_f + answers["#{question_key}_#{x_heading}_total_disadvantaged"].to_f end disadvantaged ||= 0 total = answers["#{question_key}_#{x_heading}_calculated_total"].to_f @@ -182,7 +180,7 @@ def y_heading key, label, options = {} def x_headings headings headings.each do |heading| if heading.is_a?(Array) - x_heading *heading + x_heading(*heading) else x_heading heading.to_s.parameterize.underscore, heading end @@ -192,22 +190,22 @@ def x_headings headings def y_headings headings headings.each do |heading| if heading.is_a?(Array) - y_heading *heading + y_heading(*heading) else y_heading heading.to_s.parameterize.underscore, heading end end if @q.subtotals_label - y_heading "calculated_sub_total", @q.subtotals_label, { "row_class": "auto-subtotals-row" } + y_heading "calculated_sub_total", @q.subtotals_label, { row_class: "auto-subtotals-row" } end if @q.others_label - y_heading "others", @q.others_label, { "row_class": "others-not-disadvantaged-row" } + y_heading "others", @q.others_label, { row_class: "others-not-disadvantaged-row" } end if @q.totals_label - y_heading "calculated_total", @q.totals_label, { "row_class": "auto-totals-row" } + y_heading "calculated_total", @q.totals_label, { row_class: "auto-totals-row" } end if @q.proportion_label - y_heading "calculated_proportion", @q.proportion_label, { "row_class": "auto-proportion-row" } + y_heading "calculated_proportion", @q.proportion_label, { row_class: "auto-proportion-row" } end end diff --git a/forms/qae_form_builder/multi_question_validator.rb b/forms/qae_form_builder/multi_question_validator.rb index 3e6ff98f4c..7256ee5de0 100644 --- a/forms/qae_form_builder/multi_question_validator.rb +++ b/forms/qae_form_builder/multi_question_validator.rb @@ -4,7 +4,7 @@ def errors question.entities.each_with_index do |entity, index| question.required_sub_fields_list.each do |attr| - if !entity[attr].present? + if entity[attr].blank? result[question.key] ||= {} result[question.key][index] ||= "" result[question.key][index] << "Question #{question.ref || question.sub_ref} is incomplete. #{attr.humanize} can't be blank." diff --git a/forms/qae_form_builder/number_question.rb b/forms/qae_form_builder/number_question.rb index 8eafab542e..33054e38ba 100644 --- a/forms/qae_form_builder/number_question.rb +++ b/forms/qae_form_builder/number_question.rb @@ -12,7 +12,7 @@ def fieldset_classes class NumberQuestionBuilder < TextQuestionBuilder def initialize q - super q + super(q) q.type = :number 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 49c27870b0..e61dfa5c37 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 @@ -38,7 +38,7 @@ def has_drops? end def active_fields - (1..3).map{ |y| "#{y}of3" } + (1..3).map { |y| "#{y}of3" } end def fields_count 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 8dd8478df1..09ee4e9cdb 100644 --- a/forms/qae_form_builder/one_option_by_years_question.rb +++ b/forms/qae_form_builder/one_option_by_years_question.rb @@ -28,7 +28,7 @@ def has_drops? end def active_fields - (1..3).map{ |y| "#{y}of3" } + (1..3).map { |y| "#{y}of3" } end def fields_count diff --git a/forms/qae_form_builder/options_question.rb b/forms/qae_form_builder/options_question.rb index 6115ed3bda..00be5e0f42 100644 --- a/forms/qae_form_builder/options_question.rb +++ b/forms/qae_form_builder/options_question.rb @@ -6,7 +6,7 @@ def errors return {} if skip_base_validation? if question.required? - if !question.input_value.present? + if question.input_value.blank? result[question.hash_key] = "Question #{question.ref || question.sub_ref} is incomplete. It is required and an option must be chosen from the following list." end end diff --git a/forms/qae_form_builder/qae_decorator.rb b/forms/qae_form_builder/qae_decorator.rb index 02b5f18e54..fee9e1b0a4 100644 --- a/forms/qae_form_builder/qae_decorator.rb +++ b/forms/qae_form_builder/qae_decorator.rb @@ -7,10 +7,12 @@ def initialize obj, decorator_options = {} @decorator_options = decorator_options end + # rubocop:disable Style/MissingRespondToMissing def method_missing(meth, *args, &block) result = @delegate_obj.send(meth, *args, &block) wrap result, @decorator_options end + # rubocop:enable Style/MissingRespondToMissing private diff --git a/forms/qae_form_builder/qae_form.rb b/forms/qae_form_builder/qae_form.rb index b90dd63ae8..7c92be897f 100644 --- a/forms/qae_form_builder/qae_form.rb +++ b/forms/qae_form_builder/qae_form.rb @@ -22,7 +22,7 @@ def step title, short_title, options = {}, &block step = Step.new self, title, short_title, options builder = StepBuilder.new step - builder.instance_eval &block if block_given? + builder.instance_eval(&block) if block @steps << step step end diff --git a/forms/qae_form_builder/qae_form_decorator.rb b/forms/qae_form_builder/qae_form_decorator.rb index 67b0189d55..7cb962e11b 100644 --- a/forms/qae_form_builder/qae_form_decorator.rb +++ b/forms/qae_form_builder/qae_form_decorator.rb @@ -19,7 +19,7 @@ def required_visible_questions_total private def count_questions meth - steps.map{ |step| step.send meth }.reduce(:+) + steps.sum { |step| step.send meth } end end end diff --git a/forms/qae_form_builder/queen_award_applications_question.rb b/forms/qae_form_builder/queen_award_applications_question.rb index 39acff8fe0..2f009b113a 100644 --- a/forms/qae_form_builder/queen_award_applications_question.rb +++ b/forms/qae_form_builder/queen_award_applications_question.rb @@ -7,7 +7,7 @@ class QueenAwardApplicationsQuestionValidator < MultiQuestionValidator class QueenAwardApplicationsQuestionBuilder < QuestionBuilder def year year - #TODO: type checking + # TODO: type checking @q.years << year end @@ -41,7 +41,7 @@ def after_create class QueenAwardApplicationsQuestionDecorator < MultiQuestionDecorator def required_sub_fields_list - %w(category year outcome) + %w[category year outcome] end end end diff --git a/forms/qae_form_builder/queen_award_holder_question.rb b/forms/qae_form_builder/queen_award_holder_question.rb index b2265c93c1..700c010b9d 100644 --- a/forms/qae_form_builder/queen_award_holder_question.rb +++ b/forms/qae_form_builder/queen_award_holder_question.rb @@ -6,7 +6,7 @@ class QueenAwardHolderQuestionValidator < MultiQuestionValidator class QueenAwardHolderQuestionBuilder < QuestionBuilder def year year - #TODO: type checking + # TODO: type checking @q.years << year end @@ -35,7 +35,7 @@ def after_create class QueenAwardHolderQuestionDecorator < MultiQuestionDecorator def required_sub_fields_list - %w(category year) + %w[category year] end end end diff --git a/forms/qae_form_builder/question.rb b/forms/qae_form_builder/question.rb index 4f92223c2c..39d7487195 100644 --- a/forms/qae_form_builder/question.rb +++ b/forms/qae_form_builder/question.rb @@ -32,7 +32,7 @@ def errors return {} if skip_base_validation? if question.required? - if !question.input_value.present? + if question.input_value.blank? result[question.hash_key] = "Question #{question.ref || question.sub_ref} is incomplete. It is required and and must be filled in." end end @@ -43,9 +43,7 @@ def errors private def skip_base_validation? - SKIP_PRESENCE_VALIDATION_QUESTIONS.any? do |klass| - question.delegate_obj.class.name.demodulize == klass - end + SKIP_PRESENCE_VALIDATION_QUESTIONS.any?(question.delegate_obj.class.name.demodulize) end def limit_with_buffer(limit) @@ -61,7 +59,7 @@ def valid_url?(url) unless url[/\Ahttp:\/\//] || url[/\Ahttps:\/\//] url = "http://#{url}" end - url_regexp = /\A(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?\z/ix + url_regexp = /\A(http|https):\/\/[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?\z/ix (url =~ url_regexp) ? true : false end end @@ -118,7 +116,7 @@ def halted? meth = halt_options.dig(:if) if meth.respond_to?(:call) - meth.(self) + meth.call(self) elsif respond_to?(meth) send(meth) end @@ -166,7 +164,7 @@ def fieldset_classes end def fieldset_data_hash - result = { "answer": delegate_obj.parameterized_title, "question-key" => delegate_obj.key } + result = { :answer => delegate_obj.parameterized_title, "question-key" => delegate_obj.key } if delegate_obj.drop_condition.present? result["drop-question"] = Array.wrap(delegate_obj.drop_condition).map do |k| @@ -232,28 +230,32 @@ def visible?(fetched_answers = nil) question_value = condition.question_value parent_question_answer = if fetched_answers.present? - # Used in Reports::AllEntries, as passing json of answers - # allows to make it faster - fetched_answers[condition.question_key] + # Used in Reports::AllEntries, as passing json of answers + # allows to make it faster + fetched_answers[condition.question_key] else - step.form[condition.question_key].input_value + step.form[condition.question_key].input_value end if question_value == :true parent_question_answer.present? elsif question_value == :day_month_range day, month = if fetched_answers.present? - [ - fetched_answers["#{condition.question_key}_day"], - fetched_answers["#{condition.question_key}_month"], - ] + [ + fetched_answers["#{condition.question_key}_day"], + fetched_answers["#{condition.question_key}_month"], + ] else - q = step.form[condition.question_key] - q.required_sub_fields.map { |field| q.input_value(suffix: field.keys[0]) } + q = step.form[condition.question_key] + q.required_sub_fields.map { |field| q.input_value(suffix: field.keys[0]) } end if day.present? && month.present? - date = Date.parse("#{day.to_i}/#{month.to_i}/2000") rescue nil + date = begin + Date.parse("#{day.to_i}/#{month.to_i}/2000") + rescue + nil + end if date from, to = condition.options.dig(:range) date.between?(from, to) @@ -263,12 +265,10 @@ def visible?(fetched_answers = nil) else false end + elsif parent_question_answer.is_a?(Array) + parent_question_answer.find { |a| a["type"].to_s == question_value.to_s }.present? else - if parent_question_answer.is_a?(Array) - parent_question_answer.find { |a| a["type"].to_s == question_value.to_s }.present? - else - parent_question_answer == question_value.to_s - end + parent_question_answer == question_value.to_s end end && (!dc || (dc.present? && has_drops?)) @@ -435,7 +435,7 @@ def additional_pdf_context text, **options condition = options[:if] if condition && condition.respond_to?(:call) - @q.additional_pdf_context = text if condition.call() + @q.additional_pdf_context = text if condition.call else @q.additional_pdf_context = text end @@ -591,9 +591,10 @@ def initialize step, key, title, opts = {} @display_sub_ref_on_js_form = true @show_ref_always = false - self.after_create if self.respond_to?(:after_create) + after_create if respond_to?(:after_create) end + # rubocop:disable Lint/DuplicateMethods def context if @context.respond_to?(:call) @context.call @@ -601,7 +602,9 @@ def context @context end end + # rubocop:enable Lint/DuplicateMethods + # rubocop:disable Lint/DuplicateMethods def title if @title.respond_to?(:call) @title.call @@ -609,10 +612,15 @@ def title @title end end + # rubocop:enable Lint/DuplicateMethods def decorate options = {} kls_name = self.class.name.split("::").last - kls = QaeFormBuilder.const_get "#{kls_name}Decorator" rescue nil + kls = begin + QaeFormBuilder.const_get "#{kls_name}Decorator" + rescue + nil + end (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 f6ecb14295..837a7a7f7b 100644 --- a/forms/qae_form_builder/regions_question.rb +++ b/forms/qae_form_builder/regions_question.rb @@ -27,6 +27,7 @@ def entities @entities ||= answers[delegate_obj.key.to_s] || [] end end + class RegionsQuestion < DropdownQuestion end end diff --git a/forms/qae_form_builder/sic_code_dropdown_question.rb b/forms/qae_form_builder/sic_code_dropdown_question.rb index 70ecbc1bea..b6a1e8f57f 100644 --- a/forms/qae_form_builder/sic_code_dropdown_question.rb +++ b/forms/qae_form_builder/sic_code_dropdown_question.rb @@ -4,7 +4,7 @@ def errors result = super if question.required? - if !question.input_value.present? + if question.input_value.blank? result[question.hash_key] ||= "" result[question.hash_key] = "Question #{question.ref || question.sub_ref} is incomplete. It is required and and an option must be selected from the following dropdown list." end diff --git a/forms/qae_form_builder/step.rb b/forms/qae_form_builder/step.rb index f2b6e0d0d3..5b8372fa3f 100644 --- a/forms/qae_form_builder/step.rb +++ b/forms/qae_form_builder/step.rb @@ -2,10 +2,10 @@ class QaeFormBuilder class StepDecorator < QaeDecorator - QUESTIONS_WITH_NOT_REJECTING_BLANKS_ON_SAVE = %w( + QUESTIONS_WITH_NOT_REJECTING_BLANKS_ON_SAVE = %w[ innovation_materials org_chart - ) + ] def next @next ||= form.steps[index + 1] @@ -57,13 +57,11 @@ def allowed_questions_params_list(form_data, document) end end - allowed_params = allowed_params.select do |k, v| + allowed_params.select do |k, v| v.present? || document[k.to_s].present? || QUESTIONS_WITH_NOT_REJECTING_BLANKS_ON_SAVE.include?(k.to_s) end - - allowed_params end def hashify_params(params) @@ -73,9 +71,21 @@ def hashify_params(params) def question_possible_sub_keys(question) sub_question_keys = [] - sub_fields = question.sub_fields rescue nil - required_sub_fields = question.required_sub_fields rescue nil - by_year_conditions = question.by_year_conditions rescue nil + sub_fields = begin + question.sub_fields + rescue + nil + end + required_sub_fields = begin + question.required_sub_fields + rescue + nil + end + by_year_conditions = begin + question.by_year_conditions + rescue + nil + end if sub_fields.present? sub_question_keys += sub_fields.map { |f| f.keys.first } @@ -85,11 +95,13 @@ def question_possible_sub_keys(question) sub_question_keys += required_sub_fields.map { |f| f.keys.first } end + range_values = %i[day month year] + 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) - [:day, :month, :year].map do |i| + range_values.map do |i| "#{y}of#{c.years}#{i}" end else @@ -113,7 +125,7 @@ def question_possible_sub_keys(question) 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) - [:day, :month, :year].map do |i| + range_values.map do |i| "#{y}of3#{i}" end else @@ -130,7 +142,7 @@ def question_possible_sub_keys(question) private def count_questions meth - questions.map { |q| q.send(meth) ? 1 : 0 }.reduce(:+) + questions.sum { |q| q.send(meth) ? 1 : 0 } end end @@ -146,13 +158,22 @@ def context context def submit text, &block s = StepSubmit.new text b = StepSubmitBuilder.new s - b.instance_eval &block if block + b.instance_eval(&block) if block @step.submit = s end + # rubocop:disable Style/MissingRespondToMissing 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 = begin + QaeFormBuilder.const_get("#{meth.to_s.camelize}QuestionBuilder") + rescue + nil + end + klass = begin + QaeFormBuilder.const_get("#{meth.to_s.camelize}Question") + rescue + nil + end if klass_builder && klass && args.length >= 2 && args.length <= 3 id, title, opts = args @@ -161,13 +182,14 @@ def method_missing(meth, *args, &block) super end end + # rubocop:enable Style/MissingRespondToMissing private def create_question builder_klass, klass, id, title, opts = {}, &block q = klass.new @step, id, title, opts b = builder_klass.new q - b.instance_eval &block if block_given? + b.instance_eval(&block) if block @step.questions << q if q.respond_to?(:linkable?) && q.linkable? diff --git a/forms/qae_form_builder/sub_fields_question.rb b/forms/qae_form_builder/sub_fields_question.rb index e0b82508c4..0f3afcf5ba 100644 --- a/forms/qae_form_builder/sub_fields_question.rb +++ b/forms/qae_form_builder/sub_fields_question.rb @@ -6,7 +6,7 @@ def errors if question.required? question.required_sub_fields.each do |sub_field| suffix = sub_field.keys[0] - if !question.input_value(suffix: suffix).present? + if question.input_value(suffix: suffix).blank? result[question.hash_key(suffix: suffix)] ||= "" result[question.hash_key(suffix: suffix)] << "Question #{question.ref || question.sub_ref} is incomplete. #{suffix.to_s.humanize} is required and and must be filled in." end @@ -16,7 +16,7 @@ def errors question.sub_fields.each do |sub_field| suffix = sub_field.keys[0] - length = question.input_value(suffix: suffix).to_s.split(" ").reject(&:blank?).length + length = question.input_value(suffix: suffix).to_s.split(" ").count { |element| element.present? } limit = question.delegate_obj.sub_fields_words_max diff --git a/forms/qae_form_builder/subsidiaries_associates_plants_question.rb b/forms/qae_form_builder/subsidiaries_associates_plants_question.rb index c54e44cc93..21c5bf1548 100644 --- a/forms/qae_form_builder/subsidiaries_associates_plants_question.rb +++ b/forms/qae_form_builder/subsidiaries_associates_plants_question.rb @@ -17,10 +17,10 @@ def subsidiaries @subsidiaries ||= answers[delegate_obj.key.to_s] || [] end - alias :entities :subsidiaries + alias_method :entities, :subsidiaries def required_sub_fields_list - %w(name location employees) + %w[name location employees] end end end diff --git a/forms/qae_form_builder/text_question.rb b/forms/qae_form_builder/text_question.rb index b52bde84fb..1de494c567 100644 --- a/forms/qae_form_builder/text_question.rb +++ b/forms/qae_form_builder/text_question.rb @@ -6,7 +6,7 @@ class TextQuestionValidator < QuestionValidator def errors result = super - length = question.input_value.to_s.split(" ").reject(&:blank?).length + length = question.input_value.to_s.split(" ").count { |element| element.present? } limit = question.delegate_obj.text_words_max diff --git a/forms/qae_form_builder/textarea_question.rb b/forms/qae_form_builder/textarea_question.rb index 2aa0863f0f..12d24100ec 100644 --- a/forms/qae_form_builder/textarea_question.rb +++ b/forms/qae_form_builder/textarea_question.rb @@ -3,12 +3,9 @@ class TextareaQuestionValidator < QuestionValidator def errors result = super - length = ActionView::Base.full_sanitizer.sanitize( - question.input_value.to_s, - ).split(" ") - .reject do |a| - a.blank? - end.length + length = ActionView::Base.full_sanitizer.sanitize(question.input_value.to_s) + .split(" ") + .count { |a| a.present? } limit = question.delegate_obj.words_max diff --git a/forms/qae_form_builder/trade_commercial_success_question.rb b/forms/qae_form_builder/trade_commercial_success_question.rb index 1264edb68d..497d92a6da 100644 --- a/forms/qae_form_builder/trade_commercial_success_question.rb +++ b/forms/qae_form_builder/trade_commercial_success_question.rb @@ -13,7 +13,7 @@ class PlaceholderPreselectedCondition def initialize(question_key, options = {}) @question_key = question_key options.each do |key, value| - instance_variable_set("@#{key}", value) + instance_variable_set(:"@#{key}", value) end end end @@ -48,6 +48,8 @@ def default_option(option) end class TradeCommercialSuccessQuestionDecorator < QuestionDecorator + delegate :placeholder_preselected_conditions, to: :delegate_obj + def linked_answers answers[delegate_obj.question_key.to_s] || [] end @@ -75,10 +77,6 @@ def preselected_condition end end - def placeholder_preselected_conditions - delegate_obj.placeholder_preselected_conditions - end - def preselected_condition_by_option(option) placeholder_preselected_conditions.detect do |condition| condition.question_value == option.value diff --git a/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb b/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb index 14d822e496..54b1947efc 100644 --- a/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb +++ b/forms/qae_form_builder/trade_most_recent_financial_year_options_question.rb @@ -1,16 +1,5 @@ class QaeFormBuilder class TradeMostRecentFinancialYearOptionsQuestionValidator < OptionsQuestionValidator - def errors - result = {} - - date, range = question.get_changeable_date_range - - if date.present? && range.present? && !date.in?(range) && question.year_has_changed? - result[question.key] = "You can only change the year if your dates in question D2 range between #{from.decorate.formatted_trigger_date} to #{to.decorate.formatted_trigger_date}." - end - - result - end end class TradeMostRecentFinancialYearOptionsQuestionBuilder < OptionsQuestionBuilder @@ -47,16 +36,16 @@ def get_changeable_date_range to_ts = to&.trigger_at date, range = if [from_ts, to_ts].all?(&:present?) - begin - r = (Date.new(1900, from_ts.month, from_ts.day)..Date.new(1900, to_ts.month, to_ts.day)) - rescue ArgumentError - r = (Date.new(1900, from_ts.month, from_ts.day - 1)..Date.new(1900, to_ts.month, to_ts.day - 1)) - end - d = if financial_year_date_parts.values.none?(&:nil?) - Date.new(1900, financial_year_date_parts[:month], financial_year_date_parts[:day]) - end + begin + r = (Date.new(1900, from_ts.month, from_ts.day)..Date.new(1900, to_ts.month, to_ts.day)) + rescue ArgumentError + r = (Date.new(1900, from_ts.month, from_ts.day - 1)..Date.new(1900, to_ts.month, to_ts.day - 1)) + end + d = if financial_year_date_parts.values.none?(&:nil?) + Date.new(1900, financial_year_date_parts[:month], financial_year_date_parts[:day]) + end - [d, r] + [d, r] end [date, range] diff --git a/forms/qae_form_builder/turnover_exports_calculation_question.rb b/forms/qae_form_builder/turnover_exports_calculation_question.rb index ee42de6aa5..c3a209335e 100644 --- a/forms/qae_form_builder/turnover_exports_calculation_question.rb +++ b/forms/qae_form_builder/turnover_exports_calculation_question.rb @@ -31,16 +31,19 @@ def active_by_year_condition if c.question_value.respond_to?(:call) q = form[c.question_key] if q.is_a?(QaeFormBuilder::DateQuestion) || q.is_a?(QaeFormBuilder::DateQuestionDecorator) - date = [] - q.required_sub_fields.each do |sub| - date << q.input_value(suffix: sub.keys[0]) + date = q.required_sub_fields.map do |sub| + q.input_value(suffix: sub.keys[0]) end - date = Date.parse(date.join("/")) rescue nil + date = begin + Date.parse(date.join("/")) + rescue + nil + end - c.question_value.(date) + c.question_value.call(date) else - c.question_value.(form[c.question_key].input_value) + c.question_value.call(form[c.question_key].input_value) end else form[c.question_key].input_value == c.question_value diff --git a/forms/qae_form_builder/upload_question.rb b/forms/qae_form_builder/upload_question.rb index 77aa91727b..0356fcc99c 100644 --- a/forms/qae_form_builder/upload_question.rb +++ b/forms/qae_form_builder/upload_question.rb @@ -10,6 +10,7 @@ def max_attachments num def links @q.links = true end + def description @q.description = true end diff --git a/forms/qae_form_builder/user_info_question.rb b/forms/qae_form_builder/user_info_question.rb index af2b743bb2..d47b396ef5 100644 --- a/forms/qae_form_builder/user_info_question.rb +++ b/forms/qae_form_builder/user_info_question.rb @@ -6,7 +6,7 @@ def errors if question.required? question.required_sub_fields.each do |sub_field| suffix = sub_field.keys[0] - if !question.input_value(suffix: suffix).present? + if question.input_value(suffix: suffix).blank? result[question.hash_key(suffix: suffix)] ||= "" result[question.hash_key(suffix: suffix)] << " Can't be blank." end diff --git a/forms/qae_form_builder/year_question.rb b/forms/qae_form_builder/year_question.rb index 54fd8f293b..a9ac6770bc 100644 --- a/forms/qae_form_builder/year_question.rb +++ b/forms/qae_form_builder/year_question.rb @@ -4,7 +4,7 @@ def errors result = super if question.required? - if !question.input_value.present? + if question.input_value.blank? result[question.hash_key] ||= "" result[question.hash_key] = "Question #{question.ref || question.sub_ref} is incomplete. It is required and and must be filled in. Use the format YYYY." end diff --git a/lib/extensions/action_mailer/message_delivery_decorator.rb b/lib/extensions/action_mailer/message_delivery_decorator.rb index 07e1f9485e..faa73e8bfe 100644 --- a/lib/extensions/action_mailer/message_delivery_decorator.rb +++ b/lib/extensions/action_mailer/message_delivery_decorator.rb @@ -25,4 +25,3 @@ def enqueue_delivery(delivery_method, options = {}) if ::ActionMailer::MessageDelivery.included_modules.exclude?(Extensions::ActionMailer::MessageDeliveryDecorator) ::ActionMailer::MessageDelivery.prepend(Extensions::ActionMailer::MessageDeliveryDecorator) end - diff --git a/lib/sic_code.rb b/lib/sic_code.rb index 3fa0dece14..1a7b3f38f8 100644 --- a/lib/sic_code.rb +++ b/lib/sic_code.rb @@ -3,11 +3,11 @@ class SicCode < ActiveYaml::Base REGEX = /\A\d{4}(\/\d{1})?\z/ # based on the sic codes spreadsheet - set_root_path "#{Rails.root}/db/fixtures" + set_root_path Rails.root.join("db/fixtures") set_filename "sic_codes" - def self.load_csv(csv_filename = "#{Rails.root}/sic_codes.csv") - csv = CSV.parse File.open(csv_filename).read + def self.load_csv(csv_filename = Rails.root.join("sic_codes.csv")) + csv = CSV.parse File.read(csv_filename) headers = { 0 => "code", @@ -20,7 +20,7 @@ def self.load_csv(csv_filename = "#{Rails.root}/sic_codes.csv") 7 => "year6", } - res = csv[1..-1].map do |row| + res = csv[1..].map do |row| out = {} headers.each do |index, attr_name| out[attr_name] = row[index] @@ -28,7 +28,7 @@ def self.load_csv(csv_filename = "#{Rails.root}/sic_codes.csv") out end - file = File.open("#{Rails.root}/sic_codes.yml", "w+") + file = File.open(Rails.root.join("sic_codes.yml"), "w+") file.write(res.to_yaml) file.close end @@ -44,7 +44,7 @@ def self.load_csv(csv_filename = "#{Rails.root}/sic_codes.csv") } def by_year(year) - public_send("year#{year}") + public_send(:"year#{year}") end def name diff --git a/lib/tasks/cf.rake b/lib/tasks/cf.rake index e9d735394a..60f0d31628 100644 --- a/lib/tasks/cf.rake +++ b/lib/tasks/cf.rake @@ -1,8 +1,8 @@ namespace :cf do desc "We should run migrations on the first application instance" - task :run_migrations do + task run_migrations: :environment do instance_index = ENV["CF_INSTANCE_INDEX"] - exit(0) if !instance_index.present? || !instance_index.to_i.zero? + exit(0) if instance_index.blank? || !instance_index.to_i.zero? end end diff --git a/lib/tasks/feedbacks.rake b/lib/tasks/feedbacks.rake index 1740339a49..c6db28a8e3 100644 --- a/lib/tasks/feedbacks.rake +++ b/lib/tasks/feedbacks.rake @@ -1,10 +1,10 @@ namespace :feedbacks do desc "Add locked_at to all submitted feedbacks" - task :populate_locked_at => :environment do + task populate_locked_at: :environment do Feedback.submitted.where(locked_at: nil).update_all(locked_at: Time.zone.now) end - task :populate_sustainable_development_feedback => :environment do + task populate_sustainable_development_feedback: :environment do FormAnswer.not_shortlisted.where(award_type: "development").each do |form_answer| feedback = form_answer.feedback || form_answer.build_feedback primary_assignment = form_answer.assessor_assignments.primary diff --git a/lib/tasks/form_answers.rake b/lib/tasks/form_answers.rake index bee56e2c8a..7469339e00 100644 --- a/lib/tasks/form_answers.rake +++ b/lib/tasks/form_answers.rake @@ -18,11 +18,9 @@ namespace :form_answers do f.update_column(:submitted_at, current_time) puts "[form answer] #{f.id} updating submitted_at with #{current_time}" end - else - if f.submitted - f.update_column(:submitted_at, f.created_at) - puts "[form answer] #{f.id} updating submitted_at with #{f.created_at}" - end + elsif f.submitted + f.update_column(:submitted_at, f.created_at) + puts "[form answer] #{f.id} updating submitted_at with #{f.created_at}" end end end @@ -32,12 +30,12 @@ namespace :form_answers do not_updated_entries = [] AwardYear.current.form_answers.submitted.find_each do |form_answer| - form_answer.generate_pdf_version! - sleep 1 + form_answer.generate_pdf_version! + sleep 1 - puts "[form_answer]---------------------------------#{form_answer.id} updated" + puts "[form_answer]---------------------------------#{form_answer.id} updated" rescue - not_updated_entries << form_answer.id + not_updated_entries << form_answer.id end puts "[not_updated_entries] ------------ #{not_updated_entries.inspect}" @@ -60,7 +58,7 @@ namespace :form_answers do desc "fixes attachment arrays" task fix_attachments: :environment do FormAnswer.find_each do |f| - if f.document["innovation_materials"].kind_of? Array + if f.document["innovation_materials"].is_a? Array array = f.document["innovation_materials"] hash = {} array.each_index do |i| @@ -224,8 +222,10 @@ namespace :form_answers do puts "Updating form answers..." + keys = %w[personal_address_county nominee_personal_address_county organization_address_county] + county_mapper.each do |wrong_county, correct_county| - %w(personal_address_county nominee_personal_address_county organization_address_county).each do |key| + keys.each do |key| FormAnswer.where("document ->> '#{key}' = '#{wrong_county}'").find_each do |answer| answer.document[key] = correct_county answer.save(validate: false) diff --git a/lib/tasks/temprary/feedbacks_and_assessor_assessments_version_bump.rake b/lib/tasks/temprary/feedbacks_and_assessor_assessments_version_bump.rake index d18470f3ed..ca297d2f27 100644 --- a/lib/tasks/temprary/feedbacks_and_assessor_assessments_version_bump.rake +++ b/lib/tasks/temprary/feedbacks_and_assessor_assessments_version_bump.rake @@ -5,5 +5,3 @@ namespace :db do Feedback.all.map { |f| f.touch_with_version } end end - - diff --git a/lib/tasks/temprary/fix_assessments.rake b/lib/tasks/temprary/fix_assessments.rake index 961de4ce72..f92b38e949 100644 --- a/lib/tasks/temprary/fix_assessments.rake +++ b/lib/tasks/temprary/fix_assessments.rake @@ -6,7 +6,7 @@ namespace :db do desc "fix wrong assessments on dev and staging" task fix_wrong_assessments_on_dev_and_staging: :environment do - entries = AssessorAssignment.where(award_year_id: AwardYear.find_by(year: 2017), position: [0, 1, 4]).where("assessed_at IS NOT NULL") + entries = AssessorAssignment.where(award_year_id: AwardYear.find_by(year: 2017), position: [0, 1, 4]).where.not(assessed_at: nil) # Move strategy to "corporate_social_responsibility" # and remove strategy as these award types should not have strategy @@ -44,7 +44,7 @@ namespace :db do desc "fix appraisal forms on dev and staging" task fix_staging_dev_apprailsal_forms: :environment do - entries = AssessorAssignment.where(award_year_id: AwardYear.find_by(year: 2017), position: [0, 1, 4]).where("assessed_at IS NOT NULL") + entries = AssessorAssignment.where(award_year_id: AwardYear.find_by(year: 2017), position: [0, 1, 4]).where.not(assessed_at: nil) # Reject strategy for development diff --git a/lib/tasks/temprary/fix_sust_dev_assessments.rake b/lib/tasks/temprary/fix_sust_dev_assessments.rake index e0468ae8f5..9515b73de5 100644 --- a/lib/tasks/temprary/fix_sust_dev_assessments.rake +++ b/lib/tasks/temprary/fix_sust_dev_assessments.rake @@ -6,7 +6,7 @@ namespace :db do desc "fix appraisal forms on dev and staging" task fix_sust_dev_apprailsal_forms_v: :environment do - entries = AssessorAssignment.where(award_year_id: AwardYear.find_by(year: 2017), position: [0, 1, 4]).where("assessed_at IS NOT NULL") + entries = AssessorAssignment.where(award_year_id: AwardYear.find_by(year: 2017), position: [0, 1, 4]).where.not(assessed_at: nil) development = entries.select { |e| e.form_answer.award_type == "development" } diff --git a/lib/tasks/temprary/update_mobility_forms.rake b/lib/tasks/temprary/update_mobility_forms.rake index 8961dd092d..7c80427003 100644 --- a/lib/tasks/temprary/update_mobility_forms.rake +++ b/lib/tasks/temprary/update_mobility_forms.rake @@ -4,7 +4,7 @@ namespace :db do mobility_appraisals = AssessorAssignment.joins(:form_answer) .where(award_year: AwardYear.find_by(year: 2017), position: [0, 1, 4], - form_answers: { award_type: "mobility" },) + form_answers: { award_type: "mobility" }) appraisals_removed_keys = [ "mobility_programme_benefit_desc", diff --git a/lib/tasks/users_reports.rake b/lib/tasks/users_reports.rake index 7e43b3e78e..d4bbc7603d 100644 --- a/lib/tasks/users_reports.rake +++ b/lib/tasks/users_reports.rake @@ -1,10 +1,8 @@ namespace :users_reports do desc "CSV of users for sending them a survey" task :export_csv, [:year] => :environment do |task, args| - output_directory = Rails.root.join("tmp").to_s - - CSV.open(Rails.root.join("tmp", "submitted.csv").to_s , "wb") do |submitted_csv| - CSV.open(Rails.root.join("tmp", "not_submitted.csv").to_s , "wb") do |not_submitted_csv| + CSV.open(Rails.root.join("tmp/submitted.csv").to_s, "wb") do |submitted_csv| + CSV.open(Rails.root.join("tmp/not_submitted.csv").to_s, "wb") do |not_submitted_csv| User.includes(:form_answers).find_each do |user| if user.form_answers.for_year(args[:year]).submitted.any? submitted_csv << [user.email, user.first_name, user.last_name] diff --git a/spec/acceptance/steps/application_form_creation_steps.rb b/spec/acceptance/steps/application_form_creation_steps.rb index cf96726a35..64fb942a14 100644 --- a/spec/acceptance/steps/application_form_creation_steps.rb +++ b/spec/acceptance/steps/application_form_creation_steps.rb @@ -17,15 +17,15 @@ end step "I should see innovation application link" do - expect(page).to have_link("New application", href:"/apply_innovation_award") + expect(page).to have_link("New application", href: "/apply_innovation_award") end step "I should see international trade application link" do - expect(page).to have_link("New application", href:"/apply_international_trade_award") + expect(page).to have_link("New application", href: "/apply_international_trade_award") end step "I should see sustainable development application link" do - expect(page).to have_link("New application", href:"/apply_sustainable_development_award") + expect(page).to have_link("New application", href: "/apply_sustainable_development_award") end step "I create innovation form" do @@ -33,7 +33,7 @@ click_link "New application", href: "/apply_innovation_award" click_button "Save and start eligibility questionnaire" click_link "Continue to eligibility questions" - click_button "Continue" #eligibility step + click_button "Continue" # eligibility step end step "I create international trade form" do @@ -41,7 +41,7 @@ click_link "New application", href: "/apply_international_trade_award" click_button "Start eligibility questionnaire" click_link "Continue to eligibility questions" - click_button "Continue" #eligibility step + click_button "Continue" # eligibility step end step "I create sustainable development form" do @@ -49,7 +49,7 @@ click_link "New application", href: "/apply_sustainable_development_award" click_button "Start eligibility questionnaire" click_link "Continue to eligibility questions" - click_button "Continue" #eligibility step + click_button "Continue" # eligibility step end step "I should see qae form" do diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index e69de29bb2..4dd1ec55a4 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -0,0 +1,60 @@ +require "rails_helper" + +describe AccountsController do + let(:old_password) { "^#ur9EkLm@1W+OaDvgTT" } + let(:new_password) { "^#ur9EkLm@1W+OaDvg" } + + let(:user) { create(:user, :completed_profile, password: "^#ur9EkLm@1W+OaDvgTT", password_confirmation: "^#ur9EkLm@1W+OaDvgTT") } + + before do + sign_in user + end + + describe "PATCH #update_password_settings" do + context "with valid params" do + it "updates the password and redirects to the dashboard with a success message" do + patch :update_password_settings, params: { + user: { + current_password: old_password, + password: new_password, + password_confirmation: new_password, + }, + } + + user.reload + expect(user.valid_password?(new_password)).to be_truthy + expect(flash[:notice]).to eq("Your account details were successfully saved") + expect(response).to redirect_to(dashboard_path) + end + end + + context "with invalid params" do + it "does not update the password and renders the password_settings template with an error message" do + patch :update_password_settings, params: { + user: { + current_password: "wrong_password", + password: new_password, + password_confirmation: new_password, + }, + } + + user.reload + expect(user.valid_password?(new_password)).to be_falsey + expect(flash[:alert]).to eq("Error updating your password") + expect(response).to render_template(:password_settings) + end + + it "sets @active_step to 5" do + patch :update_password_settings, params: { + user: { + current_password: "wrong_password", + password: new_password, + password_confirmation: new_password, + }, + } + + expect(assigns(:active_step)).to eq(5) + end + end + end +end diff --git a/spec/controllers/admin/admins_controller_spec.rb b/spec/controllers/admin/admins_controller_spec.rb index 0cde7121c0..b1a2d1dbe9 100644 --- a/spec/controllers/admin/admins_controller_spec.rb +++ b/spec/controllers/admin/admins_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::AdminsController do let!(:admin) { create(:admin, superadmin: true) } diff --git a/spec/controllers/admin/assessment_submissions_controller_spec.rb b/spec/controllers/admin/assessment_submissions_controller_spec.rb index 294c9d0889..814f26aeb8 100644 --- a/spec/controllers/admin/assessment_submissions_controller_spec.rb +++ b/spec/controllers/admin/assessment_submissions_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::AssessmentSubmissionsController do let!(:admin) { create(:admin, superadmin: true) } @@ -25,7 +24,7 @@ let(:form_answer) { assessor_assignment.form_answer } context "primary assessment" do - let!(:assessor_assignment) { create(:assessor_assignment, position: "primary", locked_at: Time.now) } + let!(:assessor_assignment) { create(:assessor_assignment, position: "primary", locked_at: Time.current) } before do form_answer.update_column(:state, "recommended") diff --git a/spec/controllers/admin/assessors_controller_spec.rb b/spec/controllers/admin/assessors_controller_spec.rb index 3e54f6346c..6b803d90c6 100644 --- a/spec/controllers/admin/assessors_controller_spec.rb +++ b/spec/controllers/admin/assessors_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::AssessorsController do let!(:admin) { create(:admin, superadmin: true) } diff --git a/spec/controllers/admin/audit_certificates_controller_spec.rb b/spec/controllers/admin/audit_certificates_controller_spec.rb index ab074afc12..e4ff26a601 100644 --- a/spec/controllers/admin/audit_certificates_controller_spec.rb +++ b/spec/controllers/admin/audit_certificates_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::AuditCertificatesController do let!(:admin) { create(:admin, superadmin: true) } @@ -13,7 +12,7 @@ it "assigns @resources" do allow_any_instance_of(FormAnswer).to receive(:promotion?) { false } allow_any_instance_of(FormAnswer).to receive(:shortlisted?) { true } - get :download_initial_pdf, params: { form_answer_id: form_answer.id }, :format => "pdf" + get :download_initial_pdf, params: { form_answer_id: form_answer.id }, format: "pdf" expect(response.content_type).to eq("application/pdf") end end diff --git a/spec/controllers/admin/audit_logs_controller_spec.rb b/spec/controllers/admin/audit_logs_controller_spec.rb index cfa83566a6..b1d5c9f796 100644 --- a/spec/controllers/admin/audit_logs_controller_spec.rb +++ b/spec/controllers/admin/audit_logs_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::AuditLogsController do let!(:admin) { create(:admin, superadmin: true) } diff --git a/spec/controllers/admin/comments_controller_spec.rb b/spec/controllers/admin/comments_controller_spec.rb index 819cfb40be..065fbc0a73 100644 --- a/spec/controllers/admin/comments_controller_spec.rb +++ b/spec/controllers/admin/comments_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::CommentsController do let!(:admin) { create(:admin, superadmin: true) } diff --git a/spec/controllers/admin/custom_emails_controller_spec.rb b/spec/controllers/admin/custom_emails_controller_spec.rb index abc5dff1d2..ad4882f564 100644 --- a/spec/controllers/admin/custom_emails_controller_spec.rb +++ b/spec/controllers/admin/custom_emails_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::CustomEmailsController do let!(:admin) { create(:admin, superadmin: true) } diff --git a/spec/controllers/admin/deadlines_controller_spec.rb b/spec/controllers/admin/deadlines_controller_spec.rb index ed26f97ee9..d0b87436c1 100644 --- a/spec/controllers/admin/deadlines_controller_spec.rb +++ b/spec/controllers/admin/deadlines_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::DeadlinesController do let!(:admin) { create(:admin, superadmin: true) } @@ -10,7 +9,7 @@ describe "PUT update" do it "should update a resource" do deadline = create(:deadline) - time = Time.now + time = Time.current put :update, params: { id: deadline.id, deadline: { trigger_at: time } } expect(response).to redirect_to admin_settings_path end diff --git a/spec/controllers/admin/email_notifications_controller_spec.rb b/spec/controllers/admin/email_notifications_controller_spec.rb index 220a4491ea..119bc107e8 100644 --- a/spec/controllers/admin/email_notifications_controller_spec.rb +++ b/spec/controllers/admin/email_notifications_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::EmailNotificationsController do let!(:admin) { create(:admin, superadmin: true) } diff --git a/spec/controllers/admin/form_answer_state_transitions_controller_spec.rb b/spec/controllers/admin/form_answer_state_transitions_controller_spec.rb index 27bb39f5cf..02cfc48cac 100644 --- a/spec/controllers/admin/form_answer_state_transitions_controller_spec.rb +++ b/spec/controllers/admin/form_answer_state_transitions_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::FormAnswerStateTransitionsController do let!(:admin) { create(:admin, superadmin: true) } @@ -14,7 +13,7 @@ it "should create a resource" do allow_any_instance_of(AssessmentSubmissionService).to receive(:perform) {} post :create, params: { - form_answer_id: form_answer.id , + form_answer_id: form_answer.id, form_answer_state_transition: { state: "recommended" }, } @@ -25,7 +24,7 @@ form_answer_state_transition: { state: "recommended" }, }, xhr: true - expect(response).to render_template(:partial => "admin/form_answers/_states_list") + expect(response).to render_template(partial: "admin/form_answers/_states_list") end end end diff --git a/spec/controllers/admin/press_summaries_controller_spec.rb b/spec/controllers/admin/press_summaries_controller_spec.rb index f92dea2e79..0204d15425 100644 --- a/spec/controllers/admin/press_summaries_controller_spec.rb +++ b/spec/controllers/admin/press_summaries_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::PressSummariesController do let!(:admin) { create(:admin, superadmin: true) } diff --git a/spec/controllers/admin/settings_controller_spec.rb b/spec/controllers/admin/settings_controller_spec.rb index ab931c466f..fdcd651cdc 100644 --- a/spec/controllers/admin/settings_controller_spec.rb +++ b/spec/controllers/admin/settings_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::SettingsController do let!(:admin) { create(:admin, superadmin: true) } diff --git a/spec/controllers/admin/support_letters_controller_spec.rb b/spec/controllers/admin/support_letters_controller_spec.rb index 814f51afff..48bd0d7826 100644 --- a/spec/controllers/admin/support_letters_controller_spec.rb +++ b/spec/controllers/admin/support_letters_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Admin::SupportLettersController do let!(:admin) { create(:admin, superadmin: true) } diff --git a/spec/controllers/assessor/assessment_submissions_controller_spec.rb b/spec/controllers/assessor/assessment_submissions_controller_spec.rb index ec4022eac9..58ebe27b91 100644 --- a/spec/controllers/assessor/assessment_submissions_controller_spec.rb +++ b/spec/controllers/assessor/assessment_submissions_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Assessor::AssessmentSubmissionsController do let!(:assessor) { create(:assessor) } diff --git a/spec/controllers/assessor/comments_controller_spec.rb b/spec/controllers/assessor/comments_controller_spec.rb index af1456706d..005fb5553d 100644 --- a/spec/controllers/assessor/comments_controller_spec.rb +++ b/spec/controllers/assessor/comments_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Assessor::CommentsController do let!(:assessor) { create(:assessor) } diff --git a/spec/controllers/assessor/reports_controller_spec.rb b/spec/controllers/assessor/reports_controller_spec.rb index 7194853175..8ffcaea3a4 100644 --- a/spec/controllers/assessor/reports_controller_spec.rb +++ b/spec/controllers/assessor/reports_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Assessor::ReportsController do let!(:assessor) { create(:assessor) } @@ -19,10 +18,10 @@ describe "GET show" do it "renders the show template" do - get :show, params: { id: "feedbacks", category: "trade" }, :format => "pdf" + get :show, params: { id: "feedbacks", category: "trade" }, format: "pdf" expect(response.content_type).to eq("application/pdf") - get :show, params: { id: "case_summaries", category: "trade" }, :format => "csv" + get :show, params: { id: "case_summaries", category: "trade" }, format: "csv" expect(response.content_type).to eq("text/csv") end end diff --git a/spec/controllers/form/awards_controller_spec.rb b/spec/controllers/form/awards_controller_spec.rb index 3b20425e1b..24c06b6ba7 100644 --- a/spec/controllers/form/awards_controller_spec.rb +++ b/spec/controllers/form/awards_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Form::AwardsController do let!(:user) { create(:user) } diff --git a/spec/controllers/form/current_queen_awards_controller_spec.rb b/spec/controllers/form/current_queen_awards_controller_spec.rb index 048ca13114..2b5f994a1e 100644 --- a/spec/controllers/form/current_queen_awards_controller_spec.rb +++ b/spec/controllers/form/current_queen_awards_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Form::CurrentQueensAwardsController do let!(:user) { create(:user) } diff --git a/spec/controllers/form/form_attachments_controller_spec.rb b/spec/controllers/form/form_attachments_controller_spec.rb index 6e96852e52..88107297d7 100644 --- a/spec/controllers/form/form_attachments_controller_spec.rb +++ b/spec/controllers/form/form_attachments_controller_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers RSpec.describe Form::FormAttachmentsController do let!(:user) { create(:user) } diff --git a/spec/controllers/form_controller_spec.rb b/spec/controllers/form_controller_spec.rb index 1393ec8b48..d0e0d6d3f4 100644 --- a/spec/controllers/form_controller_spec.rb +++ b/spec/controllers/form_controller_spec.rb @@ -38,66 +38,90 @@ describe "#new_international_trade_form" do it "allows to open trade form if it is the first one" do - expect(get :new_international_trade_form).to redirect_to(edit_form_url(FormAnswer.where(award_type: "trade").last)) + expect(get(:new_international_trade_form)).to redirect_to(edit_form_url(FormAnswer.where(award_type: "trade").last)) end it "denies to open trade form if it is not the first one" do create :form_answer, :trade, user: user - expect(get :new_international_trade_form).to redirect_to(dashboard_url) + expect(get(:new_international_trade_form)).to redirect_to(dashboard_url) end end describe "#new_social_mobility_form" do it "allows to open mobility form" do - expect(get :new_social_mobility_form).to redirect_to(edit_form_url(FormAnswer.where(award_type: "mobility").last)) + expect(get(:new_social_mobility_form)).to redirect_to(edit_form_url(FormAnswer.where(award_type: "mobility").last)) end end context "individual deadlines" do describe "#new_international_trade_form" do it "allows to create an application if trade start deadline has past" do - expect(get :new_international_trade_form).to redirect_to(edit_form_url(FormAnswer.where(award_type: "trade").last)) + expect(get(:new_international_trade_form)).to redirect_to(edit_form_url(FormAnswer.where(award_type: "trade").last)) end it "does not allow to create an application if trade start deadline has not past" do Settings.current.deadlines.trade_submission_start.update_column(:trigger_at, Time.zone.now + 1.day) - expect(get :new_international_trade_form).to redirect_to(dashboard_url) + expect(get(:new_international_trade_form)).to redirect_to(dashboard_url) end end describe "#new_social_mobility_form" do it "allows to create an application if mobility deadline has past" do - expect(get :new_social_mobility_form).to redirect_to(edit_form_url(FormAnswer.where(award_type: "mobility").last)) + expect(get(:new_social_mobility_form)).to redirect_to(edit_form_url(FormAnswer.where(award_type: "mobility").last)) end it "does not allow to create an application if mobility start deadline has not past" do Settings.current.deadlines.mobility_submission_start.update_column(:trigger_at, Time.zone.now + 1.day) - expect(get :new_social_mobility_form).to redirect_to(dashboard_url) + expect(get(:new_social_mobility_form)).to redirect_to(dashboard_url) end end describe "#new_sustainable_development_form" do it "allows to create an application if trade development deadline has past" do - expect(get :new_sustainable_development_form).to redirect_to(edit_form_url(FormAnswer.where(award_type: "development").last)) + expect(get(:new_sustainable_development_form)).to redirect_to(edit_form_url(FormAnswer.where(award_type: "development").last)) end it "does not allow to create an application if development start deadline has not past" do Settings.current.deadlines.development_submission_start.update_column(:trigger_at, Time.zone.now + 1.day) - expect(get :new_sustainable_development_form).to redirect_to(dashboard_url) + expect(get(:new_sustainable_development_form)).to redirect_to(dashboard_url) end end describe "#new_innovation_form" do it "allows to create an application if innovation start deadline has past" do - expect(get :new_innovation_form).to redirect_to(edit_form_url(FormAnswer.where(award_type: "innovation").last)) + expect(get(:new_innovation_form)).to redirect_to(edit_form_url(FormAnswer.where(award_type: "innovation").last)) end it "does not allow to create an application if innovation start deadline has not past" do Settings.current.deadlines.innovation_submission_start.update_column(:trigger_at, Time.zone.now + 1.day) - expect(get :new_innovation_form).to redirect_to(dashboard_url) + expect(get(:new_innovation_form)).to redirect_to(dashboard_url) end end end + + describe "#add_attachment" do + let(:file) { Rack::Test::UploadedFile.new(Rails.root.join("spec/fixtures/cat.jpg"), "image/jpeg") } + + it "adds attachment to the form answer" do + expect { + post :add_attachment, params: { + form: { + file: file, + }, + id: form_answer.id, + question_key: "org_chart", + } + }.to change { + form_answer.reload.form_answer_attachments.count + }.by(1) + + expect(response).to have_http_status(:created) + + id = JSON.parse(response.body)["id"] + attachment = FormAnswerAttachment.find_by(id: id) + expect(attachment).to be_present + end + end end diff --git a/spec/decorators/assessor_assignment_decorator_spec.rb b/spec/decorators/assessor_assignment_decorator_spec.rb index 5fb58ab76e..5eae5a5303 100644 --- a/spec/decorators/assessor_assignment_decorator_spec.rb +++ b/spec/decorators/assessor_assignment_decorator_spec.rb @@ -15,16 +15,16 @@ context "with accessed_at value" do context "with an editor" do it "returns the editable name and accessed date on a string" do - assessor_assignment.assessed_at = Time.now - expect(subject.last_editor_info).to eq("Updated by #{editor.full_name} - #{I18n.localize(assessor_assignment.assessed_at, format: :date_at_time)}") + assessor_assignment.assessed_at = Time.current + expect(subject.last_editor_info).to eq("Updated by #{editor.full_name} - #{I18n.l(assessor_assignment.assessed_at, format: :date_at_time)}") end end context "without an editor name" do it "returns the editable as Anonymous and accessed date on a string" do - assessor_assignment.assessed_at = Time.now + assessor_assignment.assessed_at = Time.current assessor_assignment.editable = User.new - expect(subject.last_editor_info).to eq("Updated by Anonymous - #{I18n.localize(assessor_assignment.assessed_at, format: :date_at_time)}") + expect(subject.last_editor_info).to eq("Updated by Anonymous - #{I18n.l(assessor_assignment.assessed_at, format: :date_at_time)}") end end end diff --git a/spec/decorators/email_notification_decorator_spec.rb b/spec/decorators/email_notification_decorator_spec.rb index 7bde11afb9..0a39ec60b6 100644 --- a/spec/decorators/email_notification_decorator_spec.rb +++ b/spec/decorators/email_notification_decorator_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" describe EmailNotificationDecorator do - let(:email_notification) { EmailNotification.new(trigger_at: Time.now) } + let(:email_notification) { EmailNotification.new(trigger_at: Time.current) } let(:subject) { EmailNotificationDecorator.decorate(email_notification) } describe "#header" do diff --git a/spec/decorators/form_answer_decorator_spec.rb b/spec/decorators/form_answer_decorator_spec.rb index b792d3b13c..9b09fc8473 100644 --- a/spec/decorators/form_answer_decorator_spec.rb +++ b/spec/decorators/form_answer_decorator_spec.rb @@ -1,43 +1,43 @@ require "rails_helper" -describe FormAnswerDecorator do - DOCUMENT_FIELDS = { - nominee_organisation: "organization_address_name", - nominee_position: "nominee_position", - nominee_building: "nominee_personal_address_building", - nominee_street: "nominee_personal_address_street", - nominee_city: "nominee_personal_address_city", - nominee_county: "nominee_personal_address_county", - nominee_postcode: "nominee_personal_address_postcode", - nominee_telephone: "nominee_phone", - nominee_email: "nominee_email", - nominee_region: "nominee_personal_address_region", - nominator_building: "personal_address_building", - nominator_street: "personal_address_street", - nominator_city: "personal_address_city", - nominator_county: "personal_address_county", - nominator_postcode: "personal_address_postcode", - nominator_telephone: "personal_phone", - nominator_email: "personal_email", - registration_number: "registration_number", - website_url: "website_url", - head_of_business_title: "head_of_business_title", - head_of_business_honours: "head_of_business_honours", - head_of_business_job_title: "head_of_business_job_title", - head_of_business_email: "head_of_business_email", - applying_for: "applying_for", - parent_company: "parent_company", - parent_company_country: "parent_company_country", - parent_ultimate_control: "parent_ultimate_control", - ultimate_control_company: "ultimate_control_company", - ultimate_control_company_country: "ultimate_control_company_country", - innovation_desc_short: "innovation_desc_short", - development_desc_short: "development_desc_short", - development_management_approach_briefly: "development_management_approach_briefly", - mobility_desc_short: "mobility_desc_short", - organisation_type: "organisation_type", - } +DOCUMENT_FIELDS = { + nominee_organisation: "organization_address_name", + nominee_position: "nominee_position", + nominee_building: "nominee_personal_address_building", + nominee_street: "nominee_personal_address_street", + nominee_city: "nominee_personal_address_city", + nominee_county: "nominee_personal_address_county", + nominee_postcode: "nominee_personal_address_postcode", + nominee_telephone: "nominee_phone", + nominee_email: "nominee_email", + nominee_region: "nominee_personal_address_region", + nominator_building: "personal_address_building", + nominator_street: "personal_address_street", + nominator_city: "personal_address_city", + nominator_county: "personal_address_county", + nominator_postcode: "personal_address_postcode", + nominator_telephone: "personal_phone", + nominator_email: "personal_email", + registration_number: "registration_number", + website_url: "website_url", + head_of_business_title: "head_of_business_title", + head_of_business_honours: "head_of_business_honours", + head_of_business_job_title: "head_of_business_job_title", + head_of_business_email: "head_of_business_email", + applying_for: "applying_for", + parent_company: "parent_company", + parent_company_country: "parent_company_country", + parent_ultimate_control: "parent_ultimate_control", + ultimate_control_company: "ultimate_control_company", + ultimate_control_company_country: "ultimate_control_company_country", + innovation_desc_short: "innovation_desc_short", + development_desc_short: "development_desc_short", + development_management_approach_briefly: "development_management_approach_briefly", + mobility_desc_short: "mobility_desc_short", + organisation_type: "organisation_type", +} +describe FormAnswerDecorator do let(:user) { build_stubbed(:user, first_name: "John", last_name: "Doe") } describe "#average_growth_for" do @@ -90,8 +90,8 @@ describe "#dashboard_status" do it "returns fill progress when application is not submitted" do - form_answer = create(:form_answer, :trade, state: "application_in_progress", document: { sic_code: SicCode.first.code }) - expect(described_class.new(form_answer).dashboard_status).to eq("Application in progress...8%") + form_answer = create(:form_answer, :trade, state: "application_in_progress", document: { sic_code: SicCode.first.code }) + expect(described_class.new(form_answer).dashboard_status).to eq("Application in progress...8%") end it "warns that assessors are not assigned if assessment is in progress and assessors are not assigned yet for admin section" do diff --git a/spec/decorators/trigger_at_decorator_spec.rb b/spec/decorators/trigger_at_decorator_spec.rb index e72ea31ecb..cea08df57f 100644 --- a/spec/decorators/trigger_at_decorator_spec.rb +++ b/spec/decorators/trigger_at_decorator_spec.rb @@ -34,7 +34,7 @@ context "without a trigger_at value" do it "returns a placeholder value" do deadline = build_stubbed(:deadline, trigger_at: nil).decorate - expect(deadline.formatted_trigger_time_short).to eq("-- --- #{AwardYear.current.year} at --:--".html_safe) + expect(deadline.formatted_trigger_time_short).to eq("-- --- #{AwardYear.current.year} at --:--") end end @@ -50,7 +50,7 @@ context "without a trigger_at value" do it "returns a date placeholder value" do deadline = build_stubbed(:deadline, trigger_at: nil).decorate - expect(deadline.formatted_trigger_date).to eq("-- --- #{AwardYear.current.year}".html_safe) + expect(deadline.formatted_trigger_date).to eq("-- --- #{AwardYear.current.year}") end end diff --git a/spec/decorators/user_decorator_spec.rb b/spec/decorators/user_decorator_spec.rb index 70290f6ef1..85d7f6b1d8 100644 --- a/spec/decorators/user_decorator_spec.rb +++ b/spec/decorators/user_decorator_spec.rb @@ -7,7 +7,8 @@ last_name: "Bar", role: "account_admin", company_name: "Umbrella Corporation", - )} + ) + } let(:subject) { UserDecorator.decorate(user) } @@ -58,7 +59,7 @@ context "when already confirmed" do it "returns false" do - user.confirmed_at = Time.now + user.confirmed_at = Time.current subject = UserDecorator.decorate(user) expect(subject.confirmation_status).to be_falsy end diff --git a/spec/decorators/user_shared_decorator_spec.rb b/spec/decorators/user_shared_decorator_spec.rb index 82e26cfd26..ec6c8f47ea 100644 --- a/spec/decorators/user_shared_decorator_spec.rb +++ b/spec/decorators/user_shared_decorator_spec.rb @@ -4,7 +4,7 @@ let(:user) do build_stubbed(:user, first_name: "John", last_name: "Doe", - last_sign_in_at: DateTime.new(2015, 2, 6, 8, 30),).decorate + last_sign_in_at: DateTime.new(2015, 2, 6, 8, 30)).decorate end describe "#full_name" do diff --git a/spec/factories/audit_certificates.rb b/spec/factories/audit_certificates.rb index 5134fa35aa..7b80013125 100644 --- a/spec/factories/audit_certificates.rb +++ b/spec/factories/audit_certificates.rb @@ -3,9 +3,7 @@ association :form_answer, factory: :form_answer attachment do Rack::Test::UploadedFile.new( - File.join( - Rails.root, "spec", "support", "file_samples", "audit_certificate_sample.pdf", - ), + Rails.root.join("spec/support/file_samples/audit_certificate_sample.pdf"), ) end diff --git a/spec/factories/eligibility.rb b/spec/factories/eligibility.rb index a1eaad5cc9..64fb3b3063 100644 --- a/spec/factories/eligibility.rb +++ b/spec/factories/eligibility.rb @@ -20,7 +20,8 @@ self_contained_enterprise: true, current_holder: "no", adherence_to_esg_principles: true, - }} + } + } end trait :trade do @@ -33,7 +34,8 @@ current_holder_of_qae_for_trade: false, qae_for_trade_award_year: "2015", growth_over_the_last_three_years: true, - } } + } + } end trait :innovation do @@ -47,7 +49,8 @@ number_of_innovative_products: 1, had_impact_on_commercial_performace_over_two_years: true, have_you_recovered_all_investments: true, - }} + } + } end trait :development do @@ -58,7 +61,8 @@ has_management_and_two_employees: "yes", sustainable_development: "yes", adheres_to_sustainable_principles: "yes", - }} + } + } end trait :mobility do @@ -73,7 +77,8 @@ social_mobility_activities: "yes", active_for_atleast_two_years: "yes", evidence_of_impact: "yes", - }} + } + } end trait :promotion do @@ -90,7 +95,8 @@ nominee_has_honours: false, nominee_was_put_forward_for_honours_this_year: false, able_to_get_two_letters_of_support: true, - }} + } + } end factory :basic_eligibility, class: "Eligibility::Basic", traits: [:basic] diff --git a/spec/factories/form_answer_attachments_factory.rb b/spec/factories/form_answer_attachments_factory.rb index 33db651c5d..2bb5088bdf 100644 --- a/spec/factories/form_answer_attachments_factory.rb +++ b/spec/factories/form_answer_attachments_factory.rb @@ -3,9 +3,7 @@ association :form_answer, factory: :form_answer file do Rack::Test::UploadedFile.new( - File.join( - Rails.root, "spec", "fixtures", "cat.jpg", - ), + Rails.root.join("spec/fixtures/cat.jpg"), ) end diff --git a/spec/factories/settings_factory.rb b/spec/factories/settings_factory.rb index b9c6e94ee2..800365ef06 100644 --- a/spec/factories/settings_factory.rb +++ b/spec/factories/settings_factory.rb @@ -3,19 +3,19 @@ skip_create initialize_with do - if attributes.present? - Settings.where(attributes).first_or_create - else - Settings.first_or_create - end + if attributes.present? + Settings.where(attributes).first_or_create + else + Settings.first_or_create + end rescue ActiveRecord::RecordNotUnique - retry + retry end end trait :submission_deadlines do after(:create) do |settings| - %w(innovation trade mobility development).each do |award| + %w[innovation trade mobility development].each do |award| settings.deadlines.where(kind: "#{award}_submission_start").first.update_column(:trigger_at, Time.zone.now - 20.days) end diff --git a/spec/factories/support_letter_attachments.rb b/spec/factories/support_letter_attachments.rb index 58bf4a5410..328dd81814 100644 --- a/spec/factories/support_letter_attachments.rb +++ b/spec/factories/support_letter_attachments.rb @@ -4,9 +4,7 @@ association :form_answer, factory: :form_answer attachment do Rack::Test::UploadedFile.new( - File.join( - Rails.root, "spec", "support", "file_samples", "photo_with_size_less_than_5MB.jpg", - ), + Rails.root.join("spec/support/file_samples/photo_with_size_less_than_5MB.jpg"), ) end end diff --git a/spec/factories/vat_returns_files.rb b/spec/factories/vat_returns_files.rb index 5f998f2c3a..663adc89ba 100644 --- a/spec/factories/vat_returns_files.rb +++ b/spec/factories/vat_returns_files.rb @@ -5,9 +5,7 @@ attachment do Rack::Test::UploadedFile.new( - File.join( - Rails.root, "spec", "support", "file_samples", "audit_certificate_sample.pdf", - ), + Rails.root.join("spec/support/file_samples/audit_certificate_sample.pdf"), ) end diff --git a/spec/features/account/collaborators_spec.rb b/spec/features/account/collaborators_spec.rb index c1fdead367..17fb4e1808 100644 --- a/spec/features/account/collaborators_spec.rb +++ b/spec/features/account/collaborators_spec.rb @@ -1,12 +1,12 @@ require "rails_helper" -include Warden::Test::Helpers -include ActiveJob::TestHelper -describe "Collaborators", %q{ +describe "Collaborators", ' As a Account Admin I want to be able to add / remove collaborators to Account So that they can collaborate form answers -} do +' do + include ActiveJob::TestHelper + let!(:account_admin) do create :user, :completed_profile, @@ -34,7 +34,7 @@ create :innovation_eligibility, form_answer: form_answer, account: account - end + end let!(:trade_eligibility) do create :trade_eligibility, diff --git a/spec/features/account/lord_lieutenant_data_sharing.rb b/spec/features/account/lord_lieutenant_data_sharing.rb index d9189efb60..7432ed929c 100644 --- a/spec/features/account/lord_lieutenant_data_sharing.rb +++ b/spec/features/account/lord_lieutenant_data_sharing.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Lord-Lieutenant data sharing" do let(:new_user) { create :user } diff --git a/spec/features/admin/accounts/search_spec.rb b/spec/features/admin/accounts/search_spec.rb index 6bc6c98b3f..a127188a88 100644 --- a/spec/features/admin/accounts/search_spec.rb +++ b/spec/features/admin/accounts/search_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Users search", " As Admin diff --git a/spec/features/admin/assessors/suspention_spec.rb b/spec/features/admin/assessors/suspention_spec.rb index bd210da9a7..1ecb39e762 100644 --- a/spec/features/admin/assessors/suspention_spec.rb +++ b/spec/features/admin/assessors/suspention_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Assessor Suspension", type: :feature do let!(:admin) { create(:admin) } diff --git a/spec/features/admin/form_answers/application_feedback_pdf_spec.rb b/spec/features/admin/form_answers/application_feedback_pdf_spec.rb index 7abe34617b..efa9a4ec8e 100644 --- a/spec/features/admin/form_answers/application_feedback_pdf_spec.rb +++ b/spec/features/admin/form_answers/application_feedback_pdf_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Admin: Download an application's feedback PDF", %q{ +describe "Admin: Download an application's feedback PDF", " As an Admin I want to Print/download an application's feedback as a pdf So that I can print and review application's feedback -} do +" do let!(:admin) { create(:admin) } let!(:user) { create :user } diff --git a/spec/features/admin/form_answers/appraisal_form_submission_spec.rb b/spec/features/admin/form_answers/appraisal_form_submission_spec.rb index 84def660c4..e594e5dce8 100644 --- a/spec/features/admin/form_answers/appraisal_form_submission_spec.rb +++ b/spec/features/admin/form_answers/appraisal_form_submission_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers Warden.test_mode! diff --git a/spec/features/admin/form_answers/assessors_assignment_spec.rb b/spec/features/admin/form_answers/assessors_assignment_spec.rb index 1a1b0e6429..4f02ec523c 100644 --- a/spec/features/admin/form_answers/assessors_assignment_spec.rb +++ b/spec/features/admin/form_answers/assessors_assignment_spec.rb @@ -1,7 +1,5 @@ require "rails_helper" -include Warden::Test::Helpers - describe "Admin assigns the primary and secondary assessors" do let!(:admin) { create(:admin) } let!(:form_answer) { create(:form_answer) } diff --git a/spec/features/admin/form_answers/attachments_management_spec.rb b/spec/features/admin/form_answers/attachments_management_spec.rb index ec53058c33..84be6886c7 100644 --- a/spec/features/admin/form_answers/attachments_management_spec.rb +++ b/spec/features/admin/form_answers/attachments_management_spec.rb @@ -1,12 +1,11 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Form answer attachments management", %q{ +describe "Form answer attachments management", ' As Admin I want to see be able to view/create the attachments per application. -} do - let!(:admin){ create(:admin) } - let!(:form_answer){ create(:form_answer) } +' do + let!(:admin) { create(:admin) } + let!(:form_answer) { create(:form_answer) } before do login_admin admin @@ -15,7 +14,7 @@ it "adds the attachment" do within "#new_form_answer_attachment" do - attach_file "form_answer_attachment_file", "#{Rails.root}/spec/fixtures/cat.jpg" + attach_file "form_answer_attachment_file", Rails.root.join("spec/fixtures/cat.jpg") find("input[type='submit']").click end expect(page).to have_selector(".form_answer_attachment", count: 1) @@ -25,9 +24,7 @@ before do form_answer.form_answer_attachments.create!( file: Rack::Test::UploadedFile.new( - File.join( - Rails.root, "spec", "support", "file_samples", "photo_with_size_less_than_5MB.jpg", - ), + Rails.root.join("spec/support/file_samples/photo_with_size_less_than_5MB.jpg"), ), attachable: admin, file_scan_results: "clean", diff --git a/spec/features/admin/form_answers/case_summary_pdf_spec.rb b/spec/features/admin/form_answers/case_summary_pdf_spec.rb index 35f2ec8c4e..cedeedc69d 100644 --- a/spec/features/admin/form_answers/case_summary_pdf_spec.rb +++ b/spec/features/admin/form_answers/case_summary_pdf_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Admin: Download an application's case summaries PDF", %q{ +describe "Admin: Download an application's case summaries PDF", " As an Admin I want to Print/download an application's case summaries as a pdf So that I can print and review application's case summaries -} do +" do let!(:admin) { create(:admin) } let!(:user) { create :user } diff --git a/spec/features/admin/form_answers/case_summary_submission_spec.rb b/spec/features/admin/form_answers/case_summary_submission_spec.rb index 414115a8e8..d24bb262b1 100644 --- a/spec/features/admin/form_answers/case_summary_submission_spec.rb +++ b/spec/features/admin/form_answers/case_summary_submission_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers Warden.test_mode! diff --git a/spec/features/admin/form_answers/collaborators_spec.rb b/spec/features/admin/form_answers/collaborators_spec.rb index 9f8ab8dde2..e4a2e59521 100644 --- a/spec/features/admin/form_answers/collaborators_spec.rb +++ b/spec/features/admin/form_answers/collaborators_spec.rb @@ -1,12 +1,12 @@ require "rails_helper" -include Warden::Test::Helpers -include ActiveJob::TestHelper -describe "Collaborators", %q{ +describe "Collaborators", ' As a an Admin I want to be able to add collaborators to any account So that they can collaborate applications -} do +' do + include ActiveJob::TestHelper + let!(:admin) { create(:admin) } let!(:form_answer) do @@ -63,11 +63,11 @@ let!(:user) { create(:user, email: email) } it "should add user to collaborators with regular role" do - find("a[aria-controls='section-company-details']").click() + find("a[aria-controls='section-company-details']").click within(".admin-search-collaborators-form") do fill_in "search[query]", with: email.to_s[2..-2] - first("input[type='submit']").click() + first("input[type='submit']").click within(".js-admin-search-collaborators-results-box") do expect_to_see(user.email) diff --git a/spec/features/admin/form_answers/comments_management_spec.rb b/spec/features/admin/form_answers/comments_management_spec.rb index 2fb70da75d..e46e003626 100644 --- a/spec/features/admin/form_answers/comments_management_spec.rb +++ b/spec/features/admin/form_answers/comments_management_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Admin comments management", %( As a Admin @@ -29,9 +28,9 @@ click_button "Comment" end - expect{ + expect { first(".link-delete-comment-confirm").click - }.to change{ Comment.count }.by(-1) + }.to change { Comment.count }.by(-1) end it "displays the comments" do diff --git a/spec/features/admin/form_answers/company_details_fulfilling_spec.rb b/spec/features/admin/form_answers/company_details_fulfilling_spec.rb index 1c173a4fbf..42de7cfff3 100644 --- a/spec/features/admin/form_answers/company_details_fulfilling_spec.rb +++ b/spec/features/admin/form_answers/company_details_fulfilling_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Admin fulfills the company details" do let!(:admin) { create(:admin) } diff --git a/spec/features/admin/form_answers/csv_reports_download_spec.rb b/spec/features/admin/form_answers/csv_reports_download_spec.rb index ba27f8663e..69af14bf7c 100644 --- a/spec/features/admin/form_answers/csv_reports_download_spec.rb +++ b/spec/features/admin/form_answers/csv_reports_download_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Admin downloads CSV reports" do let!(:admin) { create(:admin) } diff --git a/spec/features/admin/form_answers/download_all_case_summary_pdf_spec.rb b/spec/features/admin/form_answers/download_all_case_summary_pdf_spec.rb index bfada6c185..133e2f93a4 100644 --- a/spec/features/admin/form_answers/download_all_case_summary_pdf_spec.rb +++ b/spec/features/admin/form_answers/download_all_case_summary_pdf_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Admin: Download all Case Summary as one pdf", %q{ +describe "Admin: Download all Case Summary as one pdf", ' As an Admin I want to download all Case Summary PDFS as one pdf per category from Dashboard So that I can print and review application case summaries -} do +' do let!(:admin) { create(:admin) } before do @@ -18,27 +17,23 @@ end it "should be links to download case summaries" do + years = [3, 6] + FormAnswer::CURRENT_AWARD_TYPE_FULL_NAMES.each do |award_type, value| ops = { id: "case_summaries", - category: award_type, format: :pdf, + category: award_type, + format: :pdf, year: AwardYear.current.year, } if award_type == "trade" - [3, 6].map do |i| - expect(page).to have_link("Download", - href: admin_report_path( - ops.merge({ years_mode: i }), - ), - ) + years.map do |i| + expect(page) + .to have_link("Download", href: admin_report_path(ops.merge({ years_mode: i }))) end else - expect(page).to have_link("Download", - href: admin_report_path( - ops, - ), - ) + expect(page).to have_link("Download", href: admin_report_path(ops)) end end end diff --git a/spec/features/admin/form_answers/download_all_feedbacks_spec.rb b/spec/features/admin/form_answers/download_all_feedbacks_spec.rb index 1c9ebb0f84..e999940617 100644 --- a/spec/features/admin/form_answers/download_all_feedbacks_spec.rb +++ b/spec/features/admin/form_answers/download_all_feedbacks_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Admin: Download all Feedbacks as one pdf", %q{ +describe "Admin: Download all Feedbacks as one pdf", ' As an Admin I want to download all Feedbacks as one pdf per category from Dashboard So that I can print and review application feedbacks -} do +' do let!(:admin) { create(:admin) } before do @@ -23,7 +22,7 @@ expect(page).to have_link("Download", href: admin_report_path( id: "feedbacks", - category: award_type, format: :pdf, year: AwardYear.current.year, + category: award_type, format: :pdf, year: AwardYear.current.year ), ) end diff --git a/spec/features/admin/form_answers/download_original_pdf_before_deadline_ends_spec.rb b/spec/features/admin/form_answers/download_original_pdf_before_deadline_ends_spec.rb index f62f120238..55ba6f3830 100644 --- a/spec/features/admin/form_answers/download_original_pdf_before_deadline_ends_spec.rb +++ b/spec/features/admin/form_answers/download_original_pdf_before_deadline_ends_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Admin: Download original pdf of application at the deadline", %q{ +describe "Admin: Download original pdf of application at the deadline", ' As an Admin I want to download original PDF of application at the deadline So that I can see original application data was at the deadline moment -} do +' do before do login_admin(create(:admin)) diff --git a/spec/features/admin/form_answers/draft_notes_fulfillment_spec.rb b/spec/features/admin/form_answers/draft_notes_fulfillment_spec.rb index 5e35a57f96..ae9af4d5e0 100644 --- a/spec/features/admin/form_answers/draft_notes_fulfillment_spec.rb +++ b/spec/features/admin/form_answers/draft_notes_fulfillment_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers Warden.test_mode! diff --git a/spec/features/admin/form_answers/filtering_by_status_spec.rb b/spec/features/admin/form_answers/filtering_by_status_spec.rb index 71fe2e37c2..e408d64c8f 100644 --- a/spec/features/admin/form_answers/filtering_by_status_spec.rb +++ b/spec/features/admin/form_answers/filtering_by_status_spec.rb @@ -1,11 +1,9 @@ require "rails_helper" -include Warden::Test::Helpers -include FormAnswerFilteringTestHelper - -Warden.test_mode! - describe "As Admin I want to filter applications", js: true do + include FormAnswerFilteringTestHelper + Warden.test_mode! + let!(:admin) { create(:admin) } before do diff --git a/spec/features/admin/form_answers/form_answers_list_flags_spec.rb b/spec/features/admin/form_answers/form_answers_list_flags_spec.rb index 604e42ff74..a416a3fcb5 100644 --- a/spec/features/admin/form_answers/form_answers_list_flags_spec.rb +++ b/spec/features/admin/form_answers/form_answers_list_flags_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Admin sees the proper number of flags and sort by it" do let!(:admin) { create(:admin) } diff --git a/spec/features/admin/form_answers/generation_of_csv_reports_spec.rb b/spec/features/admin/form_answers/generation_of_csv_reports_spec.rb index c8004901b4..8c5c7d4492 100644 --- a/spec/features/admin/form_answers/generation_of_csv_reports_spec.rb +++ b/spec/features/admin/form_answers/generation_of_csv_reports_spec.rb @@ -13,7 +13,7 @@ data = Reports::AdminReport.new(id, AwardYear.current).as_csv if data.is_a?(Enumerator) - data.entries.map { |row| CSV.parse(row) }.flatten(1) + data.entries.flat_map { |row| CSV.parse(row) } else CSV.parse(data) end @@ -69,7 +69,7 @@ let!(:attendee) do create(:palace_attendee, palace_invite: palace_invite, title: title, - first_name: first_name,) + first_name: first_name) end it "produces proper output" do diff --git a/spec/features/admin/form_answers/list_sorting_spec.rb b/spec/features/admin/form_answers/list_sorting_spec.rb index f5fe05aacb..afe3b6d949 100644 --- a/spec/features/admin/form_answers/list_sorting_spec.rb +++ b/spec/features/admin/form_answers/list_sorting_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Form answer list sorting", js: true do let!(:subject) { create(:admin) } diff --git a/spec/features/admin/form_answers/palace_attendees_fulfilling_spec.rb b/spec/features/admin/form_answers/palace_attendees_fulfilling_spec.rb index b53a49f450..a7865f23b4 100644 --- a/spec/features/admin/form_answers/palace_attendees_fulfilling_spec.rb +++ b/spec/features/admin/form_answers/palace_attendees_fulfilling_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Admin fulfills the Palace Attendees" do let!(:admin) { create(:admin) } diff --git a/spec/features/admin/form_answers/palace_invite_submission_spec.rb b/spec/features/admin/form_answers/palace_invite_submission_spec.rb index 6da6b242b4..945f0ee146 100644 --- a/spec/features/admin/form_answers/palace_invite_submission_spec.rb +++ b/spec/features/admin/form_answers/palace_invite_submission_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Admin submits palace attendees' info" do let!(:admin) { create(:admin) } diff --git a/spec/features/admin/form_answers/previous_winnings_spec.rb b/spec/features/admin/form_answers/previous_winnings_spec.rb index 72fe234ee4..a0c9f2656f 100644 --- a/spec/features/admin/form_answers/previous_winnings_spec.rb +++ b/spec/features/admin/form_answers/previous_winnings_spec.rb @@ -1,6 +1,5 @@ require "rails_helper" -include Warden::Test::Helpers describe "Admin sets up previous winnings" do let!(:admin) { create(:admin) } diff --git a/spec/features/admin/form_answers/remove_audit_certificate_spec.rb b/spec/features/admin/form_answers/remove_audit_certificate_spec.rb index 28eef8062c..4d252a4736 100644 --- a/spec/features/admin/form_answers/remove_audit_certificate_spec.rb +++ b/spec/features/admin/form_answers/remove_audit_certificate_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Admin: ability to remove Verification of Commercial Figures", %q{ +describe "Admin: ability to remove Verification of Commercial Figures", ' As an Admin I want to have ability to delete the Verification of Commercial Figures in case the user has uploaded it in error So that User can re-upload Verification of Commercial Figures -} do +' do let!(:form_answer) do create(:form_answer, :submitted, :with_audit_certificate) end @@ -61,7 +60,7 @@ wait_for_ajax expect { - find(".js-remove-audit-certificate-link").click() + find(".js-remove-audit-certificate-link").click page.driver.browser.switch_to.alert.accept wait_for_ajax diff --git a/spec/features/admin/form_answers/search_spec.rb b/spec/features/admin/form_answers/search_spec.rb index 95fe6150a7..4a37521576 100644 --- a/spec/features/admin/form_answers/search_spec.rb +++ b/spec/features/admin/form_answers/search_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Form answer search", " As Admin diff --git a/spec/features/admin/form_answers/sic_code_selection_spec.rb b/spec/features/admin/form_answers/sic_code_selection_spec.rb index 82b51fe865..97fed3c924 100644 --- a/spec/features/admin/form_answers/sic_code_selection_spec.rb +++ b/spec/features/admin/form_answers/sic_code_selection_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "SIC Code selection", " As Admin diff --git a/spec/features/admin/form_answers/states_edition_spec.rb b/spec/features/admin/form_answers/states_edition_spec.rb index ceac924d0b..c95463026d 100644 --- a/spec/features/admin/form_answers/states_edition_spec.rb +++ b/spec/features/admin/form_answers/states_edition_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "As Admin I want to change the applications states.", js: true do let!(:admin) { create(:admin) } diff --git a/spec/features/admin/form_answers/view_edit_applications_spec.rb b/spec/features/admin/form_answers/view_edit_applications_spec.rb index 9f693be720..cb70a582de 100644 --- a/spec/features/admin/form_answers/view_edit_applications_spec.rb +++ b/spec/features/admin/form_answers/view_edit_applications_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers feature "Admin view application", js: true do scenario "As an admin I can only see the application in read only mode" do diff --git a/spec/features/admin/form_answers/withdraw_application_spec.rb b/spec/features/admin/form_answers/withdraw_application_spec.rb index 5ce997d640..25f33fe1e2 100644 --- a/spec/features/admin/form_answers/withdraw_application_spec.rb +++ b/spec/features/admin/form_answers/withdraw_application_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Admin withdraws the application", js: true do let!(:admin) { create(:admin) } diff --git a/spec/features/admin/reports/assessors_progress_report_csv_spec.rb b/spec/features/admin/reports/assessors_progress_report_csv_spec.rb index dae3ae75a8..e1bbf96796 100644 --- a/spec/features/admin/reports/assessors_progress_report_csv_spec.rb +++ b/spec/features/admin/reports/assessors_progress_report_csv_spec.rb @@ -1,7 +1,5 @@ require "rails_helper" -include Warden::Test::Helpers - describe "Assessors Progress Reports CSV" do let!(:first_assessor) { create(:assessor, :regular_for_trade) } let!(:second_assessor) { create(:assessor, :regular_for_trade) } @@ -131,7 +129,7 @@ def build_entry!(entry, assessor) ) if entry[2].present? - assessment.submitted_at = Time.now + assessment.submitted_at = Time.current end assessment.save!(validate: false) diff --git a/spec/features/assessor/appraisal_form_submission_spec.rb b/spec/features/assessor/appraisal_form_submission_spec.rb index 5ad20498ed..0536e042ac 100644 --- a/spec/features/assessor/appraisal_form_submission_spec.rb +++ b/spec/features/assessor/appraisal_form_submission_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers Warden.test_mode! diff --git a/spec/features/assessor/assessment_flow_spec.rb b/spec/features/assessor/assessment_flow_spec.rb index 7553542024..57708acccc 100644 --- a/spec/features/assessor/assessment_flow_spec.rb +++ b/spec/features/assessor/assessment_flow_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers Warden.test_mode! diff --git a/spec/features/assessor/bulk_assessors_assignment_spec.rb b/spec/features/assessor/bulk_assessors_assignment_spec.rb index abdfcc3b6b..fb0f2549a2 100644 --- a/spec/features/assessor/bulk_assessors_assignment_spec.rb +++ b/spec/features/assessor/bulk_assessors_assignment_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers Warden.test_mode! diff --git a/spec/features/assessor/download_original_pdf_before_deadline_ends_spec.rb b/spec/features/assessor/download_original_pdf_before_deadline_ends_spec.rb index 0a010c91b5..e26977ecb1 100644 --- a/spec/features/assessor/download_original_pdf_before_deadline_ends_spec.rb +++ b/spec/features/assessor/download_original_pdf_before_deadline_ends_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Assessor: Download original pdf of application at the deadline", %q{ +describe "Assessor: Download original pdf of application at the deadline", ' As an Assessor (Lead / Primary) I want to download original PDF of application at the deadline So that I can see original application data was at the deadline moment -} do +' do let(:target_url) do assessor_form_answer_path(form_answer) end diff --git a/spec/features/assessor/feedback_spec.rb b/spec/features/assessor/feedback_spec.rb index 69a0d9d5db..f8b91727a4 100644 --- a/spec/features/assessor/feedback_spec.rb +++ b/spec/features/assessor/feedback_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Assessor feedback management" do let(:assessor) { create(:assessor, :lead_for_all) } diff --git a/spec/features/assessor/flags_on_form_answers_list_spec.rb b/spec/features/assessor/flags_on_form_answers_list_spec.rb index ffecaa197c..92f78902df 100644 --- a/spec/features/assessor/flags_on_form_answers_list_spec.rb +++ b/spec/features/assessor/flags_on_form_answers_list_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "assessor sees the proper number of flags and sort by it" do let!(:assessor) { create(:assessor, :lead_for_all) } diff --git a/spec/features/assessor/fulfills_the_draft_notes_spec.rb b/spec/features/assessor/fulfills_the_draft_notes_spec.rb index 78142e03b5..4c1481518a 100644 --- a/spec/features/assessor/fulfills_the_draft_notes_spec.rb +++ b/spec/features/assessor/fulfills_the_draft_notes_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers Warden.test_mode! diff --git a/spec/features/assessor/list_sorting_spec.rb b/spec/features/assessor/list_sorting_spec.rb index 58ac3d75ac..bb049db0f3 100644 --- a/spec/features/assessor/list_sorting_spec.rb +++ b/spec/features/assessor/list_sorting_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Form answer list sorting", js: true do let!(:subject) { create(:assessor, :lead_for_all) } diff --git a/spec/features/assessor/log_in_spec.rb b/spec/features/assessor/log_in_spec.rb index 3dce22cba6..f205469c2d 100644 --- a/spec/features/assessor/log_in_spec.rb +++ b/spec/features/assessor/log_in_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Log in" do let(:subject) { create(:assessor, :lead_for_all, password: "my98ssdkjv9823kds=2") } diff --git a/spec/features/assessor/press_summary_spec.rb b/spec/features/assessor/press_summary_spec.rb index 0adb12d695..6070db8a1e 100644 --- a/spec/features/assessor/press_summary_spec.rb +++ b/spec/features/assessor/press_summary_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Assessor press_summary management", js: true do let(:assessor) { create(:assessor, :lead_for_all) } diff --git a/spec/features/assessor/review_audit_certificate_spec.rb b/spec/features/assessor/review_audit_certificate_spec.rb index 9e3d31cbc9..c926bbe390 100644 --- a/spec/features/assessor/review_audit_certificate_spec.rb +++ b/spec/features/assessor/review_audit_certificate_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Assessor reviews the audit certificate" do let(:assessor) { create(:assessor, :lead_for_all) } diff --git a/spec/features/assessor/review_shortlisted_docs_spec.rb b/spec/features/assessor/review_shortlisted_docs_spec.rb index 4ebacf15ff..ef2f26c302 100644 --- a/spec/features/assessor/review_shortlisted_docs_spec.rb +++ b/spec/features/assessor/review_shortlisted_docs_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Assessor reviews the shortlisted docs" do let(:assessor) { create(:assessor, :lead_for_all) } diff --git a/spec/features/assessor/sorting_by_assessors_spec.rb b/spec/features/assessor/sorting_by_assessors_spec.rb index a0c937c27b..7d00de56da 100644 --- a/spec/features/assessor/sorting_by_assessors_spec.rb +++ b/spec/features/assessor/sorting_by_assessors_spec.rb @@ -1,6 +1,5 @@ require "rails_helper" -include Warden::Test::Helpers Warden.test_mode! describe "As Lead Assessor I want to sort by assessors", js: true do @@ -19,7 +18,7 @@ end it "displays the forms based on the primary assessor name order" do - expected_indices = %w(0 1 2) + expected_indices = %w[0 1 2] find("th.sortable.th-primary-name", text: "Primary Assessor").find("a").click expect(assessor_names).to eq(expected_indices) @@ -37,7 +36,7 @@ def assessor_names within ".applications-table" do names = all("tbody tr").map do |tr| tr.find(".td-primary-name").text - #tr.all("td")[5].text + # tr.all("td")[5].text end end names.map { |name| name[0] } diff --git a/spec/features/assessor/status_filtering_spec.rb b/spec/features/assessor/status_filtering_spec.rb index bd3a685238..073426c7a2 100644 --- a/spec/features/assessor/status_filtering_spec.rb +++ b/spec/features/assessor/status_filtering_spec.rb @@ -1,18 +1,16 @@ require "rails_helper" -include Warden::Test::Helpers -include FormAnswerFilteringTestHelper - -Warden.test_mode! - describe "As Lead Assessor I want to filter applications by state", js: true do + include FormAnswerFilteringTestHelper + Warden.test_mode! + before do @forms = [] @forms << create( :form_answer, :trade, state: "not_submitted", - document: { sic_code: "1623" },) + document: { sic_code: "1623" }) @forms << create(:form_answer, :development, state: "application_in_progress") @forms << create(:form_answer, :trade, state: "not_eligible") diff --git a/spec/features/judge/case_summaries_spec.rb b/spec/features/judge/case_summaries_spec.rb index 200ef4fe40..090f5c8689 100644 --- a/spec/features/judge/case_summaries_spec.rb +++ b/spec/features/judge/case_summaries_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers Warden.test_mode! diff --git a/spec/features/judge/sign_in_spec.rb b/spec/features/judge/sign_in_spec.rb index 480ec692e8..d4e65f20f5 100644 --- a/spec/features/judge/sign_in_spec.rb +++ b/spec/features/judge/sign_in_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers Warden.test_mode! diff --git a/spec/features/non_js_form_dynamic_lists/current_queens_awards_spec.rb b/spec/features/non_js_form_dynamic_lists/current_queens_awards_spec.rb index eba4b6f5dd..fe304711b2 100644 --- a/spec/features/non_js_form_dynamic_lists/current_queens_awards_spec.rb +++ b/spec/features/non_js_form_dynamic_lists/current_queens_awards_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Non JS | Dynamic Lists | Current King's Awards", %q{ +describe "Non JS | Dynamic Lists | Current King's Awards", " As a User I want to be able to add Current King's Awards I hold So that I can fill form completelly even if Javascript is turned off -} do +" do include_context "non js form base" let(:innovation_award_year) do @@ -64,7 +63,7 @@ within("#non_js_applied_for_queen_awards_details-list-question") do awards.each do |award| expect(page).to have_selector( - "li[non-js-attribute=#{item_entry(award)}]", count: 1, + "li[non-js-attribute=#{item_entry(award)}]", count: 1 ) end end @@ -82,7 +81,7 @@ form_answer.reload.document } - %w(Category Year).each do |field_name| + %w[Category Year].each do |field_name| expect_to_see "#{field_name} is required and an option must be selected from the following list" end @@ -99,12 +98,12 @@ within("#non_js_applied_for_queen_awards_details-list-question") do awards.each do |award| expect(page).to have_selector( - "li[non-js-attribute=#{item_entry(award)}]", count: 1, + "li[non-js-attribute=#{item_entry(award)}]", count: 1 ) end expect(page).to have_selector( - "li[non-js-attribute=#{new_award_category}_#{new_award_category_year}]", count: 1, + "li[non-js-attribute=#{new_award_category}_#{new_award_category_year}]", count: 1 ) end end @@ -127,11 +126,11 @@ within("#non_js_applied_for_queen_awards_details-list-question") do expect(page).to have_selector( - "li[non-js-attribute=#{item_entry(first_award)}]", count: 1, + "li[non-js-attribute=#{item_entry(first_award)}]", count: 1 ) expect(page).to have_selector( - "li[non-js-attribute=#{new_award_category}_#{new_award_category_year}]", count: 1, + "li[non-js-attribute=#{new_award_category}_#{new_award_category_year}]", count: 1 ) expect(page).to_not have_selector( @@ -155,7 +154,7 @@ within("#non_js_applied_for_queen_awards_details-list-question") do expect(page).to have_selector( - "li[non-js-attribute=#{item_entry(first_award)}]", count: 1, + "li[non-js-attribute=#{item_entry(first_award)}]", count: 1 ) expect(page).to_not have_selector( diff --git a/spec/features/non_js_form_dynamic_lists/subsidiaries_spec.rb b/spec/features/non_js_form_dynamic_lists/subsidiaries_spec.rb index 32dd13ff15..93ddb12b12 100644 --- a/spec/features/non_js_form_dynamic_lists/subsidiaries_spec.rb +++ b/spec/features/non_js_form_dynamic_lists/subsidiaries_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Non JS | Dynamic Lists | Subsidiaries", %q{ +describe "Non JS | Dynamic Lists | Subsidiaries", ' As a User I want to be able to add UK subsidiaries, associates or plants So that I can fill form completelly even if Javascript is turned off -} do +' do include_context "non js form base" let(:question_key) { "trading_figures_add" } @@ -21,7 +20,7 @@ FactoryBot.create :form_answer, :trade, user: user, account: account, - document: { company_name: "Bitzesty", question_key => subsidiaries } + document: { :company_name => "Bitzesty", question_key => subsidiaries } end let!(:basic_eligibility) do @@ -56,7 +55,7 @@ within("#non_js_#{question_key}-list-question") do subsidiaries.each do |subsidiary| expect(page).to have_selector( - "li[non-js-attribute=#{subsidiary[:name]}]", count: 1, + "li[non-js-attribute=#{subsidiary[:name]}]", count: 1 ) end end @@ -100,12 +99,12 @@ within("#non_js_#{question_key}-list-question") do subsidiaries.each do |subsidiary| expect(page).to have_selector( - "li[non-js-attribute=#{subsidiary[:name]}]", count: 1, + "li[non-js-attribute=#{subsidiary[:name]}]", count: 1 ) end expect(page).to have_selector( - "li[non-js-attribute=#{new_name}]", count: 1, + "li[non-js-attribute=#{new_name}]", count: 1 ) end end @@ -129,11 +128,11 @@ within("#non_js_#{question_key}-list-question") do expect(page).to have_selector( - "li[non-js-attribute=#{first_item[:name]}]", count: 1, + "li[non-js-attribute=#{first_item[:name]}]", count: 1 ) expect(page).to have_selector( - "li[non-js-attribute=#{new_name}]", count: 1, + "li[non-js-attribute=#{new_name}]", count: 1 ) expect(page).to_not have_selector( @@ -157,7 +156,7 @@ within("#non_js_#{question_key}-list-question") do expect(page).to have_selector( - "li[non-js-attribute=#{first_item[:name]}]", count: 1, + "li[non-js-attribute=#{first_item[:name]}]", count: 1 ) expect(page).to_not have_selector( diff --git a/spec/features/palace_attendees_spec.rb b/spec/features/palace_attendees_spec.rb index 2757399975..8ad3621dce 100644 --- a/spec/features/palace_attendees_spec.rb +++ b/spec/features/palace_attendees_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Palace Attendees", %q{ +describe "Palace Attendees", ' As a head of organization I want to be able to setup Buckingham Palace attendees details So that I provide a full list of attendees for Buckingham Palace reception -} do +' do let(:user) do create :user, :completed_profile, role: "account_admin" end diff --git a/spec/features/users/account_creation_spec.rb b/spec/features/users/account_creation_spec.rb index a600672458..48db13a3ce 100644 --- a/spec/features/users/account_creation_spec.rb +++ b/spec/features/users/account_creation_spec.rb @@ -1,5 +1,5 @@ require "rails_helper" -include Warden::Test::Helpers + Warden.test_mode! describe "Account forms" do diff --git a/spec/features/users/award_winners_spec.rb b/spec/features/users/award_winners_spec.rb index 819f167f79..1ed3c9eb12 100644 --- a/spec/features/users/award_winners_spec.rb +++ b/spec/features/users/award_winners_spec.rb @@ -1,5 +1,5 @@ require "rails_helper" -include Warden::Test::Helpers + Warden.test_mode! describe "award winners section" do diff --git a/spec/features/users/collaborator_registration_flow_spec.rb b/spec/features/users/collaborator_registration_flow_spec.rb index 39498c80cb..dfff612782 100644 --- a/spec/features/users/collaborator_registration_flow_spec.rb +++ b/spec/features/users/collaborator_registration_flow_spec.rb @@ -1,5 +1,5 @@ require "rails_helper" -include Warden::Test::Helpers + Warden.test_mode! describe "Collaborator registration flow" do @@ -26,7 +26,7 @@ click_button "Add the collaborator" collab = User.find_by(email: "collab@example.com") - collab.confirmed_at = Time.now + collab.confirmed_at = Time.current collab.save! click_button "Sign out" diff --git a/spec/features/users/eligibility_form_fulfillment_spec.rb b/spec/features/users/eligibility_form_fulfillment_spec.rb index 238c93f0f0..bcf88db95c 100644 --- a/spec/features/users/eligibility_form_fulfillment_spec.rb +++ b/spec/features/users/eligibility_form_fulfillment_spec.rb @@ -1,5 +1,5 @@ require "rails_helper" -include Warden::Test::Helpers + Warden.test_mode! describe "Eligibility forms" do diff --git a/spec/features/users/expired_palace_invite_spec.rb b/spec/features/users/expired_palace_invite_spec.rb index a19291dcd6..aae293d17f 100644 --- a/spec/features/users/expired_palace_invite_spec.rb +++ b/spec/features/users/expired_palace_invite_spec.rb @@ -1,5 +1,5 @@ require "rails_helper" -include Warden::Test::Helpers + Warden.test_mode! describe "expired reception attendee information deadline" do diff --git a/spec/features/users/figures_and_vat_returns_spec.rb b/spec/features/users/figures_and_vat_returns_spec.rb index e9816d11d2..f21bada93f 100644 --- a/spec/features/users/figures_and_vat_returns_spec.rb +++ b/spec/features/users/figures_and_vat_returns_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "User uploads VAT returns and actual figures" do let(:user) { create(:user, :completed_profile) } diff --git a/spec/features/users/form_answers/audit_certificate_request_spec.rb b/spec/features/users/form_answers/audit_certificate_request_spec.rb index ca19801be1..6314593a65 100644 --- a/spec/features/users/form_answers/audit_certificate_request_spec.rb +++ b/spec/features/users/form_answers/audit_certificate_request_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Verification of Commercial Figures", %q{ +describe "Verification of Commercial Figures", ' As a User I want to be able to download an Verification of Commercial Figures So that I can check, complete it and then upload it to application -} do +' do let!(:user) do create :user end diff --git a/spec/features/users/form_answers/download_pdf_spec.rb b/spec/features/users/form_answers/download_pdf_spec.rb index 99457157da..bada582ba0 100644 --- a/spec/features/users/form_answers/download_pdf_spec.rb +++ b/spec/features/users/form_answers/download_pdf_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Download a pdf of the award form filled", %q{ +describe "Download a pdf of the award form filled", ' As a User I want to be able to download a pdf of the filled in form filled in with whatever I have entered so far So that I can review my progress or share the pdf with others -} do +' do let!(:user) do FactoryBot.create :user end diff --git a/spec/features/users/form_answers/past_applications_spec.rb b/spec/features/users/form_answers/past_applications_spec.rb index bb569f5366..8a24b1e450 100644 --- a/spec/features/users/form_answers/past_applications_spec.rb +++ b/spec/features/users/form_answers/past_applications_spec.rb @@ -1,11 +1,10 @@ require "rails_helper" -include Warden::Test::Helpers -describe "Past Applications", %q{ +describe "Past Applications", ' As an Applicant I want to be able to see Past Applications for previous years So that I see -} do +' do let(:previous_year) do Date.new(2020, 4, 1) end @@ -61,7 +60,7 @@ create(:form_answer, :innovation, :awarded, award_year: previous_award_year, - user: user,) + user: user) end before do diff --git a/spec/features/users/form_answers/press_summary_spec.rb b/spec/features/users/form_answers/press_summary_spec.rb index 1d9ab942f4..771f43b228 100644 --- a/spec/features/users/form_answers/press_summary_spec.rb +++ b/spec/features/users/form_answers/press_summary_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "Press Summary" do before do diff --git a/spec/features/users/post_submission_dashboard_spec.rb b/spec/features/users/post_submission_dashboard_spec.rb index e1b25e0bcd..beec662988 100644 --- a/spec/features/users/post_submission_dashboard_spec.rb +++ b/spec/features/users/post_submission_dashboard_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "User sees the post submission dashboard" do let(:user) { create(:user, :completed_profile) } @@ -14,7 +13,7 @@ describe "visits the post submission dashboard", js: true do it "sees applications properly" do visit dashboard_path - expect(page).to have_content"Edit application" + expect(page).to have_content "Edit application" expect(page).to have_content("Current Applications") settings.destroy diff --git a/spec/features/users/pre_submission_dashboard_spec.rb b/spec/features/users/pre_submission_dashboard_spec.rb index 0a13a842dc..62b2658e12 100644 --- a/spec/features/users/pre_submission_dashboard_spec.rb +++ b/spec/features/users/pre_submission_dashboard_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "User sees the pre submission dashboard" do let(:user) { create(:user, :completed_profile) } diff --git a/spec/features/users/progress_halted_spec.rb b/spec/features/users/progress_halted_spec.rb index 6adc36aab5..a6ba5c848b 100644 --- a/spec/features/users/progress_halted_spec.rb +++ b/spec/features/users/progress_halted_spec.rb @@ -1,5 +1,5 @@ require "rails_helper" -include Warden::Test::Helpers + Warden.test_mode! describe "Progress halt" do diff --git a/spec/features/users/site_feedback_spec.rb b/spec/features/users/site_feedback_spec.rb index 2584ea8f10..c177746d78 100644 --- a/spec/features/users/site_feedback_spec.rb +++ b/spec/features/users/site_feedback_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "User leaves feedback and admin is able to see it" do let(:admin) { create :admin } diff --git a/spec/features/users/support_letters_spec.rb b/spec/features/users/support_letters_spec.rb index d3e2f5a04a..3e259ec0fe 100644 --- a/spec/features/users/support_letters_spec.rb +++ b/spec/features/users/support_letters_spec.rb @@ -1,10 +1,10 @@ require "rails_helper" -describe "Submission of SupportLetter", %{ +describe "Submission of SupportLetter", %( As a Supporter I want to be able to fill and submit support letter So that I can support my nominator -} do +) do let!(:user) { create(:user) } let!(:form_answer) { create(:form_answer, :promotion, user: user) } let!(:supporter) do diff --git a/spec/fixtures/form_answer_innovation.json b/spec/fixtures/form_answer_innovation.json index 99820e046c..80a26f0a7b 100644 --- a/spec/fixtures/form_answer_innovation.json +++ b/spec/fixtures/form_answer_innovation.json @@ -212,5 +212,6 @@ "head_job_title": "test", "head_email": "test", "strong_esg_record": "on", -"major_issues_overcome": "test" +"major_issues_overcome": "test", +"most_recent_financial_year": "2024" } diff --git a/spec/fixtures/form_answer_trade.json b/spec/fixtures/form_answer_trade.json index d38cae39e6..66e2f5a9ff 100644 --- a/spec/fixtures/form_answer_trade.json +++ b/spec/fixtures/form_answer_trade.json @@ -178,5 +178,6 @@ "head_job_title": "test", "head_email": "test", "strong_esg_record": "on", -"major_issues_overcome": "test" +"major_issues_overcome": "test", +"most_recent_financial_year": "2024" } diff --git a/spec/form_pointers/financial_summary_pointer_spec.rb b/spec/form_pointers/financial_summary_pointer_spec.rb index 41a2545f79..184dcd4781 100644 --- a/spec/form_pointers/financial_summary_pointer_spec.rb +++ b/spec/form_pointers/financial_summary_pointer_spec.rb @@ -44,19 +44,19 @@ expect(pointer.summary_data).to eq( [ - { :dates => [nil, nil, "07/07/2021", "06/09/2022"] }, - { :employees => [ - { :name => nil, :value => nil }, - { :name => nil, :value => nil }, - { :name => "employees_1of2", :value => "10" }, - { :name => "employees_2of2", :value => "12" }, + { dates: [nil, nil, "07/07/2021", "06/09/2022"] }, + { employees: [ + { name: nil, value: nil }, + { name: nil, value: nil }, + { name: "employees_1of2", value: "10" }, + { name: "employees_2of2", value: "12" }, ] }, - { :dates => ["07/07/2019", "07/07/2020", "07/07/2021", "06/09/2022"] }, - { :sales => [ - { :name => "sales_1of4", :value => "10" }, - { :name => "sales_2of4", :value => "10" }, - { :name => "sales_3of4", :value => "10" }, - { :name => "sales_4of4", :value => "10" }, + { dates: ["07/07/2019", "07/07/2020", "07/07/2021", "06/09/2022"] }, + { sales: [ + { name: "sales_1of4", value: "10" }, + { name: "sales_2of4", value: "10" }, + { name: "sales_3of4", value: "10" }, + { name: "sales_4of4", value: "10" }, ] }, ], ) @@ -98,19 +98,19 @@ expect(pointer.summary_data).to eq( [ - { :dates => ["05/05/2019", "06/06/2020", "07/07/2021", "08/08/2022"] }, - { :employees => [ - { :name => "employees_1of4", :value => "10" }, - { :name => "employees_2of4", :value => "10" }, - { :name => "employees_3of4", :value => "10" }, - { :name => "employees_4of4", :value => "10" }, + { dates: ["05/05/2019", "06/06/2020", "07/07/2021", "08/08/2022"] }, + { employees: [ + { name: "employees_1of4", value: "10" }, + { name: "employees_2of4", value: "10" }, + { name: "employees_3of4", value: "10" }, + { name: "employees_4of4", value: "10" }, ] }, - { :dates => [nil, nil, "07/07/2021", "08/08/2022"] }, - { :sales => [ - { :name => nil, :value => nil }, - { :name => nil, :value => nil }, - { :name => "sales_1of2", :value => "10" }, - { :name => "sales_2of2", :value => "10" }, + { dates: [nil, nil, "07/07/2021", "08/08/2022"] }, + { sales: [ + { name: nil, value: nil }, + { name: nil, value: nil }, + { name: "sales_1of2", value: "10" }, + { name: "sales_2of2", value: "10" }, ] }, ], ) @@ -145,19 +145,19 @@ expect(pointer.summary_data).to eq( [ - { :dates => [nil, nil, "02/01/2022", "02/01/2023"] }, - { :employees => [ - { :name => nil, :value => nil }, - { :name => nil, :value => nil }, - { :name => "employees_1of2", :value => "10" }, - { :name => "employees_2of2", :value => "12" }, + { dates: [nil, nil, "02/01/2022", "02/01/2023"] }, + { employees: [ + { name: nil, value: nil }, + { name: nil, value: nil }, + { name: "employees_1of2", value: "10" }, + { name: "employees_2of2", value: "12" }, ] }, - { :dates => ["02/01/2020", "02/01/2021", "02/01/2022", "02/01/2023"] }, - { :sales => [ - { :name => "sales_1of4", :value => "10" }, - { :name => "sales_2of4", :value => "10" }, - { :name => "sales_3of4", :value => "10" }, - { :name => "sales_4of4", :value => "10" }, + { dates: ["02/01/2020", "02/01/2021", "02/01/2022", "02/01/2023"] }, + { sales: [ + { name: "sales_1of4", value: "10" }, + { name: "sales_2of4", value: "10" }, + { name: "sales_3of4", value: "10" }, + { name: "sales_4of4", value: "10" }, ] }, ], ) @@ -172,19 +172,19 @@ expect(pointer.summary_data).to eq( [ - { :dates => [nil, nil, "02/01/2022", "02/01/2023"] }, - { :employees => [ - { :name => nil, :value => nil }, - { :name => nil, :value => nil }, - { :name => "employees_1of2", :value => "10" }, - { :name => "employees_2of2", :value => "12" }, + { dates: [nil, nil, "02/01/2022", "02/01/2023"] }, + { employees: [ + { name: nil, value: nil }, + { name: nil, value: nil }, + { name: "employees_1of2", value: "10" }, + { name: "employees_2of2", value: "12" }, ] }, - { :dates => ["02/01/2020", "02/01/2021", "02/01/2022", "02/01/2023"] }, - { :sales => [ - { :name => "sales_1of4", :value => "10" }, - { :name => "sales_2of4", :value => "10" }, - { :name => "sales_3of4", :value => "10" }, - { :name => "sales_4of4", :value => "10" }, + { dates: ["02/01/2020", "02/01/2021", "02/01/2022", "02/01/2023"] }, + { sales: [ + { name: "sales_1of4", value: "10" }, + { name: "sales_2of4", value: "10" }, + { name: "sales_3of4", value: "10" }, + { name: "sales_4of4", value: "10" }, ] }, ], ) @@ -199,19 +199,19 @@ expect(pointer.summary_data).to eq( [ - { :dates => [nil, nil, "29/02/2024", "01/05/2025"] }, - { :employees => [ - { :name => nil, :value => nil }, - { :name => nil, :value => nil }, - { :name => "employees_1of2", :value => "10" }, - { :name => "employees_2of2", :value => "12" }, + { dates: [nil, nil, "29/02/2024", "01/05/2025"] }, + { employees: [ + { name: nil, value: nil }, + { name: nil, value: nil }, + { name: "employees_1of2", value: "10" }, + { name: "employees_2of2", value: "12" }, ] }, - { :dates => ["28/02/2022", "28/02/2023", "29/02/2024", "01/05/2025"] }, - { :sales => [ - { :name => "sales_1of4", :value => "10" }, - { :name => "sales_2of4", :value => "10" }, - { :name => "sales_3of4", :value => "10" }, - { :name => "sales_4of4", :value => "10" }, + { dates: ["28/02/2022", "28/02/2023", "29/02/2024", "01/05/2025"] }, + { sales: [ + { name: "sales_1of4", value: "10" }, + { name: "sales_2of4", value: "10" }, + { name: "sales_3of4", value: "10" }, + { name: "sales_4of4", value: "10" }, ] }, ], ) diff --git a/spec/forms/custom_email_form_spec.rb b/spec/forms/custom_email_form_spec.rb index ebb00904ad..3e07506226 100644 --- a/spec/forms/custom_email_form_spec.rb +++ b/spec/forms/custom_email_form_spec.rb @@ -6,7 +6,7 @@ CustomEmailForm.new(admin_id: admin.id, scope: scope, message: "message", - subject: "subject",) + subject: "subject") end context "myself" do @@ -22,7 +22,7 @@ it "sends email to users with qae_opt_in_group" do user_1 = create(:user, subscribed_to_emails: true, email: "1@example.com") - user_2 = create(:user, subscribed_to_emails: false, email: "2@example.com") + create(:user, subscribed_to_emails: false, email: "2@example.com") user_3 = create(:user, subscribed_to_emails: true, email: "3@example.com") expect(form.users).to eq([user_1, user_3]) @@ -34,7 +34,7 @@ it "sends email to users with bis_opt_in" do user_1 = create(:user, agree_being_contacted_by_department_of_business: true, email: "1@example.com") - user_2 = create(:user, agree_being_contacted_by_department_of_business: false, email: "2@example.com") + create(:user, agree_being_contacted_by_department_of_business: false, email: "2@example.com") user_3 = create(:user, agree_being_contacted_by_department_of_business: true, email: "3@example.com") expect(form.users).to eq([user_1, user_3]) diff --git a/spec/interactors/add_collaborator_spec.rb b/spec/interactors/add_collaborator_spec.rb index 04e8e06e88..b9ee15fdc5 100644 --- a/spec/interactors/add_collaborator_spec.rb +++ b/spec/interactors/add_collaborator_spec.rb @@ -20,7 +20,7 @@ AddCollaborator.new( account_admin, account, - create_params,) + create_params) end describe "Add new user account and add him to Collaborators" do @@ -50,26 +50,26 @@ end describe "Attempt to add to Collaborators of existing user, which is belongs_to another Account" do - let!(:existing_user_with_another_account_association) do + let!(:existing_user_with_another_account_association) do FactoryBot.create :user, :completed_profile, first_name: "Another Account Admin Dave", role: "account_admin" end - let(:existing_user_email) { existing_user_with_another_account_association.email } - let(:role) { "regular" } - let(:create_params) do - { email: existing_user_email, role: role } - end + let(:existing_user_email) { existing_user_with_another_account_association.email } + let(:role) { "regular" } + let(:create_params) do + { email: existing_user_email, role: role } + end - it "should not add existing user to collaborators as it already associated with another account" do - expect { add_collaborator_interactor.run } - .to not_change { account.reload.users.count } - .and not_change { MailDeliveryWorker.jobs.size } + it "should not add existing user to collaborators as it already associated with another account" do + expect { add_collaborator_interactor.run } + .to not_change { account.reload.users.count } + .and not_change { MailDeliveryWorker.jobs.size } - expect(account.reload.users.count).to be_eql 1 - expect(add_collaborator_interactor.errors).to be_eql ["User already associated with another account!"] - end + expect(account.reload.users.count).to be_eql 1 + expect(add_collaborator_interactor.errors).to be_eql ["User already associated with another account!"] + end end describe "Attempt to add user to Collaborators twice" do diff --git a/spec/lib/qae_form_builder_spec.rb b/spec/lib/qae_form_builder_spec.rb index b8a2c4b7c6..08398e019d 100644 --- a/spec/lib/qae_form_builder_spec.rb +++ b/spec/lib/qae_form_builder_spec.rb @@ -7,7 +7,7 @@ end end - let(:current_step){ subject.steps.first } + let(:current_step) { subject.steps.first } describe "#build" do it "creates the questions" do @@ -22,7 +22,7 @@ it "adds help context" do help = current_step.questions[1].help - expect(help.first.title =~ /That is the/).to be_present + expect(help.first.title.include?("That is the")).to be_present end it "assigns required flag" do @@ -37,7 +37,7 @@ class DummyForm def self.step1 - @step1 = Proc.new { + @step1 = proc { options :option_question1, "Are you keen to choose any option?" do ref "X 1" option "option1", "option1 value" diff --git a/spec/mailers/account_mailers/buckingham_palace_invite_mailer_spec.rb b/spec/mailers/account_mailers/buckingham_palace_invite_mailer_spec.rb index 3f07a0d128..5cd13c40f9 100644 --- a/spec/mailers/account_mailers/buckingham_palace_invite_mailer_spec.rb +++ b/spec/mailers/account_mailers/buckingham_palace_invite_mailer_spec.rb @@ -30,7 +30,7 @@ # this field is no longer used in 2019 awards, but we're using closed award year here # can be simplified when 2020 awards kick in - fa.document.merge!("queen_award_holder" => "no") + fa.document["queen_award_holder"] = "no" fa.save! fa diff --git a/spec/mailers/account_mailers/promotion_letters_of_support_reminder_spec.rb b/spec/mailers/account_mailers/promotion_letters_of_support_reminder_spec.rb index 89e42b6dee..0233e55fc1 100644 --- a/spec/mailers/account_mailers/promotion_letters_of_support_reminder_spec.rb +++ b/spec/mailers/account_mailers/promotion_letters_of_support_reminder_spec.rb @@ -21,7 +21,7 @@ before do doc = form_answer.document form_answer.document = doc.merge(nominee_info_first_name: "Jovan", - nominee_info_last_name: "Savovich",) + nominee_info_last_name: "Savovich") form_answer.save! end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index e428f7bdc7..fad9df217c 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -29,8 +29,8 @@ included_fa_1 = create(:form_answer, :trade, :submitted, award_year: current_year, user: user) included_fa_2 = create(:form_answer, :mobility, :submitted, award_year: current_year, user: user) excluded_fa_1 = create(:form_answer, :innovation, :submitted, award_year: current_year, user: user) - excluded_fa_2 = create(:form_answer, :mobility, award_year: current_year, user: user) - excluded_fa_3 = create(:form_answer, :mobility, :submitted, award_year: current_year) + create(:form_answer, :mobility, award_year: current_year, user: user) + create(:form_answer, :mobility, :submitted, award_year: current_year) expect(account.reload.other_submitted_applications(excluded_fa_1).pluck(:id)).to contain_exactly(included_fa_1.id, included_fa_2.id) end diff --git a/spec/models/assessor_assignment_spec.rb b/spec/models/assessor_assignment_spec.rb index a7abece4da..5540bc2ec6 100644 --- a/spec/models/assessor_assignment_spec.rb +++ b/spec/models/assessor_assignment_spec.rb @@ -206,12 +206,12 @@ end describe "#as_json" do - let(:form) { create(:form_answer, :trade ) } + let(:form) { create(:form_answer, :trade) } it "should return error" do assessor_assignment = build :assessor_assignment, position: nil, form_answer: form assessor_assignment.valid? - expect(assessor_assignment.as_json).to eq({ :error => ["Position is empty - it is a required field and an option should be selected from the following list"] }) + expect(assessor_assignment.as_json).to eq({ error: ["Position is empty - it is a required field and an option should be selected from the following list"] }) end it "should return empty json" do @@ -243,6 +243,6 @@ def build_assignment_with(award_type, meth) obj = build(:assessor_assignment, award_type) - obj.public_send("#{form.desc(meth)}=", "123") + obj.public_send(:"#{form.desc(meth)}=", "123") obj end diff --git a/spec/models/assessor_spec.rb b/spec/models/assessor_spec.rb index b19828d9a9..679006fbfe 100644 --- a/spec/models/assessor_spec.rb +++ b/spec/models/assessor_spec.rb @@ -88,7 +88,7 @@ expect(Reports::AssessorsProgressReport).to receive_message_chain(:new, :build) Reports::AssessorReport.new("assessors-progress", year, assessor, category: "trade").as_csv - expect{ Reports::AssessorReport.new("assessors-progress", year, assessor, category: "invalid").as_csv }.to raise_error(ArgumentError) + expect { Reports::AssessorReport.new("assessors-progress", year, assessor, category: "invalid").as_csv }.to raise_error(ArgumentError) end end diff --git a/spec/models/assessors_import/builder_spec.rb b/spec/models/assessors_import/builder_spec.rb index dc300ab2c4..313d739299 100644 --- a/spec/models/assessors_import/builder_spec.rb +++ b/spec/models/assessors_import/builder_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" describe AssessorsImport::Builder do - let(:csv_path) { File.join(Rails.root, "spec", "support", "file_samples", "emails.csv") } + let(:csv_path) { Rails.root.join("spec/support/file_samples/emails.csv") } subject { AssessorsImport::Builder.new(csv_path) } describe "#initialize" do @@ -13,17 +13,17 @@ describe "#process" do context "with emails not used by accessors" do it "creates new instances of Assessor based on the emails" do - expect{ subject.process }.to change(Assessor, :count).by(subject.csv.count) + expect { subject.process }.to change(Assessor, :count).by(subject.csv.count) end end context "save failed" do - it "return not_saved" do - allow_any_instance_of(Assessor).to receive(:save) { false } - response = subject.process - expect(response[:not_saved]).not_to be_empty - end - end + it "return not_saved" do + allow_any_instance_of(Assessor).to receive(:save) { false } + response = subject.process + expect(response[:not_saved]).not_to be_empty + end + end context "with emails already used by accessors" do before do @@ -32,7 +32,7 @@ it "does not create new Assessors for the giving emails" do subject.process - expect{ subject.process }.not_to change(Assessor, :count) + expect { subject.process }.not_to change(Assessor, :count) end end end diff --git a/spec/models/audit_certificate_spec.rb b/spec/models/audit_certificate_spec.rb index 190fa6c309..9c7416d64b 100644 --- a/spec/models/audit_certificate_spec.rb +++ b/spec/models/audit_certificate_spec.rb @@ -6,7 +6,7 @@ end describe "validations" do - %w(form_answer_id attachment).each do |field_name| + %w[form_answer_id attachment].each do |field_name| it { should validate_presence_of field_name } end diff --git a/spec/models/award_year_spec.rb b/spec/models/award_year_spec.rb index 25290cf7e1..5205633e2b 100644 --- a/spec/models/award_year_spec.rb +++ b/spec/models/award_year_spec.rb @@ -174,19 +174,19 @@ end describe "instance methods" do - let(:award_year) { build(:award_year) } - context "form_data_generation_can_be_started?" do - it "should return correct value" do - allow(Settings).to receive(:after_current_submission_deadline?) { true } - allow_any_instance_of(AwardYear).to receive(:form_data_hard_copies_state) { nil } - expect(award_year.form_data_generation_can_be_started?).to be_truthy - - allow_any_instance_of(AwardYear).to receive(:form_data_hard_copies_state) { "not_nil" } - expect(award_year.form_data_generation_can_be_started?).to be_falsey - end - end - - context "case_summary_generation_can_be_started?" do + let(:award_year) { build(:award_year) } + context "form_data_generation_can_be_started?" do + it "should return correct value" do + allow(Settings).to receive(:after_current_submission_deadline?) { true } + allow_any_instance_of(AwardYear).to receive(:form_data_hard_copies_state) { nil } + expect(award_year.form_data_generation_can_be_started?).to be_truthy + + allow_any_instance_of(AwardYear).to receive(:form_data_hard_copies_state) { "not_nil" } + expect(award_year.form_data_generation_can_be_started?).to be_falsey + end + end + + context "case_summary_generation_can_be_started?" do it "should return correct value" do allow(Settings).to receive(:winners_stage?) { true } allow_any_instance_of(AwardYear).to receive(:case_summary_hard_copies_state) { nil } @@ -195,9 +195,9 @@ allow_any_instance_of(AwardYear).to receive(:case_summary_hard_copies_state) { "not_nil" } expect(award_year.case_summary_generation_can_be_started?).to be_falsey end - end + end - context "feedback_generation_can_be_started?" do + context "feedback_generation_can_be_started?" do it "should return correct value" do allow(Settings).to receive(:unsuccessful_stage?) { true } allow_any_instance_of(AwardYear).to receive(:feedback_hard_copies_state) { nil } @@ -206,9 +206,9 @@ allow_any_instance_of(AwardYear).to receive(:feedback_hard_copies_state) { "not_nil" } expect(award_year.feedback_generation_can_be_started?).to be_falsey end - end + end - context "aggregated_case_summary_generation_can_be_started?" do + context "aggregated_case_summary_generation_can_be_started?" do it "should return correct value" do allow(Settings).to receive(:winners_stage?) { true } allow_any_instance_of(AwardYear).to receive(:aggregated_case_summary_hard_copy_state) { nil } @@ -217,24 +217,24 @@ allow_any_instance_of(AwardYear).to receive(:aggregated_case_summary_hard_copy_state) { "not_nil" } expect(award_year.aggregated_case_summary_generation_can_be_started?).to be_falsey end - end + end - context "aggregated_feedback_generation_can_be_started?" do - it "should return correct value" do - allow(Settings).to receive(:unsuccessful_stage?) { true } - allow_any_instance_of(AwardYear).to receive(:aggregated_feedback_hard_copy_state) { nil } - expect(award_year.aggregated_feedback_generation_can_be_started?).to be_truthy + context "aggregated_feedback_generation_can_be_started?" do + it "should return correct value" do + allow(Settings).to receive(:unsuccessful_stage?) { true } + allow_any_instance_of(AwardYear).to receive(:aggregated_feedback_hard_copy_state) { nil } + expect(award_year.aggregated_feedback_generation_can_be_started?).to be_truthy - allow_any_instance_of(AwardYear).to receive(:aggregated_feedback_hard_copy_state) { "not_nil" } - expect(award_year.aggregated_feedback_generation_can_be_started?).to be_falsey - end + allow_any_instance_of(AwardYear).to receive(:aggregated_feedback_hard_copy_state) { "not_nil" } + expect(award_year.aggregated_feedback_generation_can_be_started?).to be_falsey end + end - context "check_aggregated_hard_copy_pdf_generation_status!" do - it "should return false" do - expect(award_year.check_aggregated_hard_copy_pdf_generation_status!("feedback")).to be_falsey - end - end + context "check_aggregated_hard_copy_pdf_generation_status!" do + it "should return false" do + expect(award_year.check_aggregated_hard_copy_pdf_generation_status!("feedback")).to be_falsey + end + end end end diff --git a/spec/models/deadline_spec.rb b/spec/models/deadline_spec.rb index addcdb1e4a..021b74d874 100644 --- a/spec/models/deadline_spec.rb +++ b/spec/models/deadline_spec.rb @@ -8,12 +8,12 @@ describe "#passed?" do it "returns true when deadline is passed" do - deadline = Deadline.new(trigger_at: Time.zone.now - 2.hours) + deadline = Deadline.new(trigger_at: Time.current - 2.hours) expect(deadline).to be_passed end it "returns false when deadline is not passed" do - deadline = Deadline.new(trigger_at: Time.zone.now + 2.hours) + deadline = Deadline.new(trigger_at: Time.current + 2.hours) expect(deadline).not_to be_passed end @@ -25,7 +25,7 @@ describe "class methods" do it ".with_states_to_trigger should filter correctly" do - time = Time.now + time = Time.current target = Deadline.where(kind: "submission_end", states_triggered_at: nil).where("trigger_at < ?", time).to_sql expect(target).to eq Deadline.with_states_to_trigger(time).to_sql end diff --git a/spec/models/eligibility/mobility_spec.rb b/spec/models/eligibility/mobility_spec.rb index 2c58dbd21f..5478057b77 100644 --- a/spec/models/eligibility/mobility_spec.rb +++ b/spec/models/eligibility/mobility_spec.rb @@ -48,10 +48,10 @@ end describe ".award_name" do - let(:eligibility) { Eligibility::Mobility.new(account: account) } + let(:eligibility) { Eligibility::Mobility.new(account: account) } - it "should return award_name" do - expect(eligibility.class.award_name).to eq "Social Mobility Award" + it "should return award_name" do + expect(eligibility.class.award_name).to eq "Social Mobility Award" + end end end -end diff --git a/spec/models/eligibility_spec.rb b/spec/models/eligibility_spec.rb index 645c671ab8..8390c00363 100644 --- a/spec/models/eligibility_spec.rb +++ b/spec/models/eligibility_spec.rb @@ -29,7 +29,7 @@ it "should return sorted_answers" do Eligibility.property(:test, {}) eligibility = Eligibility.new(answers: { test: "ans" }) - expect(eligibility.sorted_answers).to eq ({ "test" => "ans" }) + expect(eligibility.sorted_answers).to eq({ "test" => "ans" }) end end end diff --git a/spec/models/form_answer_spec.rb b/spec/models/form_answer_spec.rb index 113c0be734..455d3eb7e9 100644 --- a/spec/models/form_answer_spec.rb +++ b/spec/models/form_answer_spec.rb @@ -125,7 +125,7 @@ end describe "validations" do - %w(user).each do |field_name| + %w[user].each do |field_name| it { should validate_presence_of field_name } end @@ -141,13 +141,13 @@ form_answer.document = form_answer.document.merge(started_trading_day: "2", started_trading_month: 12, started_trading_year: Date.current.year - 2, - trade_commercial_success: "3 to 5",) + trade_commercial_success: "3 to 5") expect(form_answer).to be_invalid form_answer.document = form_answer.document.merge(started_trading_day: "2", started_trading_month: 12, started_trading_year: Date.current.year - 7, - trade_commercial_success: "3 to 5",) + trade_commercial_success: "3 to 5") expect(form_answer).to be_valid end @@ -190,7 +190,7 @@ create(:form_answer, :trade, :submitted) end - let(:award_year) { AwardYear.current.year.to_s[2..-1] } + let(:award_year) { AwardYear.current.year.to_s[2..] } it "creates form with URN" do expect(form_answer.urn).to eq("KA0001/#{award_year}T") diff --git a/spec/models/form_answer_state_machine_spec.rb b/spec/models/form_answer_state_machine_spec.rb index 1ca9640d29..fba43b831a 100644 --- a/spec/models/form_answer_state_machine_spec.rb +++ b/spec/models/form_answer_state_machine_spec.rb @@ -26,8 +26,9 @@ describe "assessment_in_progress -> withdrawn" do let(:lead) { create(:assessor, :lead_for_all) } it "sends notification for the Lead Assessor" do - expect(Assessors::GeneralMailer).to receive( - :led_application_withdrawn).and_return(double(deliver_later!: true)) + expect(Assessors::GeneralMailer) + .to receive(:led_application_withdrawn) + .and_return(double(deliver_later!: true)) form_answer.update_column(:state, "assessment_in_progress") form_answer.state_machine.perform_transition(:withdrawn, lead) expect(form_answer.reload.state).to eq("withdrawn") diff --git a/spec/models/form_answer_statistics/picker_spec.rb b/spec/models/form_answer_statistics/picker_spec.rb index 5ed33a2fde..84d5c1ee18 100644 --- a/spec/models/form_answer_statistics/picker_spec.rb +++ b/spec/models/form_answer_statistics/picker_spec.rb @@ -94,7 +94,7 @@ fa2 = create(:form_answer) fa2.state_machine.perform_transition(:submitted, nil, false) - date = (Date.current.month == 12) ? Date.current + 12.months : Date.current + 12.months + date = Date.current + 12.months Timecop.freeze(date) do 2.times do @@ -116,7 +116,8 @@ fa1 = create(:form_answer, :trade) fa1.state_machine.perform_transition(:submitted, nil, false) - date = (Date.current.month == 12) ? Date.current + 12.months : Date.current + 12.months + date = Date.current + 12.months + Timecop.freeze(date) do fa2 = create(:form_answer, :trade) fa2.state_machine.perform_transition(:submitted, nil, false) @@ -131,7 +132,8 @@ it "calculates proper stats" do expect(subject.applications_completions["trade"]).to eq([0, 0, 0, 0, 0, 0, 0, 0]) - date = (Date.current.month == 12) ? Date.current + 12.months : Date.current + 12.months + date = Date.current + 12.months + Timecop.freeze(date) do populate_application_completions end diff --git a/spec/models/reports/admin/assessor_judge_admin_data_report_spec.rb b/spec/models/reports/admin/assessor_judge_admin_data_report_spec.rb index 93fde9508c..5bc96ebbe9 100644 --- a/spec/models/reports/admin/assessor_judge_admin_data_report_spec.rb +++ b/spec/models/reports/admin/assessor_judge_admin_data_report_spec.rb @@ -1,11 +1,11 @@ require "rails_helper" describe Reports::Admin::AssessorJudgeAdminDataReport do - let! (:admin) { create(:admin) } - let! (:assessor) { create(:assessor, :lead_for_trade) } - let! (:judge) { create(:judge, :innovation) } + let!(:admin) { create(:admin) } + let!(:assessor) { create(:assessor, :lead_for_trade) } + let!(:judge) { create(:judge, :innovation) } - let(:output) { described_class.new().as_csv } + let(:output) { described_class.new.as_csv } it "creates the output with relevant data for Admins" do expect(output).to include(admin.id.to_s) expect(output).to include(admin.first_name) diff --git a/spec/models/reports/form_document_picker_spec.rb b/spec/models/reports/form_document_picker_spec.rb index a60212fbed..a0947abaee 100644 --- a/spec/models/reports/form_document_picker_spec.rb +++ b/spec/models/reports/form_document_picker_spec.rb @@ -2,11 +2,10 @@ describe Reports::DataPickers::FormDocumentPicker do let(:dummy_class) do - klass = Class.new do + Class.new do include Reports::DataPickers::FormDocumentPicker - def obj; - end + def obj; end end end @@ -25,19 +24,19 @@ def obj; year_1, year_2, year_3 = PreviousWin.available_years awards = [ { - "category" => "innovation", - "year" => year_1, - "outcome" => "won", + "category" => "innovation", + "year" => year_1, + "outcome" => "won", }, { - "category" => "", - "year" => year_2, - "outcome" => "won", + "category" => "", + "year" => year_2, + "outcome" => "won", }, { - "category" => "trade", - "year" => year_3, - "outcome" => "did_not_win", + "category" => "trade", + "year" => year_3, + "outcome" => "did_not_win", }, ] @@ -50,29 +49,22 @@ def obj; describe "instance methods" do let(:custom_class) do - klass = Class.new do + Class.new do include Reports::DataPickers::FormDocumentPicker - def business_form? - end + def business_form?; end - def question_visible?(key) - end + def question_visible?(key); end - def obj - end + def obj; end - def trade? - end + def trade?; end - def innovation? - end + def innovation?; end - def development? - end + def development?; end - def mobility? - end + def mobility?; end end end let(:subject) { custom_class.new } diff --git a/spec/models/settings_spec.rb b/spec/models/settings_spec.rb index 789281482e..7298ec12c4 100644 --- a/spec/models/settings_spec.rb +++ b/spec/models/settings_spec.rb @@ -4,9 +4,7 @@ context "after create" do let(:settings) { Settings.current } let(:deadlines) { - Deadline::AVAILABLE_DEADLINES.sort do |a, b| - a <=> b - end + Deadline::AVAILABLE_DEADLINES.sort } it "creates all kinds of deadlines" do diff --git a/spec/models/shared/formatted_time_for_examples.rb b/spec/models/shared/formatted_time_for_examples.rb index c1deb78954..2340c12df2 100644 --- a/spec/models/shared/formatted_time_for_examples.rb +++ b/spec/models/shared/formatted_time_for_examples.rb @@ -1,39 +1,39 @@ shared_examples "date_time_for" do |field| it "returns date" do - subject.public_send("#{field}=", Time.zone.local(2012, 9, 6, 1, 30)) - expect(subject.public_send("#{field}_date")).to eq(Date.civil(2012, 9, 6)) + subject.public_send(:"#{field}=", Time.zone.local(2012, 9, 6, 1, 30)) + expect(subject.public_send(:"#{field}_date")).to eq(Date.civil(2012, 9, 6)) end it "returns seconds of beginning of day" do - subject.public_send("#{field}=", Time.zone.local(2012, 9, 6, 1, 30)) - expect(subject.public_send("formatted_#{field}_time")).to eq("01:30") - expect(subject.public_send("formatted_#{field}_date")).to eq("06/09/2012") + subject.public_send(:"#{field}=", Time.zone.local(2012, 9, 6, 1, 30)) + expect(subject.public_send(:"formatted_#{field}_time")).to eq("01:30") + expect(subject.public_send(:"formatted_#{field}_date")).to eq("06/09/2012") end it "returns Time" do - subject.public_send "formatted_#{field}_date=", "06/09/2012" - subject.public_send "formatted_#{field}_time=", "01:30" + subject.public_send :"formatted_#{field}_date=", "06/09/2012" + subject.public_send :"formatted_#{field}_time=", "01:30" expect(subject.public_send(field)).to eq(Time.zone.local(2012, 9, 6, 1, 30)) end it "resets value" do - subject.public_send("#{field}=", Time.zone.local(2012, 9, 6, 1, 30)) - subject.public_send("formatted_#{field}_date=", "") - subject.public_send("formatted_#{field}_time=", "") + subject.public_send(:"#{field}=", Time.zone.local(2012, 9, 6, 1, 30)) + subject.public_send(:"formatted_#{field}_date=", "") + subject.public_send(:"formatted_#{field}_time=", "") expect(subject.public_send(field)).to be_nil end it "updates date" do - subject.public_send("#{field}=", Time.zone.local(2012, 9, 6, 1, 30)) - subject.public_send("formatted_#{field}_date=", "05/09/2012") + subject.public_send(:"#{field}=", Time.zone.local(2012, 9, 6, 1, 30)) + subject.public_send(:"formatted_#{field}_date=", "05/09/2012") expect(subject.public_send(field)).to eq(Time.zone.local(2012, 9, 5, 1, 30)) end it "updates time twice" do - subject.public_send("#{field}=", Time.zone.local(2012, 9, 6, 1, 30)) - subject.public_send("formatted_#{field}_date=", "05/09/2012") - subject.public_send "formatted_#{field}_time=", "01:30" - subject.public_send "formatted_#{field}_time=", "03:30" + subject.public_send(:"#{field}=", Time.zone.local(2012, 9, 6, 1, 30)) + subject.public_send(:"formatted_#{field}_date=", "05/09/2012") + subject.public_send :"formatted_#{field}_time=", "01:30" + subject.public_send :"formatted_#{field}_time=", "03:30" expect(subject.public_send(field)).to eq(Time.zone.local(2012, 9, 5, 3, 30)) end end diff --git a/spec/models/support_letter_attachment_spec.rb b/spec/models/support_letter_attachment_spec.rb index 1f6be5b992..3df9f4d5a9 100644 --- a/spec/models/support_letter_attachment_spec.rb +++ b/spec/models/support_letter_attachment_spec.rb @@ -2,7 +2,7 @@ RSpec.describe SupportLetterAttachment, type: :model do describe "validations" do - %w(user form_answer attachment).each do |field_name| + %w[user form_answer attachment].each do |field_name| it { should validate_presence_of field_name } end @@ -12,23 +12,17 @@ let(:too_big_file) do Rack::Test::UploadedFile.new( - File.join( - Rails.root, "spec", "support", "file_samples", "photo_with_size_more_than_5MB.jpg", - ), + Rails.root.join("spec/support/file_samples/photo_with_size_more_than_5MB.jpg"), ) end let(:file_with_wrong_extension) do Rack::Test::UploadedFile.new( - File.join( - Rails.root, "spec", "support", "file_samples", "simple_txt_sample.log", - ), + Rails.root.join("spec/support/file_samples/simple_txt_sample.log"), ) end let(:normal_file) do Rack::Test::UploadedFile.new( - File.join( - Rails.root, "spec", "support", "file_samples", "photo_with_size_less_than_5MB.jpg", - ), + Rails.root.join("spec/support/file_samples/photo_with_size_less_than_5MB.jpg"), ) end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index dbe8414706..fb7623bdbe 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -24,7 +24,7 @@ end it ".confirmed should exclude ids" do - expect(User.where("confirmed_at IS NOT NULL").to_sql).to eq User.confirmed.to_sql + expect(User.where.not(confirmed_at: nil).to_sql).to eq User.confirmed.to_sql end end diff --git a/spec/models/users_import/builder_spec.rb b/spec/models/users_import/builder_spec.rb index a054822791..12047aef15 100644 --- a/spec/models/users_import/builder_spec.rb +++ b/spec/models/users_import/builder_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" describe UsersImport::Builder do - subject { described_class.new("#{Rails.root}/spec/fixtures/users.csv") } + subject { described_class.new(Rails.root.join("spec/fixtures/users.csv")) } describe "#process" do it "imports the users" do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 1a4b72fea6..c780c9636a 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,3 +1,26 @@ +require "simplecov" + +SimpleCov.start "rails" do + add_filter "/spec/" + add_filter "/lib/tasks/" + add_filter "vendor" + add_filter "/forms/award_years/" + add_filter "/app/pdf_generators/" + add_filter "/app/tasks/" + + enable_coverage_for_eval + + add_filter do |source_file| + source_file.filename.include?("app/controllers") && source_file.lines.count < 8 + end +end + +class LineFilter < SimpleCov::Filter + def matches?(source_file) + source_file.lines.count < filter_argument + end +end + # This file is copied to spec/ when you run 'rails generate rspec:install' require "spec_helper" ENV["RAILS_ENV"] ||= "test" @@ -7,30 +30,10 @@ require "rspec/rails" require "shoulda/matchers" require "webmock/rspec" -require "simplecov" require "codeclimate-test-reporter" WebMock.disable_net_connect!(allow: Capybara.server_host, allow_localhost: true) -SimpleCov.add_filter "vendor" - -class LineFilter < SimpleCov::Filter - def matches?(source_file) - source_file.lines.count < filter_argument - end -end - -SimpleCov.start "rails" do - add_filter "/spec/" - add_filter "/lib/tasks/" - add_filter "/app/forms/award_years/" - add_filter "/app/pdf_generators/" - add_filter "/app/tasks/" - add_filter do |source_file| - source_file.filename =~ /app\/controllers/ && source_file.lines.count < 8 - end -end - ActiveRecord::Migration.check_pending! # Add additional requires below this line. Rails is not loaded until this point! @@ -47,7 +50,7 @@ def matches?(source_file) # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. -Dir[Rails.root.join("spec", "support", "**", "*.rb")].sort.each { |f| require f } +Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f } # Checks for pending migrations and applies them before tests are run. # If you are not using ActiveRecord, you can remove these lines. @@ -68,6 +71,7 @@ def matches?(source_file) config.include UserStepDefinitions, type: :feature config.include ExpectationHelper, type: :feature config.include DeadlineHelper, type: :feature + config.include Warden::Test::Helpers config.include Devise::Test::ControllerHelpers, type: :controller config.raise_error_for_unimplemented_steps = true diff --git a/spec/renderers/mail_renderer_spec.rb b/spec/renderers/mail_renderer_spec.rb index 830cdb31e7..2ba2289643 100644 --- a/spec/renderers/mail_renderer_spec.rb +++ b/spec/renderers/mail_renderer_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe MailRenderer do describe "#submission_started_notification" do diff --git a/spec/requests/account/collaborators_spec.rb b/spec/requests/account/collaborators_spec.rb index 2a4db48acd..41d69ecc0f 100644 --- a/spec/requests/account/collaborators_spec.rb +++ b/spec/requests/account/collaborators_spec.rb @@ -1,5 +1,4 @@ require "rails_helper" -include Warden::Test::Helpers describe "API" do let!(:account_admin) do diff --git a/spec/services/assessor_assignment_service_spec.rb b/spec/services/assessor_assignment_service_spec.rb index 5b3f978950..aab69250ae 100644 --- a/spec/services/assessor_assignment_service_spec.rb +++ b/spec/services/assessor_assignment_service_spec.rb @@ -33,7 +33,7 @@ allow(assessor).to receive(:lead?).and_return(false) end - it "can not change the assigned assessor"do + it "can not change the assigned assessor" do expect(subject.permitted_params).to_not include(:assessor_id) end end @@ -132,7 +132,7 @@ subject.save expect(subject.update_params).to eq( "commercial_success_desc" => "I am description", - "strategy_desc" => "should be saved",) + "strategy_desc" => "should be saved") end end end diff --git a/spec/services/company_registration_number_spec.rb b/spec/services/company_registration_number_spec.rb index d5b0163d0e..ff69dc3df4 100644 --- a/spec/services/company_registration_number_spec.rb +++ b/spec/services/company_registration_number_spec.rb @@ -21,8 +21,8 @@ end it "extracts company registration number from HTML block" do - content = %Q{
    Registered Company Number - .06883289
    \r\n\r\n

     

    \r\n} - alternative_content = %Q{

    My company number is :06883289.

    \r\n} + content = %(
    Registered Company Number - .06883289
    \r\n\r\n

     

    \r\n) + alternative_content = %(

    My company number is :06883289.

    \r\n) expect( described_class.extract_from(content), @@ -34,7 +34,7 @@ end it "extracts multiple company registration numbers from HTML block" do - content = %Q{

    My company numbers are 06883289 and 02429054 as well as 05637000

    \r\n} + content = %(

    My company numbers are 06883289 and 02429054 as well as 05637000

    \r\n) expect( described_class.extract_from(content), @@ -42,4 +42,3 @@ end end end - diff --git a/spec/services/notifiers/email_notification_service_spec.rb b/spec/services/notifiers/email_notification_service_spec.rb index 4594fab434..d65a0465cc 100644 --- a/spec/services/notifiers/email_notification_service_spec.rb +++ b/spec/services/notifiers/email_notification_service_spec.rb @@ -2,15 +2,15 @@ describe Notifiers::EmailNotificationService do let!(:sent_notification) do - create(:email_notification, trigger_at: Time.now - 1.day, sent: true, kind: kind) + create(:email_notification, trigger_at: Time.current - 1.day, sent: true, kind: kind) end let!(:current_notification) do - create(:email_notification, trigger_at: Time.now - 1.day, kind: kind) + create(:email_notification, trigger_at: Time.current - 1.day, kind: kind) end let!(:future_notification) do - create(:email_notification, trigger_at: Time.now + 1.day, kind: kind) + create(:email_notification, trigger_at: Time.current + 1.day, kind: kind) end let(:user) do @@ -264,7 +264,7 @@ let!(:account_holder) { form_answer.account.owner } it "triggers current notification" do - mailer = double(deliver_later!: true) + double(deliver_later!: true) expect { described_class.run @@ -284,7 +284,7 @@ create(:palace_invite, email: form_answer.decorate.head_of_business_email, form_answer: form_answer, - submitted: true,) + submitted: true) expect(AccountMailers::BuckinghamPalaceInviteMailer).not_to receive(:invite) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index de1e69de2f..dad6fac296 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -51,51 +51,49 @@ # triggering implicit auto-inclusion in groups with matching metadata. config.shared_context_metadata_behavior = :apply_to_host_groups -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ + # config.disable_monkey_patching! + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 0cd81ef695..2ea0acc4de 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -4,7 +4,7 @@ require "capybara/rspec" require "selenium/webdriver" -Capybara.server = :puma #, { Silent: true } +Capybara.server = :puma # , { Silent: true } Capybara.register_driver(:chrome_headless) do |app| options = ::Selenium::WebDriver::Chrome::Options.new diff --git a/spec/support/form_answer_filtering_test_helper.rb b/spec/support/form_answer_filtering_test_helper.rb index 3a72e57127..8280d4cbcd 100644 --- a/spec/support/form_answer_filtering_test_helper.rb +++ b/spec/support/form_answer_filtering_test_helper.rb @@ -5,6 +5,7 @@ def assert_results_number(n) end end + # rubocop:disable Lint/NonLocalExitFromIterator def click_status_option(val) within ".applications-filter.status-filter" do find(".dropdown-toggle").click @@ -52,6 +53,7 @@ def click_status_option(val) end fail "NotFoundOption" end + # rubocop:enable Lint/NonLocalExitFromIterator def assign_dummy_assessors(form_answers, assessor) Array(form_answers).each do |fa| diff --git a/spec/support/shared_contexts/admin_all_case_summaries_pdf_generation.rb b/spec/support/shared_contexts/admin_all_case_summaries_pdf_generation.rb index 0162233255..76a64ef981 100644 --- a/spec/support/shared_contexts/admin_all_case_summaries_pdf_generation.rb +++ b/spec/support/shared_contexts/admin_all_case_summaries_pdf_generation.rb @@ -17,10 +17,12 @@ let(:assessor_assignment_document) do res = {} - AppraisalForm.struct(form_answer).each do |key, _| + ratings = %w[negative positive average] + + AppraisalForm.struct(form_answer).each do |key, values| res["#{key}_desc"] = "Lorem Ipsum" - if _[:type] != :non_rag - res["#{key}_rate"] = ["negative", "positive", "average"].sample + if values[:type] != :non_rag + res["#{key}_rate"] = ratings.sample end end diff --git a/spec/support/shared_contexts/admin_application_case_summaries_pdf_download.rb b/spec/support/shared_contexts/admin_application_case_summaries_pdf_download.rb index 3692deefcc..f8d3235006 100644 --- a/spec/support/shared_contexts/admin_application_case_summaries_pdf_download.rb +++ b/spec/support/shared_contexts/admin_application_case_summaries_pdf_download.rb @@ -18,10 +18,12 @@ let(:assessor_assignment_document) do res = {} + ratings = %w[negative positive average] + AppraisalForm.struct(form_answer).each do |key, value| res["#{key}_desc"] = "Lorem Ipsum" if value[:type] != :non_rag - res["#{key}_rate"] = ["negative", "positive", "average"].sample + res["#{key}_rate"] = ratings.sample end end diff --git a/spec/support/shared_contexts/admin_feedback_pdf_file_checks.rb b/spec/support/shared_contexts/admin_feedback_pdf_file_checks.rb index 15adb389f7..dcd215209d 100644 --- a/spec/support/shared_contexts/admin_feedback_pdf_file_checks.rb +++ b/spec/support/shared_contexts/admin_feedback_pdf_file_checks.rb @@ -13,11 +13,13 @@ let(:feedback_content) do res = {} + ratings = %w[average neutral negative positive] + FeedbackForm.fields_for_award_type(form_answer).each_with_index do |block, index| key = block[0] if block[1][:type] == :strengths - res["#{key}_rate"] = %w(average neutral negative positive).sample + res["#{key}_rate"] = ratings.sample else res["#{key}_strength"] = "#{index}_strength" res["#{key}_weakness"] = "#{index}_weakness" @@ -69,7 +71,7 @@ FeedbackForm.fields_for_award_type(form_answer).each do |key, opts| if opts[:type] == :strengths year = form_answer.award_year.year - expect(pdf_content).to include(AppraisalForm.const_get("STRENGTH_OPTIONS_#{year}").detect { |k, v| v == feedback.document["#{key}_rate"] }[0] ) + expect(pdf_content).to include(AppraisalForm.const_get("STRENGTH_OPTIONS_#{year}").detect { |k, v| v == feedback.document["#{key}_rate"] }[0]) else expect(pdf_content).to include(feedback.document["#{key}_strength"]) expect(pdf_content).to include(feedback.document["#{key}_weakness"]) diff --git a/spec/support/shared_contexts/appraisal_form_context.rb b/spec/support/shared_contexts/appraisal_form_context.rb index 353defdf1b..443c850015 100644 --- a/spec/support/shared_contexts/appraisal_form_context.rb +++ b/spec/support/shared_contexts/appraisal_form_context.rb @@ -132,13 +132,12 @@ def assert_description_change(section_id, header_id) end def assert_multiple_description_change(section_id, header_id, prefix) - text = "should NOT be saved" - text2 = "should be saved" + text = "should be saved" find("#{header_id} .panel-title a").click take_a_nap within section_id do - fill_in("#{prefix}_verdict", with: text2) + fill_in("#{prefix}_verdict", with: text) all(".form-cancel-link").each(&:click) all(".form-edit-link").last.click all(".form-save-link").last.click @@ -150,11 +149,11 @@ def assert_multiple_description_change(section_id, header_id, prefix) take_a_nap within section_id do - expect(page).to have_content(text2) + expect(page).to have_content(text) all(".form-edit-link").last.click - expect(page.find("##{prefix}_verdict").text).to eq text2 + expect(page.find("##{prefix}_verdict").text).to eq text end end diff --git a/spec/support/shared_contexts/non_js_form_base.rb b/spec/support/shared_contexts/non_js_form_base.rb index 7ecd785cc7..b2adb2c7f9 100644 --- a/spec/support/shared_contexts/non_js_form_base.rb +++ b/spec/support/shared_contexts/non_js_form_base.rb @@ -16,8 +16,8 @@ private def prepare_setting_deadlines - %w(innovation trade mobility development).each do |award| - start = settings.deadlines.public_send("#{award}_submission_start") + %w[innovation trade mobility development].each do |award| + start = settings.deadlines.public_send(:"#{award}_submission_start") start.update_column(:trigger_at, Time.zone.now - 20.days) end diff --git a/spec/support/shared_contexts/pdf_file_checks.rb b/spec/support/shared_contexts/pdf_file_checks.rb index a53060d0a0..ed00a0367c 100644 --- a/spec/support/shared_contexts/pdf_file_checks.rb +++ b/spec/support/shared_contexts/pdf_file_checks.rb @@ -25,10 +25,10 @@ end let(:award_application_title) do - if form_answer.promotion? - award_title = "King's Award for Enterprise Promotion #{AwardYear.current.year}" + award_title = if form_answer.promotion? + "King's Award for Enterprise Promotion #{AwardYear.current.year}" else - award_title = form_answer.decorate.award_application_title_print + form_answer.decorate.award_application_title_print end award_title.upcase end @@ -43,7 +43,7 @@ let(:match_name_condition) do if award_type == :promotion - form_answer.send("nominee_full_name_from_document").upcase + form_answer.send(:nominee_full_name_from_document).upcase else company_name end @@ -90,12 +90,12 @@ private def fetch_question_by_question_key(questions, question_key) - questions.select { |q| q.key.to_s == question_key.to_s }.first + questions.find { |q| q.key.to_s == question_key.to_s } end def question_option_title(question, answer) - question.options.select do |option| + question.options.find do |option| option.value.to_s == answer.to_s - end.first.text + end.text end end diff --git a/spec/tasks/manual_updaters/trade_award_downgrader_spec.rb b/spec/tasks/manual_updaters/trade_award_downgrader_spec.rb index 1b1c98d094..f15e4d2f71 100644 --- a/spec/tasks/manual_updaters/trade_award_downgrader_spec.rb +++ b/spec/tasks/manual_updaters/trade_award_downgrader_spec.rb @@ -30,13 +30,13 @@ document["employees_#{i + 1}of6"] = i + 1 end - %w(day month).each do |attr| + %w[day month].each do |attr| 5.times do |i| document["financial_year_changed_dates_#{i + 1}of6#{attr}"] = i + 1 end end - %w(overseas_sales total_turnover net_profit).each do |attr| + %w[overseas_sales total_turnover net_profit].each do |attr| 6.times do |i| document["#{attr}_#{i + 1}of6"] = 100000 + i + 1 end @@ -54,13 +54,13 @@ expect(document["employees_#{i + 1}of3"]).to eq(i + 4) end - %w(day month).each do |attr| + %w[day month].each do |attr| 2.times do |i| expect(document["financial_year_changed_dates_#{i + 1}of3#{attr}"]).to eq(i + 4) end end - %w(overseas_sales total_turnover net_profit).each do |attr| + %w[overseas_sales total_turnover net_profit].each do |attr| 3.times do |i| expect(document["#{attr}_#{i + 1}of3"]).to eq(100000 + i + 4) end diff --git a/spec/unit/pdf_generators/case_summary_pdfs/base_spec.rb b/spec/unit/pdf_generators/case_summary_pdfs/base_spec.rb index e4f46d0ee2..d679e8007d 100644 --- a/spec/unit/pdf_generators/case_summary_pdfs/base_spec.rb +++ b/spec/unit/pdf_generators/case_summary_pdfs/base_spec.rb @@ -14,15 +14,15 @@ end before do - [:current_year].each do |year| - [:innovation, :trade].each do |award_type| - form_answer = send("form_answer_#{year}_#{award_type}") - create :assessor_assignment, form_answer: form_answer, - submitted_at: Date.current, - assessor: nil, - position: "case_summary", - document: set_case_summary_content(form_answer) - end + award_types = %i[innovation trade] + + award_types.each do |award_type| + form_answer = send(:"form_answer_current_year_#{award_type}") + create :assessor_assignment, form_answer: form_answer, + submitted_at: Date.current, + assessor: nil, + position: "case_summary", + document: set_case_summary_content(form_answer) end end @@ -32,7 +32,7 @@ "all", nil, { category: "innovation", award_year: award_year, - }, + } ).set_form_answers .map(&:id) @@ -45,7 +45,7 @@ category: "trade", award_year: award_year, years_mode: "3", - }, + } ).set_form_answers .map(&:id) @@ -60,9 +60,11 @@ def set_case_summary_content(form_answer) res = {} + ratings = %w[negative positive average] + AppraisalForm.struct(form_answer).each do |key, value| res["#{key}_desc"] = "Lorem Ipsum" - res["#{key}_rate"] = ["negative", "positive", "average"].sample + res["#{key}_rate"] = ratings.sample end res diff --git a/spec/unit/pdf_generators/feedback_pdfs/base_spec.rb b/spec/unit/pdf_generators/feedback_pdfs/base_spec.rb index 426f8bb1e5..89b23f82e1 100644 --- a/spec/unit/pdf_generators/feedback_pdfs/base_spec.rb +++ b/spec/unit/pdf_generators/feedback_pdfs/base_spec.rb @@ -29,7 +29,7 @@ "all", nil, { category: "innovation", award_year: award_year, - }, + } ).set_feedbacks .map(&:id) @@ -41,7 +41,7 @@ "all", nil, { category: "trade", award_year: award_year, - }, + } ).set_feedbacks .map(&:id) diff --git a/spec/validators/company_registration_number_validator_spec.rb b/spec/validators/company_registration_number_validator_spec.rb index 8f10e76504..fbf1c80938 100644 --- a/spec/validators/company_registration_number_validator_spec.rb +++ b/spec/validators/company_registration_number_validator_spec.rb @@ -32,4 +32,3 @@ end end end - diff --git a/spec/workers/hard_copy_generators/aggregated_feedbacks_worker_spec.rb b/spec/workers/hard_copy_generators/aggregated_feedbacks_worker_spec.rb index c045cfb9ac..c2acfbd812 100644 --- a/spec/workers/hard_copy_generators/aggregated_feedbacks_worker_spec.rb +++ b/spec/workers/hard_copy_generators/aggregated_feedbacks_worker_spec.rb @@ -12,7 +12,3 @@ described_class.new.perform end end - - - - diff --git a/spec/workers/hard_copy_generators/base_worker_spec.rb b/spec/workers/hard_copy_generators/base_worker_spec.rb index 5c91fe42e3..c110719c64 100644 --- a/spec/workers/hard_copy_generators/base_worker_spec.rb +++ b/spec/workers/hard_copy_generators/base_worker_spec.rb @@ -3,7 +3,3 @@ RSpec.describe HardCopyPdfGenerators::BaseWorker do it { is_expected.to save_backtrace } end - - - - diff --git a/spec/workers/hard_copy_generators/collection_case_summary_worker_spec.rb b/spec/workers/hard_copy_generators/collection_case_summary_worker_spec.rb index 5e28fb7c24..bed6a37baa 100644 --- a/spec/workers/hard_copy_generators/collection_case_summary_worker_spec.rb +++ b/spec/workers/hard_copy_generators/collection_case_summary_worker_spec.rb @@ -11,7 +11,3 @@ described_class.new.perform end end - - - - diff --git a/spec/workers/hard_copy_generators/collection_feedback_worker_spec.rb b/spec/workers/hard_copy_generators/collection_feedback_worker_spec.rb index 441886caf2..71ddf178cf 100644 --- a/spec/workers/hard_copy_generators/collection_feedback_worker_spec.rb +++ b/spec/workers/hard_copy_generators/collection_feedback_worker_spec.rb @@ -11,7 +11,3 @@ described_class.new.perform end end - - - - diff --git a/spec/workers/hard_copy_generators/collection_form_data_worker_spec.rb b/spec/workers/hard_copy_generators/collection_form_data_worker_spec.rb index 7c6c695670..0cec8069f9 100644 --- a/spec/workers/hard_copy_generators/collection_form_data_worker_spec.rb +++ b/spec/workers/hard_copy_generators/collection_form_data_worker_spec.rb @@ -11,7 +11,3 @@ described_class.new.perform end end - - - - diff --git a/spec/workers/hard_copy_generators/feedback_worker_spec.rb b/spec/workers/hard_copy_generators/feedback_worker_spec.rb index fba8aa2e14..12722c0fea 100644 --- a/spec/workers/hard_copy_generators/feedback_worker_spec.rb +++ b/spec/workers/hard_copy_generators/feedback_worker_spec.rb @@ -8,7 +8,3 @@ described_class.new.perform(1) end end - - - - diff --git a/spec/workers/hard_copy_generators/form_data_worker_spec.rb b/spec/workers/hard_copy_generators/form_data_worker_spec.rb index 22e782c65a..9df7d224fe 100644 --- a/spec/workers/hard_copy_generators/form_data_worker_spec.rb +++ b/spec/workers/hard_copy_generators/form_data_worker_spec.rb @@ -12,7 +12,3 @@ described_class.new.perform(1) end end - - - - diff --git a/spec/workers/hard_copy_generators/status_checkers_aggregated_case_summary_worker_spec.rb b/spec/workers/hard_copy_generators/status_checkers_aggregated_case_summary_worker_spec.rb index 9b07da5e35..96c6296a35 100644 --- a/spec/workers/hard_copy_generators/status_checkers_aggregated_case_summary_worker_spec.rb +++ b/spec/workers/hard_copy_generators/status_checkers_aggregated_case_summary_worker_spec.rb @@ -9,7 +9,3 @@ described_class.new.perform end end - - - - diff --git a/spec/workers/hard_copy_generators/status_checkers_aggregated_feedback_worker_spec.rb b/spec/workers/hard_copy_generators/status_checkers_aggregated_feedback_worker_spec.rb index cdcfbbd5a8..c362047495 100644 --- a/spec/workers/hard_copy_generators/status_checkers_aggregated_feedback_worker_spec.rb +++ b/spec/workers/hard_copy_generators/status_checkers_aggregated_feedback_worker_spec.rb @@ -9,7 +9,3 @@ described_class.new.perform end end - - - - diff --git a/spec/workers/hard_copy_generators/status_checkers_case_summary_worker_spec.rb b/spec/workers/hard_copy_generators/status_checkers_case_summary_worker_spec.rb index efc4ecaf01..1dbfaf91c6 100644 --- a/spec/workers/hard_copy_generators/status_checkers_case_summary_worker_spec.rb +++ b/spec/workers/hard_copy_generators/status_checkers_case_summary_worker_spec.rb @@ -9,7 +9,3 @@ described_class.new.perform end end - - - - diff --git a/spec/workers/hard_copy_generators/status_checkers_feedback_worker_spec.rb b/spec/workers/hard_copy_generators/status_checkers_feedback_worker_spec.rb index 8d649e2d6c..18954c48a9 100644 --- a/spec/workers/hard_copy_generators/status_checkers_feedback_worker_spec.rb +++ b/spec/workers/hard_copy_generators/status_checkers_feedback_worker_spec.rb @@ -9,7 +9,3 @@ described_class.new.perform end end - - - - diff --git a/spec/workers/hard_copy_generators/status_checkers_form_data_worker_spec.rb b/spec/workers/hard_copy_generators/status_checkers_form_data_worker_spec.rb index 04aaee960e..a518a49321 100644 --- a/spec/workers/hard_copy_generators/status_checkers_form_data_worker_spec.rb +++ b/spec/workers/hard_copy_generators/status_checkers_form_data_worker_spec.rb @@ -9,7 +9,3 @@ described_class.new.perform end end - - - - diff --git a/spec/workers/scheduled_base_worker_spec.rb b/spec/workers/scheduled_base_worker_spec.rb index 0770ea0cf4..c60076f4e3 100644 --- a/spec/workers/scheduled_base_worker_spec.rb +++ b/spec/workers/scheduled_base_worker_spec.rb @@ -3,7 +3,3 @@ RSpec.describe Scheduled::BaseWorker do it { is_expected.to save_backtrace } end - - - -