Rails 4 fixes

Update to ruby 2.3.8
Update gems
Fix tests
This commit is contained in:
Ari Timonen 2020-03-15 20:31:46 +02:00
parent 5fcf4b2a72
commit 322001f8d3
16 changed files with 94 additions and 216 deletions

8
DEVELOPMENT.md Normal file
View file

@ -0,0 +1,8 @@
# Development
Currently buggy.
# Handy commands
`docker-compose -f docker-compose.dev.yml exec -u web web /bin/bash`
`docker-compose -f docker-compose.dev.yml restart web`

View file

@ -1,4 +1,4 @@
FROM ruby:2.2.10 FROM ruby:2.3.8
ENV RAILS_ENV development ENV RAILS_ENV development
@ -6,20 +6,20 @@ ENV RAILS_ENV development
RUN adduser web --home /home/web --shell /bin/bash --disabled-password --gecos "" RUN adduser web --home /home/web --shell /bin/bash --disabled-password --gecos ""
RUN apt-get update && apt-get -y upgrade \ RUN apt-get update && apt-get -y upgrade \
&& apt-get -y install mysql-client libmysqlclient-dev memcached nodejs firefox-esr \ && apt-get -y install libmariadb-dev libmariadb-dev-compat nodejs \
&& service memcached start zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev \
libxslt1-dev imagemagick libmagickwand-dev
# Separate Gemfile ADD so that `bundle install` can be cached more effectively # Separate Gemfile ADD so that `bundle install` can be cached more effectively
ADD Gemfile Gemfile.lock /var/www/ ADD Gemfile Gemfile.lock /var/www/
RUN mkdir -p /var/bundle && chown -R web:web /var/bundle && chown -R web:web /var/www RUN mkdir -p /var/bundle && chown -R web:web /var/bundle && chown -R web:web /var/www
RUN su -c "bundle config github.https true; cd /var/www && bundle install --path /var/bundle --jobs 4" -s /bin/bash -l web
WORKDIR /var/www WORKDIR /var/www
USER web USER web
RUN bundle config github.https true; cd /var/www && bundle install --path /var/bundle --jobs 4 RUN bundle config github.https true && \
bundle install --path /var/bundle --jobs 8
USER root USER root
CMD ["/var/www/script/entry.sh"] CMD ["/var/www/script/entry.sh"]

64
Gemfile
View file

