From f48c78bc1b6da2d3977ead0edf44eaaa308b66a0 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 12:56:08 +0200 Subject: [PATCH 01/23] add rails 8 appraisal --- Appraisals | 5 +++++ gemfiles/rails_8.0.gemfile | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 gemfiles/rails_8.0.gemfile diff --git a/Appraisals b/Appraisals index 97a25f8e0..b7160fbab 100644 --- a/Appraisals +++ b/Appraisals @@ -28,6 +28,11 @@ appraise "rails-7.2" do gem "tailwindcss-rails", "~> 2.0" end +appraise "rails-8.0" do + gem "rails", "~> 8.0" + gem "tailwindcss-rails", "~> 2.0" +end + appraise "rails-main" do gem "rails", github: "rails/rails", branch: "main" gem "tailwindcss-rails", "~> 2.0" diff --git a/gemfiles/rails_8.0.gemfile b/gemfiles/rails_8.0.gemfile new file mode 100644 index 000000000..9d730ef48 --- /dev/null +++ b/gemfiles/rails_8.0.gemfile @@ -0,0 +1,27 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "capybara", "~> 3" +gem "rails", "~> 8.0" +gem "rspec-rails", "~> 5" +gem "net-imap", require: false +gem "net-pop", require: false +gem "net-smtp", require: false +gem "debug" + +gem "tailwindcss-rails", "~> 2.0" + +group :test do + gem "cuprite", "~> 0.15" + gem "puma", "~> 6" + gem "warning" + gem "selenium-webdriver", "4.9.0" +end + +group :development, :test do + gem "appraisal", "~> 2.5" +end + +gemspec path: "../" + From d7817fafc72e2f83cb3122ae9e82ba4280cfb968 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 13:02:06 +0200 Subject: [PATCH 02/23] add rails 8 ci --- .github/workflows/ci.yml | 6 ++++++ docs/CHANGELOG.md | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0e94f1df..1a897c431 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,6 +51,12 @@ jobs: - ruby_version: "3.3" rails_version: "7.2" mode: "capture_patch_enabled" + - ruby_version: "3.3" + rails_version: "8.0" + mode: "capture_patch_disabled" + - ruby_version: "3.3" + rails_version: "8.0" + mode: "capture_patch_enabled" - ruby_version: "head" rails_version: "main" mode: "capture_patch_disabled" diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c106fb61d..c941bf46d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -18,6 +18,10 @@ nav_order: 5 *Joel Hawksley* +* Add rails 8 support + + *Reegan Viljoen + ## 3.20.0 * Allow rendering `with_collection` to accept an optional `spacer_component` to be rendered between each item. From cb9c88cdc8530d711b91503b7baa1e704120376f Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 21:28:15 +0200 Subject: [PATCH 03/23] fix lint --- gemfiles/rails_8.0.gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/gemfiles/rails_8.0.gemfile b/gemfiles/rails_8.0.gemfile index 9d730ef48..de152c420 100644 --- a/gemfiles/rails_8.0.gemfile +++ b/gemfiles/rails_8.0.gemfile @@ -24,4 +24,3 @@ group :development, :test do end gemspec path: "../" - From 7141b9eb9a07f5231648ea7519b4f460d5f5da7c Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 21:38:26 +0200 Subject: [PATCH 04/23] updatre gemfile --- gemfiles/rails_8.0.gemfile | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/gemfiles/rails_8.0.gemfile b/gemfiles/rails_8.0.gemfile index de152c420..f80d3c6ea 100644 --- a/gemfiles/rails_8.0.gemfile +++ b/gemfiles/rails_8.0.gemfile @@ -2,25 +2,8 @@ source "https://rubygems.org" -gem "capybara", "~> 3" gem "rails", "~> 8.0" -gem "rspec-rails", "~> 5" -gem "net-imap", require: false -gem "net-pop", require: false -gem "net-smtp", require: false -gem "debug" - gem "tailwindcss-rails", "~> 2.0" +gem "turbo-rails", "~> 1" -group :test do - gem "cuprite", "~> 0.15" - gem "puma", "~> 6" - gem "warning" - gem "selenium-webdriver", "4.9.0" -end - -group :development, :test do - gem "appraisal", "~> 2.5" -end - -gemspec path: "../" +gemspec path: "../" \ No newline at end of file From 1d550e0307d432250e36f8066df4d3665fde2b6d Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 21:40:13 +0200 Subject: [PATCH 05/23] fix lint --- gemfiles/rails_8.0.gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gemfiles/rails_8.0.gemfile b/gemfiles/rails_8.0.gemfile index f80d3c6ea..6262f9017 100644 --- a/gemfiles/rails_8.0.gemfile +++ b/gemfiles/rails_8.0.gemfile @@ -6,4 +6,4 @@ gem "rails", "~> 8.0" gem "tailwindcss-rails", "~> 2.0" gem "turbo-rails", "~> 1" -gemspec path: "../" \ No newline at end of file +gemspec path: "../" From f3863634e0fc59f0bd63e3048d364763bf121eb6 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 22:24:15 +0200 Subject: [PATCH 06/23] fix specs --- Appraisals | 5 +++++ Gemfile.lock | 8 -------- test/sandbox/config/application.rb | 3 ++- test/sandbox/config/initializers/assets.rb | 3 ++- test/sandbox/test/rendering_test.rb | 21 ++++++++++++++------- view_component.gemspec | 1 - 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Appraisals b/Appraisals index b7160fbab..b89853039 100644 --- a/Appraisals +++ b/Appraisals @@ -3,6 +3,7 @@ appraise "rails-6.1" do gem "rails", "~> 6.1" gem "tailwindcss-rails", "~> 2.0" + gem "sprockets-rails", "~> 3.4.2" # Required for Ruby 3.1.0 gem "net-smtp", require: false @@ -15,22 +16,26 @@ appraise "rails-7.0" do gem "rails", "~> 7.0" gem "tailwindcss-rails", "~> 2.0" gem "turbo-rails", "~> 1" + gem "sprockets-rails", "~> 3.4.2" end appraise "rails-7.1" do gem "rails", "~> 7.1" gem "tailwindcss-rails", "~> 2.0" gem "turbo-rails", "~> 1" + gem "sprockets-rails", "~> 3.4.2" end appraise "rails-7.2" do gem "rails", "~> 7.2" gem "tailwindcss-rails", "~> 2.0" + gem "sprockets-rails", "~> 3.4.2" end appraise "rails-8.0" do gem "rails", "~> 8.0" gem "tailwindcss-rails", "~> 2.0" + gem "propshaft", "~> 1.1.0" end appraise "rails-main" do diff --git a/Gemfile.lock b/Gemfile.lock index b70346e73..776cd76aa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -284,13 +284,6 @@ GEM temple (~> 0.10.0) tilt (>= 2.1.0) smart_properties (1.17.0) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - sprockets (>= 3.0.0) standard (1.41.1) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.0) @@ -364,7 +357,6 @@ DEPENDENCIES simplecov (~> 0.22.0) simplecov-console (~> 0.9.1) slim (~> 5.1) - sprockets-rails (~> 3.4.2) standard (~> 1) turbo-rails (~> 1) view_component! diff --git a/test/sandbox/config/application.rb b/test/sandbox/config/application.rb index a23c1fba6..a560615b5 100644 --- a/test/sandbox/config/application.rb +++ b/test/sandbox/config/application.rb @@ -7,7 +7,8 @@ require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" -require "sprockets/railtie" +require "sprockets/railtie" if Rails.version.to_f <= 7.2 +# require "propshaft/railtie" if Rails.version.to_f >= 7.2 require "turbo-rails" diff --git a/test/sandbox/config/initializers/assets.rb b/test/sandbox/config/initializers/assets.rb index 8b7b89611..0c76edc8f 100644 --- a/test/sandbox/config/initializers/assets.rb +++ b/test/sandbox/config/initializers/assets.rb @@ -1,3 +1,4 @@ # frozen_string_literal: true -Rails.application.config.assets.precompile += %w[admin.css] +if Rails.version.to_f <= 7.2 then R + precompile += %w[admin.css] end diff --git a/test/sandbox/test/rendering_test.rb b/test/sandbox/test/rendering_test.rb index bd39865b7..49862ea16 100644 --- a/test/sandbox/test/rendering_test.rb +++ b/test/sandbox/test/rendering_test.rb @@ -330,16 +330,23 @@ def test_renders_component_without_format def test_renders_component_with_asset_url component = AssetComponent.new - assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text) + if Rails.version.to_f <= 7.2 + assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text) - component.config.asset_host = nil - assert_match(%r{/assets/application-\w+.css}, render_inline(component).text) + # cant do this in Rails 8 https://github.com/rails/propshaft/pull/59 + component.config.asset_host = nil + assert_match(%r{/assets/application-\w+.css}, render_inline(component).text) + + component.config.asset_host = "http://assets.example.com" + assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text) + + component.config.asset_host = "assets.example.com" + assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text) + else + assert_match(%r{http://assets.example.com/application.css}, render_inline(component).text) + end - component.config.asset_host = "http://assets.example.com" - assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text) - component.config.asset_host = "assets.example.com" - assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text) end def test_template_changes_are_not_reflected_if_cache_is_not_cleared diff --git a/view_component.gemspec b/view_component.gemspec index 711abf550..8b693635a 100644 --- a/view_component.gemspec +++ b/view_component.gemspec @@ -55,7 +55,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "simplecov", "~> 0.22.0" spec.add_development_dependency "simplecov-console", "~> 0.9.1" spec.add_development_dependency "slim", "~> 5.1" - spec.add_development_dependency "sprockets-rails", "~> 3.4.2" spec.add_development_dependency "turbo-rails", "~> 1" spec.add_development_dependency "warning" spec.add_development_dependency "yard", "~> 0.9.34" From ae63e0fb64564bef501862ae92f6be12a983480d Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 22:37:30 +0200 Subject: [PATCH 07/23] fix specx=cs again --- gemfiles/rails_6.1.gemfile | 1 + gemfiles/rails_7.0.gemfile | 1 + gemfiles/rails_7.1.gemfile | 1 + gemfiles/rails_7.2.gemfile | 2 ++ test/sandbox/config/initializers/assets.rb | 3 +-- 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile index d78c28030..184a53ffa 100644 --- a/gemfiles/rails_6.1.gemfile +++ b/gemfiles/rails_6.1.gemfile @@ -8,5 +8,6 @@ gem "net-smtp", require: false gem "net-imap", require: false gem "net-pop", require: false gem "turbo-rails", "~> 1" +gem "sprockets-rails", "~> 3.4.2" gemspec path: "../" diff --git a/gemfiles/rails_7.0.gemfile b/gemfiles/rails_7.0.gemfile index a703d2cc6..da308880c 100644 --- a/gemfiles/rails_7.0.gemfile +++ b/gemfiles/rails_7.0.gemfile @@ -5,5 +5,6 @@ source "https://rubygems.org" gem "rails", "~> 7.0" gem "tailwindcss-rails", "~> 2.0" gem "turbo-rails", "~> 1" +gem "sprockets-rails", "~> 3.4.2" gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index 105811883..a6a5d6021 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -5,5 +5,6 @@ source "https://rubygems.org" gem "rails", "~> 7.1" gem "tailwindcss-rails", "~> 2.0" gem "turbo-rails", "~> 1" +gem "sprockets-rails", "~> 3.4.2" gemspec path: "../" diff --git a/gemfiles/rails_7.2.gemfile b/gemfiles/rails_7.2.gemfile index b7eadcc95..840b6a532 100644 --- a/gemfiles/rails_7.2.gemfile +++ b/gemfiles/rails_7.2.gemfile @@ -12,6 +12,8 @@ gem "debug" gem "tailwindcss-rails", "~> 2.0" +gem "sprockets-rails", "~> 3.4.2" + group :test do gem "cuprite", "~> 0.15" gem "puma", "~> 6" diff --git a/test/sandbox/config/initializers/assets.rb b/test/sandbox/config/initializers/assets.rb index 0c76edc8f..8193dc2f0 100644 --- a/test/sandbox/config/initializers/assets.rb +++ b/test/sandbox/config/initializers/assets.rb @@ -1,4 +1,3 @@ # frozen_string_literal: true -if Rails.version.to_f <= 7.2 then R - precompile += %w[admin.css] end +if Rails.version.to_f <= 7.2 then Rails.application.config.assets.precompile += %w[admin.css] end From 4b63e8088b1e7d5ebad387e6fbc559969315e6eb Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 22:43:19 +0200 Subject: [PATCH 08/23] fix specs --- test/sandbox/test/rendering_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sandbox/test/rendering_test.rb b/test/sandbox/test/rendering_test.rb index 49862ea16..f0cec9738 100644 --- a/test/sandbox/test/rendering_test.rb +++ b/test/sandbox/test/rendering_test.rb @@ -15,7 +15,7 @@ def test_render_inline_allocations ViewComponent::CompileCache.cache.delete(MyComponent) MyComponent.ensure_compiled - assert_allocations("3.4.0" => 109, "3.3.6" => 115, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123) do + assert_allocations("3.4.0" => 109, "3.3.6" => 124, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123) do render_inline(MyComponent.new) end From bf714f0ffd0eb3c1fd94b48679db68e19da72586 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 22:48:47 +0200 Subject: [PATCH 09/23] fix specs --- test/sandbox/test/rendering_test.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/sandbox/test/rendering_test.rb b/test/sandbox/test/rendering_test.rb index f0cec9738..2ce3766d0 100644 --- a/test/sandbox/test/rendering_test.rb +++ b/test/sandbox/test/rendering_test.rb @@ -15,8 +15,14 @@ def test_render_inline_allocations ViewComponent::CompileCache.cache.delete(MyComponent) MyComponent.ensure_compiled - assert_allocations("3.4.0" => 109, "3.3.6" => 124, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123) do - render_inline(MyComponent.new) + if Rails.versions.to_f >= 8.0 + assert_allocations("3.4.0" => 109, "3.3.6" => 124, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123) do + render_inline(MyComponent.new) + end + else + assert_allocations("3.4.0" => 109, "3.3.6" => 115, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123) do + render_inline(MyComponent.new) + end end assert_selector("div", text: "hello,world!") From ad907bce4858b771a0c4026215284237c0bf8a98 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 22:50:23 +0200 Subject: [PATCH 10/23] f*** these specs already --- test/sandbox/test/rendering_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sandbox/test/rendering_test.rb b/test/sandbox/test/rendering_test.rb index 2ce3766d0..b3634b2fb 100644 --- a/test/sandbox/test/rendering_test.rb +++ b/test/sandbox/test/rendering_test.rb @@ -15,7 +15,7 @@ def test_render_inline_allocations ViewComponent::CompileCache.cache.delete(MyComponent) MyComponent.ensure_compiled - if Rails.versions.to_f >= 8.0 + if Rails.version.to_f >= 8.0 assert_allocations("3.4.0" => 109, "3.3.6" => 124, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123) do render_inline(MyComponent.new) end From e01bd43f2cd5892d63609e9bac89607136f53eb4 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 22:51:39 +0200 Subject: [PATCH 11/23] fix lint --- test/sandbox/test/rendering_test.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/sandbox/test/rendering_test.rb b/test/sandbox/test/rendering_test.rb index b3634b2fb..b8366e94b 100644 --- a/test/sandbox/test/rendering_test.rb +++ b/test/sandbox/test/rendering_test.rb @@ -351,8 +351,6 @@ def test_renders_component_with_asset_url else assert_match(%r{http://assets.example.com/application.css}, render_inline(component).text) end - - end def test_template_changes_are_not_reflected_if_cache_is_not_cleared From f19e0b1469a9cf339f8aeb495c43fc31dbb5c215 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 22:56:27 +0200 Subject: [PATCH 12/23] fix benchmarks --- .github/workflows/ci.yml | 2 ++ test/sandbox/config/application.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a897c431..22e7bdc44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,8 @@ jobs: with: ruby-version: 3.3 bundler-cache: true + env: + BENCHMARK: true - name: Run benchmarks run: | bundle exec rake partial_benchmark diff --git a/test/sandbox/config/application.rb b/test/sandbox/config/application.rb index a560615b5..4674eafa1 100644 --- a/test/sandbox/config/application.rb +++ b/test/sandbox/config/application.rb @@ -7,7 +7,7 @@ require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" -require "sprockets/railtie" if Rails.version.to_f <= 7.2 +require "sprockets/railtie" if (Rails.version.to_f <= 7.2 || ENV['BENCHMARK'].present?) # require "propshaft/railtie" if Rails.version.to_f >= 7.2 require "turbo-rails" From 5a76f9653269d7a6714f72c082b2fa56e07c9266 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 22:58:43 +0200 Subject: [PATCH 13/23] f*** these specs already --- test/sandbox/config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sandbox/config/application.rb b/test/sandbox/config/application.rb index 4674eafa1..8d3d12157 100644 --- a/test/sandbox/config/application.rb +++ b/test/sandbox/config/application.rb @@ -7,7 +7,7 @@ require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" -require "sprockets/railtie" if (Rails.version.to_f <= 7.2 || ENV['BENCHMARK'].present?) +require "sprockets/railtie" if (Rails.version.to_f <= 7.2 || !ENV['BENCHMARK'].present?) # require "propshaft/railtie" if Rails.version.to_f >= 7.2 require "turbo-rails" From c4007446850bb3ea230ca51be9d441ff38effc82 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Mon, 18 Nov 2024 23:02:14 +0200 Subject: [PATCH 14/23] fix lint --- test/sandbox/config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sandbox/config/application.rb b/test/sandbox/config/application.rb index 8d3d12157..1565037d5 100644 --- a/test/sandbox/config/application.rb +++ b/test/sandbox/config/application.rb @@ -7,7 +7,7 @@ require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" -require "sprockets/railtie" if (Rails.version.to_f <= 7.2 || !ENV['BENCHMARK'].present?) +require "sprockets/railtie" if Rails.version.to_f <= 7.2 || !ENV["BENCHMARK"].present? # require "propshaft/railtie" if Rails.version.to_f >= 7.2 require "turbo-rails" From a2b9c599f1b9fbc338ab95c1da5a28cfb293ea7b Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Tue, 19 Nov 2024 08:18:09 +0200 Subject: [PATCH 15/23] fis spcs --- test/sandbox/config/application.rb | 4 ++-- test/sandbox/test/rendering_test.rb | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/sandbox/config/application.rb b/test/sandbox/config/application.rb index 1565037d5..d9a514e47 100644 --- a/test/sandbox/config/application.rb +++ b/test/sandbox/config/application.rb @@ -7,8 +7,8 @@ require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" -require "sprockets/railtie" if Rails.version.to_f <= 7.2 || !ENV["BENCHMARK"].present? -# require "propshaft/railtie" if Rails.version.to_f >= 7.2 +require "sprockets/railtie" if Rails.version.to_f < 8.0 && !ENV["BENCHMARK"].present? +require "propshaft" if Rails.version.to_f >= 8.0 require "turbo-rails" diff --git a/test/sandbox/test/rendering_test.rb b/test/sandbox/test/rendering_test.rb index b8366e94b..86b9c2af4 100644 --- a/test/sandbox/test/rendering_test.rb +++ b/test/sandbox/test/rendering_test.rb @@ -336,10 +336,11 @@ def test_renders_component_without_format def test_renders_component_with_asset_url component = AssetComponent.new - if Rails.version.to_f <= 7.2 - assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text) + assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text) + + if Rails.version.to_f < 8.0 - # cant do this in Rails 8 https://github.com/rails/propshaft/pull/59 + # Propshaft doesnt allow setting custom hosts so this only works in Rails < 8 component.config.asset_host = nil assert_match(%r{/assets/application-\w+.css}, render_inline(component).text) @@ -348,8 +349,6 @@ def test_renders_component_with_asset_url component.config.asset_host = "assets.example.com" assert_match(%r{http://assets.example.com/assets/application-\w+.css}, render_inline(component).text) - else - assert_match(%r{http://assets.example.com/application.css}, render_inline(component).text) end end From 3e106a971a12e53696c1584cd4e6bf0d2c34e13a Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Tue, 19 Nov 2024 10:43:19 +0200 Subject: [PATCH 16/23] fix ci --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22e7bdc44..ed986a845 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,9 +16,9 @@ jobs: with: ruby-version: 3.3 bundler-cache: true - env: - BENCHMARK: true - name: Run benchmarks + env: + BENCHMARK: true run: | bundle exec rake partial_benchmark bundle exec rake translatable_benchmark From 29aa3ad583a0e5c14835f242063a920f6dcedd70 Mon Sep 17 00:00:00 2001 From: Reegan Viljoen <62689748+reeganviljoen@users.noreply.github.com> Date: Tue, 19 Nov 2024 21:17:06 +0200 Subject: [PATCH 17/23] Update test/sandbox/test/rendering_test.rb Co-authored-by: Cameron Dutro --- test/sandbox/test/rendering_test.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/sandbox/test/rendering_test.rb b/test/sandbox/test/rendering_test.rb index 86b9c2af4..8526d9381 100644 --- a/test/sandbox/test/rendering_test.rb +++ b/test/sandbox/test/rendering_test.rb @@ -15,14 +15,12 @@ def test_render_inline_allocations ViewComponent::CompileCache.cache.delete(MyComponent) MyComponent.ensure_compiled - if Rails.version.to_f >= 8.0 - assert_allocations("3.4.0" => 109, "3.3.6" => 124, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123) do - render_inline(MyComponent.new) - end - else - assert_allocations("3.4.0" => 109, "3.3.6" => 115, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123) do - render_inline(MyComponent.new) - end + allocations = Rails.version.to_f >= 8.0 ? + { "3.4.0" => 109, "3.3.6" => 124, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123 } : + { "3.4.0" => 109, "3.3.6" => 115, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123 } + + assert_allocations(**allocations) do + render_inline(MyComponent.new) end assert_selector("div", text: "hello,world!") From 56441b082f0d39a1d44c382f632979da985d8287 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Tue, 19 Nov 2024 21:50:29 +0200 Subject: [PATCH 18/23] fix ci --- .github/workflows/ci.yml | 6 ++---- gemfiles/rails_8.0.gemfile | 1 + gemfiles/rails_main.gemfile | 1 + test/sandbox/config/application.rb | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed986a845..dc0fa6f78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,11 +17,9 @@ jobs: ruby-version: 3.3 bundler-cache: true - name: Run benchmarks - env: - BENCHMARK: true run: | - bundle exec rake partial_benchmark - bundle exec rake translatable_benchmark + bundle exec appraisal rails-8.0 rake partial_benchmark + bundle exec appraisal rails-8.0 rake translatable_benchmark test: name: test (${{ matrix.rails_version }}, ${{ matrix.ruby_version }}, ${{ matrix.mode }}) runs-on: ubuntu-latest diff --git a/gemfiles/rails_8.0.gemfile b/gemfiles/rails_8.0.gemfile index 6262f9017..6280d60ba 100644 --- a/gemfiles/rails_8.0.gemfile +++ b/gemfiles/rails_8.0.gemfile @@ -5,5 +5,6 @@ source "https://rubygems.org" gem "rails", "~> 8.0" gem "tailwindcss-rails", "~> 2.0" gem "turbo-rails", "~> 1" +gem "propshaft", "~> 1.1.0" gemspec path: "../" diff --git a/gemfiles/rails_main.gemfile b/gemfiles/rails_main.gemfile index 7a2bff157..5c92f2cf5 100644 --- a/gemfiles/rails_main.gemfile +++ b/gemfiles/rails_main.gemfile @@ -5,5 +5,6 @@ source "https://rubygems.org" gem "rails", github: "rails/rails", branch: "main" gem "tailwindcss-rails", "~> 2.0" gem "turbo-rails", "~> 1" +gem "propshaft", "~> 1.1.0" gemspec path: "../" diff --git a/test/sandbox/config/application.rb b/test/sandbox/config/application.rb index d9a514e47..6a8ced48d 100644 --- a/test/sandbox/config/application.rb +++ b/test/sandbox/config/application.rb @@ -7,7 +7,8 @@ require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" -require "sprockets/railtie" if Rails.version.to_f < 8.0 && !ENV["BENCHMARK"].present? +require "sprockets/railtie" if Rails.version.to_f < 8.0 +binding.irb require "propshaft" if Rails.version.to_f >= 8.0 require "turbo-rails" From d59eec1f6e8af0b17151fde83faaf8f072563552 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Tue, 19 Nov 2024 21:52:57 +0200 Subject: [PATCH 19/23] fix lint --- docs/CHANGELOG.md | 2 +- test/sandbox/test/rendering_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c941bf46d..f0cc6c94b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -20,7 +20,7 @@ nav_order: 5 * Add rails 8 support - *Reegan Viljoen + *Reegan Viljoen* ## 3.20.0 diff --git a/test/sandbox/test/rendering_test.rb b/test/sandbox/test/rendering_test.rb index 8526d9381..11992fadc 100644 --- a/test/sandbox/test/rendering_test.rb +++ b/test/sandbox/test/rendering_test.rb @@ -15,9 +15,9 @@ def test_render_inline_allocations ViewComponent::CompileCache.cache.delete(MyComponent) MyComponent.ensure_compiled - allocations = Rails.version.to_f >= 8.0 ? - { "3.4.0" => 109, "3.3.6" => 124, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123 } : - { "3.4.0" => 109, "3.3.6" => 115, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123 } + allocations = (Rails.version.to_f >= 8.0) ? + {"3.4.0" => 109, "3.3.6" => 124, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123} : + {"3.4.0" => 109, "3.3.6" => 115, "3.3.0" => 127, "3.2.6" => 114, "3.1.6" => 114, "3.0.7" => 123} assert_allocations(**allocations) do render_inline(MyComponent.new) From 37a7f06582c5ae08fc2f56ae5138dc6e77fa5b4a Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Tue, 19 Nov 2024 21:53:28 +0200 Subject: [PATCH 20/23] fix lint --- test/sandbox/config/application.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/sandbox/config/application.rb b/test/sandbox/config/application.rb index 6a8ced48d..a92e48278 100644 --- a/test/sandbox/config/application.rb +++ b/test/sandbox/config/application.rb @@ -8,7 +8,6 @@ require "action_mailer/railtie" require "action_view/railtie" require "sprockets/railtie" if Rails.version.to_f < 8.0 -binding.irb require "propshaft" if Rails.version.to_f >= 8.0 require "turbo-rails" From 74ea9d8e386a2a4584b2a53ca59c6da380246fc0 Mon Sep 17 00:00:00 2001 From: reeganviljoen Date: Tue, 19 Nov 2024 21:56:56 +0200 Subject: [PATCH 21/23] try fix benchmark ci --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc0fa6f78..fd901df25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,8 @@ on: jobs: benchmark: runs-on: ubuntu-latest + env: + BUNDLE_GEMFILE: gemfiles/rails_8.0.gemfile steps: - uses: actions/checkout@v4.1.1 - name: Setup Ruby From abd713345961867a109a564a2085d78bb8eab168 Mon Sep 17 00:00:00 2001 From: Joel Hawksley Date: Thu, 21 Nov 2024 09:48:42 -0700 Subject: [PATCH 22/23] Apply suggestions from code review --- docs/CHANGELOG.md | 2 +- test/sandbox/config/initializers/assets.rb | 2 +- test/sandbox/test/rendering_test.rb | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f0cc6c94b..ef7ebf334 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -18,7 +18,7 @@ nav_order: 5 *Joel Hawksley* -* Add rails 8 support +* Add rails 8 support to CI. *Reegan Viljoen* diff --git a/test/sandbox/config/initializers/assets.rb b/test/sandbox/config/initializers/assets.rb index 8193dc2f0..5b2fa7a75 100644 --- a/test/sandbox/config/initializers/assets.rb +++ b/test/sandbox/config/initializers/assets.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -if Rails.version.to_f <= 7.2 then Rails.application.config.assets.precompile += %w[admin.css] end +Rails.application.config.assets.precompile += %w[admin.css] if Rails.version.to_f <= 7.2 diff --git a/test/sandbox/test/rendering_test.rb b/test/sandbox/test/rendering_test.rb index 11992fadc..7767d27c7 100644 --- a/test/sandbox/test/rendering_test.rb +++ b/test/sandbox/test/rendering_test.rb @@ -338,7 +338,8 @@ def test_renders_component_with_asset_url if Rails.version.to_f < 8.0 - # Propshaft doesnt allow setting custom hosts so this only works in Rails < 8 + # Propshaft doesn't allow setting custom hosts so this only works in Rails < 8 + # TODO: Revisit this comment for v4 to see if we need to make any deprecations component.config.asset_host = nil assert_match(%r{/assets/application-\w+.css}, render_inline(component).text) From 419dff2b4743c996c1aabb3e6d3fe290582e16f0 Mon Sep 17 00:00:00 2001 From: Joel Hawksley Date: Thu, 21 Nov 2024 12:58:39 -0700 Subject: [PATCH 23/23] Update test/sandbox/test/rendering_test.rb --- test/sandbox/test/rendering_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sandbox/test/rendering_test.rb b/test/sandbox/test/rendering_test.rb index 7767d27c7..95854912f 100644 --- a/test/sandbox/test/rendering_test.rb +++ b/test/sandbox/test/rendering_test.rb @@ -338,7 +338,7 @@ def test_renders_component_with_asset_url if Rails.version.to_f < 8.0 - # Propshaft doesn't allow setting custom hosts so this only works in Rails < 8 + # Propshaft doesn't allow setting custom hosts so this only works in Rails < 8 # TODO: Revisit this comment for v4 to see if we need to make any deprecations component.config.asset_host = nil assert_match(%r{/assets/application-\w+.css}, render_inline(component).text)