Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize rails 6 update #594

Merged
merged 3 commits into from
Sep 1, 2019
Merged

Finalize rails 6 update #594

merged 3 commits into from
Sep 1, 2019

Conversation

BatedUrGonnaDie
Copy link
Collaborator

@BatedUrGonnaDie BatedUrGonnaDie commented Aug 30, 2019

Updates a ton of gems and packages. Just did blanket updates for both yarn and bundle.

Closes #517

Also, is it possible to highjack the beta branch to make sure that the cookie changes will not break production? There was 2 this time and the extra assurance would be nice.

@@ -45,7 +45,7 @@ group :production do
end

# administration
gem 'administrate'
gem 'administrate', github: 'thoughtbot/administrate'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Administrate doesn't have a release that will bundle install when using rails 6, but master does work. They have a plan to release a version sometime soon to fix this.

@@ -1,5 +1,5 @@
class Api::V3::CategoryBlueprint < Blueprinter::Base
fields :id, :name, :created_at, :updated_at

association :game, blueprint: Api::V3::GameBlueprint, if: ->(_, options) { options[:toplevel] == :category }
association :game, blueprint: Api::V3::GameBlueprint, if: ->(_, _, options) { options[:toplevel] == :category }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Blueprinter has a depreciation warning now, because they changed the conditionals to take 3 parameters now instead of 2.

def sign_in(user)
self.current_user = user
create_auth_session(user)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When updating authie, I noticed now that it recommends using this method over calling self.current_user = user

@@ -1,7 +1,5 @@
require 'uri'

require 'speedrundotcom'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if this was no longer needed because of the new autoloader, or because at some point /lib was added to the autoloading path.

require 'speedrundotcom'

module SRDCRun
module SpeedrunDotComRun
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The new autoloader didn't like this old class name, so I updated it to be consistent with all the models that reference speedrun.com stuff.

end

class Parser
class Parser::LivesplitCoreParser
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The new autoloader also did not like the way this was defined before. Since /lib is the top level namespace, anything under it needs to be namespaced according to its directory structure.

@@ -175,7 +175,7 @@
it 'returns the correct content-type header' do
request.headers['Accept'] = 'application/wsplit'

expect(response.content_type).to eq('application/wsplit')
expect(response.media_type).to eq('application/wsplit')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

response.content_type now returns the full content type header as is, while response.media_type now returns just the MIME component as previous versions of rails did.

Copy link
Owner

@glacials glacials left a comment

Choose a reason for hiding this comment

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

lgtm! Thanks for the comments describing the reason for each change. Yeah feel free to take over beta, just delete the current branch or do whatever you need to do if it's still leftover from racing.

@BatedUrGonnaDie
Copy link
Collaborator Author

I totally forgot that in development mode it was only loading classes that were accessed in a request. When I went to test on beta I hit a autoloading error, and this is where I ended up. Since I had to change a lot of names and removed some stuff, another review seems appropriate.

@@ -1,7 +0,0 @@
if Rails.configuration.read_only
module ActiveRecord::Base
def readonly?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I couldn't find any reference to this method outside of the definition. Looks like everything was just checking the environment variable.

v0.11.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since I needed LSC to be in the Parser:: namespace, I took this opportunity to just update it as well.

@@ -1,4 +1,4 @@
module ExchangeFormat
module Programs::ExchangeFormat
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since lib/ is now a top level namespace, zeitwerk is expecting programs/ to define a new namespace. All programs now reside in the namespace, and allows us to easily get all constants of this namespace in run.rb instead of needing to manually name all programs there every time we change something.

Copy link
Owner

Choose a reason for hiding this comment

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

👍 Love it!

@@ -1,41 +0,0 @@
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm pretty positive we don't use bower anymore, and it was causing an issue for some reason (not really sure why). Seemed like a good time to kill this folder.

@@ -16,6 +16,9 @@
#
environment ENV.fetch("RAILS_ENV") { "development" }

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I found this from Rails diff which is a pretty cool website for checking config changes between rails versions.

@@ -14,3 +14,8 @@
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym('SplitterZ')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It didn't make sense to change the file name for these 2 programs to me, since logically they couldn't be considered words. Instead by making them an inflector zeitwerk will use this definied camelization instead of needing the underscores. I can do this for any of the other programs if you think that would be a better idea than renaming the files

Copy link
Owner

Choose a reason for hiding this comment

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

Can we add a comment to each of these programs' files explaining that? I'm afraid we'll add a program later that needs this, forget about it, and be confused for hours or days about why it doesn't work the same way the others do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can totally see that happening as well, will do.

Copy link
Owner

@glacials glacials left a comment

Choose a reason for hiding this comment

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

SeemsGood

@@ -1,4 +1,4 @@
module ExchangeFormat
module Programs::ExchangeFormat
Copy link
Owner

Choose a reason for hiding this comment

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

👍 Love it!

@@ -14,3 +14,8 @@
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym('SplitterZ')
Copy link
Owner

Choose a reason for hiding this comment

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

Can we add a comment to each of these programs' files explaining that? I'm afraid we'll add a program later that needs this, forget about it, and be confused for hours or days about why it doesn't work the same way the others do.

data.sub!('module LiveSplitCore', 'module Parser::LiveSplitCore')
File.open("#{PARSER_FOLDER}/LiveSplitCore.rb", 'w') do |f|
f.write(data)
end
Copy link
Owner

Choose a reason for hiding this comment

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

Another possible solution to this problem in case you haven't seen it, though I have no opinion either way:

https://stackoverflow.com/a/8762740

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the link, I ended up liking that way a bit more 👍

@BatedUrGonnaDie BatedUrGonnaDie merged commit 0ba738f into master Sep 1, 2019
@BatedUrGonnaDie BatedUrGonnaDie deleted the rails-6 branch September 1, 2019 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rails 6 Compatibility Tracker
2 participants