Skip to content

Commit

Permalink
Upgrade activerecord and activesupport to 5.0.3
Browse files Browse the repository at this point in the history
* One major change with respect to connection management -
  `ActiveRecord::ConnectionAdapters::ConnectionManagement` is no
  longer part of Rails. It was being used to handle connections (close
  connection after every request). But this was [not a public
  API](rails/rails#26947 (comment))
  and hence is
  [removed](https://github.com/rails/rails/pull/23807/files). This
  means we have to close connections after
  every request ourselves. Relevant code has been added to
  `ExercismWeb::App` and `ExercismAPI::App` classes.
* concurrent-ruby which is dependency of both sidekiq and
  activesupport both. It created version conflict, hence had to update
  sidekiq as well. But with sidekiq it is not a major version upgrade.
* Also fix a few warnings and failing tests
  • Loading branch information
tejasbubane committed May 19, 2017
1 parent 6006d95 commit e7fcf57
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 26 deletions.
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ source 'https://rubygems.org'

ruby '2.3.3'

gem 'activesupport', '~> 4.2.8'
gem 'activerecord', '~> 4.2.8'
gem 'activesupport', '~> 5.0.3'
gem 'activerecord', '~> 5.0.3'

gem 'bugsnag', '~> 5.3'
gem 'faraday'
Expand All @@ -21,7 +21,7 @@ gem 'redcarpet', '~> 3.1'
gem 'rouge', '~> 2.0.5'
gem 'sinatra', '~> 2.0.0', require: 'sinatra/base'
gem 'sinatra-contrib', '~> 2.0.0'
gem 'sidekiq'
gem 'sidekiq', '~> 4.2.10'
gem 'trackler', '~> 2.1.0'
gem 'will_paginate'
gem 'will_paginate-bootstrap'
Expand Down
35 changes: 17 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (4.2.8)
activesupport (= 4.2.8)
builder (~> 3.1)
activerecord (4.2.8)
activemodel (= 4.2.8)
activesupport (= 4.2.8)
arel (~> 6.0)
activesupport (4.2.8)
activemodel (5.0.3)
activesupport (= 5.0.3)
activerecord (5.0.3)
activemodel (= 5.0.3)
activesupport (= 5.0.3)
arel (~> 7.0)
activesupport (5.0.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
approvals (0.0.22)
nokogiri (~> 1.6)
thor (~> 0.18)
arel (6.0.4)
arel (7.1.4)
ast (2.2.0)
autoprefixer-rails (6.3.5)
execjs
Expand All @@ -26,7 +25,6 @@ GEM
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
bugsnag (5.3.1)
builder (3.2.3)
capybara (2.6.2)
addressable
mime-types (>= 1.16)
Expand All @@ -48,8 +46,8 @@ GEM
sass (>= 3.3.0, < 3.5)
compass-import-once (1.0.5)
sass (>= 3.2, < 3.5)
concurrent-ruby (1.0.1)
connection_pool (2.2.0)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
coveralls (0.8.13)
json (~> 1.8)
simplecov (~> 0.11.0)
Expand Down Expand Up @@ -131,7 +129,7 @@ GEM
ffi (>= 0.5.0)
rb-readline (0.5.3)
redcarpet (3.3.4)
redis (3.2.2)
redis (3.3.3)
rouge (2.0.5)
rubocop (0.36.0)
parser (>= 2.3.0.0, < 3.0)
Expand All @@ -142,9 +140,10 @@ GEM
rubypants (0.6.0)
rubyzip (1.2.1)
sass (3.4.21)
sidekiq (4.1.1)
sidekiq (4.2.10)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0)
redis (~> 3.2, >= 3.2.1)
simplecov (0.11.2)
docile (~> 1.1.0)
Expand Down Expand Up @@ -187,8 +186,8 @@ PLATFORMS
ruby

DEPENDENCIES
activerecord (~> 4.2.8)
activesupport (~> 4.2.8)
activerecord (~> 5.0.3)
activesupport (~> 5.0.3)
approvals
bootstrap-sass
bugsnag (~> 5.3)
Expand Down Expand Up @@ -220,7 +219,7 @@ DEPENDENCIES
rouge (~> 2.0.5)
rubocop (= 0.36.0)
sass
sidekiq
sidekiq (~> 4.2.10)
simplecov
sinatra (~> 2.0.0)
sinatra-contrib (~> 2.0.0)
Expand Down
4 changes: 4 additions & 0 deletions api/v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ module ExercismAPI

module ExercismAPI
class App < Sinatra::Base
configure do
after { ActiveRecord::Base.connection.close }
end

use Routes::Exercises
use Routes::Iterations
use Routes::Submissions
Expand Down
1 change: 1 addition & 0 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module ExercismWeb
class App < Sinatra::Base
configure do
use Rack::Session::Cookie, secret: ENV.fetch('SESSION_SECRET', DEFAULT_SESSION_KEY)
after { ActiveRecord::Base.connection.close }
end

if settings.development?
Expand Down
1 change: 0 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ require 'api/v1'

ENV['RACK_ENV'] ||= 'development'

use ActiveRecord::ConnectionAdapters::ConnectionManagement
use Rack::MethodOverride
run Rack::URLMap.new(
"/" => ExercismWeb::App,
Expand Down
5 changes: 4 additions & 1 deletion lib/exercism/homework.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def status(language)

def extract(sql)
UserExercise.connection.execute(sql).each_with_object(empty_hash) do |row, exercises|
exercises[row['language']] << { 'slug' => row['slug'], 'state' => row['archived'] == 't' ? 'archived' : 'active' }
exercises[row['language']] << {
'slug' => row['slug'],
'state' => row['archived'] ? 'archived' : 'active'
}
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/exercism/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def potential_members(comma_delimited_names)

def normalize_slug
return unless slug
self.slug = slug.tr('_', '-').parameterize('-')
self.slug = slug.tr('_', '-').parameterize(separator: '-')
end

def provide_default_slug
Expand Down
1 change: 0 additions & 1 deletion test/active_record_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
ENV['RACK_ENV'] = 'test'
require_relative './test_helper'
gem 'activerecord', '~> 4.0'
require 'active_record'
require 'database_cleaner'
require 'db/connection'
Expand Down
2 changes: 1 addition & 1 deletion test/exercism/use_cases/creates_comment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_should_return_invalid_comment_if_invalid
def test_empty_nit_does_not_get_created
nitpicker = User.new(username: 'alice')
CreatesComment.new(submission.id, nitpicker, '').create
assert_equal 0, submission.comments(true).count
assert_equal 0, submission.comments.reload.count
end

def test_nitpicking_archived_exercise_does_not_reactivate_it
Expand Down

0 comments on commit e7fcf57

Please sign in to comment.