Skip to content

Commit

Permalink
Add railtie_spec.rb
Browse files Browse the repository at this point in the history
Add CHANGELOG.md
  • Loading branch information
ericproulx committed Oct 7, 2023
1 parent f13ae4c commit 9b0eef0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_7_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
source 'https://rubygems.org'

gem 'rails', '~> 7.1.0'
gem 'tzinfo-data', require: false

group :development, :test do
gem 'bundler'
Expand Down
2 changes: 1 addition & 1 deletion lib/grape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
9 changes: 9 additions & 0 deletions spec/config/spec_test_prof.rb
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions spec/grape/railtie_spec.rb
Original file line number Diff line number Diff line change
@@ -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
19 changes: 6 additions & 13 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9b0eef0

Please sign in to comment.