@ -1,34 +1,47 @@
source 'http://rubygems.org' source 'http://rubygems.org'
ruby '2.2.10' ruby '2.3.8'
gem 'dotenv-rails'
gem 'rails', '~> 4.1.16' gem 'rails', '~> 4.1.16'
gem 'mysql2', '~> 0.3.18'
gem 'dalli', '~> 2.7.0'
gem 'puma', '~> 2.11.1'
gem 'i18n-js' # Dotenv
gem 'exceptional', '~> 2.0.33' gem 'dotenv-rails'
gem 'oj', '~> 2.5.5'
# DB
# Fixme: using this bc puma startup problem
gem 'mysql2', '0.3.18'
gem 'dalli', '~> 2.7.0'
gem 'active_record_union'
# Web server
gem 'puma'
gem 'faraday', '~> 0.9.0' gem 'faraday', '~> 0.9.0'
# Model plugins
# FIXME: using this b/c ruby 2.4 not supported
gem 'unread', '0.10.1'
# View helper gems
gem 'nokogiri', '~> 1.9.0' gem 'nokogiri', '~> 1.9.0'
gem 'bbcoder', '~> 1.0.1' gem 'bbcoder', '~> 1.0.1'
gem 'sanitize', '~> 2.1.0' gem 'sanitize', '~> 2.1.0'
gem 'carrierwave', '~> 0.10.0' gem 'carrierwave', '~> 0.10.0'
gem 'bluecloth', '~> 2.2.0' gem 'bluecloth', '~> 2.2.0'
gem 'newrelic_rpm', '~> 3.13.0.299' gem 'rmagick'
gem 'will_paginate', '~> 3.0.5' gem 'will_paginate', '~> 3.0.5'
gem 'dynamic_form', '~> 1.1.4' gem 'dynamic_form', '~> 1.1.4'
gem 'active_link_to', '~> 1.0.2'
gem 'country_select', require: 'country_select_without_sort_alphabetical' gem 'country_select', require: 'country_select_without_sort_alphabetical'
gem 'i18n_country_select' gem 'i18n_country_select'
gem 'active_link_to', '~> 1.0.2' gem 'public_suffix', '~> 3.1.1'
gem 'rmagick', '~> 2.13.4', require: false
gem 'test-unit', '~> 3.1.3' # External APIs
gem 'google-api-client', '~> 0.10.3' gem 'google-api-client', '~> 0.10.3'
gem 'steam-condenser', github: 'koraktor/steam-condenser-ruby' gem 'steam-condenser', github: 'koraktor/steam-condenser-ruby'
gem 'public_suffix', '~> 3.1.1'
gem 'active_record_union' # Legacy feature shims
gem 'protected_attributes', '~> 1.1.3'
gem 'rails_autolink', '~> 1.1.5'
# Dependency version fix # Dependency version fix
gem 'signet', '0.11.0' gem 'signet', '0.11.0'
@ -36,34 +49,32 @@ gem 'signet', '0.11.0'
# Please install nodejs locally. # Please install nodejs locally.
#gem 'therubyracer', '~> 0.12.1' if RUBY_PLATFORM == 'x86_64-linux' #gem 'therubyracer', '~> 0.12.1' if RUBY_PLATFORM == 'x86_64-linux'
# Move these to assets group
gem 'coffee-rails', '~> 4.0.0' gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails', '~> 2.0.2' gem 'jquery-rails', '~> 2.0.2'
gem 'tinymce-rails', '~> 3.5.9' gem 'tinymce-rails', '~> 3.5.9'
gem 'sass-rails', '~> 5.0.3' gem 'sass-rails', '~> 5.0.3'
gem 'font-awesome-sass', '~> 4.1.0.0' gem 'font-awesome-sass', '~> 4.1.0.0'
gem 'bourbon', '~> 3.1.8' gem 'bourbon', '~> 3.1.8'
gem 'neat', '~> 1.6.0' gem 'neat', '~> 1.6.0'
gem 'haml', '~> 4.0.5' gem 'haml', '~> 4.0.5'
gem 'rails_autolink', '~> 1.1.5'
gem 'uglifier', '~> 2.5.0' gem 'uglifier', '~> 2.5.0'
gem 'i18n-js'
# Legacy feature shims group :production do
gem 'protected_attributes', '~> 1.1.3' gem 'newrelic_rpm', '~> 3.13.0.299'
end
group :development do group :development do
gem 'capistrano', '~> 3.1.0' gem 'better_errors'
gem 'capistrano-rbenv', '~> 2.0.2' gem 'binding_of_caller'
gem 'capistrano-bundler', '~> 1.1.2' gem 'annotate'
gem 'capistrano-rails', '~> 1.1' gem 'quiet_assets'
gem 'better_errors', '~> 1.1.0'
gem 'binding_of_caller', '~> 0.7.2'
gem 'annotate', '~> 2.6.2'
gem 'quiet_assets', '~> 1.0.2'
gem 'web-console' gem 'web-console'
end end
group :test do group :test do
# gem 'spring'
gem 'simplecov', '~> 0.7.1', require: false gem 'simplecov', '~> 0.7.1', require: false
gem 'codeclimate-test-reporter', '~> 0.3.0', require: nil gem 'codeclimate-test-reporter', '~> 0.3.0', require: nil
gem 'database_cleaner', '~> 1.2.0' gem 'database_cleaner', '~> 1.2.0'
@ -74,6 +85,7 @@ group :test do
gem 'factory_bot_rails' gem 'factory_bot_rails'
gem 'timecop', '~> 0.7.1' gem 'timecop', '~> 0.7.1'
gem 'rspec' gem 'rspec'
gem 'test-unit', '~> 3.1.3'
end end
group :development, :test do group :development, :test do

View file

