Skip to content

Commit

Permalink
Merge pull request #3358 from projectblacklight/backport-test-8
Browse files Browse the repository at this point in the history
[Backport] Test on Rails 8
  • Loading branch information
jcoyne authored Dec 2, 2024
2 parents 529d598 + 2cb411e commit d69ccde
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 21 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
additional_engine_cart_rails_options: [""]
additional_name: [""]
include:
- ruby: "3.3"
rails_version: "8.0.0"
additional_engine_cart_rails_options: --css=bootstrap
- ruby: "3.2"
rails_version: "6.1.7.8"
- ruby: "3.2"
Expand Down Expand Up @@ -76,7 +79,7 @@ jobs:
VIEW_COMPONENT_VERSION: ${{ matrix.view_component_version }}
BOOTSTRAP_VERSION: ${{ matrix.bootstrap_version }}
BLACKLIGHT_API_TEST: ${{ matrix.api }}
ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test ${{ matrix.additional_engine_cart_rails_options }}"
ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-kamal --skip-solid --skip-coffee --skip-test ${{ matrix.additional_engine_cart_rails_options }}"
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
Expand Down
4 changes: 2 additions & 2 deletions blacklight.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 2.7'

s.add_dependency "rails", '>= 6.1', '< 8'
s.add_dependency "rails", '>= 6.1', '< 9'
s.add_dependency "globalid"
s.add_dependency "jbuilder", '~> 2.7'
s.add_dependency "kaminari", ">= 0.15" # the pagination (page 1,2,3, etc..) of our search results
Expand All @@ -49,6 +49,6 @@ Gem::Specification.new do |s|
s.add_development_dependency "rubocop-capybara"
s.add_development_dependency "rubocop-rspec_rails"
s.add_development_dependency "rubocop-factory_bot"
s.add_development_dependency "i18n-tasks"
s.add_development_dependency "i18n-tasks", '~> 1.0'
s.add_development_dependency "solr_wrapper"
end
36 changes: 29 additions & 7 deletions lib/generators/blacklight/assets/importmap_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def import_javascript_assets
CONTENT
end

return unless defined?(Sprockets)

append_to_file 'app/assets/config/manifest.js' do
<<~CONTENT
//= link blacklight/manifest.js
Expand All @@ -28,23 +30,43 @@ def import_javascript_assets
end

def append_blacklight_javascript
# This may already be present if rails new was invoked with `--css bootstrap'
append_to_file 'app/javascript/application.js' do
<<~CONTENT
import * as bootstrap from "bootstrap"
CONTENT
end

append_to_file 'app/javascript/application.js' do
<<~CONTENT
import bootstrap from "bootstrap"
import githubAutoCompleteElement from "@github/auto-complete-element"
import Blacklight from "blacklight"
CONTENT
end
end

def add_stylesheet
gem "sassc-rails", "~> 2.1" if Rails.version > '7'
if File.exist? 'app/assets/stylesheets/application.bootstrap.scss'
if ENV['CI']
run "yarn add file:#{Blacklight::Engine.root}"
else
run "yarn add blacklight-frontend@#{Blacklight::VERSION}"
end

create_file 'app/assets/stylesheets/blacklight.scss' do
<<~CONTENT
@import 'bootstrap';
@import 'blacklight/blacklight';
CONTENT
append_to_file 'app/assets/stylesheets/application.bootstrap.scss' do
<<~CONTENT
@import "blacklight-frontend/app/assets/stylesheets/blacklight/blacklight";
CONTENT
end
else
gem "sassc-rails", "~> 2.1"

create_file 'app/assets/stylesheets/blacklight.scss' do
<<~CONTENT
@import 'bootstrap';
@import 'blacklight/blacklight';
CONTENT
end
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/generators/blacklight/assets_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class AssetsGenerator < Rails::Generators::Base
def run_asset_pipeline_specific_generator
generated_options = "--bootstrap-version='#{options[:'bootstrap-version']}'" if options[:'bootstrap-version']

generator = if defined?(Propshaft)
'blacklight:assets:propshaft'
elsif defined?(Importmap)
generator = if defined?(Importmap)
'blacklight:assets:importmap'
elsif defined?(Propshaft)
'blacklight:assets:propshaft'
elsif defined?(Sprockets)
'blacklight:assets:sprockets'
end
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/blacklight/controller_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def inject_blacklight_routes
route <<-EOF
concern :searchable, Blacklight::Routes::Searchable.new
resource :catalog, only: [:index], as: 'catalog', path: '/catalog', controller: 'catalog' do
resource :catalog, only: [], as: 'catalog', path: '/catalog', controller: 'catalog' do
concerns :searchable
end
EOF
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/blacklight/test_support_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def alternate_controller
copy_file "alternate_controller.rb", "app/controllers/alternate_controller.rb"

routing_code = <<-EOF
resource :alternate, controller: 'alternate', only: [:index] do
resource :alternate, controller: 'alternate', only: [] do
concerns :searchable
end
EOF
Expand Down
1 change: 1 addition & 0 deletions spec/test_app_templates/Gemfile.extra
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
gem 'rails-controller-testing'
gem 'rails-i18n', github: 'Shopify/rails-i18n', branch: 'schwad_rails_8'

unless ENV['VIEW_COMPONENT_VERSION'].to_s == ""
gem 'view_component', ENV.fetch('VIEW_COMPONENT_VERSION')
Expand Down
6 changes: 0 additions & 6 deletions spec/test_app_templates/lib/generators/test_app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ def run_test_support_generator
generate(:'blacklight:test_support')
end

def add_local_assets_for_propshaft
return unless defined?(Propshaft)

run "yarn add #{Blacklight::Engine.root}"
end

def add_component_template_override
src_template = File.join(Blacklight::Engine.root, 'app', 'components', 'blacklight', 'top_navbar_component.html.erb')
target_template = File.join('app', 'components', 'blacklight', 'top_navbar_component.html.erb')
Expand Down

0 comments on commit d69ccde

Please sign in to comment.