Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/reusable-workflow-rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
include:
- ruby-version: 3.4
- ruby-version: 3.4
rails-version: "~> 7.2"
rails-version: "~> 8.1.0"

env:
PAGEFLOW_RAILS_VERSION: ${{ matrix.rails-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rails-version: ['~> 7.1.0', '~> 7.2.0']
rails-version: ['~> 7.2.0', '~> 8.1.0']
job:
- pageflow
- pageflow_js
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Pageflow runs in environments with:

* Ruby >= 3.4
* Node >= 22
* Rails 7.1
* Rails >= 7.2, < 8.2
* Redis server (for Resque)
* A database server supported by Active Record (tested with MySQL)
* ImageMagick
Expand Down
15 changes: 11 additions & 4 deletions app/models/concerns/pageflow/auto_generated_perma_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ def ensure_perma_id

entry = entry_for_auto_generated_perma_id

entry.with_lock do
entry.increment!(:perma_id_counter)
self.perma_id = entry.perma_id_counter
end
self.perma_id =
if entry.new_record?
# No other process can see the entry yet, so there is nothing
# to lock.
entry.increment(:perma_id_counter).perma_id_counter
else
entry.with_lock do
entry.increment!(:perma_id_counter)
entry.perma_id_counter
end
end
end

def entry_for_auto_generated_perma_id
Expand Down
6 changes: 2 additions & 4 deletions app/models/concerns/pageflow/serialization_blacklist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ module Pageflow
# @api private
module SerializationBlacklist
def serializable_hash(options = nil)
options ||= {}

options[:except] = Array(options[:except])
options[:except].concat(blacklist_for_serialization)
options = (options || {}).dup
options[:except] = Array(options[:except]) + blacklist_for_serialization

super
end
Expand Down
7 changes: 3 additions & 4 deletions lib/pageflow/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,7 @@ def page_types
def register_page_type(page_type)
Pageflow::Deprecation.warn(
'Pageflow::Configuration#register_page_type is deprecated. ' \
'Use config.page_types.register instead.',
caller
'Use config.page_types.register instead.'
)
page_types.register(page_type)
end
Expand All @@ -637,13 +636,13 @@ def register_page_type(page_type)
# Please change your forms accordingly.
def paperclip_filesystem_root
Pageflow::Deprecation.warn(
'Pageflow::Configuration#paperclip_filesystem_root is deprecated.', caller
'Pageflow::Configuration#paperclip_filesystem_root is deprecated.'
)
end

def paperclip_filesystem_root=(_val)
Pageflow::Deprecation.warn(
'Pageflow::Configuration#paperclip_filesystem_root is deprecated.', caller
'Pageflow::Configuration#paperclip_filesystem_root is deprecated.'
)
end

Expand Down
15 changes: 13 additions & 2 deletions lib/pageflow/rails_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,27 @@ module Pageflow
module RailsVersion
extend self

SUPPORTED = ['>= 7.2', '< 8.2'].freeze
DEFAULT = '~> 7.2.0'.freeze

def detect
from_env || '~> 7.2.0'
from_env || DEFAULT
end

def requirement
experimental? ? [] : SUPPORTED
end

def experimental?
detect != '~> 7.2.0'
!Gem::Requirement.new(SUPPORTED).satisfied_by?(requested_version)
end

private

def requested_version
Gem::Requirement.new(detect).requirements.first.last
end

def from_env
ENV['PAGEFLOW_RAILS_VERSION'] if ENV['PAGEFLOW_RAILS_VERSION'] != ''
end
Expand Down
5 changes: 3 additions & 2 deletions pageflow.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

require 'pageflow/version'
require 'pageflow/rails_version'

Gem::Specification.new do |s|
s.name = 'pageflow'
Expand Down Expand Up @@ -30,7 +31,7 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 3.2'

s.add_dependency 'rails', ['>= 7.1.2', '< 7.3']
s.add_dependency 'rails', *Pageflow::RailsVersion.requirement

# Framework for admin interface
s.add_dependency 'activeadmin', '~> 3.0'
Expand All @@ -54,7 +55,7 @@ Gem::Specification.new do |s|
s.add_dependency 'state_machines-activerecord', '~> 0.9.0'

# Trigger resque jobs with a state machine
s.add_dependency 'state_machine_job', '~> 3.0'
s.add_dependency 'state_machine_job', '~> 3.3'

# File attachments
s.add_dependency 'kt-paperclip', '~> 7.2'
Expand Down
13 changes: 12 additions & 1 deletion spec/support/pageflow/dummy/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ def generate
end

require(File.join(ENV.fetch('RAILS_ROOT', nil), 'config', 'environment'))

load_routes
end

# Routes are only loaded on demand unless eager loading is
# enabled. Active Admin defines its controllers while routes are
# drawn, and specs reference those constants as they are loaded.
def load_routes
return unless Rails.application.respond_to?(:reload_routes_unless_loaded)

Rails.application.reload_routes_unless_loaded
end

def directory
Expand All @@ -30,7 +41,7 @@ def template_path
end

def rails_new_options
result = '--skip-test-unit --skip-bundle --database=mysql'
result = '--skip-test-unit --skip-bundle --database=mysql --skip-active-storage'
result << ' --skip-javascript'
result
end
Expand Down
8 changes: 6 additions & 2 deletions spec/support/pageflow/dummy/rails_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ def source_paths

generate 'pageflow:install', '--force'

if ENV['PAGEFLOW_PLUGIN_ENGINE'].present?
generate "#{ENV['PAGEFLOW_PLUGIN_ENGINE']}:install", '--force'
# Invoking a generator that does not exist aborts the template, and not
# every plugin engine comes with an install generator.
plugin_engine = ENV['PAGEFLOW_PLUGIN_ENGINE'].presence

if plugin_engine && Rails::Generators.find_by_namespace('install', plugin_engine)
generate "#{plugin_engine}:install", '--force'
end

# Devise needs default_url_options for generating mails.
Expand Down
Loading