@ -42,15 +42,16 @@ GEM
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.7.0) addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
annotate (2.6.10) annotate (3.1.0)
activerecord (>= 3.2, <= 4.3) activerecord (>= 3.2, < 7.0)
rake (~> 10.4) rake (>= 10.4, < 14.0)
arel (5.0.1.20140414130214) arel (5.0.1.20140414130214)
bbcoder (1.0.1) bbcoder (1.0.1)
better_errors (1.1.0) better_errors (2.6.0)
coderay (>= 1.0.0) coderay (>= 1.0.0)
erubis (>= 2.6.6) erubi (>= 1.0.0)
binding_of_caller (0.7.3) rack (>= 0.9.0)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1) debug_inspector (>= 0.0.1)
bluecloth (2.2.0) bluecloth (2.2.0)
bourbon (3.1.8) bourbon (3.1.8)
@ -60,19 +61,6 @@ GEM
byebug (2.7.0) byebug (2.7.0)
columnize (~> 0.3) columnize (~> 0.3)
debugger-linecache (~> 1.2) debugger-linecache (~> 1.2)
capistrano (3.1.0)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
capistrano-bundler (1.1.4)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-rails (1.4.0)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rbenv (2.0.4)
capistrano (~> 3.1)
sshkit (~> 1.3)
capybara (2.4.4) capybara (2.4.4)
mime-types (>= 1.16) mime-types (>= 1.16)
nokogiri (>= 1.3.3) nokogiri (>= 1.3.3)
@ -113,13 +101,13 @@ GEM
declarative (0.0.10) declarative (0.0.10)
declarative-option (0.1.0) declarative-option (0.1.0)
diff-lcs (1.3) diff-lcs (1.3)
dotenv (0.10.0) dotenv (2.7.5)
dotenv-rails (0.10.0) dotenv-rails (2.7.5)
dotenv (= 0.10.0) dotenv (= 2.7.5)
railties (>= 3.2, < 6.1)
dynamic_form (1.1.4) dynamic_form (1.1.4)
erubi (1.9.0)
erubis (2.7.0) erubis (2.7.0)
exceptional (2.0.33)
rack
execjs (2.7.0) execjs (2.7.0)
factory_bot (4.11.1) factory_bot (4.11.1)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
@ -186,17 +174,14 @@ GEM
multi_json (1.14.1) multi_json (1.14.1)
multi_xml (0.6.0) multi_xml (0.6.0)
multipart-post (2.1.1) multipart-post (2.1.1)
mysql2 (0.3.21) mysql2 (0.3.18)
neat (1.6.0) neat (1.6.0)
bourbon (>= 3.1) bourbon (>= 3.1)
sass (>= 3.3) sass (>= 3.3)
net-scp (2.0.0)
net-ssh (>= 2.6.5, < 6.0.0)
net-ssh (5.2.0)
newrelic_rpm (3.13.0.299) newrelic_rpm (3.13.0.299)
nio4r (2.5.2)
nokogiri (1.9.1) nokogiri (1.9.1)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
oj (2.5.5)
os (0.9.6) os (0.9.6)
poltergeist (1.6.0) poltergeist (1.6.0)
capybara (~> 2.1) capybara (~> 2.1)
@ -213,9 +198,9 @@ GEM
byebug (~> 2.7) byebug (~> 2.7)
pry (~> 0.10) pry (~> 0.10)
public_suffix (3.1.1) public_suffix (3.1.1)
puma (2.11.3) puma (4.3.3)
rack (>= 1.1, < 2.0) nio4r (~> 2.0)
quiet_assets (1.0.3) quiet_assets (1.1.0)
railties (>= 3.1, < 5.0) railties (>= 3.1, < 5.0)
rack (1.5.5) rack (1.5.5)
rack-test (0.6.3) rack-test (0.6.3)
@ -237,7 +222,7 @@ GEM
activesupport (= 4.1.16) activesupport (= 4.1.16)
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rake (10.5.0) rake (13.0.1)
rb-fsevent (0.10.3) rb-fsevent (0.10.3)
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
@ -246,7 +231,7 @@ GEM
declarative-option (< 0.2.0) declarative-option (< 0.2.0)
uber (< 0.2.0) uber (< 0.2.0)
retriable (3.1.2) retriable (3.1.2)
rmagick (2.13.4) rmagick (4.0.0)
rspec (3.3.0) rspec (3.3.0)
rspec-core (~> 3.3.0) rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0) rspec-expectations (~> 3.3.0)
@ -306,9 +291,6 @@ GEM
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0) sprockets (>= 2.8, < 4.0)
sshkit (1.21.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
test-unit (3.1.9) test-unit (3.1.9)
power_assert power_assert
thor (0.20.3) thor (0.20.3)
@ -324,6 +306,8 @@ GEM
execjs (>= 0.3.0) execjs (>= 0.3.0)
json (>= 1.8.0) json (>= 1.8.0)
unicode_utils (1.4.0) unicode_utils (1.4.0)
unread (0.10.1)
activerecord (>= 3)
web-console (2.3.0) web-console (2.3.0)
activemodel (>= 4.0) activemodel (>= 4.0)
binding_of_caller (>= 0.7.2) binding_of_caller (>= 0.7.2)
@ -343,16 +327,12 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
active_link_to (~> 1.0.2) active_link_to (~> 1.0.2)
active_record_union active_record_union
annotate (~> 2.6.2) annotate
bbcoder (~> 1.0.1) bbcoder (~> 1.0.1)
better_errors (~> 1.1.0) better_errors
binding_of_caller (~> 0.7.2) binding_of_caller
bluecloth (~> 2.2.0) bluecloth (~> 2.2.0)
bourbon (~> 3.1.8) bourbon (~> 3.1.8)
capistrano (~> 3.1.0)
capistrano-bundler (~> 1.1.2)
capistrano-rails (~> 1.1)
capistrano-rbenv (~> 2.0.2)
capybara (~> 2.4.4) capybara (~> 2.4.4)
carrierwave (~> 0.10.0) carrierwave (~> 0.10.0)
codeclimate-test-reporter (~> 0.3.0) codeclimate-test-reporter (~> 0.3.0)
@ -362,7 +342,6 @@ DEPENDENCIES
database_cleaner (~> 1.2.0) database_cleaner (~> 1.2.0)
dotenv-rails dotenv-rails
dynamic_form (~> 1.1.4) dynamic_form (~> 1.1.4)
exceptional (~> 2.0.33)
factory_bot_rails factory_bot_rails
faraday (~> 0.9.0) faraday (~> 0.9.0)
font-awesome-sass (~> 4.1.0.0) font-awesome-sass (~> 4.1.0.0)
@ -371,20 +350,19 @@ DEPENDENCIES
i18n-js i18n-js
i18n_country_select i18n_country_select
jquery-rails (~> 2.0.2) jquery-rails (~> 2.0.2)
mysql2 (~> 0.3.18) mysql2 (= 0.3.18)
neat (~> 1.6.0) neat (~> 1.6.0)
newrelic_rpm (~> 3.13.0.299) newrelic_rpm (~> 3.13.0.299)
nokogiri (~> 1.9.0) nokogiri (~> 1.9.0)
oj (~> 2.5.5)
poltergeist (~> 1.6.0) poltergeist (~> 1.6.0)
protected_attributes (~> 1.1.3) protected_attributes (~> 1.1.3)
pry-byebug (~> 1.3.2) pry-byebug (~> 1.3.2)
public_suffix (~> 3.1.1) public_suffix (~> 3.1.1)
puma (~> 2.11.1) puma
quiet_assets (~> 1.0.2) quiet_assets
rails (~> 4.1.16) rails (~> 4.1.16)
rails_autolink (~> 1.1.5) rails_autolink (~> 1.1.5)
rmagick (~> 2.13.4) rmagick
rspec rspec
rspec-rails (~> 3.3.3) rspec-rails (~> 3.3.3)
sanitize (~> 2.1.0) sanitize (~> 2.1.0)
@ -397,11 +375,12 @@ DEPENDENCIES
timecop (~> 0.7.1) timecop (~> 0.7.1)
tinymce-rails (~> 3.5.9) tinymce-rails (~> 3.5.9)
uglifier (~> 2.5.0) uglifier (~> 2.5.0)
unread (= 0.10.1)
web-console web-console
will_paginate (~> 3.0.5) will_paginate (~> 3.0.5)
RUBY VERSION RUBY VERSION
ruby 2.2.10p489 ruby 2.3.8p459
BUNDLED WITH BUNDLED WITH
1.17.3 1.17.3

View file

@ -63,7 +63,7 @@ class Group < ActiveRecord::Base
def self.referees def self.referees
referees = [] referees = []
referee_group = where(id: REFEREES).firsto referee_group = where(id: REFEREES).first
return referees unless referee_group return referees unless referee_group
(referee_group.groupers).each do |g| (referee_group.groupers).each do |g|

View file

@ -95,7 +95,9 @@ class User < ActiveRecord::Base
joins("LEFT JOIN bans ON bans.user_id = users.id AND expiry > UTC_TIMESTAMP()") joins("LEFT JOIN bans ON bans.user_id = users.id AND expiry > UTC_TIMESTAMP()")
.conditions("bans.id IS NOT NULL") } .conditions("bans.id IS NOT NULL") }
scope :idle, -> { scope :idle, -> {
joins("lastvisit < ?", 30.minutes.ago.utc) } where("lastvisit < ?", 30.minutes.ago.utc) }
scope :lately, -> {
where("lastvisit > ?", 30.days.ago.utc) }
validates_uniqueness_of :username, :email, :steamid validates_uniqueness_of :username, :email, :steamid
validates_length_of :firstname, :in => 1..15, :allow_blank => true validates_length_of :firstname, :in => 1..15, :allow_blank => true

