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

323: upgrade to rails 5.1 #324

Merged
merged 12 commits into from
Nov 13, 2022
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
!/log/.keep
/tmp

.DS_Store
rubberduck.txt
tester.rb
tester2.rb
Expand Down
6 changes: 2 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ source 'https://rubygems.org'

ruby '2.7.6'
gem 'puma', '4.3.12'
gem 'rails', '5.0.7'
gem 'rails', '5.1.7'
gem 'pg', '~> 0.18'
gem 'sass-rails', '~> 5.0'
gem 'sass-rails'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'

gem 'bigdecimal', '1.3.5'
gem 'jquery-rails'
Expand All @@ -25,7 +24,6 @@ gem 'stamp'
gem 'sentry-raven'

group :development do
gem 'web-console', '~> 2.0'
gem 'better_errors'
gem 'binding_of_caller'
end
Expand Down
120 changes: 52 additions & 68 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.7)
actionpack (= 5.0.7)
nio4r (>= 1.2, < 3.0)
actioncable (5.1.7)
actionpack (= 5.1.7)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.7)
actionpack (= 5.0.7)
actionview (= 5.0.7)
activejob (= 5.0.7)
actionmailer (5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.7)
actionview (= 5.0.7)
activesupport (= 5.0.7)
actionpack (5.1.7)
actionview (= 5.1.7)
activesupport (= 5.1.7)
rack (~> 2.0)
rack-test (~> 0.6.3)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.7)
activesupport (= 5.0.7)
actionview (5.1.7)
activesupport (= 5.1.7)
builder (~> 3.1)
erubis (~> 2.7.0)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.7)
activesupport (= 5.0.7)
activejob (5.1.7)
activesupport (= 5.1.7)
globalid (>= 0.3.6)
activemodel (5.0.7)
activesupport (= 5.0.7)
activerecord (5.0.7)
activemodel (= 5.0.7)
activesupport (= 5.0.7)
arel (~> 7.0)
activesupport (5.0.7)
activemodel (5.1.7)
activesupport (= 5.1.7)
activerecord (5.1.7)
activemodel (= 5.1.7)
activesupport (= 5.1.7)
arel (~> 8.0)
activesupport (5.1.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
arel (7.1.4)
arel (8.0.0)
ast (2.4.2)
awesome_print (1.9.2)
bcrypt (3.1.18)
Expand All @@ -67,13 +67,6 @@ GEM
childprocess (4.1.0)
choice (0.2.0)
coderay (1.1.3)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.10)
coveralls (0.8.11)
json (~> 1.8)
Expand All @@ -100,7 +93,6 @@ GEM
diff-lcs (1.5.0)
docile (1.1.5)
erubi (1.11.0)
erubis (2.7.0)
execjs (2.8.1)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -195,19 +187,19 @@ GEM
rack (2.2.4)
rack-mini-profiler (3.0.0)
rack (>= 1.2.0)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.7)
actioncable (= 5.0.7)
actionmailer (= 5.0.7)
actionpack (= 5.0.7)
actionview (= 5.0.7)
activejob (= 5.0.7)
activemodel (= 5.0.7)
activerecord (= 5.0.7)
activesupport (= 5.0.7)
rack-test (2.0.2)
rack (>= 1.3)
rails (5.1.7)
actioncable (= 5.1.7)
actionmailer (= 5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
activemodel (= 5.1.7)
activerecord (= 5.1.7)
activesupport (= 5.1.7)
bundler (>= 1.3.0)
railties (= 5.0.7)
railties (= 5.1.7)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
Expand All @@ -228,9 +220,9 @@ GEM
rails_stdout_logging
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (5.0.7)
actionpack (= 5.0.7)
activesupport (= 5.0.7)
railties (5.1.7)
actionpack (= 5.1.7)
activesupport (= 5.1.7)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
Expand Down Expand Up @@ -284,17 +276,16 @@ GEM
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
Expand All @@ -313,7 +304,7 @@ GEM
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
sprockets (3.7.2)
sprockets (4.1.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
Expand All @@ -336,11 +327,6 @@ GEM
vcr (6.1.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
webdrivers (5.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
Expand Down Expand Up @@ -368,7 +354,6 @@ DEPENDENCIES
binding_of_caller
capybara
capybara-email
coffee-rails (~> 4.1.0)
coveralls (= 0.8.11)
database_cleaner
devise
Expand All @@ -387,21 +372,20 @@ DEPENDENCIES
pry
puma (= 4.3.12)
rack-mini-profiler
rails (= 5.0.7)
rails (= 5.1.7)
rails-controller-testing
rails-erd
rails_12factor
rspec-rails (~> 3.0)
rubocop-rspec
sass-rails (~> 5.0)
sass-rails
sdoc (~> 0.4.0)
sentry-raven
shoulda-matchers
stamp
terminal-notifier-guard
uglifier (>= 1.3.0)
vcr
web-console (~> 2.0)
webdrivers
webmock
will_paginate
Expand Down
3 changes: 3 additions & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ApplicationController < ActionController::Base

def restrict_to_admin!
return if current_user.admin?
redirect_to :back, alert: 'Must be an admin to access that feature'
redirect_back(fallback_location: root_path, alert: 'Must be an admin to access that feature')
end

def configure_permitted_parameters
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/invites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ def invite_params
params.require(:invite).permit(:sender_id, :receiver_id, :token, :email, :list_id)
end

end
end
8 changes: 4 additions & 4 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class RegistrationsController < Devise::RegistrationsController
prepend_before_filter :require_no_authentication, only: [:new, :create, :cancel]
prepend_before_filter :authenticate_scope!, only: [:edit, :update, :destroy]
prepend_before_action :require_no_authentication, only: [:new, :create, :cancel]
prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy]
Comment on lines +2 to +3
Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't know what the difference between a before_action and a prepend_before_action was, so I looked it up.

A prepend_before_action runs before a before_action. There are no before_actions in this controller, so it seems like these prepends could just be regular before_actions. 🤔

Since we're dealing with Devise stuff, and I am not sure of the order of loading or any including that may be happening between controllers, I feel hesitant to make that change. Of course, if the Devise docs say this is the way, then this is the way. I'll do a deeper dive on that in a bit. I've got 80 more files to investigate...

Copy link
Owner Author

Choose a reason for hiding this comment

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

after_action :add_queue

# GET /resource/sign_up
Expand Down Expand Up @@ -71,7 +71,7 @@ def update
:update_needs_confirmation : :updated
set_flash_message :notice, flash_key
end
sign_in resource_name, resource, bypass: true
bypass_sign_in(resource)
Copy link
Owner Author

Choose a reason for hiding this comment

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

This was because of devise deprecation warning

respond_with resource, location: after_update_path_for(resource)
else
clean_up_passwords resource
Expand Down Expand Up @@ -169,4 +169,4 @@ def add_queue
resource.lists.create(name: "my queue", is_main: true, description: "My first list.")
end
end
end
end
4 changes: 2 additions & 2 deletions app/models/invite.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Invite < ApplicationRecord
belongs_to :sender, :class_name => "User"
belongs_to :receiver, :class_name => "User"
belongs_to :sender, class_name: 'User'
belongs_to :receiver, class_name: 'User', optional: true
belongs_to :list

validates_presence_of :email
Expand Down
6 changes: 3 additions & 3 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class Tag < ApplicationRecord

def self.by_user_or_list(userlist)
if userlist.is_a?(User)
joins(:taggings).where(taggings: { user_id: userlist.id }).uniq
joins(:taggings).where(taggings: { user_id: userlist.id }).distinct
elsif userlist.is_a?(List) && !userlist.members.present?
joins(:taggings).where(taggings: { user_id: userlist.owner.id }).uniq
joins(:taggings).where(taggings: { user_id: userlist.owner.id }).distinct
else
joins(:taggings).where(taggings: { user_id: userlist.members.ids }).uniq
joins(:taggings).where(taggings: { user_id: userlist.members.ids }).distinct
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/views/devise/confirmations/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<h2>Resend confirmation instructions</h2>

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>
Copy link
Owner Author

Choose a reason for hiding this comment

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

Resolve devise deprecation warning


<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
<%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
</div>

<div class="actions">
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/passwords/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2>Change your password</h2>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>
<%= f.hidden_field :reset_password_token %>

<div class="field">
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/passwords/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2>Forgot your password?</h2>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>

<div class="field">
<%= f.label :email %><br />
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>

<div class="field">
<%= f.label :email %><br />
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<h1><span class="fa fa-step-forward"></span> Flicks On Lists</h1>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>

<% if @token.present? %>
<%= hidden_field_tag :token, @token %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/unlocks/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2>Resend unlock instructions</h2>

<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>

<div class="field">
<%= f.label :email %><br />
Expand Down
7 changes: 1 addition & 6 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
5 changes: 0 additions & 5 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
Loading