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 #1520. Calling Grape.eager_load!
would fail with:

```
uninitialized constant Grape::ServeFile (NameError)
```
  • Loading branch information
stanhu authored and dblock committed Jun 28, 2020
1 parent 0d5cf40 commit b3adbb4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
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
4 changes: 3 additions & 1 deletion 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 All @@ -10,9 +11,10 @@

#### Fixes

* Your contribution here.
* [#2067](https://github.com/ruby-grape/grape/pull/2067): Coerce empty string to nil for all primitive types except String - [@petekinnecom](https://github.com/petekinnecom).
* [#2064](https://github.com/ruby-grape/grape/pull/2064): Fix Ruby 2.7 deprecation warning in `Grape::Middleware::Base#initialize` - [@skarger](https://github.com/skarger).
* [#2072](https://github.com/ruby-grape/grape/pull/2072): Fix `Grape.eager_load!` and `compile!` - [@stanhu](https://github.com/stanhu).
* Your contribution here.

### 1.3.3 (2020/05/23)

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'

describe Grape do
it 'eager_load!' do
require 'grape/eager_load'
expect { Grape.eager_load! }.to_not raise_error
end

it 'compile!' do
expect { Class.new(Grape::API).compile! }.to_not raise_error
end
end

0 comments on commit b3adbb4

Please sign in to comment.