Add support for Rails 6.0 to `ViewContext::BuildStrategy` (#866)

* Add support for Rails 6.0 to `ViewContext::BuildStrategy`

In Rails 6.0 the API for `ActionView::Base.new` is changing.
`ActionView::Base.new` now take arguments [1], otherwise you
will see the following deprecation warning:

```
DEPRECATION WARNING: ActionView::Base instances should be constructed with a lookup context, assignments, and a controller.
```

[1] e17fe52e0e

`ViewContext::BuildStrategy::Fast` does not have lookup context, so use `empty`
method instead of `new` to build instance.

* Bump a Rails version of dummy application

Also bump a sqlite version because Rails 6.0 requires upper sqlite
1.4.0.

* Add `ApplicationController` to dummy application

Because Action Text expects `ApplicationController` exists.
Ref: https://github.com/rails/rails/issues/35749#issuecomment-525083643

* Test against Rails 6.0 that only supported Ruby versions
This commit is contained in:
y-yagi 2020-01-08 01:58:00 +09:00 committed by Cliff Braton
parent 661c1a9f0f
commit 89ec4b70f4
3 changed files with 13 additions and 3 deletions

12
Gemfile
View File

@ -3,7 +3,11 @@ source "https://rubygems.org"
gemspec
platforms :ruby do
gem 'sqlite3', '~> 1.3.6'
if RUBY_VERSION >= "2.5.0"
gem 'sqlite3'
else
gem 'sqlite3', '~> 1.3.6'
end
end
platforms :jruby do
@ -11,5 +15,9 @@ platforms :jruby do
gem "activerecord-jdbcsqlite3-adapter"
end
gem "rails", "~> 5.0"
if RUBY_VERSION >= "2.5.0"
gem "rails", "~> 6.0"
else
gem "rails", "~> 5.0"
end
gem "mongoid", github: "mongodb/mongoid"

View File

@ -12,7 +12,7 @@ module Draper
end
def call
view_context_class.new
view_context_class.respond_to?(:empty) ? view_context_class.empty : view_context_class.new
end
private

View File

@ -0,0 +1,2 @@
class ApplicationController < ActionController::Base
end