Skip to content

Upgrade to Rails 7#5762

Merged
mitchellhenke merged 7 commits intomainfrom
mitchellhenke/rails-7
Jul 28, 2022
Merged

Upgrade to Rails 7#5762
mitchellhenke merged 7 commits intomainfrom
mitchellhenke/rails-7

Conversation

@mitchellhenke
Copy link
Contributor

@mitchellhenke mitchellhenke commented Dec 29, 2021

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch 3 times, most recently from 1c0dc32 to dc29e91 Compare December 29, 2021 20:27
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch 2 times, most recently from c608c4f to 9db6bca Compare February 1, 2022 14:05
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch 7 times, most recently from cd552d9 to d6c9a74 Compare February 15, 2022 17:35
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch from 830059e to f4762ee Compare March 3, 2022 16:23
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch from ec072da to e60e0c5 Compare March 16, 2022 14:12
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch from e60e0c5 to e89e062 Compare March 23, 2022 18:16
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch from e89e062 to 1637868 Compare May 4, 2022 16:30
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch 3 times, most recently from 2d702a5 to a437d73 Compare May 19, 2022 15:21
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch 4 times, most recently from a729d9b to 35aba3d Compare June 2, 2022 01:57
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch from 35aba3d to 0568c0f Compare July 20, 2022 19:26
@mitchellhenke mitchellhenke changed the title WIP: Upgrade to Rails 7 Upgrade to Rails 7 Jul 20, 2022
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch from 0568c0f to f2bc030 Compare July 20, 2022 19:29
@mitchellhenke mitchellhenke marked this pull request as ready for review July 20, 2022 19:29
make lint_analytics_events
@echo "--- brakeman ---"
bundle exec brakeman
@echo "--- zeitwerk check ---"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is no longer needed since the classic loader no longer exists in Rails 7

stub_analytics
stub_sign_in(user)
allow(IdentityConfig.store).to receive(:domain_name).and_return('localhost:3000')
request.host = 'localhost:3000'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is required to ensure that the webauthn domain name does not conflict with the host in the request, otherwise we get (and also because this isn't a request where we want to allow other hosts):

ActionController::Redirecting::UnsafeRedirectError:
       Unsafe redirect to "http://localhost/account", pass allow_other_host: true to redirect anyway.

visible: :all,
text: {
'clock.svg' => '/clock.svg',
'clock.svg' => 'http://test.host/clock.svg',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is due to request now existing when the function is called in this spec here:

elsif request
request.base_url
end

I'm not sure why it would have changed, but I don't think it affects the primary motivation behind the test?

# Generate CSRF tokens that are encoded in URL-safe Base64.
#
# This change is not backwards compatible with earlier Rails versions.
# It's best enabled when your entire app is migrated and stable on 6.1.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have been stable on 6.1 for some time now 🙂

only_option = if_option_for(action)[0]

"#{only_option.class}OptionParser".constantize.new(only_option).parse
if_option_for(action)[0]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll be honest, I don't have confidence in my understanding of this file's metaprogramming, and I'd rather see us test the behaviors around the before_actions via controller specs than ensure a method is called.

Copy link
Contributor

Choose a reason for hiding this comment

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

omg I didn't realize this file was parsing the source, and not just introspecting the controller in memory. but +1 would rather see something like expect(controller).to receive(:some_action).and_call_original

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's passing around a bunch of stuff and has to call instance_variable_get to get private instance variables, which isn't ideal and it's hard to follow the process. I don't mind it as kind of a simpler check if it was well-supported, but it's unfortunately not the case.

It is used pretty extensively though.

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch 3 times, most recently from 2b86d9a to a635f27 Compare July 21, 2022 15:25
@mitchellhenke mitchellhenke requested review from aduth and jmhooper July 22, 2022 13:50
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch from a635f27 to 8c2b310 Compare July 22, 2022 13:51
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch from 8c2b310 to f2cc0c3 Compare July 22, 2022 16:18
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM!

Mitchell Henke added 7 commits July 28, 2022 09:54
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/rails-7 branch from f2cc0c3 to 8a17616 Compare July 28, 2022 14:54
@mitchellhenke mitchellhenke merged commit c6ccbf1 into main Jul 28, 2022
@mitchellhenke mitchellhenke deleted the mitchellhenke/rails-7 branch July 28, 2022 16:10
@solipet solipet mentioned this pull request Aug 9, 2022
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.

2 participants