Use Zeitwerk instead of the classic autoloader
In Rails 6.1, the classic autoloader is deprecated. We were getting an error because we were using `autoload` in the ActiveStorage plugin for CKEditor: expected file app/lib/ckeditor/backend/active_storage.rb to define constant Ckeditor::Backend::ActiveStorage So we're removing the line causing the error. Finally, we can now restore all the tests that that failed sometimes with the classic autoloader and that we modified in commits2af1fc72fand8ba37b295.
This commit is contained in:
@@ -67,7 +67,5 @@ module Ckeditor
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
autoload :ActiveStorage, "ckeditor/backend/active_storage"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,10 +32,6 @@ module Consul
|
|||||||
# in any CONSUL DEMOCRACY installations
|
# in any CONSUL DEMOCRACY installations
|
||||||
config.active_support.use_authenticated_message_encryption = false
|
config.active_support.use_authenticated_message_encryption = false
|
||||||
|
|
||||||
# Keep using the classic autoloader until we decide how custom classes
|
|
||||||
# should work with zeitwerk
|
|
||||||
config.autoloader = :classic
|
|
||||||
|
|
||||||
# Don't enable has_many_inversing because it doesn't seem to currently
|
# Don't enable has_many_inversing because it doesn't seem to currently
|
||||||
# work with the _count database columns we use for caching purposes
|
# work with the _count database columns we use for caching purposes
|
||||||
config.active_record.has_many_inversing = false
|
config.active_record.has_many_inversing = false
|
||||||
@@ -143,6 +139,7 @@ module Consul
|
|||||||
"app/models/custom/concerns"
|
"app/models/custom/concerns"
|
||||||
].each do |path|
|
].each do |path|
|
||||||
config.autoload_paths << Rails.root.join(path)
|
config.autoload_paths << Rails.root.join(path)
|
||||||
|
config.eager_load_paths << Rails.root.join(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
config.paths["app/views"].unshift(Rails.root.join("app", "views", "custom"))
|
config.paths["app/views"].unshift(Rails.root.join("app", "views", "custom"))
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ Rails.application.configure do
|
|||||||
# Annotate rendered view with file names.
|
# Annotate rendered view with file names.
|
||||||
# config.action_view.annotate_rendered_view_with_filenames = true
|
# config.action_view.annotate_rendered_view_with_filenames = true
|
||||||
|
|
||||||
|
config.eager_load_paths << "#{Rails.root}/spec/mailers/previews"
|
||||||
config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews"
|
config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews"
|
||||||
|
|
||||||
# Limit size of local logs
|
# Limit size of local logs
|
||||||
|
|||||||
@@ -178,16 +178,15 @@ describe "Homepage", :admin do
|
|||||||
link_text: "Link1 text",
|
link_text: "Link1 text",
|
||||||
link_url: "consul1.dev")
|
link_url: "consul1.dev")
|
||||||
|
|
||||||
# TODO: uncomment again after switching to zeitwerk
|
card2 = create(:widget_card, label: "Card2 label",
|
||||||
# card2 = create(:widget_card, label: "Card2 label",
|
title: "Card2 text",
|
||||||
# title: "Card2 text",
|
description: "Card2 description",
|
||||||
# description: "Card2 description",
|
link_text: "Link2 text",
|
||||||
# link_text: "Link2 text",
|
link_url: "consul2.dev")
|
||||||
# link_url: "consul2.dev")
|
|
||||||
|
|
||||||
visit root_path
|
visit root_path
|
||||||
|
|
||||||
expect(page).to have_css(".card", count: 1) # TODO: change to `count: 2 after switching to zeitwerk
|
expect(page).to have_css(".card", count: 2)
|
||||||
|
|
||||||
within("#widget_card_#{card1.id}") do
|
within("#widget_card_#{card1.id}") do
|
||||||
expect(page).to have_content("CARD1 LABEL")
|
expect(page).to have_content("CARD1 LABEL")
|
||||||
@@ -198,15 +197,14 @@ describe "Homepage", :admin do
|
|||||||
expect(page).to have_css("img[alt='#{card1.image.title}']")
|
expect(page).to have_css("img[alt='#{card1.image.title}']")
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: uncomment again after switching to zeitwerk
|
within("#widget_card_#{card2.id}") do
|
||||||
# within("#widget_card_#{card2.id}") do
|
expect(page).to have_content("CARD2 LABEL")
|
||||||
# expect(page).to have_content("CARD2 LABEL")
|
expect(page).to have_content("CARD2 TEXT")
|
||||||
# expect(page).to have_content("CARD2 TEXT")
|
expect(page).to have_content("Card2 description")
|
||||||
# expect(page).to have_content("Card2 description")
|
expect(page).to have_content("Link2 text")
|
||||||
# expect(page).to have_content("Link2 text")
|
expect(page).to have_link(href: "consul2.dev")
|
||||||
# expect(page).to have_link(href: "consul2.dev")
|
expect(page).to have_css("img[alt='#{card2.image.title}']")
|
||||||
# expect(page).to have_css("img[alt='#{card2.image.title}']")
|
end
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Recomendations" do
|
scenario "Recomendations" do
|
||||||
|
|||||||
@@ -59,16 +59,14 @@ describe "Cards", :admin do
|
|||||||
|
|
||||||
scenario "Show" do
|
scenario "Show" do
|
||||||
card_1 = create(:widget_card, title: "Card homepage large", columns: 8)
|
card_1 = create(:widget_card, title: "Card homepage large", columns: 8)
|
||||||
# TODO: uncomment after switching to zeitwerk
|
card_2 = create(:widget_card, title: "Card homepage medium", columns: 4)
|
||||||
# card_2 = create(:widget_card, title: "Card homepage medium", columns: 4)
|
card_3 = create(:widget_card, title: "Card homepage small", columns: 2)
|
||||||
# card_3 = create(:widget_card, title: "Card homepage small", columns: 2)
|
|
||||||
|
|
||||||
visit root_path
|
visit root_path
|
||||||
|
|
||||||
expect(page).to have_css("#widget_card_#{card_1.id}.medium-8")
|
expect(page).to have_css("#widget_card_#{card_1.id}.medium-8")
|
||||||
# TODO: uncomment after switching to zeitwerk
|
expect(page).to have_css("#widget_card_#{card_2.id}.medium-4")
|
||||||
# expect(page).to have_css("#widget_card_#{card_2.id}.medium-4")
|
expect(page).to have_css("#widget_card_#{card_3.id}.medium-2")
|
||||||
# expect(page).to have_css("#widget_card_#{card_3.id}.medium-2")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Edit" do
|
scenario "Edit" do
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ describe "Polls" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Polls can be listed" do
|
scenario "Polls can be listed" do
|
||||||
polls = [create(:poll, :with_image)] # TODO: generate a list again after switching to zeitwerk
|
polls = create_list(:poll, 3, :with_image)
|
||||||
|
|
||||||
visit polls_path
|
visit polls_path
|
||||||
|
|
||||||
@@ -210,24 +210,23 @@ describe "Polls" do
|
|||||||
expect("Second question").to appear_before("Third question")
|
expect("Second question").to appear_before("Third question")
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: uncomment after switching to zeitwerk
|
scenario "Buttons to slide through images work back and forth" do
|
||||||
# scenario "Buttons to slide through images work back and forth" do
|
question = create(:poll_question, :yes_no, poll: poll)
|
||||||
# question = create(:poll_question, :yes_no, poll: poll)
|
create(:image, imageable: question.question_answers.last, title: "The no movement")
|
||||||
# create(:image, imageable: question.question_answers.last, title: "The no movement")
|
create(:image, imageable: question.question_answers.last, title: "No movement planning")
|
||||||
# create(:image, imageable: question.question_answers.last, title: "No movement planning")
|
|
||||||
|
|
||||||
# visit poll_path(poll)
|
visit poll_path(poll)
|
||||||
|
|
||||||
# within(".orbit-bullets") do
|
within(".orbit-bullets") do
|
||||||
# find("[data-slide='1']").click
|
find("[data-slide='1']").click
|
||||||
|
|
||||||
# expect(page).to have_css ".is-active[data-slide='1']"
|
expect(page).to have_css ".is-active[data-slide='1']"
|
||||||
|
|
||||||
# find("[data-slide='0']").click
|
find("[data-slide='0']").click
|
||||||
|
|
||||||
# expect(page).to have_css ".is-active[data-slide='0']"
|
expect(page).to have_css ".is-active[data-slide='0']"
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
|
|
||||||
scenario "Non-logged in users" do
|
scenario "Non-logged in users" do
|
||||||
create(:poll_question, :yes_no, poll: poll)
|
create(:poll_question, :yes_no, poll: poll)
|
||||||
|
|||||||
Reference in New Issue
Block a user