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

Upgrade to Rails 6 #414

Closed
Tracked by #416
aaronskiba opened this issue Aug 8, 2023 · 5 comments · Fixed by #474
Closed
Tracked by #416

Upgrade to Rails 6 #414

aaronskiba opened this issue Aug 8, 2023 · 5 comments · Fixed by #474

Comments

@aaronskiba
Copy link
Collaborator

aaronskiba commented Aug 8, 2023

In order to complete #416, we must upgrade to Rails 6.

Anything noteworthy pertaining to this upgrade will be documented within the comments of this issue.

@aaronskiba
Copy link
Collaborator Author

aaronskiba commented Aug 8, 2023

PROBLEM

After upgrading to Rails 6, the following error is encountered when attempting to select an existing plan within the web app:
Screenshot 2023-08-08 at 10 53 16 AM

Within def show of class PlansController:

@plan = Plan.includes(
      template: { phases: { sections: { questions: :answers } } },
      plans_guidance_groups: { guidance_group: :guidances }
    ).find(params[:id])

Within class Plan:

has_and_belongs_to_many :guidance_groups, join_table: :plans_guidance_groups

SOLUTION

The following upstream commit addresses this same error when upgrading Rails: DMPRoadmap@e540504. Applying it to our codebase fixed the error.

@aaronskiba
Copy link
Collaborator Author

aaronskiba commented Aug 8, 2023

PROBLEM

When running rspec tests, many tests fail with the following message:

Templates Org admin edits a template
      Failure/Error: <% if template.latest? && phase.modifiable %>
      
      ActionView::Template::Error:
        missing attribute: modifiable

Testing with byebug:

  11:             <%= link_to _('Edit phase'), edit_org_admin_template_phase_path(template.id, phase.id), { class: "btn btn-default", role: 'button' } %>
   12:           <% else %>
   13:             <%= link_to _('Show phase'), org_admin_template_phase_path(template.id, phase.id), { class: "btn btn-default", role: 'button' } %>
   14:           <% end %>
   15:           <%byebug%>
=> 16:           <% if template.latest? && phase.modifiable %>
   17:             <%= link_to _('Delete phase'), org_admin_template_phase_path(template.id, phase.id),
   18:                         data: { confirm: _("You are about to delete the '%{phase_title}' phase. This will remove all of the sections and questions listed below. Are you sure?") % { phase_title: phase.title },
   19:                                 length: 20, omission: _('... (continued)') }, method: :delete, class: 'btn btn-default', role: 'button' %>
   20:           <% end %>
(byebug) phase
#<Phase id: 25, title: "Doloremque qui pariatur maiores.", description: "Error doloribus id. Veniam est accusamus. Aut magn...">
(byebug) phase.modifiable
*** ActiveModel::MissingAttributeError Exception: missing attribute: modifiable

nil
(byebug) Phase.find(25)
#<Phase id: 25, title: "Ad eaque qui est.", description: "Error doloribus id. Veniam est accusamus. Aut magn...", number: 1, template_id: 137, created_at: "2023-08-08 19:03:59.828214000 +0000", updated_at: "2023-08-08 19:03:59.828214000 +0000", modifiable: true, versionable_id: "9940ad9a-ee30-4629-9b77-8751f227193d">
(byebug) Phase.find(25).modifiable
true

This error can be replicated within the app. The user must be an Org Admin, then they must click Admin>Templates. Next, they must select the Org Templates. Finally, they must click Actions>Edit on an existing template.

Screenshot 2023-08-08 at 1 42 26 PM

SOLUTION

The following upstream commit addresses this same error: DMPRoadmap@1eec4f5. Applying it to our codebase fixed the error.

@aaronskiba
Copy link
Collaborator Author

aaronskiba commented Aug 8, 2023

PROBLEM

rspec ./spec/models/plan_spec.rb resulted in the following:

Failed examples:

