Skip to content

Commit a4585f8

Browse files
committed
Add Rails 8 to the CI
1 parent 1ec204a commit a4585f8

File tree

6 files changed

+40
-9
lines changed

6 files changed

+40
-9
lines changed

.github/workflows/test.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
- "7.0"
1818
- "7.1"
1919
- "7.2"
20+
- "8.0"
2021

2122
ruby:
2223
- "2.6"
@@ -25,8 +26,12 @@ jobs:
2526
- "3.1"
2627
- "3.2"
2728
- "3.3"
29+
- "3.4"
2830

2931
exclude:
32+
- rails: "6.1"
33+
ruby: "3.4"
34+
3035
- rails: "7.0"
3136
ruby: "2.6"
3237

@@ -35,13 +40,20 @@ jobs:
3540

3641
- rails: "7.2"
3742
ruby: "2.6"
38-
3943
- rails: "7.2"
4044
ruby: "2.7"
41-
4245
- rails: "7.2"
4346
ruby: "3.0"
4447

48+
- rails: "8.0"
49+
ruby: "2.6"
50+
- rails: "8.0"
51+
ruby: "2.7"
52+
- rails: "8.0"
53+
ruby: "3.0"
54+
- rails: "8.0"
55+
ruby: "3.1"
56+
4557
env:
4658
BUNDLE_GEMFILE: ${{ github.workspace }}/spec/gemfiles/Gemfile.rails-${{ matrix.rails }}
4759

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Drop support for Ruby < 2.6 and Rails < 6.1
66
- Require at least caxlsx 4.0
7+
- Add Rails 8.0 and Ruby 3.4 to the CI matrix
78

89
**June 18, 2024**: 0.6.4 release
910

lib/axlsx_rails/action_controller.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
require 'action_controller'
44

5-
unless Mime[:xlsx]
6-
Mime::Type.register 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :xlsx
7-
end
5+
Mime::Type.register 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :xlsx unless Mime[:xlsx]
86

97
ActionController::Renderers.add :xlsx do |filename, options|
108
#
@@ -22,14 +20,21 @@
2220
# render 'controller/diff_action'
2321
# end
2422
#
25-
options[:template] = filename.gsub(/^.*\//,'') if options[:template] == action_name
23+
if options[:template].nil?
24+
options[:template] ||= action_name
25+
options[:prefixes] ||= self.class.ancestors
26+
.take_while { |a| a.respond_to?(:controller_path) }
27+
.map(&:controller_path)
28+
end
29+
30+
options[:template] = filename.gsub(%r{^.*/}, '') if options[:template] == action_name
2631

2732
# force layout false
2833
options[:layout] = false
2934

3035
# disposition / filename
3136
disposition = options.delete(:disposition) || 'attachment'
32-
file_name = options.delete(:filename) || "#{filename.gsub(/^.*\//,'')}.xlsx"
37+
file_name = options.delete(:filename) || "#{filename.gsub(%r{^.*/}, '')}.xlsx"
3338
file_name = "#{file_name}.xlsx" unless file_name =~ /\.xlsx$/
3439

3540
# alternate settings
@@ -51,7 +56,7 @@ def to_xlsx
5156
if @default_response
5257
@default_response.call(options)
5358
else
54-
controller.render({xlsx: controller.action_name}.merge(options))
59+
controller.render({ xlsx: controller.action_name }.merge(options))
5560
end
5661
end
5762
end

spec/gemfiles/Gemfile.rails-8.0

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
source "http://rubygems.org"
2+
3+
gemspec path: '../../'
4+
5+
gem 'rails', '~> 8.0.0'
6+
gem 'puma'
7+
gem 'responders', '~> 3.0'
8+
gem 'sqlite3'
9+
gem 'sprockets', '~> 4.0'
10+
gem 'capybara', '~> 3.0'
11+
12+
gem 'debug'

spec/rails_app/spec/requests/render_templates_controller_spec.rb renamed to spec/rails_app/spec/requests/render_template_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require 'spec_helper'
44

5-
describe Examples::RespondToController do
5+
describe Examples::RenderTemplateController do
66
let(:path) { "/examples/render_template/#{variant}.xlsx" }
77

88
shared_examples_for 'responds properly' do

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
config.use_transactional_fixtures = false
2525
config.infer_base_class_for_anonymous_controllers = false
2626
config.order = "random"
27+
config.filter_run_when_matching :focus
2728
end
2829

2930
# TODO: move to the support folder

0 commit comments

Comments
 (0)