diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index e367e4d7a6..1bc8cddbb8 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -19,13 +19,33 @@ jobs:
rspec-command: bin/rspec --tag ~js
install-audiowaveform: true
+ - engine-name: pageflow
+ ruby-version: 3.2
+ rails-version: "~> 7.1"
+ engine-directory: .
+ rspec-command: bin/rspec --tag ~js
+ install-audiowaveform: true
+
- engine-name: pageflow
ruby-version: 3.2
engine-directory: .
rspec-command: bin/rspec-with-retry --tag js
+ - engine-name: pageflow
+ ruby-version: 3.2
+ rails-version: "~> 7.1"
+ engine-directory: .
+ rspec-command: bin/rspec-with-retry --tag js
+
+ - engine-name: pageflow_paged
+ ruby-version: 3.2
+ engine-directory: entry_types/paged
+ plugin-name: pageflow_paged
+ rspec-command: bin/rspec
+
- engine-name: pageflow_paged
ruby-version: 3.2
+ rails-version: "~> 7.1"
engine-directory: entry_types/paged
plugin-name: pageflow_paged
rspec-command: bin/rspec
@@ -36,12 +56,29 @@ jobs:
plugin-name: pageflow_scrolled
rspec-command: bin/rspec --tag ~js
+ - engine-name: pageflow_scrolled
+ ruby-version: 3.2
+ rails-version: "~> 7.1"
+ engine-directory: entry_types/scrolled
+ plugin-name: pageflow_scrolled
+ rspec-command: bin/rspec --tag ~js
+
- engine-name: pageflow_scrolled
ruby-version: 3.2
engine-directory: entry_types/scrolled
plugin-name: pageflow_scrolled
rspec-command: bin/rspec-with-retry-on-timeout --tag js
+ - engine-name: pageflow_scrolled
+ ruby-version: 3.2
+ rails-version: "~> 7.1"
+ engine-directory: entry_types/scrolled
+ plugin-name: pageflow_scrolled
+ rspec-command: bin/rspec-with-retry-on-timeout --tag js
+
+ env:
+ PAGEFLOW_RAILS_VERSION: ${{ matrix.rails-version }}
+
services:
mysql:
image: mysql:5.7
diff --git a/Gemfile b/Gemfile
index 2056fcd3e3..8fb76f9894 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,6 +5,8 @@ gemspec
require File.expand_path('lib/pageflow/rails_version', File.dirname(__FILE__))
gem 'rails', Pageflow::RailsVersion.detect
+gem 'ammeter', '~> 1.1', require: false
+
gem 'pageflow-support', path: 'spec/support'
gem 'spring-commands-rspec', group: :development
diff --git a/app/controllers/pageflow/entries_controller.rb b/app/controllers/pageflow/entries_controller.rb
index 061edd8416..eefb47d136 100644
--- a/app/controllers/pageflow/entries_controller.rb
+++ b/app/controllers/pageflow/entries_controller.rb
@@ -8,7 +8,7 @@ class EntriesController < Pageflow::ApplicationController
def index
site = Site.for_request(request).with_home_url.first!
- redirect_to(site.home_url)
+ redirect_to(site.home_url, allow_other_host: true)
end
def show
diff --git a/app/helpers/pageflow/revision_file_helper.rb b/app/helpers/pageflow/revision_file_helper.rb
index a2e4bc11e6..46b93cc309 100644
--- a/app/helpers/pageflow/revision_file_helper.rb
+++ b/app/helpers/pageflow/revision_file_helper.rb
@@ -19,9 +19,9 @@ module RevisionFileHelper
#
# @since 15.0
# @returns UsedFile
- def find_file_in_entry(file_type, file_perma_id)
- raise 'No entry of type PublishedEntry or DraftEntry set.' unless @entry.present?
- @entry.find_file_by_perma_id(file_type, file_perma_id)
+ def find_file_in_entry(file_type, file_perma_id, entry = @entry)
+ raise 'No entry of type PublishedEntry or DraftEntry set.' unless entry.present?
+ entry.find_file_by_perma_id(file_type, file_perma_id)
end
end
end
diff --git a/app/helpers/pageflow/social_share_helper.rb b/app/helpers/pageflow/social_share_helper.rb
index fe72640a64..928e5758ef 100644
--- a/app/helpers/pageflow/social_share_helper.rb
+++ b/app/helpers/pageflow/social_share_helper.rb
@@ -8,7 +8,7 @@ def social_share_meta_tags_for(target)
if target.is_a?(Page)
render('pageflow/social_share/page_meta_tags', entry: @entry, page: @entry.share_target)
else
- render('pageflow/social_share/entry_meta_tags', entry: @entry)
+ render('pageflow/social_share/entry_meta_tags', entry: target)
end
end
@@ -55,7 +55,7 @@ def social_share_entry_description(entry)
def social_share_entry_image_tags(entry)
share_images = []
- image_file = find_file_in_entry(ImageFile, entry.share_image_id)
+ image_file = find_file_in_entry(ImageFile, entry.share_image_id, entry)
if image_file
image_url = image_file.thumbnail_url(:medium)
diff --git a/app/models/concerns/pageflow/uploadable_file.rb b/app/models/concerns/pageflow/uploadable_file.rb
index f151c15854..1c9e7d4658 100644
--- a/app/models/concerns/pageflow/uploadable_file.rb
+++ b/app/models/concerns/pageflow/uploadable_file.rb
@@ -38,6 +38,11 @@ module UploadableFile
end
end
+ # see https://github.com/rails/rails/issues/50048
+ def file_name
+ attachment_on_s3_file_name
+ end
+
def attachment
attachment_on_s3
end
diff --git a/entry_types/paged/spec/support/config/database_cleaner.rb b/entry_types/paged/spec/support/config/database_cleaner.rb
index 5ce7835ba3..209df9b6b5 100644
--- a/entry_types/paged/spec/support/config/database_cleaner.rb
+++ b/entry_types/paged/spec/support/config/database_cleaner.rb
@@ -1,4 +1,4 @@
-require 'database_cleaner'
+require 'database_cleaner-active_record'
RSpec.configure do |config|
config.before(:suite) do
diff --git a/entry_types/scrolled/app/controllers/pageflow_scrolled/entries_controller.rb b/entry_types/scrolled/app/controllers/pageflow_scrolled/entries_controller.rb
index 8df04fbc24..e17b83a04a 100644
--- a/entry_types/scrolled/app/controllers/pageflow_scrolled/entries_controller.rb
+++ b/entry_types/scrolled/app/controllers/pageflow_scrolled/entries_controller.rb
@@ -13,10 +13,16 @@ class EntriesController < ActionController::Base
helper FaviconHelper
def show
- @entry = get_published_entry_from_env
- @widget_scope = get_entry_mode_from_env
+ entry = get_published_entry_from_env
- I18n.locale = @entry.locale
+ I18n.locale = entry.locale
+
+ render(
+ locals: {
+ entry: entry,
+ widget_scope: get_entry_mode_from_env
+ }
+ )
end
end
end
diff --git a/entry_types/scrolled/app/helpers/pageflow_scrolled/editor/seed_html_helper.rb b/entry_types/scrolled/app/helpers/pageflow_scrolled/editor/seed_html_helper.rb
index 403f8e3f68..2be6778f32 100644
--- a/entry_types/scrolled/app/helpers/pageflow_scrolled/editor/seed_html_helper.rb
+++ b/entry_types/scrolled/app/helpers/pageflow_scrolled/editor/seed_html_helper.rb
@@ -15,12 +15,12 @@ module SeedHtmlHelper
def scrolled_editor_iframe_seed_html_script_tag(entry)
html = render(template: 'pageflow_scrolled/entries/show',
locals: {
- :@entry => entry,
- :@widget_scope => :editor,
- :@skip_ssr => true,
- :@skip_structured_data => true,
- :@skip_feed_link_tags => true,
- :@seed_options => {
+ entry: entry,
+ widget_scope: :editor,
+ skip_ssr: true,
+ skip_structured_data: true,
+ skip_feed_link_tags: true,
+ seed_options: {
skip_collections: true,
include_unused_additional_seed_data: true,
translations: {include_inline_editing: true}
diff --git a/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb b/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb
index 6b19f34bcf..5f5acb0cb6 100644
--- a/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb
+++ b/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb
@@ -1,26 +1,26 @@
-<%= cache_scrolled_entry(entry: @entry, widget_scope: @widget_scope) do %>
+<%= cache_scrolled_entry(entry: entry, widget_scope: widget_scope) do %>
- <%= content_tag(:html, lang: @entry.locale, dir: text_direction(@entry.locale)) do %>
+ <%= content_tag(:html, lang: entry.locale, dir: text_direction(entry.locale)) do %>
- <%= pretty_entry_title(@entry) %>
+ <%= pretty_entry_title(entry) %>
- <%= social_share_meta_tags_for(@entry) %>
- <%= meta_tags_for_entry(@entry) %>
- <%= feed_link_tags_for_entry(@entry) unless @skip_feed_link_tags%>
+ <%= social_share_meta_tags_for(entry) %>
+ <%= meta_tags_for_entry(entry) %>
+ <%= feed_link_tags_for_entry(entry) unless local_assigns[:skip_feed_link_tags] %>
- <%= scrolled_favicons_for_entry(@entry, entry_mode: @widget_scope) %>
+ <%= scrolled_favicons_for_entry(entry, entry_mode: widget_scope) %>
<%= javascript_include_tag 'pageflow_scrolled/legacy' %>
- <%= scrolled_frontend_stylesheet_packs_tag(@entry, widget_scope: @widget_scope) %>
+ <%= scrolled_frontend_stylesheet_packs_tag(entry, widget_scope: widget_scope) %>
- <%= scrolled_theme_properties_style_tag(@entry.theme) %>
- <%= scrolled_theme_stylesheet_pack_tags(@entry.theme) %>
+ <%= scrolled_theme_properties_style_tag(entry.theme) %>
+ <%= scrolled_theme_stylesheet_pack_tags(entry.theme) %>
- <%= render_widget_head_fragments(@entry, scope: @widget_scope) %>
+ <%= render_widget_head_fragments(entry, scope: widget_scope) %>
<% if Rails.env.development? %>
<% end %>
- <% ssr_html = @skip_ssr ? '' : render_scrolled_entry(@entry) %>
+ <% ssr_html = local_assigns[:skip_ssr] ? '' : render_scrolled_entry(entry) %>
- <% if !@skip_ssr && (params[:frontend] == 'v2' || @entry.feature_state('frontend_v2')) %>
+ <% if !local_assigns[:skip_ssr] && (params[:frontend] == 'v2' || entry.feature_state('frontend_v2')) %>
<%= generated_media_queries_tags_for(ssr_html) %>
<% end %>
- <%= structured_data_for_entry(@entry) unless @skip_structured_data %>
+ <%= structured_data_for_entry(entry) unless local_assigns[:skip_structured_data] %>
<%= render 'pageflow_scrolled/entries/global_notices' %>
@@ -49,13 +49,13 @@
<%= ssr_html %>
- <%= render_widgets(@entry, scope: @widget_scope, insert_point: :bottom_of_entry) %>
+ <%= render_widgets(entry, scope: widget_scope, insert_point: :bottom_of_entry) %>
<%= scrolled_webpack_public_path_script_tag %>
- <%= scrolled_frontend_javascript_packs_tag(@entry, widget_scope: @widget_scope) %>
+ <%= scrolled_frontend_javascript_packs_tag(entry, widget_scope: widget_scope) %>
- <%= scrolled_entry_json_seed_script_tag(@entry, @seed_options || {}) %>
+ <%= scrolled_entry_json_seed_script_tag(entry, local_assigns[:seed_options] || {}) %>
<% end %>
<% end %>
diff --git a/entry_types/scrolled/lib/pageflow_scrolled/web_app_manifest.rb b/entry_types/scrolled/lib/pageflow_scrolled/web_app_manifest.rb
index 2f0d049121..acf20745fd 100644
--- a/entry_types/scrolled/lib/pageflow_scrolled/web_app_manifest.rb
+++ b/entry_types/scrolled/lib/pageflow_scrolled/web_app_manifest.rb
@@ -2,7 +2,7 @@ module PageflowScrolled
WebAppManifest = lambda do |entry|
EntriesController.renderer.render(
partial: 'manifest',
- formats: 'json',
+ format: 'json',
locals: {
theme: entry.theme
}
diff --git a/entry_types/scrolled/spec/support/config/database_cleaner.rb b/entry_types/scrolled/spec/support/config/database_cleaner.rb
index 5ce7835ba3..209df9b6b5 100644
--- a/entry_types/scrolled/spec/support/config/database_cleaner.rb
+++ b/entry_types/scrolled/spec/support/config/database_cleaner.rb
@@ -1,4 +1,4 @@
-require 'database_cleaner'
+require 'database_cleaner-active_record'
RSpec.configure do |config|
config.before(:suite) do
diff --git a/pageflow.gemspec b/pageflow.gemspec
index 536b4ea6e7..97dfc8aae0 100644
--- a/pageflow.gemspec
+++ b/pageflow.gemspec
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
s.require_paths = ['lib', 'entry_types/paged/lib', 'entry_types/scrolled/lib']
- s.add_dependency 'rails', '~> 6.1.0'
+ s.add_dependency 'rails', Pageflow::RailsVersion.detect
# Framework for admin interface
s.add_dependency 'activeadmin', '~> 3.0'
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
#
# Pageflow::UserMixin depends on Devise internals. We therefore use
# a conservative version constraint.
- s.add_dependency 'devise', '~> 4.7.3'
+ s.add_dependency 'devise', '~> 4.9.3'
# Faster JSON backend
s.add_dependency 'yajl-ruby', '~> 1.2'
@@ -150,7 +150,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'resque', '~> 1.25'
s.add_development_dependency 'resque-scheduler', '~> 4.10'
- s.add_development_dependency 'ar_after_transaction', '~> 0.8.0'
+ s.add_development_dependency 'ar_after_transaction', '~> 0.10.0'
s.add_development_dependency 'redis', '~> 3.0'
s.add_development_dependency 'redis-namespace', '~> 1.5'
@@ -189,7 +189,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'pundit-matchers', '~> 1.0'
# Clean database in integration tests
- s.add_development_dependency 'database_cleaner', '~> 1.2'
+ s.add_development_dependency 'database_cleaner-active_record', '~> 2.1'
# Freeze time in tests
s.add_development_dependency 'timecop', '~> 0.7.1'
diff --git a/spec/helpers/pageflow/revision_file_helper_spec.rb b/spec/helpers/pageflow/revision_file_helper_spec.rb
index 36518297cd..53f03cdae9 100644
--- a/spec/helpers/pageflow/revision_file_helper_spec.rb
+++ b/spec/helpers/pageflow/revision_file_helper_spec.rb
@@ -49,6 +49,17 @@ module Pageflow
expect(result).to eq(image_file)
end
end
+
+ it 'allows passing entry explicitly' do
+ entry = create(:entry)
+ revision = create(:revision, :published, entry: entry)
+ image_file = create(:image_file)
+ usage = create(:file_usage, revision: revision, file: image_file)
+ entry = PublishedEntry.new(entry)
+
+ result = helper.find_file_in_entry(ImageFile, usage.perma_id, entry)
+ expect(result).to eq(image_file)
+ end
end
end
end
diff --git a/spec/helpers/pageflow/social_share_helper_spec.rb b/spec/helpers/pageflow/social_share_helper_spec.rb
index 92bbadfac2..0a33d095de 100644
--- a/spec/helpers/pageflow/social_share_helper_spec.rb
+++ b/spec/helpers/pageflow/social_share_helper_spec.rb
@@ -2,6 +2,17 @@
module Pageflow
describe SocialShareHelper do
+ describe '#social_share_meta_tags_for' do
+ it 'renders canonical url' do
+ entry = create(:entry, :published)
+ published_entry = PublishedEntry.new(entry)
+
+ result = helper.social_share_meta_tags_for(published_entry)
+
+ expect(result).to have_selector('link[rel=canonical]', visible: false)
+ end
+ end
+
describe '#social_share_entry_url' do
it 'returns share_url if present' do
entry = create(:entry, :published, published_revision_attributes: {
diff --git a/spec/support/config/database_cleaner.rb b/spec/support/config/database_cleaner.rb
index cb20d431ac..5a6859728c 100644
--- a/spec/support/config/database_cleaner.rb
+++ b/spec/support/config/database_cleaner.rb
@@ -1,4 +1,4 @@
-require 'database_cleaner'
+require 'database_cleaner-active_record'
RSpec.configure do |config|
config.before(:suite) do
diff --git a/spec/support/helpers/stub_template_in_helper_specs.rb b/spec/support/helpers/stub_template_in_helper_specs.rb
index 9c93d744d7..20f9e37009 100644
--- a/spec/support/helpers/stub_template_in_helper_specs.rb
+++ b/spec/support/helpers/stub_template_in_helper_specs.rb
@@ -1,7 +1,11 @@
RSpec.configure do |config|
module StubTemplateTestHelper
def stub_template(hash)
- view.view_paths.unshift(ActionView::FixtureResolver.new(hash))
+ if view.view_paths.respond_to?(:unshift)
+ view.view_paths.unshift(ActionView::FixtureResolver.new(hash))
+ else
+ view.lookup_context.prepend_view_paths([ActionView::FixtureResolver.new(hash)])
+ end
end
end
diff --git a/spec/support/pageflow-support.gemspec b/spec/support/pageflow-support.gemspec
index 898ec86bde..0ce8159ec3 100644
--- a/spec/support/pageflow-support.gemspec
+++ b/spec/support/pageflow-support.gemspec
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'resque', '~> 1.25'
s.add_runtime_dependency 'resque-scheduler', '~> 4.10'
- s.add_runtime_dependency 'ar_after_transaction', '~> 0.8.0'
+ s.add_runtime_dependency 'ar_after_transaction', '~> 0.10.0'
s.add_runtime_dependency 'redis', '~> 3.0'
s.add_runtime_dependency 'redis-namespace', '~> 1.5'
diff --git a/spec/support/pageflow/dummy/app.rb b/spec/support/pageflow/dummy/app.rb
index 5cd390c5c1..8f752ce479 100644
--- a/spec/support/pageflow/dummy/app.rb
+++ b/spec/support/pageflow/dummy/app.rb
@@ -11,13 +11,13 @@ def generate
if File.exist?(directory)
puts("Dummy directory #{directory} exists.")
else
- system("bundle exec rails new #{directory} --skip-spring " \
+ system('SKIP_EAGER_LOAD=true ' \
+ "bundle exec rails new #{directory} --skip-spring " \
"--template #{template_path} #{rails_new_options}") ||
raise('Error generating dummy app.')
end
require(File.join(ENV['RAILS_ROOT'], 'config', 'environment'))
- require('pageflow/dummy/config/pageflow')
end
def directory
diff --git a/spec/support/pageflow/dummy/config/pageflow.rb b/spec/support/pageflow/dummy/config/pageflow.rb
index 256d25b32f..c1a4d7f057 100644
--- a/spec/support/pageflow/dummy/config/pageflow.rb
+++ b/spec/support/pageflow/dummy/config/pageflow.rb
@@ -14,6 +14,3 @@
}
end
end
-
-# Reconstruct current config to ensure config block above is used
-Pageflow.configure!
diff --git a/spec/support/pageflow/dummy/rails_template.rb b/spec/support/pageflow/dummy/rails_template.rb
index bbdcb77289..00d02dc9d1 100644
--- a/spec/support/pageflow/dummy/rails_template.rb
+++ b/spec/support/pageflow/dummy/rails_template.rb
@@ -21,6 +21,10 @@ def source_paths
/^ database: /,
" database: #{database_prefix}-")
+gsub_file('config/environments/test.rb',
+ 'config.eager_load = ENV["CI"].present?',
+ 'config.eager_load = ENV["CI"].present? && !ENV["SKIP_EAGER_LOAD"]')
+
append_to_file('config/application.rb', <<-END)
if ENV['PAGEFLOW_DB_HOST'].present?
ActiveRecord::Tasks::DatabaseTasks::LOCAL_HOSTS << ENV['PAGEFLOW_DB_HOST']
@@ -40,6 +44,8 @@ def source_paths
# Recreate db. Ignore if it does not exist.
in_root { run('rake db:environment:set db:drop:all', capture: true, abort_on_failure: false) }
+
+rake 'db:create' # workaround for https://github.com/rails/rails/issues/50038
rake 'db:create:all'
# Install Webpacker
@@ -63,6 +69,12 @@ def source_paths
ActiveAdmin.application.load_paths.unshift(Dir[Rails.root.join('app/admin')].first)\n
END
+# Adapt default configuration
+
+inject_into_file('config/initializers/pageflow.rb',
+ "require 'pageflow/dummy/config/pageflow'\n",
+ after: "Pageflow.finalize!\n")
+
# Add required files for test theme
copy_file('test_theme.scss',
@@ -91,4 +103,4 @@ def source_paths
copy_file('add_custom_fields.rb',
'db/migrate/99990000000000_add_custom_fields.rb')
-rake 'db:migrate db:test:load', env: 'development'
+rake 'db:migrate db:test:load_schema', env: 'development'