Skip to content

Commit

Permalink
Fix eager loading due to ServeStream rename
Browse files Browse the repository at this point in the history
ServeFile was renamed to ServeStream in ruby-grape#1520. Calling Grape.eager_load!
would fail with:

```
uninitialized constant Grape::ServeFile (NameError)
```
  • Loading branch information
stanhu committed Jun 28, 2020
1 parent 9198f7e commit 09e3156
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ matrix:
gemfile: gemfiles/rails_5.gemfile
- rvm: 2.7.1
gemfile: gemfiles/rails_6.gemfile
- rvm: 2.7.1
gemfile: Gemfile
script:
- bundle exec rspec spec/integration/eager_load
- rvm: 2.7.1
gemfile: gemfiles/multi_json.gemfile
script:
Expand Down
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

* [#2072](https://github.com/ruby-grape/grape/pull/2072): Fix eager loading due to ServeStream rename - [@stanhu](https://github.com/stanhu).
* [#1520](https://github.com/ruby-grape/grape/pull/1520): Un-deprecate stream-like objects - [@urkle](https://github.com/urkle).
* [#2060](https://github.com/ruby-grape/grape/pull/2060): Drop support for Ruby 2.4 - [@dblock](https://github.com/dblock).
* [#2060](https://github.com/ruby-grape/grape/pull/2060): Upgraded Rubocop to 0.84.0 - [@dblock](https://github.com/dblock).
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/eager_load.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
Grape::DSL.eager_load!
Grape::API.eager_load!
Grape::Presenters.eager_load!
Grape::ServeFile.eager_load!
Grape::ServeStream.eager_load!
Rack::Head # AutoLoads the Rack::Head
15 changes: 15 additions & 0 deletions spec/integration/eager_load/eager_load_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
require 'grape'
require 'grape/eager_load'

describe 'eager loading' do
class API < Grape::API
end

it 'loads successfully' do
expect { Grape.eager_load! }.to_not raise_error
expect { API.compile! }.to_not raise_error
end
end

0 comments on commit 09e3156

Please sign in to comment.