From a915b28b0520c43bb2d7c3d14a21ccd4c05af6b2 Mon Sep 17 00:00:00 2001 From: Andrew vonderLuft Date: Wed, 25 Dec 2024 19:49:41 -0800 Subject: [PATCH] Rails 8 compatibility, Ruby 3.4.1 compatibility - Rails 8 now supported - Rails 6 no longer supported --- .github/workflows/rubyonrails.yml | 3 +- .rubocop.yml | 5 +- CHANGELOG.md | 12 ++-- Gemfile | 5 +- README.md | 68 ++++++++++++++----- app/helpers/comfy/admin/cms_helper.rb | 4 +- comfortable_media_surfer.gemspec | 2 +- config/application.rb | 2 +- config/environments/development.rb | 18 +++-- config/puma.rb | 43 ++++++++++++ gemfiles/7.1.gemfile | 2 +- gemfiles/7.2.gemfile | 2 +- gemfiles/{7.0.gemfile => 8.0.gemfile} | 4 +- .../extensions/has_revisions.rb | 2 +- .../render_methods.rb | 14 ++-- lib/comfortable_media_surfer/version.rb | 2 +- .../comfy/scaffold/scaffold_generator.rb | 2 +- test/lib/content/tags/helper_test.rb | 4 +- test/lib/content/tags/partial_test.rb | 6 +- 19 files changed, 142 insertions(+), 58 deletions(-) create mode 100644 config/puma.rb rename gemfiles/{7.0.gemfile => 8.0.gemfile} (93%) diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml index 2e78cd95..41a9933c 100644 --- a/.github/workflows/rubyonrails.yml +++ b/.github/workflows/rubyonrails.yml @@ -10,12 +10,13 @@ jobs: strategy: matrix: ruby-version: - - "3.1" - "3.2" - "3.3" + - "3.4" rails-version: - "7.1" - "7.2" + - "8.0" continue-on-error: [true] name: ${{ format('Tests (Ruby {0}, Rails {1})', matrix.ruby-version, matrix.rails-version) }} runs-on: ubuntu-latest diff --git a/.rubocop.yml b/.rubocop.yml index fc31fcc6..f75109f4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ require: # - rubocop-minitest AllCops: - TargetRubyVersion: 3.0 + TargetRubyVersion: 3.2 NewCops: enable Exclude: - bin/* @@ -59,6 +59,9 @@ Style/Documentation: Style/DocumentDynamicEvalDefinition: Enabled: false +Style/HashSyntax: + Enabled: false + Style/IfUnlessModifier: Enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index a2c2935d..8dbc4da6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,16 +12,16 @@ For all changes prior to the inception of this project, see the [Release History ## [Unreleased] -Changes since the last non-beta release. +- [Remove sassc sprockets](https://github.com/shakacode/comfortable-media-surfer/pull/4) -_Please add entries here for your pull requests that have not yet been released._ - -## [3.0.1] - 2024-12-01 +## [3.1.0] - 2024-12-26 ### Added -- Added this CHANGELOG -- Added badges to README for CI build, Test Coverage, Gem version, Gem downloads, and last release +- Deprecated Rails 6.x support, since it is not being maintained as of October 2024 +- Added compatibility and support for Rails 8 +- Added documentation to README for converting from the older CMSs +- Updated README links to the Surfer wiki ## [3.0.0] - 2024-11-30 diff --git a/Gemfile b/Gemfile index 76d35285..18cb2479 100644 --- a/Gemfile +++ b/Gemfile @@ -5,14 +5,14 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } gemspec -gem 'rails', '~> 7.2' +gem 'rails', '~> 8.0' group :development, :test do gem 'autoprefixer-rails', '~> 10.4.16.0' gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw] gem 'gem-release' gem 'image_processing', '>= 1.12.0' - gem 'sqlite3', '~> 1.6.7' + gem 'sqlite3', '>= 2.1' # gem 'mysql2', '~> 0.5' # gem 'pg', '~> 1.5.4' end @@ -31,6 +31,7 @@ group :test do gem 'minitest', '>= 5.23.0' gem 'minitest-reporters', '>= 1.6.1' gem 'mocha', '>= 2.3.0', require: false + gem 'ostruct' gem 'rails-controller-testing', '~> 1.0.5' gem 'rubocop', '~> 1.63.0', require: false gem 'rubocop-minitest' diff --git a/README.md b/README.md index 9ab2dcca..1e3b3500 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Rails CI](https://github.com/shakacode/comfortable-media-surfer/actions/workflows/rubyonrails.yml/badge.svg)](https://github.com/shakacode/comfortable-media-surfer/actions/workflows/rubyonrails.yml) -[![Coverage Status](https://coveralls.io/repos/github/shakacode/comfortable-media-surfer/badge.svg?branch=master)](https://coveralls.io/github/shakacode/comfortable-media-surfer?branch=master) +[![Coverage Status](https://coveralls.io/repos/github/shakacode/comfortable-media-surfer/badge.svg?branch=HEAD)](https://coveralls.io/github/shakacode/comfortable-media-surfer?branch=HEAD) [![Gem Version](https://img.shields.io/gem/v/comfortable_media_surfer.svg?style=flat)](http://rubygems.org/gems/comfortable_media_surfer) [![Gem Downloads](https://img.shields.io/gem/dt/comfortable_media_surfer.svg?style=flat)](http://rubygems.org/gems/comfortable_media_surfer) [![GitHub Release Date - Published_At](https://img.shields.io/github/release-date/shakacode/comfortable-media-surfer?label=last%20release&color=seagreen)](https://github.com/shakacode/comfortable-media-surfer/releases) @@ -11,19 +11,19 @@ ComfortableMediaSurfer is a powerful Ruby 7.0+ CMS (Content Management System) E ## Features - Simple drop-in integration with Rails 7.0+ apps with minimal configuration -- The CMS keeps clear from the rest of your application -- Powerful page templating capability using [Content Tags](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Content-Tags) -- [Multiple Sites](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Sites) from a single installation -- Multi-Language Support (i18n) (ca, cs, da, de, en, es, fi, fr, gr, hr, it, ja, nb, nl, pl, pt-BR, ru, sv, tr, uk, zh-CN, zh-TW) and page localization. -- [CMS Seeds](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-CMS-Seeds) for initial content population -- [Revision History](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Revisions) to revert changes -- [Extendable Admin Area](https://github.com/comfy/comfortable-mexican-sofa/wiki/HowTo:-Reusing-Admin-Area) built with [Bootstrap 4](http://getbootstrap.com) (responsive design). Using [CodeMirror](http://codemirror.net) for HTML and Markdown highlighing and [Redactor](http://imperavi.com/redactor) as the WYSIWYG editor. +* The CMS keeps clear from the rest of your application +* Powerful page templating capability using [Content Tags](https://github.com/shakacode/comfortable-media-surfer/wiki/Docs:-Content-Tags) +* [Multiple Sites](https://github.com/shakacode/comfortable-media-surfer/wiki/Docs:-Sites) from a single installation +* Multi-Language Support (i18n) (ca, cs, da, de, en, es, fi, fr, gr, hr, it, ja, nb, nl, pl, pt-BR, ru, sv, tr, uk, zh-CN, zh-TW) and page localization. +* [CMS Seeds](https://github.com/shakacode/comfortable-media-surfer/wiki/Docs:-CMS-Seeds) for initial content population +* [Revision History](https://github.com/shakacode/comfortable-media-surfer/wiki/Docs:-Revisions) to revert changes +* [Extendable Admin Area](https://github.com/shakacode/comfortable-media-surfer/wiki/HowTo:-Reusing-Admin-Area) built with [Bootstrap 4](http://getbootstrap.com) (responsive design). Using [CodeMirror](http://codemirror.net) for HTML and Markdown highlighing and [Redactor](http://imperavi.com/redactor) as the WYSIWYG editor. ## Dependencies - File attachments are handled by [ActiveStorage](https://github.com/rails/rails/tree/master/activestorage). Make sure that you can run appropriate migrations by running: `rails active_storage:install` - Image resizing is done with with [ImageMagick](http://www.imagemagick.org/script/download.php), so make sure it's installed. -- Pagination is handled by [kaminari](https://github.com/amatsuda/kaminari) or [will_paginate](https://github.com/mislav/will_paginate). Please add one of those to your Gemfile. +- Pagination is handled by [kaminari](https://github.com/amatsuda/kaminari). ## Compatibility @@ -34,14 +34,16 @@ On Ruby 3.x, Rails 7.x + Add gem definition to your Gemfile: ```ruby -gem "comfortable_media_surfer", "~> 3.0.0" +gem "comfortable_media_surfer", "~> 3.1.0" ``` Then from the Rails project's root run: +``` bundle install rails generate comfy:cms rake db:migrate +``` Now take a look inside your `config/routes.rb` file. You'll see where routes attach for the admin area and content serving. Make sure that content serving route appears as a very last item or it will make all other routes to be inaccessible. @@ -50,6 +52,40 @@ comfy_route :cms_admin, path: "/admin" comfy_route :cms, path: "/" ``` +## Converting from ComfortableMexicanSofa or Occams + +### From Sofa to Surfer + +The database structure is the same. Your Sofa project will also need to be upgraded to >= Rails 7.x +Then you should simply be able to update your Gemfile thus, and run bundle + +```ruby +gem 'comfortable_media_surfer', '~> 3.1.0' +``` + +### From Occams to Surfer + +Again the project must be >= Rails 7.x. Since the schema is different, executing this SQL should get you set for Surfer + +```sql +ALTER TABLE occams_cms_categories RENAME TO comfy_cms_categories; +ALTER TABLE occams_cms_categorizations RENAME TO comfy_cms_categorizations; +ALTER TABLE occams_cms_files RENAME TO comfy_cms_files; +ALTER TABLE occams_cms_fragments RENAME TO comfy_cms_fragments; +ALTER TABLE occams_cms_layouts RENAME TO comfy_cms_layouts; +ALTER TABLE occams_cms_pages RENAME TO comfy_cms_pages; +ALTER TABLE occams_cms_revisions RENAME TO comfy_cms_revisions; +ALTER TABLE occams_cms_sites RENAME TO comfy_cms_sites; +ALTER TABLE occams_cms_snippets RENAME TO comfy_cms_snippets; +ALTER TABLE occams_cms_translations RENAME TO comfy_cms_translations; +UPDATE comfy_cms_fragments SET record_type = 'Comfy::Cms::Page' WHERE record_type = 'Occams::Cms::Page'; +UPDATE comfy_cms_fragments SET record_type = 'Comfy::Cms::Layout' WHERE record_type = 'Occams::Cms::Layout'; +UPDATE comfy_cms_fragments SET record_type = 'Comfy::Cms::Snippet' WHERE record_type = 'Occams::Cms::Snippet'; +UPDATE comfy_cms_revisions SET record_type = 'Comfy::Cms::Page' WHERE record_type = 'Occams::Cms::Page'; +UPDATE comfy_cms_revisions SET record_type = 'Comfy::Cms::Layout' WHERE record_type = 'Occams::Cms::Layout'; +UPDATE comfy_cms_revisions SET record_type = 'Comfy::Cms::Snippet' WHERE record_type = 'Occams::Cms::Snippet'; +``` + ## Quick Start Guide After finishing installation you should be able to navigate to http://localhost:3000/admin @@ -73,11 +109,8 @@ Once you have a layout, you may start creating pages and populating content. It' ## Documentation -For more information on how to use this CMS please refer to the [Wiki](https://github.com/comfy/comfortable-mexican-sofa/wiki). Section that might be of interest is the entry -on [Content Tags](https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-Content-Tags). - -[Comfy Demo App](https://github.com/comfy/comfy-demo) also can be used as an -example of a default Rails app with CMS installed. +For more information on how to use this CMS please refer to the [Wiki](https://github.com/shakacode/comfortable-media-surfer/wiki). Section that might be of interest is the entry +on [Content Tags](https://github.com/shakacode/comfortable-media-surfer/wiki/Docs:-Content-Tags). ## Add-ons @@ -86,10 +119,9 @@ If you want to add a Blog functionality to your app take a look at ![Admin Area Preview](doc/preview.jpg) -#### Old Versions +#### Old Versions of ComfortableMexicanSofa -[CHANGELOG](//github.com/comfy/comfortable-mexican-sofa/releases) is documented -in Github releases. +[CHANGELOG](//github.com/comfy/comfortable-mexican-sofa/releases) is documented in ComfortableMexicanSofa Github releases. #### Contributing diff --git a/app/helpers/comfy/admin/cms_helper.rb b/app/helpers/comfy/admin/cms_helper.rb index d0225ccf..83619901 100644 --- a/app/helpers/comfy/admin/cms_helper.rb +++ b/app/helpers/comfy/admin/cms_helper.rb @@ -4,11 +4,11 @@ module Comfy module Admin module CmsHelper # Wrapper around Comfy::FormBuilder - def comfy_form_with(**options, &block) + def comfy_form_with(**options, &) form_options = options.merge(builder: ComfortableMediaSurfer::FormBuilder) form_options[:bootstrap] = { layout: :horizontal } form_options[:local] = true - bootstrap_form_with(**form_options, &block) + bootstrap_form_with(**form_options, &) end def comfy_admin_partial(path, params = {}) diff --git a/comfortable_media_surfer.gemspec b/comfortable_media_surfer.gemspec index 95a354e7..57fe1629 100644 --- a/comfortable_media_surfer.gemspec +++ b/comfortable_media_surfer.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| f.match(%r{^(test|doc)/}) end - spec.required_ruby_version = '>= 3.0.0' + spec.required_ruby_version = '>= 3.2.0' spec.metadata['rubygems_mfa_required'] = 'true' spec.add_dependency 'active_link_to', '~> 1.0', '>= 1.0.5' diff --git a/config/application.rb b/config/application.rb index 79efd495..a058ef15 100644 --- a/config/application.rb +++ b/config/application.rb @@ -17,7 +17,7 @@ class Application < Rails::Application if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1.0') config.active_record.default_column_serializer = YAML config.active_record.before_committed_on_all_records = false - config.active_record.commit_transaction_on_non_local_return = false + # config.active_record.commit_transaction_on_non_local_return = false # deprecated in Rails 8 config.active_record.run_after_transaction_callbacks_in_order_defined = false config.active_support.message_serializer = :json config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = true diff --git a/config/environments/development.rb b/config/environments/development.rb index fcad87e9..5be610c2 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -16,22 +16,19 @@ # Show full error reports. config.consider_all_requests_local = true - # Enable server timing + # Enable server timing. config.server_timing = true - # Enable/disable caching. By default caching is disabled. - # Run rails dev:cache to toggle caching. + # Enable/disable Action Controller caching. By default Action Controller caching is disabled. + # Run rails dev:cache to toggle Action Controller caching. if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store - config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{2.days.to_i}" - } + config.public_file_server.headers = { 'cache-control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false - config.cache_store = :null_store end @@ -41,8 +38,12 @@ # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + # Make template changes take effect immediately. config.action_mailer.perform_caching = false + # Set localhost to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log @@ -77,4 +78,7 @@ # Raise error when a before_action's only/except options reference missing actions config.action_controller.raise_on_missing_callback_actions = true end + + # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. + # config.generators.apply_rubocop_autocorrect_after_generate! end diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 00000000..d3983379 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. +# +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. +# +# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You +# should only set this value when you want to run 2 or more workers. The +# default is already 1. +# +# The ideal number of threads per worker depends both on how much time the +# application spends waiting for IO operations and on how much you wish to +# prioritize throughput over latency. +# +# As a rule of thumb, increasing the number of threads will increase how much +# traffic a given process can handle (throughput), but due to CRuby's +# Global VM Lock (GVL) it has diminishing returns and will degrade the +# response time (latency) of the application. +# +# The default is set to 3 threads as it's deemed a decent compromise between +# throughput and latency for the average Rails application. +# +# Any libraries that use a connection pool or another resource pool should +# be configured to provide at least as many connections as the number of +# threads. This includes Active Record's `pool` parameter in `database.yml`. +threads_count = ENV.fetch('RAILS_MAX_THREADS', 3) +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +port ENV.fetch('PORT', 3000) + +# Allow puma to be restarted by `bin/rails restart` command. +plugin :tmp_restart + +# Run the Solid Queue supervisor inside of Puma for single-server deployments +plugin :solid_queue if ENV['SOLID_QUEUE_IN_PUMA'] + +# Specify the PID file. Defaults to tmp/pids/server.pid in development. +# In other environments, only set the PID file if requested. +pidfile ENV['PIDFILE'] if ENV['PIDFILE'] diff --git a/gemfiles/7.1.gemfile b/gemfiles/7.1.gemfile index 97d04107..22e67170 100644 --- a/gemfiles/7.1.gemfile +++ b/gemfiles/7.1.gemfile @@ -11,7 +11,7 @@ group :development, :test do gem 'autoprefixer-rails', '~> 10.4.16.0' gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw] gem 'image_processing', '>= 1.12.0' - gem 'sqlite3', '~> 1.6.7' + gem 'sqlite3', '>= 2.1' end group :test do diff --git a/gemfiles/7.2.gemfile b/gemfiles/7.2.gemfile index 97dd4a82..16b46e84 100644 --- a/gemfiles/7.2.gemfile +++ b/gemfiles/7.2.gemfile @@ -11,7 +11,7 @@ group :development, :test do gem 'autoprefixer-rails', '~> 10.4.16.0' gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw] gem 'image_processing', '>= 1.12.0' - gem 'sqlite3', '~> 1.6.7' + gem 'sqlite3', '>= 2.1' end group :test do diff --git a/gemfiles/7.0.gemfile b/gemfiles/8.0.gemfile similarity index 93% rename from gemfiles/7.0.gemfile rename to gemfiles/8.0.gemfile index dfc3f66d..b40e2513 100644 --- a/gemfiles/7.0.gemfile +++ b/gemfiles/8.0.gemfile @@ -5,13 +5,13 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } gemspec path: '../' -gem 'rails', '~> 7.0.0' +gem 'rails', '~> 8.0.1' group :development, :test do gem 'autoprefixer-rails', '~> 10.4.16.0' gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw] gem 'image_processing', '>= 1.12.0' - gem 'sqlite3', '~> 1.6.7' + gem 'sqlite3', '>= 2.1' end group :test do diff --git a/lib/comfortable_media_surfer/extensions/has_revisions.rb b/lib/comfortable_media_surfer/extensions/has_revisions.rb index b9ba42ce..d9389a7f 100644 --- a/lib/comfortable_media_surfer/extensions/has_revisions.rb +++ b/lib/comfortable_media_surfer/extensions/has_revisions.rb @@ -31,7 +31,7 @@ def prepare_revision return if new_record? if (respond_to?(:fragments_attributes_changed) && fragments_attributes_changed) || - !(changed & revision_fields).empty? + !!changed.intersect?(revision_fields) self.revision_data = revision_fields.each_with_object({}) do |field, c| c[field] = send("#{field}_was") end diff --git a/lib/comfortable_media_surfer/render_methods.rb b/lib/comfortable_media_surfer/render_methods.rb index 9c3a1518..2d31a9aa 100644 --- a/lib/comfortable_media_surfer/render_methods.rb +++ b/lib/comfortable_media_surfer/render_methods.rb @@ -33,7 +33,7 @@ def self.included(base) # it by passing :cms_site parameter with site's slug. For example: # render cms_page: '/path/to/page', cms_site: 'default' # - def render(options = {}, locals = {}, &block) + def render(options = {}, locals = {}, &) return super unless options.is_a?(Hash) if (site_identifier = options.delete(:cms_site)) && !(@cms_site = Comfy::Cms::Site.find_by_identifier(site_identifier)) @@ -47,15 +47,15 @@ def render(options = {}, locals = {}, &block) end if page_path - render_cms_page(page_path, options, locals, &block) + render_cms_page(page_path, options, locals, &) elsif layout_identifier - render_cms_layout(layout_identifier, options, locals, &block) + render_cms_layout(layout_identifier, options, locals, &) else super end end - def render_cms_page(path, options = {}, locals = {}, &block) + def render_cms_page(path, options = {}, locals = {}, &) path.gsub!(%r{^/#{@cms_site.path}}, '') if @cms_site.path.present? unless (@cms_page = @cms_site.pages.find_by_full_path(path)) @@ -77,10 +77,10 @@ def render_cms_page(path, options = {}, locals = {}, &block) options[:layout] ||= cms_app_layout.blank? ? nil : cms_app_layout options[:inline] = @cms_page.render - render(options, locals, &block) + render(options, locals, &) end - def render_cms_layout(identifier, options = {}, locals = {}, &block) + def render_cms_layout(identifier, options = {}, locals = {}, &) unless (@cms_layout = @cms_site.layouts.find_by_identifier(identifier)) raise ComfortableMediaSurfer::MissingLayout, identifier end @@ -97,7 +97,7 @@ def render_cms_layout(identifier, options = {}, locals = {}, &block) options[:layout] ||= cms_app_layout.blank? ? nil : cms_app_layout options[:inline] = cms_page.render - render(options, locals, &block) + render(options, locals, &) end end diff --git a/lib/comfortable_media_surfer/version.rb b/lib/comfortable_media_surfer/version.rb index 9b38f7b6..4e42d92e 100644 --- a/lib/comfortable_media_surfer/version.rb +++ b/lib/comfortable_media_surfer/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module ComfortableMediaSurfer - VERSION = '3.0.1' + VERSION = '3.1.0' end diff --git a/lib/generators/comfy/scaffold/scaffold_generator.rb b/lib/generators/comfy/scaffold/scaffold_generator.rb index 6d5a72cc..1ec6492f 100644 --- a/lib/generators/comfy/scaffold/scaffold_generator.rb +++ b/lib/generators/comfy/scaffold/scaffold_generator.rb @@ -16,7 +16,7 @@ class ScaffoldGenerator < Rails::Generators::NamedBase argument :model_args, type: :array, default: [], banner: 'attribute:type' - def initialize(*args, &block) + def initialize(*args, &) super @model_attrs = [] model_args.each do |arg| diff --git a/test/lib/content/tags/helper_test.rb b/test/lib/content/tags/helper_test.rb index c66a12ec..b24d3838 100644 --- a/test/lib/content/tags/helper_test.rb +++ b/test/lib/content/tags/helper_test.rb @@ -30,7 +30,7 @@ def test_content context: @page, params: ['method_name', 'param', { 'key' => 'val' }] ) - assert_equal '<%= method_name("param",{"key"=>"val"}) %>', tag.content + assert_match(%r{<%= method_name\("param",{"key"\s*=>\s*"val"}\) %>}, tag.content) end def test_render @@ -38,7 +38,7 @@ def test_render context: @page, params: ['method_name', 'param', { 'key' => 'val' }] ) - assert_equal '<%= method_name("param",{"key"=>"val"}) %>', tag.render + assert_match(%r{<%= method_name\("param",{"key"\s*=>\s*"val"}\) %>}, tag.render) end def test_render_with_whitelist diff --git a/test/lib/content/tags/partial_test.rb b/test/lib/content/tags/partial_test.rb index 0e481ee8..70d3d597 100644 --- a/test/lib/content/tags/partial_test.rb +++ b/test/lib/content/tags/partial_test.rb @@ -36,7 +36,7 @@ def test_content context: @page, params: ['path/to/partial', { 'key' => 'val' }] ) - assert_equal '<%= render partial: "path/to/partial", locals: {"key"=>"val"} %>', tag.content + assert_match(%r{<%= render partial: "path/to/partial", locals: {"key"\s*=>\s*"val"} %>}, tag.content) end def test_render @@ -44,7 +44,7 @@ def test_render context: @page, params: ['path/to/partial', { 'key' => 'val' }] ) - assert_equal '<%= render partial: "path/to/partial", locals: {"key"=>"val"} %>', tag.render + assert_match(%r{<%= render partial: "path/to/partial", locals: {"key"\s*=>\s*"val"} %>}, tag.render) end def test_render_with_whitelist @@ -68,6 +68,6 @@ def test_render_with_erb_injection context: @page, params: ["foo\#{:bar}", { 'key' => "va\#{:l}ue" }] ) - assert_equal "<%= render partial: \"foo\\\#{:bar}\", locals: {\"key\"=>\"va\\\#{:l}ue\"} %>", tag.render + assert_match(%r{<%= render partial: "foo\\\#{:bar}", locals: {"key"\s*=>\s*"va\\\#{:l}ue"} %>}, tag.render) end end