From d18c627392c1d628cd949020d7989bd0dbf71a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 31 Oct 2025 14:40:32 +0100 Subject: [PATCH] Add and apply Layout/EmptyLinesAfterModuleInclusion rule This rule was added in rubocop 1.79. We were inconsistent about it, so we're adding it to get more consistency. --- .rubocop.yml | 3 +++ app/components/admin/action_component.rb | 1 + app/components/admin/banners/form_component.rb | 1 + app/components/admin/budget_groups/groups_component.rb | 1 + app/components/admin/budget_headings/form_component.rb | 1 + app/components/admin/budgets/index_component.rb | 1 + app/components/admin/budgets/show_component.rb | 1 + app/components/admin/budgets_wizard/budgets/edit_component.rb | 1 + app/components/admin/budgets_wizard/budgets/new_component.rb | 1 + app/components/admin/budgets_wizard/groups/edit_component.rb | 1 + app/components/admin/budgets_wizard/groups/index_component.rb | 1 + app/components/admin/budgets_wizard/headings/edit_component.rb | 1 + .../admin/budgets_wizard/headings/index_component.rb | 1 + app/components/admin/budgets_wizard/phases/edit_component.rb | 1 + app/components/admin/budgets_wizard/phases/index_component.rb | 1 + app/components/admin/geozones/index_component.rb | 1 + .../admin/legislation/draft_versions/form_component.rb | 1 + app/components/admin/locales/show_component.rb | 1 + app/components/admin/machine_learning/show_component.rb | 1 + app/components/admin/menu_component.rb | 1 + app/components/admin/poll/questions/form_component.rb | 1 + app/components/admin/progress_bars/form_component.rb | 1 + app/components/admin/proposals/index_component.rb | 1 + app/components/admin/proposals/successful_component.rb | 1 + .../admin/site_customization/images/index_component.rb | 1 + .../admin/site_customization/pages/edit_component.rb | 1 + .../admin/site_customization/pages/form_component.rb | 1 + .../admin/site_customization/pages/index_component.rb | 1 + app/components/admin/site_customization/pages/new_component.rb | 1 + app/components/admin/tenants/edit_component.rb | 1 + app/components/admin/tenants/index_component.rb | 1 + app/components/admin/tenants/new_component.rb | 1 + app/components/admin/widget/cards/edit_component.rb | 1 + app/components/admin/widget/cards/new_component.rb | 1 + app/components/application_component.rb | 1 + app/components/budgets/groups/index_component.rb | 1 + app/components/budgets/investments/form_component.rb | 1 + app/components/budgets/investments/new_component.rb | 1 + app/components/concerns/sdg/tag_list.rb | 1 + app/components/debates/form_component.rb | 1 + app/components/debates/new_component.rb | 1 + app/components/moderation/shared/index_component.rb | 1 + app/components/moderation/users/index_component.rb | 1 + app/components/proposals/form_component.rb | 1 + app/components/proposals/new_component.rb | 1 + app/components/sdg_management/relations/index_component.rb | 1 + app/components/sdg_management/relations/search_component.rb | 1 + app/controllers/admin/base_controller.rb | 1 + app/controllers/admin/budgets_controller.rb | 1 + app/controllers/admin/budgets_wizard/budgets_controller.rb | 1 + app/controllers/admin/dashboard/actions_controller.rb | 1 + app/controllers/admin/legislation/milestones_controller.rb | 1 + app/controllers/admin/legislation/progress_bars_controller.rb | 1 + app/controllers/admin/poll/polls_controller.rb | 1 + app/controllers/admin/proposals_controller.rb | 1 + app/controllers/admin/site_customization/cards_controller.rb | 1 + app/controllers/admin/site_customization/pages_controller.rb | 1 + app/controllers/admin/widget/cards_controller.rb | 1 + app/controllers/budgets/groups_controller.rb | 1 + app/controllers/budgets/investments/votes_controller.rb | 1 + app/controllers/budgets/stats_controller.rb | 1 + app/controllers/budgets_controller.rb | 1 + app/controllers/concerns/admin/budget_groups_actions.rb | 1 + app/controllers/concerns/admin/budget_headings_actions.rb | 1 + app/controllers/concerns/has_filters.rb | 1 + app/controllers/concerns/has_orders.rb | 1 + app/controllers/concerns/moderate_actions.rb | 1 + app/controllers/dashboard/polls_controller.rb | 1 + app/controllers/direct_uploads_controller.rb | 1 + app/controllers/management/base_controller.rb | 1 + app/controllers/management/budgets/investments_controller.rb | 1 + app/controllers/management/budgets_controller.rb | 1 + app/controllers/management/sessions_controller.rb | 1 + app/controllers/pages_controller.rb | 1 + app/controllers/sdg/goals_controller.rb | 1 + app/controllers/sdg_management/base_controller.rb | 1 + app/controllers/sdg_management/cards_controller.rb | 1 + app/controllers/sdg_management/header_controller.rb | 1 + app/controllers/valuation/budgets_controller.rb | 1 + app/lib/remote_translations/microsoft/client.rb | 1 + app/mailers/devise_mailer.rb | 1 + app/models/application_record.rb | 1 + app/models/budget/group.rb | 1 + app/models/budget/heading.rb | 1 + app/models/budget/stats.rb | 1 + app/models/comment.rb | 1 + app/models/concerns/statisticable.rb | 1 + app/models/milestone.rb | 1 + app/models/poll.rb | 1 + app/models/poll/stats.rb | 1 + app/models/poll/web_vote.rb | 1 + app/models/progress_bar.rb | 1 + app/models/proposal.rb | 1 + app/models/sdg/phase.rb | 1 + app/models/sdg/process_enabled.rb | 1 + app/models/site_customization/page.rb | 1 + app/models/user.rb | 1 + app/models/widget/card.rb | 1 + spec/components/budgets/ballot/ballot_component_spec.rb | 1 + spec/components/polls/questions/read_more_component_spec.rb | 1 + .../shared/agree_with_terms_of_service_field_component_spec.rb | 1 + spec/components/shared/date_of_birth_field_component_spec.rb | 1 + spec/components/shared/embedded_video_component_spec.rb | 1 + spec/components/shared/moderation_actions_component_spec.rb | 1 + spec/controllers/concerns/has_filters_spec.rb | 1 + spec/controllers/concerns/has_orders_spec.rb | 1 + spec/form_builders/consul_form_builder_spec.rb | 1 + spec/form_builders/translatable_form_builder_spec.rb | 1 + spec/models/geojson_format_validator_spec.rb | 1 + spec/models/globalizable_spec.rb | 1 + spec/models/skip_validation_spec.rb | 2 ++ spec/models/statisticable_spec.rb | 1 + spec/rails_helper.rb | 1 + spec/views/shared/errors_spec.rb | 1 + 114 files changed, 117 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 1f679491b..075c2f309 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -101,6 +101,9 @@ Layout/EmptyLineBetweenDefs: Layout/EmptyLines: Enabled: true +Layout/EmptyLinesAfterModuleInclusion: + Enabled: true + Layout/EmptyLinesAroundAccessModifier: Enabled: true diff --git a/app/components/admin/action_component.rb b/app/components/admin/action_component.rb index f7918834c..7be071e4d 100644 --- a/app/components/admin/action_component.rb +++ b/app/components/admin/action_component.rb @@ -1,5 +1,6 @@ class Admin::ActionComponent < ApplicationComponent include Admin::Namespace + attr_reader :action, :record, :options def initialize(action, record, **options) diff --git a/app/components/admin/banners/form_component.rb b/app/components/admin/banners/form_component.rb index 26c51f9ba..287b65d65 100644 --- a/app/components/admin/banners/form_component.rb +++ b/app/components/admin/banners/form_component.rb @@ -1,6 +1,7 @@ class Admin::Banners::FormComponent < ApplicationComponent include TranslatableFormHelper include GlobalizeHelper + attr_reader :banner def initialize(banner) diff --git a/app/components/admin/budget_groups/groups_component.rb b/app/components/admin/budget_groups/groups_component.rb index 09ba87bbf..4ccc9cb51 100644 --- a/app/components/admin/budget_groups/groups_component.rb +++ b/app/components/admin/budget_groups/groups_component.rb @@ -1,5 +1,6 @@ class Admin::BudgetGroups::GroupsComponent < ApplicationComponent include Admin::Namespace + attr_reader :groups def initialize(groups) diff --git a/app/components/admin/budget_headings/form_component.rb b/app/components/admin/budget_headings/form_component.rb index 16dd3cbfd..33c653e7d 100644 --- a/app/components/admin/budget_headings/form_component.rb +++ b/app/components/admin/budget_headings/form_component.rb @@ -1,6 +1,7 @@ class Admin::BudgetHeadings::FormComponent < ApplicationComponent include TranslatableFormHelper include GlobalizeHelper + attr_reader :heading, :path, :action def initialize(heading, path:, action:) diff --git a/app/components/admin/budgets/index_component.rb b/app/components/admin/budgets/index_component.rb index 72b3c4615..de7760f68 100644 --- a/app/components/admin/budgets/index_component.rb +++ b/app/components/admin/budgets/index_component.rb @@ -1,5 +1,6 @@ class Admin::Budgets::IndexComponent < ApplicationComponent include Header + attr_reader :budgets def initialize(budgets) diff --git a/app/components/admin/budgets/show_component.rb b/app/components/admin/budgets/show_component.rb index f8d6e98b1..ba598ae3f 100644 --- a/app/components/admin/budgets/show_component.rb +++ b/app/components/admin/budgets/show_component.rb @@ -1,5 +1,6 @@ class Admin::Budgets::ShowComponent < ApplicationComponent include Header + attr_reader :budget def initialize(budget) diff --git a/app/components/admin/budgets_wizard/budgets/edit_component.rb b/app/components/admin/budgets_wizard/budgets/edit_component.rb index 7b3d686c9..8ef60a7a3 100644 --- a/app/components/admin/budgets_wizard/budgets/edit_component.rb +++ b/app/components/admin/budgets_wizard/budgets/edit_component.rb @@ -1,5 +1,6 @@ class Admin::BudgetsWizard::Budgets::EditComponent < ApplicationComponent include Header + attr_reader :budget def initialize(budget) diff --git a/app/components/admin/budgets_wizard/budgets/new_component.rb b/app/components/admin/budgets_wizard/budgets/new_component.rb index 496363200..59829934b 100644 --- a/app/components/admin/budgets_wizard/budgets/new_component.rb +++ b/app/components/admin/budgets_wizard/budgets/new_component.rb @@ -1,5 +1,6 @@ class Admin::BudgetsWizard::Budgets::NewComponent < ApplicationComponent include Header + attr_reader :budget use_helpers :single_heading? diff --git a/app/components/admin/budgets_wizard/groups/edit_component.rb b/app/components/admin/budgets_wizard/groups/edit_component.rb index cc8c8fbfe..5adf771fb 100644 --- a/app/components/admin/budgets_wizard/groups/edit_component.rb +++ b/app/components/admin/budgets_wizard/groups/edit_component.rb @@ -1,5 +1,6 @@ class Admin::BudgetsWizard::Groups::EditComponent < ApplicationComponent include Header + attr_reader :group def initialize(group) diff --git a/app/components/admin/budgets_wizard/groups/index_component.rb b/app/components/admin/budgets_wizard/groups/index_component.rb index 5c9b206b1..8a91f34cf 100644 --- a/app/components/admin/budgets_wizard/groups/index_component.rb +++ b/app/components/admin/budgets_wizard/groups/index_component.rb @@ -1,5 +1,6 @@ class Admin::BudgetsWizard::Groups::IndexComponent < Admin::BudgetsWizard::BaseComponent include Header + attr_reader :groups, :new_group def initialize(groups, new_group) diff --git a/app/components/admin/budgets_wizard/headings/edit_component.rb b/app/components/admin/budgets_wizard/headings/edit_component.rb index ee6250b23..37c3cb7df 100644 --- a/app/components/admin/budgets_wizard/headings/edit_component.rb +++ b/app/components/admin/budgets_wizard/headings/edit_component.rb @@ -1,5 +1,6 @@ class Admin::BudgetsWizard::Headings::EditComponent < ApplicationComponent include Header + attr_reader :heading def initialize(heading) diff --git a/app/components/admin/budgets_wizard/headings/index_component.rb b/app/components/admin/budgets_wizard/headings/index_component.rb index f789a00e8..6c4b06981 100644 --- a/app/components/admin/budgets_wizard/headings/index_component.rb +++ b/app/components/admin/budgets_wizard/headings/index_component.rb @@ -1,5 +1,6 @@ class Admin::BudgetsWizard::Headings::IndexComponent < Admin::BudgetsWizard::BaseComponent include Header + attr_reader :headings, :new_heading def initialize(headings, new_heading) diff --git a/app/components/admin/budgets_wizard/phases/edit_component.rb b/app/components/admin/budgets_wizard/phases/edit_component.rb index 68645ed95..4f5c2cbb1 100644 --- a/app/components/admin/budgets_wizard/phases/edit_component.rb +++ b/app/components/admin/budgets_wizard/phases/edit_component.rb @@ -1,5 +1,6 @@ class Admin::BudgetsWizard::Phases::EditComponent < ApplicationComponent include Header + attr_reader :phase def initialize(phase) diff --git a/app/components/admin/budgets_wizard/phases/index_component.rb b/app/components/admin/budgets_wizard/phases/index_component.rb index b0236804f..18ba9d349 100644 --- a/app/components/admin/budgets_wizard/phases/index_component.rb +++ b/app/components/admin/budgets_wizard/phases/index_component.rb @@ -1,5 +1,6 @@ class Admin::BudgetsWizard::Phases::IndexComponent < Admin::BudgetsWizard::BaseComponent include Header + attr_reader :budget def initialize(budget) diff --git a/app/components/admin/geozones/index_component.rb b/app/components/admin/geozones/index_component.rb index 0d3c0f6ff..ffe91823b 100644 --- a/app/components/admin/geozones/index_component.rb +++ b/app/components/admin/geozones/index_component.rb @@ -1,5 +1,6 @@ class Admin::Geozones::IndexComponent < ApplicationComponent include Header + attr_reader :geozones use_helpers :render_map diff --git a/app/components/admin/legislation/draft_versions/form_component.rb b/app/components/admin/legislation/draft_versions/form_component.rb index 007295478..9f8cf0147 100644 --- a/app/components/admin/legislation/draft_versions/form_component.rb +++ b/app/components/admin/legislation/draft_versions/form_component.rb @@ -1,6 +1,7 @@ class Admin::Legislation::DraftVersions::FormComponent < ApplicationComponent include TranslatableFormHelper include GlobalizeHelper + attr_reader :draft_version, :url use_helpers :admin_submit_action diff --git a/app/components/admin/locales/show_component.rb b/app/components/admin/locales/show_component.rb index e33e66b51..bbdd54a63 100644 --- a/app/components/admin/locales/show_component.rb +++ b/app/components/admin/locales/show_component.rb @@ -1,5 +1,6 @@ class Admin::Locales::ShowComponent < ApplicationComponent include Header + attr_reader :locales_settings def initialize(locales_settings) diff --git a/app/components/admin/machine_learning/show_component.rb b/app/components/admin/machine_learning/show_component.rb index 0986f408b..9177703ea 100644 --- a/app/components/admin/machine_learning/show_component.rb +++ b/app/components/admin/machine_learning/show_component.rb @@ -1,5 +1,6 @@ class Admin::MachineLearning::ShowComponent < ApplicationComponent include Header + attr_reader :machine_learning_job def initialize(machine_learning_job) diff --git a/app/components/admin/menu_component.rb b/app/components/admin/menu_component.rb index d25e0860f..adb89f879 100644 --- a/app/components/admin/menu_component.rb +++ b/app/components/admin/menu_component.rb @@ -1,5 +1,6 @@ class Admin::MenuComponent < ApplicationComponent include LinkListHelper + use_helpers :can? def links diff --git a/app/components/admin/poll/questions/form_component.rb b/app/components/admin/poll/questions/form_component.rb index 6f52382a0..6eb54013c 100644 --- a/app/components/admin/poll/questions/form_component.rb +++ b/app/components/admin/poll/questions/form_component.rb @@ -1,6 +1,7 @@ class Admin::Poll::Questions::FormComponent < ApplicationComponent include TranslatableFormHelper include GlobalizeHelper + attr_reader :question, :url use_helpers :can? diff --git a/app/components/admin/progress_bars/form_component.rb b/app/components/admin/progress_bars/form_component.rb index a93f6c0fb..aa74ed146 100644 --- a/app/components/admin/progress_bars/form_component.rb +++ b/app/components/admin/progress_bars/form_component.rb @@ -1,6 +1,7 @@ class Admin::ProgressBars::FormComponent < ApplicationComponent include TranslatableFormHelper include GlobalizeHelper + attr_reader :progress_bar def initialize(progress_bar) diff --git a/app/components/admin/proposals/index_component.rb b/app/components/admin/proposals/index_component.rb index 1ca5ef298..b9d68b481 100644 --- a/app/components/admin/proposals/index_component.rb +++ b/app/components/admin/proposals/index_component.rb @@ -1,5 +1,6 @@ class Admin::Proposals::IndexComponent < ApplicationComponent include Header + attr_reader :proposals def initialize(proposals) diff --git a/app/components/admin/proposals/successful_component.rb b/app/components/admin/proposals/successful_component.rb index 553485665..98385eb3f 100644 --- a/app/components/admin/proposals/successful_component.rb +++ b/app/components/admin/proposals/successful_component.rb @@ -1,5 +1,6 @@ class Admin::Proposals::SuccessfulComponent < ApplicationComponent include Header + attr_reader :proposals def initialize(proposals) diff --git a/app/components/admin/site_customization/images/index_component.rb b/app/components/admin/site_customization/images/index_component.rb index 41c5b0585..705d6447c 100644 --- a/app/components/admin/site_customization/images/index_component.rb +++ b/app/components/admin/site_customization/images/index_component.rb @@ -1,5 +1,6 @@ class Admin::SiteCustomization::Images::IndexComponent < ApplicationComponent include Header + attr_reader :images def initialize(images) diff --git a/app/components/admin/site_customization/pages/edit_component.rb b/app/components/admin/site_customization/pages/edit_component.rb index 0e1cf20f4..f61af25c9 100644 --- a/app/components/admin/site_customization/pages/edit_component.rb +++ b/app/components/admin/site_customization/pages/edit_component.rb @@ -1,5 +1,6 @@ class Admin::SiteCustomization::Pages::EditComponent < ApplicationComponent include Header + attr_reader :page def initialize(page) diff --git a/app/components/admin/site_customization/pages/form_component.rb b/app/components/admin/site_customization/pages/form_component.rb index b4f705107..661402350 100644 --- a/app/components/admin/site_customization/pages/form_component.rb +++ b/app/components/admin/site_customization/pages/form_component.rb @@ -1,6 +1,7 @@ class Admin::SiteCustomization::Pages::FormComponent < ApplicationComponent include TranslatableFormHelper include GlobalizeHelper + attr_reader :page def initialize(page) diff --git a/app/components/admin/site_customization/pages/index_component.rb b/app/components/admin/site_customization/pages/index_component.rb index d68123b59..9b54014d3 100644 --- a/app/components/admin/site_customization/pages/index_component.rb +++ b/app/components/admin/site_customization/pages/index_component.rb @@ -1,5 +1,6 @@ class Admin::SiteCustomization::Pages::IndexComponent < ApplicationComponent include Header + attr_reader :pages def initialize(pages) diff --git a/app/components/admin/site_customization/pages/new_component.rb b/app/components/admin/site_customization/pages/new_component.rb index 74c90de79..e4b0632db 100644 --- a/app/components/admin/site_customization/pages/new_component.rb +++ b/app/components/admin/site_customization/pages/new_component.rb @@ -1,5 +1,6 @@ class Admin::SiteCustomization::Pages::NewComponent < ApplicationComponent include Header + attr_reader :page def initialize(page) diff --git a/app/components/admin/tenants/edit_component.rb b/app/components/admin/tenants/edit_component.rb index ee73145d4..940291eb3 100644 --- a/app/components/admin/tenants/edit_component.rb +++ b/app/components/admin/tenants/edit_component.rb @@ -1,5 +1,6 @@ class Admin::Tenants::EditComponent < ApplicationComponent include Header + attr_reader :tenant def initialize(tenant) diff --git a/app/components/admin/tenants/index_component.rb b/app/components/admin/tenants/index_component.rb index eb37a6832..e2c4c2848 100644 --- a/app/components/admin/tenants/index_component.rb +++ b/app/components/admin/tenants/index_component.rb @@ -1,5 +1,6 @@ class Admin::Tenants::IndexComponent < ApplicationComponent include Header + attr_reader :tenants def initialize(tenants) diff --git a/app/components/admin/tenants/new_component.rb b/app/components/admin/tenants/new_component.rb index f5c0c4d41..b591cdab5 100644 --- a/app/components/admin/tenants/new_component.rb +++ b/app/components/admin/tenants/new_component.rb @@ -1,5 +1,6 @@ class Admin::Tenants::NewComponent < ApplicationComponent include Header + attr_reader :tenant use_helpers :current_user diff --git a/app/components/admin/widget/cards/edit_component.rb b/app/components/admin/widget/cards/edit_component.rb index 4c9b7d263..38d1deacc 100644 --- a/app/components/admin/widget/cards/edit_component.rb +++ b/app/components/admin/widget/cards/edit_component.rb @@ -1,5 +1,6 @@ class Admin::Widget::Cards::EditComponent < ApplicationComponent include Header + attr_reader :card, :index_path, :form_path def initialize(card, index_path:, form_path: nil) diff --git a/app/components/admin/widget/cards/new_component.rb b/app/components/admin/widget/cards/new_component.rb index 5bb856344..0a829ebac 100644 --- a/app/components/admin/widget/cards/new_component.rb +++ b/app/components/admin/widget/cards/new_component.rb @@ -1,5 +1,6 @@ class Admin::Widget::Cards::NewComponent < ApplicationComponent include Header + attr_reader :card, :index_path, :form_path def initialize(card, index_path:, form_path: nil) diff --git a/app/components/application_component.rb b/app/components/application_component.rb index 28a42d91b..3786a4e49 100644 --- a/app/components/application_component.rb +++ b/app/components/application_component.rb @@ -1,5 +1,6 @@ class ApplicationComponent < ViewComponent::Base include SettingsHelper + use_helpers :back_link_to, :t delegate :default_form_builder, to: :controller end diff --git a/app/components/budgets/groups/index_component.rb b/app/components/budgets/groups/index_component.rb index 29740fb24..43e92cbdc 100644 --- a/app/components/budgets/groups/index_component.rb +++ b/app/components/budgets/groups/index_component.rb @@ -1,5 +1,6 @@ class Budgets::Groups::IndexComponent < ApplicationComponent include Header + attr_reader :budget def initialize(budget) diff --git a/app/components/budgets/investments/form_component.rb b/app/components/budgets/investments/form_component.rb index df69a34a7..0ee340ed3 100644 --- a/app/components/budgets/investments/form_component.rb +++ b/app/components/budgets/investments/form_component.rb @@ -1,6 +1,7 @@ class Budgets::Investments::FormComponent < ApplicationComponent include TranslatableFormHelper include GlobalizeHelper + attr_reader :investment, :url use_helpers :current_user, :budget_heading_select_options, :suggest_data diff --git a/app/components/budgets/investments/new_component.rb b/app/components/budgets/investments/new_component.rb index ff16bf257..e1e828b7b 100644 --- a/app/components/budgets/investments/new_component.rb +++ b/app/components/budgets/investments/new_component.rb @@ -1,5 +1,6 @@ class Budgets::Investments::NewComponent < ApplicationComponent include Header + attr_reader :budget def initialize(budget) diff --git a/app/components/concerns/sdg/tag_list.rb b/app/components/concerns/sdg/tag_list.rb index 59ba6d4e3..a01483599 100644 --- a/app/components/concerns/sdg/tag_list.rb +++ b/app/components/concerns/sdg/tag_list.rb @@ -1,5 +1,6 @@ module SDG::TagList extend ActiveSupport::Concern + attr_reader :record, :limit def initialize(record, limit: nil) diff --git a/app/components/debates/form_component.rb b/app/components/debates/form_component.rb index da52f2d2a..26c2ba7b4 100644 --- a/app/components/debates/form_component.rb +++ b/app/components/debates/form_component.rb @@ -1,6 +1,7 @@ class Debates::FormComponent < ApplicationComponent include TranslatableFormHelper include GlobalizeHelper + attr_reader :debate use_helpers :suggest_data diff --git a/app/components/debates/new_component.rb b/app/components/debates/new_component.rb index d28e75971..163556ccf 100644 --- a/app/components/debates/new_component.rb +++ b/app/components/debates/new_component.rb @@ -1,5 +1,6 @@ class Debates::NewComponent < ApplicationComponent include Header + attr_reader :debate use_helpers :new_window_link_to diff --git a/app/components/moderation/shared/index_component.rb b/app/components/moderation/shared/index_component.rb index 117f0610f..8f38520c5 100644 --- a/app/components/moderation/shared/index_component.rb +++ b/app/components/moderation/shared/index_component.rb @@ -1,5 +1,6 @@ class Moderation::Shared::IndexComponent < ApplicationComponent include Header + attr_reader :records def initialize(records) diff --git a/app/components/moderation/users/index_component.rb b/app/components/moderation/users/index_component.rb index d933a9ef5..cb8ba7a0c 100644 --- a/app/components/moderation/users/index_component.rb +++ b/app/components/moderation/users/index_component.rb @@ -1,5 +1,6 @@ class Moderation::Users::IndexComponent < ApplicationComponent include Header + attr_reader :users def initialize(users) diff --git a/app/components/proposals/form_component.rb b/app/components/proposals/form_component.rb index a8af6c6fa..17ec5713c 100644 --- a/app/components/proposals/form_component.rb +++ b/app/components/proposals/form_component.rb @@ -1,6 +1,7 @@ class Proposals::FormComponent < ApplicationComponent include TranslatableFormHelper include GlobalizeHelper + attr_reader :proposal, :url use_helpers :current_user, :suggest_data, :geozone_select_options diff --git a/app/components/proposals/new_component.rb b/app/components/proposals/new_component.rb index 02f822dea..5a4e25c3e 100644 --- a/app/components/proposals/new_component.rb +++ b/app/components/proposals/new_component.rb @@ -1,5 +1,6 @@ class Proposals::NewComponent < ApplicationComponent include Header + attr_reader :proposal use_helpers :new_window_link_to diff --git a/app/components/sdg_management/relations/index_component.rb b/app/components/sdg_management/relations/index_component.rb index 55fdde345..16a49194c 100644 --- a/app/components/sdg_management/relations/index_component.rb +++ b/app/components/sdg_management/relations/index_component.rb @@ -1,5 +1,6 @@ class SDGManagement::Relations::IndexComponent < ApplicationComponent include Header + attr_reader :records def initialize(records) diff --git a/app/components/sdg_management/relations/search_component.rb b/app/components/sdg_management/relations/search_component.rb index c48504424..d5e0a8bed 100644 --- a/app/components/sdg_management/relations/search_component.rb +++ b/app/components/sdg_management/relations/search_component.rb @@ -1,5 +1,6 @@ class SDGManagement::Relations::SearchComponent < ApplicationComponent include SDG::OptionsForSelect + attr_reader :label def initialize(label:) diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index 797ded423..00cd15fe6 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -1,5 +1,6 @@ class Admin::BaseController < ApplicationController include IpDeniedHandler + layout "admin" before_action :authenticate_user! diff --git a/app/controllers/admin/budgets_controller.rb b/app/controllers/admin/budgets_controller.rb index c0facf84b..093bd2afd 100644 --- a/app/controllers/admin/budgets_controller.rb +++ b/app/controllers/admin/budgets_controller.rb @@ -3,6 +3,7 @@ class Admin::BudgetsController < Admin::BaseController include ReportAttributes include ImageAttributes include FeatureFlags + feature_flag :budgets has_filters %w[all open finished], only: :index diff --git a/app/controllers/admin/budgets_wizard/budgets_controller.rb b/app/controllers/admin/budgets_wizard/budgets_controller.rb index 84b92f890..800601bac 100644 --- a/app/controllers/admin/budgets_wizard/budgets_controller.rb +++ b/app/controllers/admin/budgets_wizard/budgets_controller.rb @@ -2,6 +2,7 @@ class Admin::BudgetsWizard::BudgetsController < Admin::BudgetsWizard::BaseContro include Translatable include ImageAttributes include FeatureFlags + feature_flag :budgets load_and_authorize_resource diff --git a/app/controllers/admin/dashboard/actions_controller.rb b/app/controllers/admin/dashboard/actions_controller.rb index 33de2a45e..1de7a8fdb 100644 --- a/app/controllers/admin/dashboard/actions_controller.rb +++ b/app/controllers/admin/dashboard/actions_controller.rb @@ -1,5 +1,6 @@ class Admin::Dashboard::ActionsController < Admin::Dashboard::BaseController include DocumentAttributes + helper_method :dashboard_action, :resource def index diff --git a/app/controllers/admin/legislation/milestones_controller.rb b/app/controllers/admin/legislation/milestones_controller.rb index 09d55f6ca..ef436c583 100644 --- a/app/controllers/admin/legislation/milestones_controller.rb +++ b/app/controllers/admin/legislation/milestones_controller.rb @@ -1,5 +1,6 @@ class Admin::Legislation::MilestonesController < Admin::MilestonesController include FeatureFlags + feature_flag :legislation def index diff --git a/app/controllers/admin/legislation/progress_bars_controller.rb b/app/controllers/admin/legislation/progress_bars_controller.rb index ba00d5e91..c730d3822 100644 --- a/app/controllers/admin/legislation/progress_bars_controller.rb +++ b/app/controllers/admin/legislation/progress_bars_controller.rb @@ -1,5 +1,6 @@ class Admin::Legislation::ProgressBarsController < Admin::ProgressBarsController include FeatureFlags + feature_flag :legislation def index diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index 3f1d65e55..30bcfeee4 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -2,6 +2,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController include Translatable include ImageAttributes include ReportAttributes + load_and_authorize_resource before_action :load_geozones, only: [:new, :create, :edit, :update] diff --git a/app/controllers/admin/proposals_controller.rb b/app/controllers/admin/proposals_controller.rb index a0c2770d1..34b9252a7 100644 --- a/app/controllers/admin/proposals_controller.rb +++ b/app/controllers/admin/proposals_controller.rb @@ -2,6 +2,7 @@ class Admin::ProposalsController < Admin::BaseController include HasOrders include CommentableActions include FeatureFlags + feature_flag :proposals has_orders %w[created_at] diff --git a/app/controllers/admin/site_customization/cards_controller.rb b/app/controllers/admin/site_customization/cards_controller.rb index 0e2e2f190..b07251e04 100644 --- a/app/controllers/admin/site_customization/cards_controller.rb +++ b/app/controllers/admin/site_customization/cards_controller.rb @@ -1,5 +1,6 @@ class Admin::SiteCustomization::CardsController < Admin::SiteCustomization::BaseController include Admin::Widget::CardsActions + load_and_authorize_resource :page, class: "::SiteCustomization::Page" load_and_authorize_resource :card, through: :page, class: "Widget::Card" helper_method :index_path diff --git a/app/controllers/admin/site_customization/pages_controller.rb b/app/controllers/admin/site_customization/pages_controller.rb index 85a476dde..42dc6d8ed 100644 --- a/app/controllers/admin/site_customization/pages_controller.rb +++ b/app/controllers/admin/site_customization/pages_controller.rb @@ -1,5 +1,6 @@ class Admin::SiteCustomization::PagesController < Admin::SiteCustomization::BaseController include Translatable + load_and_authorize_resource :page, class: "SiteCustomization::Page" def index diff --git a/app/controllers/admin/widget/cards_controller.rb b/app/controllers/admin/widget/cards_controller.rb index 64ea72bb5..91cc115bc 100644 --- a/app/controllers/admin/widget/cards_controller.rb +++ b/app/controllers/admin/widget/cards_controller.rb @@ -1,5 +1,6 @@ class Admin::Widget::CardsController < Admin::BaseController include Admin::Widget::CardsActions + load_and_authorize_resource :card, class: "Widget::Card" helper_method :index_path diff --git a/app/controllers/budgets/groups_controller.rb b/app/controllers/budgets/groups_controller.rb index 542be0fb6..f13a8bff2 100644 --- a/app/controllers/budgets/groups_controller.rb +++ b/app/controllers/budgets/groups_controller.rb @@ -1,6 +1,7 @@ module Budgets class GroupsController < ApplicationController include FeatureFlags + feature_flag :budgets before_action :load_budget diff --git a/app/controllers/budgets/investments/votes_controller.rb b/app/controllers/budgets/investments/votes_controller.rb index 29e52a196..bd66c8404 100644 --- a/app/controllers/budgets/investments/votes_controller.rb +++ b/app/controllers/budgets/investments/votes_controller.rb @@ -2,6 +2,7 @@ module Budgets module Investments class VotesController < ApplicationController include FeatureFlags + feature_flag :remove_investments_supports, only: :destroy load_and_authorize_resource :budget diff --git a/app/controllers/budgets/stats_controller.rb b/app/controllers/budgets/stats_controller.rb index 353ff113b..c52f2c02c 100644 --- a/app/controllers/budgets/stats_controller.rb +++ b/app/controllers/budgets/stats_controller.rb @@ -1,6 +1,7 @@ module Budgets class StatsController < ApplicationController include FeatureFlags + feature_flag :budgets before_action :load_budget diff --git a/app/controllers/budgets_controller.rb b/app/controllers/budgets_controller.rb index fd5ecbbd5..cdc4b9e05 100644 --- a/app/controllers/budgets_controller.rb +++ b/app/controllers/budgets_controller.rb @@ -1,6 +1,7 @@ class BudgetsController < ApplicationController include FeatureFlags include BudgetsHelper + feature_flag :budgets before_action :load_budget, only: :show diff --git a/app/controllers/concerns/admin/budget_groups_actions.rb b/app/controllers/concerns/admin/budget_groups_actions.rb index 096f9c7bc..4c04144e1 100644 --- a/app/controllers/concerns/admin/budget_groups_actions.rb +++ b/app/controllers/concerns/admin/budget_groups_actions.rb @@ -4,6 +4,7 @@ module Admin::BudgetGroupsActions included do include Translatable include FeatureFlags + feature_flag :budgets before_action :load_budget diff --git a/app/controllers/concerns/admin/budget_headings_actions.rb b/app/controllers/concerns/admin/budget_headings_actions.rb index 6e611e891..f8b324dd6 100644 --- a/app/controllers/concerns/admin/budget_headings_actions.rb +++ b/app/controllers/concerns/admin/budget_headings_actions.rb @@ -4,6 +4,7 @@ module Admin::BudgetHeadingsActions included do include Translatable include FeatureFlags + feature_flag :budgets before_action :load_budget diff --git a/app/controllers/concerns/has_filters.rb b/app/controllers/concerns/has_filters.rb index 88054757c..a59fe7a1f 100644 --- a/app/controllers/concerns/has_filters.rb +++ b/app/controllers/concerns/has_filters.rb @@ -1,5 +1,6 @@ module HasFilters extend ActiveSupport::Concern + attr_reader :valid_filters, :current_filter included do diff --git a/app/controllers/concerns/has_orders.rb b/app/controllers/concerns/has_orders.rb index 478770ab9..cf25e0010 100644 --- a/app/controllers/concerns/has_orders.rb +++ b/app/controllers/concerns/has_orders.rb @@ -1,5 +1,6 @@ module HasOrders extend ActiveSupport::Concern + attr_reader :valid_orders, :current_order included do diff --git a/app/controllers/concerns/moderate_actions.rb b/app/controllers/concerns/moderate_actions.rb index a96c2d6a6..e2e295cb1 100644 --- a/app/controllers/concerns/moderate_actions.rb +++ b/app/controllers/concerns/moderate_actions.rb @@ -1,6 +1,7 @@ module ModerateActions extend ActiveSupport::Concern include Polymorphic + PER_PAGE = 50 def index diff --git a/app/controllers/dashboard/polls_controller.rb b/app/controllers/dashboard/polls_controller.rb index ba70228c3..9beb8842a 100644 --- a/app/controllers/dashboard/polls_controller.rb +++ b/app/controllers/dashboard/polls_controller.rb @@ -1,5 +1,6 @@ class Dashboard::PollsController < Dashboard::BaseController include DocumentAttributes + helper_method :poll before_action :authorize_manage_polls diff --git a/app/controllers/direct_uploads_controller.rb b/app/controllers/direct_uploads_controller.rb index c6b2a034c..5a48a7a04 100644 --- a/app/controllers/direct_uploads_controller.rb +++ b/app/controllers/direct_uploads_controller.rb @@ -1,6 +1,7 @@ class DirectUploadsController < ApplicationController include DirectUploadsHelper include ActionView::Helpers::UrlHelper + before_action :authenticate_user! skip_authorization_check only: :create diff --git a/app/controllers/management/base_controller.rb b/app/controllers/management/base_controller.rb index 745688743..48d6da0eb 100644 --- a/app/controllers/management/base_controller.rb +++ b/app/controllers/management/base_controller.rb @@ -1,6 +1,7 @@ class Management::BaseController < ActionController::Base include TenantVariants include GlobalizeFallbacks + layout "management" default_form_builder ConsulFormBuilder diff --git a/app/controllers/management/budgets/investments_controller.rb b/app/controllers/management/budgets/investments_controller.rb index 5d1b32577..541c2b1dd 100644 --- a/app/controllers/management/budgets/investments_controller.rb +++ b/app/controllers/management/budgets/investments_controller.rb @@ -4,6 +4,7 @@ class Management::Budgets::InvestmentsController < Management::BaseController include DocumentAttributes include MapLocationAttributes include FeatureFlags + feature_flag :budgets before_action :load_budget diff --git a/app/controllers/management/budgets_controller.rb b/app/controllers/management/budgets_controller.rb index 2c2e3607e..a96fc29a6 100644 --- a/app/controllers/management/budgets_controller.rb +++ b/app/controllers/management/budgets_controller.rb @@ -1,6 +1,7 @@ class Management::BudgetsController < Management::BaseController include FeatureFlags include HasFilters + feature_flag :budgets before_action :only_verified_users, except: :print_investments diff --git a/app/controllers/management/sessions_controller.rb b/app/controllers/management/sessions_controller.rb index 0e4168975..e7cf9bc06 100644 --- a/app/controllers/management/sessions_controller.rb +++ b/app/controllers/management/sessions_controller.rb @@ -2,6 +2,7 @@ class Management::SessionsController < ActionController::Base include TenantVariants include GlobalizeFallbacks include AccessDeniedHandler + default_form_builder ConsulFormBuilder def create diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 267f659e0..1d551643a 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,5 +1,6 @@ class PagesController < ApplicationController include FeatureFlags + skip_authorization_check feature_flag :help_page, if: lambda { params[:id] == "help/index" } diff --git a/app/controllers/sdg/goals_controller.rb b/app/controllers/sdg/goals_controller.rb index 8fcc94f3c..07adeb365 100644 --- a/app/controllers/sdg/goals_controller.rb +++ b/app/controllers/sdg/goals_controller.rb @@ -1,5 +1,6 @@ class SDG::GoalsController < ApplicationController include FeatureFlags + feature_flag :sdg load_and_authorize_resource find_by: :code, id_param: :code diff --git a/app/controllers/sdg_management/base_controller.rb b/app/controllers/sdg_management/base_controller.rb index 4fff2b0f2..46399ce9e 100644 --- a/app/controllers/sdg_management/base_controller.rb +++ b/app/controllers/sdg_management/base_controller.rb @@ -1,5 +1,6 @@ class SDGManagement::BaseController < ApplicationController include FeatureFlags + feature_flag :sdg layout "admin" diff --git a/app/controllers/sdg_management/cards_controller.rb b/app/controllers/sdg_management/cards_controller.rb index f3af9ed19..018977d55 100644 --- a/app/controllers/sdg_management/cards_controller.rb +++ b/app/controllers/sdg_management/cards_controller.rb @@ -1,5 +1,6 @@ class SDGManagement::CardsController < SDGManagement::BaseController include Admin::Widget::CardsActions + helper_method :index_path load_and_authorize_resource :phase, class: "SDG::Phase", id_param: "sdg_phase_id" diff --git a/app/controllers/sdg_management/header_controller.rb b/app/controllers/sdg_management/header_controller.rb index f3bf73ae3..e4daf46a7 100644 --- a/app/controllers/sdg_management/header_controller.rb +++ b/app/controllers/sdg_management/header_controller.rb @@ -1,5 +1,6 @@ class SDGManagement::HeaderController < SDGManagement::BaseController include Admin::Widget::CardsActions + helper_method :index_path before_action :load_cardable diff --git a/app/controllers/valuation/budgets_controller.rb b/app/controllers/valuation/budgets_controller.rb index 729c39112..7e37c2912 100644 --- a/app/controllers/valuation/budgets_controller.rb +++ b/app/controllers/valuation/budgets_controller.rb @@ -1,5 +1,6 @@ class Valuation::BudgetsController < Valuation::BaseController include FeatureFlags + feature_flag :budgets load_and_authorize_resource diff --git a/app/lib/remote_translations/microsoft/client.rb b/app/lib/remote_translations/microsoft/client.rb index 81ccff153..1a653ae75 100644 --- a/app/lib/remote_translations/microsoft/client.rb +++ b/app/lib/remote_translations/microsoft/client.rb @@ -1,5 +1,6 @@ class RemoteTranslations::Microsoft::Client include RemoteTranslations::Microsoft::SentencesParser + CHARACTERS_LIMIT_PER_REQUEST = 5000 PREVENTING_TRANSLATION_KEY = "notranslate".freeze diff --git a/app/mailers/devise_mailer.rb b/app/mailers/devise_mailer.rb index 738dcc9c0..ed4e6f270 100644 --- a/app/mailers/devise_mailer.rb +++ b/app/mailers/devise_mailer.rb @@ -1,5 +1,6 @@ class DeviseMailer < Devise::Mailer include Devise::Controllers::UrlHelpers + default template_path: "devise/mailer" protected diff --git a/app/models/application_record.rb b/app/models/application_record.rb index d145cec8a..b24f22908 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,6 +1,7 @@ class ApplicationRecord < ActiveRecord::Base include HumanName include SkipValidation + self.abstract_class = true def self.sample(count = 1) diff --git a/app/models/budget/group.rb b/app/models/budget/group.rb index a2e0164e4..8fd6d66f9 100644 --- a/app/models/budget/group.rb +++ b/app/models/budget/group.rb @@ -4,6 +4,7 @@ class Budget translates :name, touch: true include Globalizable + translation_class_delegate :budget class Translation diff --git a/app/models/budget/heading.rb b/app/models/budget/heading.rb index 40cd75580..0ef7b6d5a 100644 --- a/app/models/budget/heading.rb +++ b/app/models/budget/heading.rb @@ -6,6 +6,7 @@ class Budget translates :name, touch: true include Globalizable + translation_class_delegate :budget class Translation diff --git a/app/models/budget/stats.rb b/app/models/budget/stats.rb index 673c1727d..deab0b556 100644 --- a/app/models/budget/stats.rb +++ b/app/models/budget/stats.rb @@ -1,5 +1,6 @@ class Budget::Stats include Statisticable + alias_method :budget, :resource def self.stats_methods diff --git a/app/models/comment.rb b/app/models/comment.rb index 3dda76443..beec83c60 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -11,6 +11,7 @@ class Comment < ApplicationRecord acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases + acts_as_votable has_ancestry touch: true diff --git a/app/models/concerns/statisticable.rb b/app/models/concerns/statisticable.rb index a36e889a7..88a49fc9c 100644 --- a/app/models/concerns/statisticable.rb +++ b/app/models/concerns/statisticable.rb @@ -1,5 +1,6 @@ module Statisticable extend ActiveSupport::Concern + PARTICIPATIONS = %w[gender age geozone].freeze included do diff --git a/app/models/milestone.rb b/app/models/milestone.rb index b1794c652..536c84660 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -4,6 +4,7 @@ class Milestone < ApplicationRecord translates :title, :description, touch: true include Globalizable + translation_class_delegate :status_id belongs_to :milestoneable, polymorphic: true diff --git a/app/models/poll.rb b/app/models/poll.rb index 8012f2fcd..2702ebdd1 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -1,5 +1,6 @@ class Poll < ApplicationRecord include Imageable + acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases include Notifiable diff --git a/app/models/poll/stats.rb b/app/models/poll/stats.rb index 5e03114b4..81a55d461 100644 --- a/app/models/poll/stats.rb +++ b/app/models/poll/stats.rb @@ -1,5 +1,6 @@ class Poll::Stats include Statisticable + alias_method :poll, :resource CHANNELS = Poll::Voter::VALID_ORIGINS diff --git a/app/models/poll/web_vote.rb b/app/models/poll/web_vote.rb index f3f26f4a3..803b8016a 100644 --- a/app/models/poll/web_vote.rb +++ b/app/models/poll/web_vote.rb @@ -1,5 +1,6 @@ class Poll::WebVote include ActiveModel::Validations + attr_reader :poll, :user delegate :t, to: "ApplicationController.helpers" diff --git a/app/models/progress_bar.rb b/app/models/progress_bar.rb index d79f61b8f..5fc974ef6 100644 --- a/app/models/progress_bar.rb +++ b/app/models/progress_bar.rb @@ -8,6 +8,7 @@ class ProgressBar < ApplicationRecord translates :title, touch: true include Globalizable + translation_class_delegate :primary? validates :progressable, presence: true diff --git a/app/models/proposal.rb b/app/models/proposal.rb index ef4bcbfb5..99850827e 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -31,6 +31,7 @@ class Proposal < ApplicationRecord translates :summary, touch: true translates :retired_explanation, touch: true include Globalizable + translation_class_delegate :retired_at belongs_to :author, -> { with_hidden }, class_name: "User", inverse_of: :proposals diff --git a/app/models/sdg/phase.rb b/app/models/sdg/phase.rb index 4a57fb531..84a975011 100644 --- a/app/models/sdg/phase.rb +++ b/app/models/sdg/phase.rb @@ -1,5 +1,6 @@ class SDG::Phase < ApplicationRecord include Cardable + enum :kind, { sensitization: 0, planning: 1, monitoring: 2 } validates :kind, presence: true, uniqueness: true diff --git a/app/models/sdg/process_enabled.rb b/app/models/sdg/process_enabled.rb index 0378155e2..ebb21bb33 100644 --- a/app/models/sdg/process_enabled.rb +++ b/app/models/sdg/process_enabled.rb @@ -1,5 +1,6 @@ class SDG::ProcessEnabled include SettingsHelper + attr_reader :record_or_name def initialize(record_or_name) diff --git a/app/models/site_customization/page.rb b/app/models/site_customization/page.rb index a57123d5e..a1608d1b8 100644 --- a/app/models/site_customization/page.rb +++ b/app/models/site_customization/page.rb @@ -1,6 +1,7 @@ class SiteCustomization::Page < ApplicationRecord VALID_STATUSES = %w[draft published].freeze include Cardable + translates :title, touch: true translates :subtitle, touch: true translates :content, touch: true diff --git a/app/models/user.rb b/app/models/user.rb index 7af90cdbe..cbd23dd85 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,6 @@ class User < ApplicationRecord include Verification + attribute :registering_from_web, default: false %i[newsletter email_digest email_on_direct_message public_activity recommended_debates recommended_proposals].each do |field| diff --git a/app/models/widget/card.rb b/app/models/widget/card.rb index a07920b35..1b83e54d5 100644 --- a/app/models/widget/card.rb +++ b/app/models/widget/card.rb @@ -1,5 +1,6 @@ class Widget::Card < ApplicationRecord include Imageable + belongs_to :cardable, polymorphic: true translates :label, touch: true diff --git a/spec/components/budgets/ballot/ballot_component_spec.rb b/spec/components/budgets/ballot/ballot_component_spec.rb index 3ba9d4c8a..de1c0f3da 100644 --- a/spec/components/budgets/ballot/ballot_component_spec.rb +++ b/spec/components/budgets/ballot/ballot_component_spec.rb @@ -2,6 +2,7 @@ require "rails_helper" describe Budgets::Ballot::BallotComponent do include Rails.application.routes.url_helpers + before { vc_test_request.session[:ballot_referer] = "/" } let(:budget) { create(:budget, :balloting) } let(:ballot) { create(:budget_ballot, user: create(:user), budget: budget) } diff --git a/spec/components/polls/questions/read_more_component_spec.rb b/spec/components/polls/questions/read_more_component_spec.rb index 239e7b28c..9e1bdc7ae 100644 --- a/spec/components/polls/questions/read_more_component_spec.rb +++ b/spec/components/polls/questions/read_more_component_spec.rb @@ -2,6 +2,7 @@ require "rails_helper" describe Polls::Questions::ReadMoreComponent do include Rails.application.routes.url_helpers + let(:poll) { create(:poll) } let(:question) { create(:poll_question, poll: poll, title: "Question title?") } let(:option) { create(:poll_question_option, question: question) } diff --git a/spec/components/shared/agree_with_terms_of_service_field_component_spec.rb b/spec/components/shared/agree_with_terms_of_service_field_component_spec.rb index 1c79271ea..41a99e4f0 100644 --- a/spec/components/shared/agree_with_terms_of_service_field_component_spec.rb +++ b/spec/components/shared/agree_with_terms_of_service_field_component_spec.rb @@ -4,6 +4,7 @@ describe Shared::AgreeWithTermsOfServiceFieldComponent do before do dummy_model = Class.new do include ActiveModel::Model + attr_accessor :terms_of_service end diff --git a/spec/components/shared/date_of_birth_field_component_spec.rb b/spec/components/shared/date_of_birth_field_component_spec.rb index 403df8693..f7c0f1d93 100644 --- a/spec/components/shared/date_of_birth_field_component_spec.rb +++ b/spec/components/shared/date_of_birth_field_component_spec.rb @@ -4,6 +4,7 @@ describe Shared::DateOfBirthFieldComponent do before do dummy_model = Class.new do include ActiveModel::Model + attr_accessor :date_of_birth end diff --git a/spec/components/shared/embedded_video_component_spec.rb b/spec/components/shared/embedded_video_component_spec.rb index e4d9e05f6..b82439c8d 100644 --- a/spec/components/shared/embedded_video_component_spec.rb +++ b/spec/components/shared/embedded_video_component_spec.rb @@ -5,6 +5,7 @@ describe Shared::EmbeddedVideoComponent do before do dummy_class = Class.new do include ActiveModel::Model + attr_accessor :title, :video_url include Videoable diff --git a/spec/components/shared/moderation_actions_component_spec.rb b/spec/components/shared/moderation_actions_component_spec.rb index f305a14d6..a3f482735 100644 --- a/spec/components/shared/moderation_actions_component_spec.rb +++ b/spec/components/shared/moderation_actions_component_spec.rb @@ -2,6 +2,7 @@ require "rails_helper" describe Shared::ModerationActionsComponent do include Rails.application.routes.url_helpers + before { sign_in(create(:administrator).user) } describe "Hide button" do diff --git a/spec/controllers/concerns/has_filters_spec.rb b/spec/controllers/concerns/has_filters_spec.rb index c921f6255..841dfe0a7 100644 --- a/spec/controllers/concerns/has_filters_spec.rb +++ b/spec/controllers/concerns/has_filters_spec.rb @@ -3,6 +3,7 @@ require "rails_helper" describe HasFilters do controller(ActionController::Base) do include HasFilters + has_filters ["all", "pending", "reviewed"], only: :index def index diff --git a/spec/controllers/concerns/has_orders_spec.rb b/spec/controllers/concerns/has_orders_spec.rb index 4248e5cd5..644e30a6c 100644 --- a/spec/controllers/concerns/has_orders_spec.rb +++ b/spec/controllers/concerns/has_orders_spec.rb @@ -3,6 +3,7 @@ require "rails_helper" describe HasOrders do controller(ActionController::Base) do include HasOrders + has_orders ["created_at", "votes_count", "flags_count", "relevance"], only: :index has_orders ->(c) { ["votes_count", "flags_count"] }, only: :new diff --git a/spec/form_builders/consul_form_builder_spec.rb b/spec/form_builders/consul_form_builder_spec.rb index db57847d2..da56b3982 100644 --- a/spec/form_builders/consul_form_builder_spec.rb +++ b/spec/form_builders/consul_form_builder_spec.rb @@ -4,6 +4,7 @@ describe ConsulFormBuilder do before do dummy_model = Class.new do include ActiveModel::Model + attr_accessor :title, :quality, :published end diff --git a/spec/form_builders/translatable_form_builder_spec.rb b/spec/form_builders/translatable_form_builder_spec.rb index fd8747f3f..234eed765 100644 --- a/spec/form_builders/translatable_form_builder_spec.rb +++ b/spec/form_builders/translatable_form_builder_spec.rb @@ -10,6 +10,7 @@ describe TranslatableFormBuilder do translates :title, touch: true include Globalizable + has_many :translations, class_name: "DummyBanner::Translation", foreign_key: "banner_id" end diff --git a/spec/models/geojson_format_validator_spec.rb b/spec/models/geojson_format_validator_spec.rb index a0a5f4eef..15e0883c2 100644 --- a/spec/models/geojson_format_validator_spec.rb +++ b/spec/models/geojson_format_validator_spec.rb @@ -4,6 +4,7 @@ describe GeojsonFormatValidator do before do dummy_model = Class.new do include ActiveModel::Model + attr_accessor :geojson validates :geojson, geojson_format: true end diff --git a/spec/models/globalizable_spec.rb b/spec/models/globalizable_spec.rb index 7cd16a4aa..9c45a47a8 100644 --- a/spec/models/globalizable_spec.rb +++ b/spec/models/globalizable_spec.rb @@ -10,6 +10,7 @@ describe Globalizable do translates :title, touch: true include Globalizable + has_many :translations, class_name: "DummyBanner::Translation", foreign_key: "banner_id" validates_translation :title, length: { minimum: 7 } diff --git a/spec/models/skip_validation_spec.rb b/spec/models/skip_validation_spec.rb index 8e18197e2..ca830cad7 100644 --- a/spec/models/skip_validation_spec.rb +++ b/spec/models/skip_validation_spec.rb @@ -6,6 +6,7 @@ describe SkipValidation do dummy_model = Class.new do include ActiveModel::Model include SkipValidation + attr_accessor :title, :description validates :title, presence: true, length: { in: 10..60, allow_nil: true } @@ -58,6 +59,7 @@ describe SkipValidation do translates :title, touch: true translates :description, touch: true include Globalizable + has_many :translations, class_name: "DummyBanner::Translation", foreign_key: "banner_id" validates_translation :title, presence: true diff --git a/spec/models/statisticable_spec.rb b/spec/models/statisticable_spec.rb index fa3301610..9bef4b76d 100644 --- a/spec/models/statisticable_spec.rb +++ b/spec/models/statisticable_spec.rb @@ -4,6 +4,7 @@ describe Statisticable do before do dummy_stats = Class.new do include Statisticable + attr_accessor :total stats_cache :total diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 16a958e38..961ebb375 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -40,6 +40,7 @@ end Rails.application.load_tasks if Rake::Task.tasks.empty? include Warden::Test::Helpers + Warden.test_mode! ActiveRecord::Migration.maintain_test_schema! diff --git a/spec/views/shared/errors_spec.rb b/spec/views/shared/errors_spec.rb index 1159f58c7..19fef1205 100644 --- a/spec/views/shared/errors_spec.rb +++ b/spec/views/shared/errors_spec.rb @@ -4,6 +4,7 @@ describe "shared errors" do before do dummy_model = Class.new do include ActiveModel::Model + attr_accessor :title, :description, :days validates :title, presence: true