View file

@ -1,4 +1,5 @@
require File.expand_path('../boot', __FILE__) require File.expand_path('../boot', __FILE__)
require 'rails/all' require 'rails/all'
Bundler.require(*Rails.groups(assets: %w(development test))) Bundler.require(*Rails.groups(assets: %w(development test)))

View file

@ -35,8 +35,10 @@ Ensl::Application.configure do
# config.threadsafe! # config.threadsafe!
config.eager_load = false config.eager_load = false
config.web_console.permissions = '172.18.0.0/16' config.web_console.whitelisted_ips = '172.18.0.0/16'
config.web_console.whiny_requests = true config.web_console.whiny_requests = true
config.eager_load = false config.eager_load = false
config.assets.debug = true
end end

View file

@ -1,6 +1,8 @@
Ensl::Application.routes.draw do Ensl::Application.routes.draw do
%w(403 404 422 500).each do |code| if not Rails.env.development?
get code, to: "errors#show", code: code %w(403 404 422 500).each do |code|
get code, to: "errors#show", code: code
end
end end
namespace :api do namespace :api do

View file

@ -1,47 +0,0 @@
ActsAsReadable
==============
ActsAsReadable allows you to create a generic relationship of items which can
be marked as 'read' by users. This is useful for forums or any other kind of
situation where you might need to know whether or not a user has seen a particular
model.
Installation
============
To install the plugin just install from the SVN:
script/plugin install http://svn.intridea.com/svn/public/acts_as_readable
You will need the readings table to use this plugin. A generator has been included,
simply type
script/generate acts_as_readable_migration
to get the standard migration created for you.
Example
=======
class Post < ActiveRecord::Base
acts_as_readable
end
bob = User.find_by_name("bob")
bob.readings # => []
Post.find_unread_by(bob) # => [<Post 1>,<Post 2>,<Post 3>...]
Post.find_read_by(bob) # => []
Post.find(1).read_by?(bob) # => false
Post.find(1).read_by!(bob) # => <Reading 1>
Post.find(1).read_by?(bob) # => true
Post.find(1).users_who_read # => [<User bob>]
Post.find_unread_by(bob) # => [<Post 2>,<Post 3>...]
Post.find_read_by(bob) # => [<Post 1>]
bob.readings # => [<Reading 1>]
Copyright (c) 2008 Michael Bleigh and Intridea, Inc. released under the MIT license

View file

@ -1,11 +0,0 @@
class ActsAsReadableMigrationGenerator < Rails::Generator::Base
def manifest
record do |m|
m.migration_template 'migration.rb', 'db/migrate'
end
end
def file_name
"acts_as_readable_migration"
end
end

View file

@ -1,14 +0,0 @@
class ActsAsReadableMigration < ActiveRecord::Migration
def self.up
create_table :readings do |t|
t.string :readable_type
t.integer :readable_id
t.integer :user_id
t.timestamps
end
end
def self.down
drop_table :readings
end
end

View file

@ -1,3 +0,0 @@
require 'acts_as_readable'
ActiveRecord::Base.send :include, ActiveRecord::Acts::Readable

View file

@ -1,43 +0,0 @@
module ActiveRecord
module Acts
module Readable
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_readable
has_many :readings, :as => :readable
has_many :users_who_read, :through => :readings, :source => :user
include ActiveRecord::Acts::Readable::InstanceMethods
extend ActiveRecord::Acts::Readable::SingletonMethods
end
end
module SingletonMethods
def find_unread_by(user)
find(:all) - find_read_by(user)
end
def find_read_by(user)
find(:all, :conditions => ["readings.readable_id = #{table_name}.id AND readings.user_id=?", user.id], :include => :readings)
end
end
module InstanceMethods
def read_by!(user)
readings << Reading.new(:user_id => user.id)
end
def unread_by!(user)
readings.find(:first, :conditions => ["user_id = ?",user.id])
end
def read_by?(user)
!!users_who_read.find(:first, :conditions => ["user_id = ?",user.id])
end
end
end
end
end

View file

@ -1,7 +0,0 @@
class Reading < ActiveRecord::Base
belongs_to :user
belongs_to :readable, :polymorphic => true
validates_presence_of :user_id, :readable_id, :readable_type
validates_uniqueness_of :user_id, :scope => [:readable_id, :readable_type]
end

View file

@ -1,3 +0,0 @@
User.class_eval do
has_many :readings
end