Skip to content

Commit a07b434

Browse files
committed
Clean up test to make it easier to fix recent Rails versions
1 parent 0d6158f commit a07b434

File tree

81 files changed

+467
-1004
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+467
-1004
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Test
22
on:
33
push:
4-
branches: ['*']
4+
branches: ["*"]
55
pull_request:
6-
branches: ['*']
6+
branches: ["*"]
77

88
jobs:
99
test_ruby_and_rails_versions:
@@ -13,121 +13,26 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
rails:
16-
- "4.2"
17-
- "5.0"
18-
- "5.1"
19-
- "5.2"
20-
- "6.0"
2116
- "6.1"
2217
- "7.0"
2318
- "7.1"
2419
- "7.2"
2520

2621
ruby:
27-
- "2.4"
28-
- "2.5"
2922
- "2.6"
3023
- "2.7"
3124
- "3.0"
3225
- "3.1"
3326
- "3.2"
3427
- "3.3"
3528

36-
include:
37-
- rails: "4.2"
38-
bundler: "1.17.3"
39-
4029
exclude:
41-
- rails: "4.2"
42-
ruby: "2.7"
43-
44-
- rails: "4.2"
45-
ruby: "3.0"
46-
47-
- rails: "4.2"
48-
ruby: "3.1"
49-
50-
- rails: "4.2"
51-
ruby: "3.2"
52-
53-
- rails: "4.2"
54-
ruby: "3.3"
55-
56-
- rails: "5.0"
57-
ruby: "3.0"
58-
59-
- rails: "5.0"
60-
ruby: "3.1"
61-
62-
- rails: "5.0"
63-
ruby: "3.2"
64-
65-
- rails: "5.0"
66-
ruby: "3.3"
67-
68-
- rails: "5.1"
69-
ruby: "3.0"
70-
71-
- rails: "5.1"
72-
ruby: "3.1"
73-
74-
- rails: "5.1"
75-
ruby: "3.2"
76-
77-
- rails: "5.1"
78-
ruby: "3.3"
79-
80-
- rails: "5.2"
81-
ruby: "3.0"
82-
83-
- rails: "5.2"
84-
ruby: "3.1"
85-
86-
- rails: "5.2"
87-
ruby: "3.2"
88-
89-
- rails: "5.2"
90-
ruby: "3.3"
91-
92-
- rails: "6.0"
93-
ruby: "2.4"
94-
95-
- rails: "6.0"
96-
ruby: "3.1"
97-
98-
- rails: "6.0"
99-
ruby: "3.2"
100-
101-
- rails: "6.0"
102-
ruby: "3.3"
103-
104-
- rails: "6.1"
105-
ruby: "2.4"
106-
107-
- rails: "7.0"
108-
ruby: "2.4"
109-
110-
- rails: "7.0"
111-
ruby: "2.5"
112-
11330
- rails: "7.0"
11431
ruby: "2.6"
11532

116-
- rails: "7.1"
117-
ruby: "2.4"
118-
119-
- rails: "7.1"
120-
ruby: "2.5"
121-
12233
- rails: "7.1"
12334
ruby: "2.6"
12435

125-
- rails: "7.2"
126-
ruby: "2.4"
127-
128-
- rails: "7.2"
129-
ruby: "2.5"
130-
13136
- rails: "7.2"
13237
ruby: "2.6"
13338

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change log
22

3+
**Unreleased**
4+
5+
- Drop support for Ruby < 2.6 and Rails < 6.1
6+
- Require at least caxlsx 4.0
7+
38
**June 18, 2024**: 0.6.4 release
49

510
- Convert to Github actions
@@ -104,4 +109,3 @@
104109

105110
- Initial posting.
106111
- It works, but there are no tests! Bad programmer!
107-

caxlsx_rails.gemspec

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,15 @@ Gem::Specification.new do |s|
1919

2020
s.files = Dir['lib/**/*', 'CHANGELOG.md', 'README.md', 'MIT-LICENSE', 'caxlsx_rails.gemspec']
2121

