diff --git a/Gemfile b/Gemfile index e8d20ce9af..6ca57b6cbe 100644 --- a/Gemfile +++ b/Gemfile @@ -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' @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index a3b8cbc4d6..8307e655ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/api/v1.rb b/api/v1.rb index 7135e81e65..d1e9d811b8 100644 --- a/api/v1.rb +++ b/api/v1.rb @@ -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 diff --git a/app.rb b/app.rb index 816d77d7e2..20095c013b 100644 --- a/app.rb +++ b/app.rb @@ -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? diff --git a/config.ru b/config.ru index bec5932fac..df04445946 100644 --- a/config.ru +++ b/config.ru @@ -25,7 +25,6 @@ require 'api/v1' ENV['RACK_ENV'] ||= 'development' -use ActiveRecord::ConnectionAdapters::ConnectionManagement use Rack::MethodOverride run Rack::URLMap.new( "/" => ExercismWeb::App, diff --git a/lib/exercism/homework.rb b/lib/exercism/homework.rb index df6b7736bc..7eade9f16d 100644 --- a/lib/exercism/homework.rb +++ b/lib/exercism/homework.rb @@ -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 diff --git a/lib/exercism/team.rb b/lib/exercism/team.rb index 56192b510b..6f5c9f46b1 100644 --- a/lib/exercism/team.rb +++ b/lib/exercism/team.rb @@ -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 diff --git a/test/active_record_helper.rb b/test/active_record_helper.rb index d1cd8dace9..c3b042693e 100644 --- a/test/active_record_helper.rb +++ b/test/active_record_helper.rb @@ -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' diff --git a/test/exercism/use_cases/creates_comment_test.rb b/test/exercism/use_cases/creates_comment_test.rb index 12087f4d79..2b85cf1052 100644 --- a/test/exercism/use_cases/creates_comment_test.rb +++ b/test/exercism/use_cases/creates_comment_test.rb @@ -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