rspec ./spec/models/plan_spec.rb:301 # Plan.is_test when plan visibility is is_test is expected to include #<Plan id: 33, title: "morph compelling architectures", template_id: 51, created_at: "2023-08-08 21:5...Aut reicie...", ethical_issues_report: "http://jacobs-hirthe.org/marnie", funding_status: "planned">
rspec ./spec/models/plan_spec.rb:469 # Plan.stats_filter when plan visibility is test is expected not to include #<Plan id: 76, title: "leverage killer architectures", template_id: 129, created_at: "2023-08-08 21:5...us. Qui a...", ethical_issues_report: "http://friesen-koelpin.net/edyth", funding_status: "planned">
rspec ./spec/models/plan_spec.rb:160 # Plan.privately_visible when plan visibility is privately_visible is expected to include #<Plan id: 100, title: "redefine integrated action-items", template_id: 153, created_at: "2023-08-08 ... et. Qu...", ethical_issues_report: "http://bechtelar.info/lino_homenick", funding_status: "funded">
rspec ./spec/models/plan_spec.rb:86 # Plan.publicly_visible when plan visibility is publicly_visible is expected to include #<Plan id: 164, title: "visualize e-business communities", template_id: 255, created_at: "2023-08-08 ... nul...", ethical_issues_report: "http://marquardt.biz/madaline.prohaska", funding_status: "funded">
rspec ./spec/models/plan_spec.rb:114 # Plan.organisationally_visible when plan visibility is publicly_visible is expected not to include #<Plan id: 217, title: "recontextualize one-to-one portals", template_id: 350, created_at: "2023-08-0.... Quia voluptas...", ethical_issues_report: "http://bogisich.org/modesto", funding_status: "funded">
rspec ./spec/models/plan_spec.rb:126 # Plan.organisationally_visible when plan visibility is is_test is expected not to include #<Plan id: 221, title: "enhance enterprise supply-chains", template_id: 354, created_at: "2023-08-08 ...equi n...", ethical_issues_report: "http://ankunding-treutel.com/teofila", funding_status: "denied">
rspec ./spec/models/plan_spec.rb:132 # Plan.organisationally_visible when plan visibility is privately_visible is expected not to include #<Plan id: 223, title: "transform world-class communities", template_id: 356, created_at: "2023-08-08...l consequ...", ethical_issues_report: "http://gerlach.io/consuela_cronin", funding_status: "funded">

SOLUTION

The following upstream commit edited app/models/plan.rb DMPRoadmap@4b2fe7e. Applying the same changes to app/models/plan.rb in our codebase fixed the errors.

@aaronskiba
Copy link
Collaborator Author

aaronskiba commented Aug 9, 2023

PROBLEM

The following warnings appear when executing rails s, rails c, and rspec tests:

/Users/aaronskiba/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError
/Users/aaronskiba/.rvm/gems/[email protected]/gems/net-protocol-0.2.1/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here
/Users/aaronskiba/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE
/Users/aaronskiba/.rvm/gems/[email protected]/gems/net-protocol-0.2.1/lib/net/protocol.rb:214: warning: previous definition of BUFSIZE was here
/Users/aaronskiba/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket
/Users/aaronskiba/.rvm/gems/[email protected]/gems/net-protocol-0.2.1/lib/net/protocol.rb:541: warning: previous definition of Socket was here

SOLUTION

@aaronskiba
Copy link
Collaborator Author

aaronskiba commented Aug 9, 2023

PROBLEM

In addition to upgrading Gemfile to Rails 6.1, config.load_defaults 6.1 should be set in config/application.rb. However, this is resulting in many rspec test failues with the error ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found for the 'other' role.

IDEAS

OBSERVATIONS

  • config.load_defaults 6.1 results in 197 rspec failures
  • config.load_defaults 6.0 results in no rspec failures
  • The following:
    config.load_defaults 6.1
    config.active_record.legacy_connection_handling = true
    
    results in 1 rspec failure:
    Failed examples:
    rspec ./spec/features/modal_search_spec.rb:25 # ModalSearchDialog Modal search opens and closes and allows user to 
    search, select and remove items
    

SOLUTION

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant