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

Rails upgrade 7.0.8 to 7.1.0 #5478

Merged
merged 22 commits into from
Jan 31, 2024

Conversation

sarvaiyanidhi
Copy link
Contributor

What github issue is this PR for, if any?

Resolves #5462

What changed, and why?

Upgrade Rails to newer version

How will this affect user permissions?

  • Volunteer permissions: Not Effected
  • Supervisor permissions: Not Effected
  • Admin permissions: Not Effected

How is this tested? (please write tests!) 💖💪

Have made changes in existing test to pass as per new configuration

Screenshots please :)

NA

@sarvaiyanidhi sarvaiyanidhi marked this pull request as draft January 8, 2024 22:08
@github-actions github-actions bot added dependencies Pull requests that update a dependency file ruby Pull requests that update Ruby code Tests! 🎉💖👏 erb labels Jan 8, 2024
@@ -34,7 +34,8 @@
</div>
<div class="col-sm align-middle my-auto">
<% if current_organization.court_report_template.attached? %>
<%= link_to 'Download Current Template', rails_blob_path(current_organization.court_report_template, only_path: true), class: "btn btn-info" %>
<% ActiveStorage::Current.url_options = { host: request.base_url } %>
<%= link_to 'Download Current Template', current_organization.court_report_template.url(only_path: true), class: "btn btn-info" %>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to remove rails_blob_path and update with url code to handle ActionView::Template::Error: Cannot get a signed_id for a new record error.

Referred this open issue - https://stackoverflow.com/questions/77201333/cannot-get-a-signed-id-for-a-new-record-with-url-for-after-attaching-pictur

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have kept this file for just review. Later I will delete and update application.rb to load 7.1 defaults

@@ -17,7 +17,8 @@
it { is_expected.to have_http_status(:success) }

it "shows casa orgs" do
page = request.parsed_body
# Code changes to fix response as earlier HTML String instead of Nokogiri::HTML5::Document object as received in Rails 7.1.0 to pass expectation
page = request.parsed_body.to_html
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to update code as request.parsed_body in Rails 7.1 was returning Nokogiri::HTML5::Document object which was failing spec

Copy link
Collaborator

Choose a reason for hiding this comment

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

makes sense

@sarvaiyanidhi
Copy link
Contributor Author

Getting same below error for all failing 337 specs

can't modify frozen Array: ["/home/runner/work/casa/casa/lib", #Pathname:/home/runner/work/casa/casa/lib/mailers/previews, "/home/runner/work/casa/casa/test/mailers/previews"]

But I am not able to replicate same error locally by running bin/rails spec and all tests are passing locally.

Trying to figure out issue, but can anyone try locally by pulling branch and check if encountering same issue.

@@ -73,4 +75,7 @@

# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = false
Copy link
Contributor Author

@sarvaiyanidhi sarvaiyanidhi Jan 10, 2024

Choose a reason for hiding this comment

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

By default this was set to true but I have changed it to false as it was failing specs for verify_authorized action

@sarvaiyanidhi
Copy link
Contributor Author

Hi @FireLemons Can you please review code and also help with issue I am facing with rspec failure as I am not able to replicate same issue locally and able to pass all specs.

@compwron compwron marked this pull request as ready for review January 13, 2024 03:32
Copy link
Collaborator

@compwron compwron left a comment

Choose a reason for hiding this comment

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

Seems reasonable!

@@ -19,7 +24,8 @@ class Application < Rails::Application
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")

config.action_mailer.preview_path ||= defined?(Rails.root) ? Rails.root.join("lib", "mailers", "previews") : nil
config.action_mailer.preview_paths << (defined?(Rails.root) ? Rails.root.join("lib", "mailers", "previews") : nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if the difference between ||= and << is what's causing the failing rspec test in github @sarvaiyanidhi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In Rails 7.1.0 there is now support for multiple preview paths so I am appending as per new configuration.

https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#support-multiple-preview-paths-for-actionmailer-preview

In one of the earlier commit, I still reverted to earlier code base to check if specs pass with it but encountered same issue so not sure if this is the problem 1d639db

@schoork
Copy link
Collaborator

schoork commented Jan 15, 2024

Getting same below error for all failing 337 specs

can't modify frozen Array: ["/home/runner/work/casa/casa/lib", #Pathname:/home/runner/work/casa/casa/lib/mailers/previews, "/home/runner/work/casa/casa/test/mailers/previews"]

But I am not able to replicate same error locally by running bin/rails spec and all tests are passing locally.

Trying to figure out issue, but can anyone try locally by pulling branch and check if encountering same issue.

I can confirm they pass locally.

@sarvaiyanidhi
Copy link
Contributor Author

Getting same below error for all failing 337 specs
can't modify frozen Array: ["/home/runner/work/casa/casa/lib", #Pathname:/home/runner/work/casa/casa/lib/mailers/previews, "/home/runner/work/casa/casa/test/mailers/previews"]
But I am not able to replicate same error locally by running bin/rails spec and all tests are passing locally.
Trying to figure out issue, but can anyone try locally by pulling branch and check if encountering same issue.

I can confirm they pass locally.

Thank you for the confirmation @schoork

@compwron
Copy link
Collaborator

This is sooooo close to being mergeable... how can we get it over the line?

@compwron
Copy link
Collaborator

What if we merge and then fix-forward? I don't have time to own it right now but it might be a possibility this weekend...

@sarvaiyanidhi
Copy link
Contributor Author

This is sooooo close to being mergeable... how can we get it over the line?

Yes, let me try to fix spec issue again. I am trying to replicate issue locally so that I can figure out solution.

@sarvaiyanidhi
Copy link
Contributor Author

Hi @compwron @schoork Finally spec issue is fixed. It was small fix but took some time to evaluate the exact cause.
Basically I had to add mailers folder in config.autoload_lib(ignore: %w[assets tasks mailers]) so that it won't get eager loaded as it is not necessary.

Also, this file config/initializers/new_framework_defaults_7_1.rb is just kept for you to review changes applicable in upgrade and can be removed before merging code in main branch once changes are confirmed.

Please review PR and let me know if I need to do any more changes in code. Thanks

@compwron
Copy link
Collaborator

Very cool!! Will review

@@ -10,6 +10,9 @@
# by default. You can change it below and use your own secret key.
# config.secret_key = 'a42b150b56c158d6e064aa257c8434390c921811007f42c5aa16c7455b78e3777087c5a4bcf18bfb0886fdd9296dec34eaa02fc0b47bed58417347eba971ee2d'

# Fixes rspec triggering Rails.application.secrets deprecation warning for Rails 7.1.0 upgrade
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems good

@compwron compwron merged commit f62f955 into rubyforgood:main Jan 31, 2024
13 checks passed
@schoork
Copy link
Collaborator

schoork commented Jan 31, 2024

Programmer of the month award! 🎉🏆🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file erb ruby Pull requests that update Ruby code Tests! 🎉💖👏
Projects
None yet
Development

Successfully merging this pull request may close these issues.

upgrade rails from 7.0.8 to 7.1.0
3 participants