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 5.2 #173

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source 'https://rubygems.org'

gem 'rails', '>= 5.1.7', '< 5.1.99'
gem 'rails', '>= 5.2.0', '< 5.2.99'
gem 'rails-i18n'
gem 'responders'

Expand Down Expand Up @@ -41,6 +41,9 @@ end

gem 'listen'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false

# Debugger
gem 'byebug', group: %i[development test]

Expand Down
158 changes: 82 additions & 76 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,61 @@ GEM
remote: https://rubygems.org/
specs:
Ascii85 (1.0.3)
actioncable (5.1.7)
actionpack (= 5.1.7)
actioncable (5.2.8.1)
actionpack (= 5.2.8.1)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
websocket-driver (>= 0.6.1)
actionmailer (5.2.8.1)
actionpack (= 5.2.8.1)
actionview (= 5.2.8.1)
activejob (= 5.2.8.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.7)
actionview (= 5.1.7)
activesupport (= 5.1.7)
rack (~> 2.0)
actionpack (5.2.8.1)
actionview (= 5.2.8.1)
activesupport (= 5.2.8.1)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.7)
activesupport (= 5.1.7)
actionview (5.2.8.1)
activesupport (= 5.2.8.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_hash (3.1.1)
activesupport (>= 5.0.0)
activejob (5.1.7)
activesupport (= 5.1.7)
activejob (5.2.8.1)
activesupport (= 5.2.8.1)
globalid (>= 0.3.6)
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)
activemodel (5.2.8.1)
activesupport (= 5.2.8.1)
activerecord (5.2.8.1)
activemodel (= 5.2.8.1)
activesupport (= 5.2.8.1)
arel (>= 9.0)
activestorage (5.2.8.1)
actionpack (= 5.2.8.1)
activerecord (= 5.2.8.1)
marcel (~> 1.0.0)
activesupport (5.2.8.1)
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)
afm (0.2.2)
arel (8.0.0)
arel (9.0.0)
ast (2.4.2)
audited (5.0.2)
activerecord (>= 5.0, < 7.1)
autoprefixer-rails (10.4.7.0)
execjs (~> 2)
bcrypt (3.1.18)
bootsnap (1.15.0)
msgpack (~> 1.2)
bootstrap-sass (3.4.1)
autoprefixer-rails (>= 5.2.1)
sassc (>= 2.0.0)
Expand Down Expand Up @@ -89,9 +95,9 @@ GEM
activesupport
tzinfo
cocoon (1.2.15)
coffee-rails (4.2.2)
coffee-rails (5.0.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
railties (>= 5.2.0)
coffee-script (2.4.1)
coffee-script-source
execjs
Expand Down Expand Up @@ -128,9 +134,9 @@ GEM
diff-lcs (1.5.0)
docile (1.4.0)
erubi (1.11.0)
exception_notification (4.4.3)
actionmailer (>= 4.0, < 7)
activesupport (>= 4.0, < 7)
exception_notification (4.5.0)
actionmailer (>= 5.2, < 8)
activesupport (>= 5.2, < 8)
execjs (2.8.1)
ffi (1.15.5)
git (1.13.1)
Expand All @@ -147,20 +153,20 @@ GEM
activesupport (>= 5.1)
haml (>= 4.0.6)
railties (>= 5.1)
has_scope (0.7.2)
actionpack (>= 4.1)
activesupport (>= 4.1)
has_scope (0.8.0)
actionpack (>= 5.2)
activesupport (>= 5.2)
hashery (2.1.2)
htmlentities (4.3.4)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
inherited_resources (1.11.0)
actionpack (>= 5.0, < 6.1)
inherited_resources (1.13.1)
actionpack (>= 5.2, < 7.1)
has_scope (~> 0.6)
railties (>= 5.0, < 6.1)
railties (>= 5.2, < 7.1)
responders (>= 2, < 4)
jquery-rails (4.5.1)
rails-dom-testing (>= 1, < 3)
Expand All @@ -184,10 +190,11 @@ GEM
addressable (~> 2.7)
letter_opener (1.8.1)
launchy (>= 2.2, < 3)
letter_opener_web (1.4.1)
actionmailer (>= 3.2)
letter_opener (~> 1.0)
railties (>= 3.2)
letter_opener_web (2.0.0)
actionmailer (>= 5.2)
letter_opener (~> 1.7)
railties (>= 5.2)
rexml
libv8-node (16.10.0.0)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
Expand All @@ -206,6 +213,7 @@ GEM
mini_racer (0.6.3)
libv8-node (~> 16.10.0.0)
minitest (5.17.0)
msgpack (1.6.0)
nio4r (2.5.8)
nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
Expand All @@ -220,8 +228,6 @@ GEM
hashery (~> 2.0)
ruby-rc4
ttfunk
polyamorous (2.3.0)
activerecord (>= 5.0)
powerpack (0.1.3)
prawn (0.13.2)
pdf-reader (~> 1.2)
Expand All @@ -238,17 +244,18 @@ GEM
rack (2.2.6.2)
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)
rails (5.2.8.1)
actioncable (= 5.2.8.1)
actionmailer (= 5.2.8.1)
actionpack (= 5.2.8.1)
actionview (= 5.2.8.1)
activejob (= 5.2.8.1)
activemodel (= 5.2.8.1)
activerecord (= 5.2.8.1)
activestorage (= 5.2.8.1)
activesupport (= 5.2.8.1)
bundler (>= 1.3.0)
railties (= 5.1.7)
railties (= 5.2.8.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
Expand All @@ -258,20 +265,18 @@ GEM
rails-i18n (5.1.3)
i18n (>= 0.7, < 2)
railties (>= 5.0, < 6)
railties (5.1.7)
actionpack (= 5.1.7)
activesupport (= 5.1.7)
railties (5.2.8.1)
actionpack (= 5.2.8.1)
activesupport (= 5.2.8.1)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
thor (>= 0.19.0, < 2.0)
rainbow (3.1.1)
rake (13.0.6)
ransack (2.3.0)
actionpack (>= 5.0)
activerecord (>= 5.0)
activesupport (>= 5.0)
ransack (2.5.0)
activerecord (>= 5.2.4)
activesupport (>= 5.2.4)
i18n
polyamorous (= 2.3.0)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
Expand All @@ -291,10 +296,10 @@ GEM
rspec-mocks (3.12.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-rails (4.1.2)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-rails (5.1.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
railties (>= 5.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
Expand Down Expand Up @@ -330,14 +335,14 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
shoulda-matchers (4.5.1)
activesupport (>= 4.2.0)
show_for (0.7.0)
actionpack (>= 5.0)
activemodel (>= 5.0)
simple_form (5.0.3)
actionpack (>= 5.0)
activemodel (>= 5.0)
shoulda-matchers (5.2.0)
activesupport (>= 5.2.0)
show_for (0.8.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
simple_form (5.1.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand All @@ -348,9 +353,9 @@ GEM
sprockets (4.1.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.6.0)
mini_portile2 (~> 2.8.0)
Expand Down Expand Up @@ -383,7 +388,7 @@ GEM
rack (>= 2.0.9)
webrick (1.7.0)
websocket (1.2.9)
websocket-driver (0.6.5)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
Expand All @@ -399,6 +404,7 @@ PLATFORMS
DEPENDENCIES
active_hash
audited
bootsnap
bootstrap-sass
byebug
cancancan (~> 1.17)
Expand Down Expand Up @@ -432,7 +438,7 @@ DEPENDENCIES
prawn_rails
psych (< 4.0)
puma
rails (>= 5.1.7, < 5.1.99)
rails (>= 5.2.0, < 5.2.99)
rails-i18n
ransack
redcarpet
Expand Down
2 changes: 1 addition & 1 deletion app/models/event_organizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ class EventOrganizer < ApplicationRecord
validates :user_id, uniqueness: { scope: :event_id, message: 'Already an event organizer for this event' }

def self.autocomplete_users(term)
User.order('lower(nickname)').where('nickname like ? or email like ?', "%#{term}%", "%#{term}%").pluck(:nickname, :email)
User.order(Arel.sql('lower(nickname)')).where('nickname like ? or email like ?', "%#{term}%", "%#{term}%").pluck(:nickname, :email)
end
end
12 changes: 6 additions & 6 deletions app/models/travel_expense_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TravelExpenseReport < ApplicationRecord
delegate :user, to: :request, prefix: false
delegate :event, to: :request, prefix: false

@by = {
BY = {
event: [
{ field: :event_id, sql: 'event_id', hidden: true },
{ field: :event_name, sql: 'events.name' },
Expand Down Expand Up @@ -61,7 +61,7 @@ class TravelExpenseReport < ApplicationRecord
{ field: :event_name, sql: 'events.name' },
{ field: :subject, sql: 'request_expenses.subject' }
]
}
}.freeze

# Main scope for using the whole model. Takes cares of all the grouping,
# conditions and selections needed for a given amount field and a given
Expand All @@ -76,9 +76,9 @@ class TravelExpenseReport < ApplicationRecord
currency = RequestExpense.currency_field_for(type.to_sym)
r = joins(request: [{ user: :profile }, :event])
r = r.joins('LEFT JOIN reimbursements ON reimbursements.request_id = requests.id')
r = r.select("sum(#{type}_amount) AS sum_amount, #{currency} AS sum_currency, #{@by[g.to_sym].map { |f| "#{f[:sql]} AS #{f[:field]}" }.join(', ')}")
r = r.select("sum(#{type}_amount) AS sum_amount, #{currency} AS sum_currency, #{TravelExpenseReport::BY[g.to_sym].map { |f| "#{f[:sql]} AS #{f[:field]}" }.join(', ')}")
r = r.where("#{type}_amount IS NOT NULL")
r = r.group("#{currency}, #{@by[g.to_sym].map { |f| f[:sql] }.join(', ')}")
r = r.group("#{currency}, #{TravelExpenseReport::BY[g.to_sym].map { |f| f[:sql] }.join(', ')}")
}

# Scope for filtering
Expand Down Expand Up @@ -136,14 +136,14 @@ class TravelExpenseReport < ApplicationRecord
# @param [#to_sym] group The grouping option used when invoking the scope
# @return [array] The names of the resulting fields (as an array of symbols)
def self.fields_for(group)
@by[group.to_sym].reject { |f| f[:hidden] }.map { |i| i[:field] } + %i[sum_amount sum_currency]
TravelExpenseReport::BY[group.to_sym].reject { |f| f[:hidden] }.map { |i| i[:field] } + %i[sum_amount sum_currency]
end

# Available group options for calling the 'by' scope
#
# @return [array] An array with the available grouping criterias (as symbols)
def self.groups
@by.keys
TravelExpenseReport::BY.keys
end

# Casted value of a given attribute.
Expand Down
2 changes: 1 addition & 1 deletion bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby.ruby2.7
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')
Loading