22-
s.add_dependency 'actionpack', '>= 3.1'
23-
s.add_dependency 'caxlsx', '>= 3.0'
22+
s.add_dependency 'actionpack', '>= 6.1'
23+
s.add_dependency 'caxlsx', '>= 4.0'
2424

2525
s.add_development_dependency 'bundler'
2626
s.add_development_dependency 'rake'
2727
s.add_development_dependency 'rspec-rails'
28-
s.add_development_dependency 'guard-rspec'
2928
s.add_development_dependency 'capybara'
3029
s.add_development_dependency 'roo'
3130
s.add_development_dependency 'rubyzip'
32-
s.add_development_dependency 'growl'
33-
s.add_development_dependency 'rb-fsevent'
34-
s.add_development_dependency 'coveralls'
35-
s.add_development_dependency 'pry'
36-
s.add_development_dependency 'pry-nav'
31+
32+
s.required_ruby_version = '>= 2.6'
3733
end

lib/axlsx_rails.rb

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

33
warn "DEPRECATION WARNING: axlsx_rails has been renamed to caxlsx_rails. See http://github.com/caxlsx"
44

5-
require 'axlsx_rails/railtie' if defined?(Rails)
5+
require 'caxlsx_rails'

lib/axlsx_rails/action_controller.rb

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22

33
require 'action_controller'
44

5-
if Rails.version.to_f >= 5
6-
unless Mime[:xlsx]
7-
Mime::Type.register 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :xlsx
8-
end
9-
else
10-
unless defined? Mime::XLSX
11-
Mime::Type.register 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :xlsx
12-
end
5+
unless Mime[:xlsx]
6+
Mime::Type.register 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :xlsx
137
end
148

159
ActionController::Renderers.add :xlsx do |filename, options|
@@ -19,7 +13,7 @@
1913
# def called_action
2014
# render xlsx: 'filename', template: 'controller/diff_action'
2115
# end
22-
#
16+
#
2317
# And the normal use case works:
2418
#
2519
# def called_action
@@ -46,15 +40,11 @@
4640
options[:locals][:xlsx_use_shared_strings] = options.delete(:xlsx_use_shared_strings)
4741
end
4842

49-
mime = Rails.version.to_f >= 5 ? Mime[:xlsx] : Mime::XLSX
50-
send_data render_to_string(options), filename: file_name, type: mime, disposition: disposition
43+
send_data render_to_string(options), filename: file_name, type: Mime[:xlsx], disposition: disposition
5144
end
5245

5346
# For respond_to default
54-
begin
55-
ActionController::Responder
56-
rescue
57-
else
47+
if defined?(ActionController::Responder)
5848
class ActionController::Responder
5949
def to_xlsx
6050
@_action_has_layout = false

lib/axlsx_rails/template_handler.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,12 @@
55
module AxlsxRails
66
class TemplateHandler
77
def default_format
8-
case
9-
when Rails.version.to_f >= 6
10-
Mime[:xlsx].symbol
11-
when Rails.version.to_f >= 5
12-
Mime[:xlsx]
13-
else
14-
Mime::XLSX
15-
end
8+
Mime[:xlsx].symbol
169
end
1710

1811
def call(template, source = nil)
1912
builder = StringIO.new
20-
builder << "require 'axlsx';"
13+
builder << "require 'caxlsx';"
2114
builder << "xlsx_author = defined?(xlsx_author).nil? ? nil : xlsx_author;"
2215
builder << "xlsx_created_at = defined?(xlsx_created_at).nil? ? nil : xlsx_created_at;"
2316
builder << "xlsx_use_shared_strings = defined?(xlsx_use_shared_strings).nil? ? nil : xlsx_use_shared_strings;"

lib/tasks/axlsx_rails_tasks.rake

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe ActionController::Renderers do
6+
it 'is registered' do
7+
ActionController::Renderers::RENDERERS.include?(:xlsx)
8+
end
9+
10+
it 'has mime type' do
11+
expect(Mime[:xlsx].to_sym).to eq(:xlsx)
12+
expect(Mime[:xlsx].to_s).to eq("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
13+
end
14+
end

spec/axlsx_builder_spec.rb

Lines changed: 0 additions & 88 deletions
This file was deleted.

spec/axlsx_mailer_spec.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)