Skip to content

Commit

Permalink
Rails 6.0 beta support
Browse files Browse the repository at this point in the history
Changes include:
1. Fix to the multi-threaded collection renderer.
2. Removing dependency on `factory_bot_rails`, instead using plain
   `factory_bot` (as we don't need reloading support anyway).
3. Using git versions of `roadie-rails` and `rspec-rails`.

Fixes #801
Refs #800
  • Loading branch information
glebm committed Mar 31, 2019
1 parent 7781837 commit 44da1f6
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 84 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -2,7 +2,7 @@ language: ruby
dist: xenial
sudo: false
rvm:
- 2.3.8
- 2.5.3

addons:
apt:
Expand Down Expand Up @@ -33,6 +33,7 @@ gemfile:
- spec/gemfiles/rails_5_0.gemfile
- spec/gemfiles/rails_5_1.gemfile
- spec/gemfiles/rails_5_2.gemfile
- spec/gemfiles/rails_6_0.gemfile
env:
matrix:
# Username and password from http://docs.travis-ci.com/user/database-setup/
Expand Down
15 changes: 11 additions & 4 deletions Gemfile
Expand Up @@ -2,14 +2,21 @@

source 'https://rubygems.org'

# Rails 5
gem 'rails', '~> 5.2.2'
gem 'rails', '~> 6.0.0.beta3'
gem 'rails-i18n', '~> 6.0.0.beta1'

# https://github.com/rails/rails/blob/v5.2.2/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L12
gem 'sqlite3', '~> 1.3.6'
# https://github.com/rails/rails/blob/v6.0.0.beta3/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L12
gem 'sqlite3', '~> 1.3', '>= 1.3.6'

group :test do
gem 'rails-controller-testing'

# https://github.com/rspec/rspec-rails/issues/2103
gem 'rspec-rails', git: 'https://github.com/rspec/rspec-rails', branch: '4-0-dev'
gem 'rspec-core', git: 'https://github.com/rspec/rspec-core'
gem 'rspec-mocks', git: 'https://github.com/rspec/rspec-mocks'
gem 'rspec-support', git: 'https://github.com/rspec/rspec-support'
gem 'rspec-expectations', git: 'https://github.com/rspec/rspec-expectations'
end

gemspec
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/thredded/post_common.rb
Expand Up @@ -23,7 +23,7 @@ module PostCommon
result = all
ActiveRecord::Associations::Preloader.new.preload(
result.map(&:postable), :first_post,
Thredded::Post.where(<<~SQL.delete("\n"))
unscoped.where(<<~SQL.delete("\n"))
#{posts_table_name}.created_at = (
SELECT MAX(p2.created_at) from #{posts_table_name} p2 WHERE p2.postable_id = #{posts_table_name}.postable_id)
SQL
Expand Down
13 changes: 8 additions & 5 deletions heroku.gemfile
@@ -1,13 +1,13 @@
# frozen_string_literal: true

source 'https://rubygems.org'
ruby '2.5.3'
ruby '2.5.5'

gem 'thredded', path: File.dirname(__FILE__)

gem 'mustache'

gem 'rails', '~> 5.2.0'
gem 'rails', '~> 6.0.0.beta3'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier'
Expand All @@ -16,12 +16,15 @@ gem 'uglifier'
gem 'puma'
gem 'pg'
gem 'rails_email_preview', '>= 2.2.1'
gem 'roadie-rails'

# https://github.com/Mange/roadie-rails/pull/88
gem 'roadie-rails', git: 'https://github.com/glebm/roadie-rails', branch: 'patch-2'

gem 'turbolinks'
gem 'rails-i18n'
gem 'rails-i18n', '~> 6.0.0.beta1'
gem 'kaminari-i18n'
gem 'http_accept_language'
gem 'factory_bot_rails'
gem 'factory_bot'
gem 'faker', '>= 1.6.2'
gem 'twemoji'

Expand Down
142 changes: 80 additions & 62 deletions heroku.gemfile.lock
@@ -1,3 +1,12 @@
GIT
remote: https://github.com/glebm/roadie-rails
revision: bd7f0db505ccf35ba671fbc81952ac6d8da041b9
branch: patch-2
specs:
roadie-rails (2.0.0)
railties (>= 5.1, < 6.1)
roadie (~> 3.1)

PATH
remote: .
specs:
Expand Down Expand Up @@ -26,74 +35,83 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.2)
actionpack (= 5.2.2)
actioncable (6.0.0.beta3)
actionpack (= 6.0.0.beta3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.2)
actionpack (= 5.2.2)
actionview (= 5.2.2)
activejob (= 5.2.2)
actionmailbox (6.0.0.beta3)
actionpack (= 6.0.0.beta3)
activejob (= 6.0.0.beta3)
activerecord (= 6.0.0.beta3)
activestorage (= 6.0.0.beta3)
activesupport (= 6.0.0.beta3)
mail (>= 2.7.1)
actionmailer (6.0.0.beta3)
actionpack (= 6.0.0.beta3)
actionview (= 6.0.0.beta3)
activejob (= 6.0.0.beta3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.2)
actionview (= 5.2.2)
activesupport (= 5.2.2)
actionpack (6.0.0.beta3)
actionview (= 6.0.0.beta3)
activesupport (= 6.0.0.beta3)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.2)
activesupport (= 5.2.2)
actiontext (6.0.0.beta3)
actionpack (= 6.0.0.beta3)
activerecord (= 6.0.0.beta3)
activestorage (= 6.0.0.beta3)
activesupport (= 6.0.0.beta3)
nokogiri (>= 1.8.5)
actionview (6.0.0.beta3)
activesupport (= 6.0.0.beta3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_record_union (1.3.0)
activerecord (>= 4.0)
activejob (5.2.2)
activesupport (= 5.2.2)
activejob (6.0.0.beta3)
activesupport (= 6.0.0.beta3)
globalid (>= 0.3.6)
activemodel (5.2.2)
activesupport (= 5.2.2)
activerecord (5.2.2)
activemodel (= 5.2.2)
activesupport (= 5.2.2)
arel (>= 9.0)
activestorage (5.2.2)
actionpack (= 5.2.2)
activerecord (= 5.2.2)
activemodel (6.0.0.beta3)
activesupport (= 6.0.0.beta3)
activerecord (6.0.0.beta3)
activemodel (= 6.0.0.beta3)
activesupport (= 6.0.0.beta3)
activestorage (6.0.0.beta3)
actionpack (= 6.0.0.beta3)
activerecord (= 6.0.0.beta3)
marcel (~> 0.3.1)
activesupport (5.2.2)
activesupport (6.0.0.beta3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 1.3, >= 1.3.1)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
arel (9.0.0)
autoprefixer-rails (9.4.9)
autoprefixer-rails (9.5.0)
execjs
babel-source (5.8.35)
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
builder (3.2.3)
coderay (1.1.2)
concurrent-ruby (1.1.4)
concurrent-ruby (1.1.5)
crass (1.0.4)
css_parser (1.7.0)
addressable
dalli (2.7.9)
dalli (2.7.10)
db_text_search (0.3.0)
activerecord (>= 4.1.15, < 6.0)
erubi (1.8.0)
execjs (2.7.0)
factory_bot (5.0.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.1)
factory_bot (~> 5.0.0)
railties (>= 4.2.0)
faker (1.9.3)
i18n (>= 0.7)
ffi (1.10.0)
Expand All @@ -106,7 +124,7 @@ GEM
nokogiri (>= 1.4)
htmlentities (4.3.4)
http_accept_language (2.1.1)
i18n (1.5.3)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
inline_svg (1.3.1)
activesupport (>= 3.0)
Expand Down Expand Up @@ -149,16 +167,16 @@ GEM
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
moneta (1.0.0)
moneta (1.1.0)
multi_json (1.13.1)
mustache (1.1.0)
newrelic_rpm (6.1.0.352)
newrelic_rpm (6.2.0.354)
nio4r (2.3.1)
nokogiri (1.10.1)
nokogiri (1.10.2)
mini_portile2 (~> 2.4.0)
nokogumbo (2.0.1)
nokogiri (~> 1.8, >= 1.8.4)
onebox (1.8.79)
onebox (1.8.82)
htmlentities (~> 4.3)
moneta (~> 1.0)
multi_json (~> 1.11)
Expand All @@ -167,7 +185,7 @@ GEM
sanitize
pg (1.1.4)
public_suffix (3.0.3)
puma (3.12.0)
puma (3.12.1)
pundit (2.0.1)
activesupport (>= 3.0.0)
rack (2.0.6)
Expand All @@ -176,38 +194,40 @@ GEM
rack (>= 1.0.0, < 3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.2)
actioncable (= 5.2.2)
actionmailer (= 5.2.2)
actionpack (= 5.2.2)
actionview (= 5.2.2)
activejob (= 5.2.2)
activemodel (= 5.2.2)
activerecord (= 5.2.2)
activestorage (= 5.2.2)
activesupport (= 5.2.2)
rails (6.0.0.beta3)
actioncable (= 6.0.0.beta3)
actionmailbox (= 6.0.0.beta3)
actionmailer (= 6.0.0.beta3)
actionpack (= 6.0.0.beta3)
actiontext (= 6.0.0.beta3)
actionview (= 6.0.0.beta3)
activejob (= 6.0.0.beta3)
activemodel (= 6.0.0.beta3)
activerecord (= 6.0.0.beta3)
activestorage (= 6.0.0.beta3)
activesupport (= 6.0.0.beta3)
bundler (>= 1.3.0)
railties (= 5.2.2)
railties (= 6.0.0.beta3)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
rails-i18n (5.1.3)
rails-i18n (6.0.0.beta1)
i18n (>= 0.7, < 2)
railties (>= 5.0, < 6)
railties (>= 6.0.0.beta1, < 7)
rails_email_preview (2.2.1)
rails (>= 4.2)
request_store
sassc-rails (>= 2.0.0)
turbolinks
railties (5.2.2)
actionpack (= 5.2.2)
activesupport (= 5.2.2)
railties (6.0.0.beta3)
actionpack (= 6.0.0.beta3)
activesupport (= 6.0.0.beta3)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
thor (>= 0.20.3, < 2.0)
rake (12.3.2)
rb-gravatar (1.0.5)
request_store (1.4.1)
Expand All @@ -216,10 +236,7 @@ GEM
roadie (3.4.0)
css_parser (~> 1.4)
nokogiri (~> 1.5)
roadie-rails (2.0.0)
railties (>= 5.1, < 5.3)
roadie (~> 3.1)
rollbar (2.19.2)
rollbar (2.19.3)
multi_json
sanitize (5.0.0)
crass (~> 1.0.2)
Expand Down Expand Up @@ -268,13 +285,14 @@ GEM
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
zeitwerk (1.4.3)

PLATFORMS
ruby

DEPENDENCIES
dalli
factory_bot_rails
factory_bot
faker (>= 1.6.2)
http_accept_language
kaminari-i18n
Expand All @@ -284,10 +302,10 @@ DEPENDENCIES
pg
puma
rack-canonical-host
rails (~> 5.2.0)
rails-i18n
rails (~> 6.0.0.beta3)
rails-i18n (~> 6.0.0.beta1)
rails_email_preview (>= 2.2.1)
roadie-rails
roadie-rails!
rollbar
thredded!
thredded-markdown_coderay
Expand All @@ -298,7 +316,7 @@ DEPENDENCIES
uglifier

RUBY VERSION
ruby 2.5.3p105
ruby 2.5.5p157

BUNDLED WITH
1.17.3
6 changes: 6 additions & 0 deletions lib/thredded.rb
Expand Up @@ -251,6 +251,12 @@ def rails_gte_51?
@rails_gte_51
end

# @api private
def rails_gte_60?
@rails_gte_60 = (Rails::VERSION::MAJOR >= 6) if @rails_gte_60.nil?
@rails_gte_60
end

# @api private
def rails_supports_csp_nonce?
@rails_supports_csp_nonce = (Rails.gem_version >= Gem::Version.new('5.2.0')) if @rails_supports_csp_nonce.nil?
Expand Down
9 changes: 8 additions & 1 deletion lib/thredded/collection_to_strings_with_cache_renderer.rb
Expand Up @@ -83,7 +83,14 @@ def render_partials(view_context, collection:, render_threads:, **opts)
# @return [Array<String>]
def render_partials_serial(view_context, collection, opts)
partial_renderer = ActionView::PartialRenderer.new(@lookup_context)
collection.map { |object| partial_renderer.render(view_context, opts.merge(object: object), nil) }
collection.map do |object|
result = partial_renderer.render(view_context, opts.merge(object: object), nil)
if Thredded.rails_gte_60?
result.body
else
result
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/thredded/database_seeder.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'factory_bot_rails'
require 'factory_bot'
require_relative '../../spec/support/features/fake_content'

# rubocop:disable HandleExceptions
Expand Down

0 comments on commit 44da1f6

Please sign in to comment.