Skip to content

Commit

Permalink
DEV: Upgrade Discourse to Rails 6 (#8083)
Browse files Browse the repository at this point in the history
* Adjustments to pass specs on Rails 6.0.0
* Use classic autoloader instead of Zeitwerk
* Update Rails 6.0.0 deprecated methods
* Rails 6.0.0 not allowing column with integer name
* Drop freedom_patches/rails6.rb
* Default value for trigger_transactional_callbacks? is true
* Bump rspec-rails version to 4.0.0.beta2
  • Loading branch information
lis2 authored and SamSaffron committed Sep 12, 2019
1 parent eeb8480 commit 32b8a2c
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 185 deletions.
16 changes: 8 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ if rails_master?
else
# until rubygems gives us optional dependencies we are stuck with this
# bundle update actionmailer actionpack actionview activemodel activerecord activesupport railties
gem 'actionmailer', '5.2.3'
gem 'actionpack', '5.2.3'
gem 'actionview', '5.2.3'
gem 'activemodel', '5.2.3'
gem 'activerecord', '5.2.3'
gem 'activesupport', '5.2.3'
gem 'railties', '5.2.3'
gem 'actionmailer', '6.0.0'
gem 'actionpack', '6.0.0'
gem 'actionview', '6.0.0'
gem 'activemodel', '6.0.0'
gem 'activerecord', '6.0.0'
gem 'activesupport', '6.0.0'
gem 'railties', '6.0.0'
gem 'sprockets-rails'
end

Expand Down Expand Up @@ -140,7 +140,7 @@ group :test, :development do
gem 'mocha', require: false
gem 'rb-fsevent', require: RUBY_PLATFORM =~ /darwin/i ? 'rb-fsevent' : false
gem 'rb-inotify', '~> 0.9', require: RUBY_PLATFORM =~ /linux/i ? 'rb-inotify' : false
gem 'rspec-rails', require: false
gem 'rspec-rails', '4.0.0.beta2', require: false
gem 'shoulda-matchers', '~> 3.1', '>= 3.1.3', require: false
gem 'rspec-html-matchers'
gem 'pry-nav'
Expand Down
88 changes: 44 additions & 44 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
actionmailer (6.0.0)
actionpack (= 6.0.0)
actionview (= 6.0.0)
activejob (= 6.0.0)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.3)
actionview (= 5.2.3)
activesupport (= 5.2.3)
actionpack (6.0.0)
actionview (= 6.0.0)
activesupport (= 6.0.0)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.3)
activesupport (= 5.2.3)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (6.0.0)
activesupport (= 6.0.0)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_model_serializers (0.8.4)
activemodel (>= 3.0)
activejob (5.2.3)
activesupport (= 5.2.3)
activejob (6.0.0)
activesupport (= 6.0.0)
globalid (>= 0.3.6)
activemodel (5.2.3)
activesupport (= 5.2.3)
activerecord (5.2.3)
activemodel (= 5.2.3)
activesupport (= 5.2.3)
arel (>= 9.0)
activesupport (5.2.3)
activemodel (6.0.0)
activesupport (= 6.0.0)
activerecord (6.0.0)
activemodel (= 6.0.0)
activesupport (= 6.0.0)
activesupport (6.0.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.1, >= 2.1.8)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
annotate (2.7.5)
activerecord (>= 3.2, < 7.0)
rake (>= 10.4, < 13.0)
arel (9.0.0)
ast (2.4.0)
aws-eventstream (1.0.3)
aws-partitions (1.154.0)
Expand Down Expand Up @@ -183,7 +182,7 @@ GEM
rack (>= 1.1.3)
metaclass (0.0.4)
method_source (0.9.2)
mini_mime (1.0.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
mini_racer (0.2.6)
libv8 (>= 6.9.411)
Expand Down Expand Up @@ -282,20 +281,20 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
rails-html-sanitizer (1.2.0)
loofah (~> 2.2, >= 2.2.2)
rails_multisite (2.0.7)
activerecord (> 4.2, < 7)
railties (> 4.2, < 7)
railties (5.2.3)
actionpack (= 5.2.3)
activesupport (= 5.2.3)
railties (6.0.0)
actionpack (= 6.0.0)
activesupport (= 6.0.0)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
raindrops (0.19.0)
rake (12.3.2)
rake (12.3.3)
rake-compiler (1.0.7)
rake
rb-fsevent (0.10.3)
Expand Down Expand Up @@ -330,14 +329,14 @@ GEM
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-rails (3.8.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-rails (4.0.0.beta2)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.8)
rspec-expectations (~> 3.8)
rspec-mocks (~> 3.8)
rspec-support (~> 3.8)
rspec-support (3.8.0)
rtlit (0.0.5)
rubocop (0.69.0)
Expand Down Expand Up @@ -417,18 +416,19 @@ GEM
hkdf (~> 0.2)
jwt (~> 2.0)
yaml-lint (0.0.10)
zeitwerk (2.1.10)

PLATFORMS
ruby

DEPENDENCIES
actionmailer (= 5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
actionmailer (= 6.0.0)
actionpack (= 6.0.0)
actionview (= 6.0.0)
active_model_serializers (~> 0.8.3)
activemodel (= 5.2.3)
activerecord (= 5.2.3)
activesupport (= 5.2.3)
activemodel (= 6.0.0)
activerecord (= 6.0.0)
activesupport (= 6.0.0)
annotate
aws-sdk-s3
aws-sdk-sns
Expand Down Expand Up @@ -504,7 +504,7 @@ DEPENDENCIES
rack-mini-profiler
rack-protection
rails_multisite
railties (= 5.2.3)
railties (= 6.0.0)
rake
rb-fsevent
rb-inotify (~> 0.9)
Expand All @@ -517,7 +517,7 @@ DEPENDENCIES
rqrcode
rspec
rspec-html-matchers
rspec-rails
rspec-rails (= 4.0.0.beta2)
rtlit
rubocop
ruby-prof
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="user-crawler">
<img src='<%= UrlHelper.local_cdn_url(get_absolute_image_url(@user.small_avatar_url)) %>' alt='<%= @user.username %>' title='<%= @user.username %>' />
<img src='<%= ::UrlHelper.local_cdn_url(get_absolute_image_url(@user.small_avatar_url)) %>' alt='<%= @user.username %>' title='<%= @user.username %>' />
<h2 class='username'><%= @user.username %></h2>
</div>

Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def config.database_configuration
# issue is image_optim crashes on missing dependencies
config.assets.image_optim = false

config.autoloader = :classic

# Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += Dir["#{config.root}/app/serializers"]
config.autoload_paths += Dir["#{config.root}/lib/validators/"]
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20130430052751_add_topic_allowed_groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ class AddTopicAllowedGroups < ActiveRecord::Migration[4.2]
def change
create_table :topic_allowed_groups, force: true do |t|
# oops
t.integer :group_id, :integer, null: false
t.integer :topic_id, :integer, null: false
t.integer :group_id, null: false
t.integer :topic_id, null: false
end

add_index :topic_allowed_groups, [:group_id, :topic_id], unique: true
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20130501105651_fix_topic_allowed_groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
class FixTopicAllowedGroups < ActiveRecord::Migration[4.2]
def change
# big oops
remove_column :topic_allowed_groups, :integer
remove_column :topic_allowed_groups, :integer if column_exists?(:topic_allowed_groups, :integer)
end
end
110 changes: 0 additions & 110 deletions lib/freedom_patches/rails6.rb

This file was deleted.

3 changes: 3 additions & 0 deletions lib/mini_sql_multisite_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def committed!(*)

def before_committed!(*); end
def rolledback!(*); end
def trigger_transactional_callbacks?
true
end
end

# Allows running arbitrary code after the current transaction has been committed.
Expand Down
4 changes: 2 additions & 2 deletions spec/components/migration/safe_migrate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
end

def migrate_up(path)
migrations = ActiveRecord::MigrationContext.new(path).migrations
ActiveRecord::Migrator.new(:up, migrations, migrations.first.version).run
migrations = ActiveRecord::MigrationContext.new(path, ActiveRecord::SchemaMigration).migrations
ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration, migrations.first.version).run
end

it "bans all table removal" do
Expand Down
2 changes: 1 addition & 1 deletion spec/components/post_revisor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@
let(:bumped_at) { 1.day.ago }

before do
topic.update_attributes!(bumped_at: bumped_at)
topic.update!(bumped_at: bumped_at)
create_hidden_tags(['important', 'secret'])
topic = post.topic
topic.tags = [Fabricate(:tag, name: "super"), Tag.where(name: "important").first, Fabricate(:tag, name: "stuff")]
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/user_notifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
]
SiteSetting.post_excerpts_in_emails = true
SiteSetting.post_excerpt_maxlength = paragraphs.first.length
response.update_attributes!(raw: paragraphs.join("\n\n"))
response.update!(raw: paragraphs.join("\n\n"))
mail = UserNotifications.user_replied(
user,
post: response,
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/badges_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
it 'renders rss feed of a badge' do
get "/badges/#{badge.id}.rss"
expect(response.status).to eq(200)
expect(response.content_type).to eq('application/rss+xml')
expect(response.media_type).to eq('application/rss+xml')
end
end
end

2 comments on commit 32b8a2c

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/hello-from-gitpod-installing-on-google-cloud-automated-dev-setup/128783/6

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/uploaded-js-file-for-theme-causes-a-rejection/129753/8

Please sign in to comment.