diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d550bc29e..9ece6ce4e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ #### Features +* [#2353](https://github.com/ruby-grape/grape/pull/2353): Add rails 7.1 in test suite + compatibility - [@ericproulx](https://github.com/ericproulx). * Your contribution here. #### Fixes diff --git a/gemfiles/rails_7_1.gemfile b/gemfiles/rails_7_1.gemfile index e917b42db1..01fbd7900d 100644 --- a/gemfiles/rails_7_1.gemfile +++ b/gemfiles/rails_7_1.gemfile @@ -5,6 +5,7 @@ source 'https://rubygems.org' gem 'rails', '~> 7.1.0' +gem 'tzinfo-data', require: false group :development, :test do gem 'bundler' diff --git a/lib/grape.rb b/lib/grape.rb index d612dc2a87..680bea819f 100644 --- a/lib/grape.rb +++ b/lib/grape.rb @@ -309,4 +309,4 @@ module Types # https://api.rubyonrails.org/classes/ActiveSupport/Deprecation.html # adding Grape.deprecator to Rails App if any -require 'grape/railtie' if defined?(Rails::Railtie) && ActiveSupport::VERSION::MAJOR == 7 && ActiveSupport::VERSION::MINOR.positive? +require 'grape/railtie' if defined?(Rails::Railtie) && ActiveSupport.gem_version >= Gem::Version.new('7.1') diff --git a/spec/config/spec_test_prof.rb b/spec/config/spec_test_prof.rb new file mode 100644 index 0000000000..e5259e110b --- /dev/null +++ b/spec/config/spec_test_prof.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'test_prof/recipes/rspec/let_it_be' + +TestProf::BeforeAll.adapter = Class.new do + def begin_transaction; end + + def rollback_transaction; end +end.new diff --git a/spec/grape/railtie_spec.rb b/spec/grape/railtie_spec.rb new file mode 100644 index 0000000000..4a95551087 --- /dev/null +++ b/spec/grape/railtie_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +if defined?(Rails::Railtie) && ActiveSupport.gem_version >= Gem::Version.new('7.1') + describe Grape::Railtie do + describe '.railtie' do + subject { test_app.deprecators[:grape] } + + let(:test_app) do + Class.new(Rails::Application) do + config.eager_load = false + config.load_defaults 7.1 + end + end + + before { test_app.initialize! } + + it { is_expected.to be(Grape.deprecator) } + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f09fdd3567..d12138af62 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,23 +4,16 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'support')) -require 'grape' -require 'test_prof/recipes/rspec/let_it_be' - -class NullAdapter - def begin_transaction; end - - def rollback_transaction; end -end - -TestProf::BeforeAll.adapter = NullAdapter.new - require 'rubygems' require 'bundler' Bundler.require :default, :test -Dir["#{File.dirname(__FILE__)}/support/*.rb"].sort.each do |file| - require file +require 'grape' + +%w(config support).each do |dir| + Dir["#{File.dirname(__FILE__)}/#{dir}/**/*.rb"].sort.each do |file| + require file + end end # The default value for this setting is true in a standard Rails app,