1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2025-12-10 08:46:41 +01:00

Merge pull request #44 from PFischbeck/rails-5-update

Rails 5 update
This commit is contained in:
Philipp Fischbeck 2017-11-23 14:19:30 +01:00 committed by GitHub
commit 9d6464d18a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 463 additions and 280 deletions

View File

@ -1,9 +1,9 @@
language: ruby
cache: bundler
rvm:
- 2.2.3
- 2.1.7
- 1.9.3
- 2.4
- 2.3
- 2.2
script:
- export RAILS_ENV=test
- bundle exec rake db:create db:migrate

47
Gemfile
View File

@ -2,50 +2,49 @@ source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
gem 'rails', '5.1.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
gem 'sqlite3', '~> 1.3.13'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.4'
gem 'sass-rails', '~> 5.0.7'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '~> 2.7.2'
gem 'uglifier', '~> 3.2.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
gem 'coffee-rails', '~> 4.2.2'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'rails-controller-testing'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-rails', '~> 4.3.1'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
gem 'turbolinks', '~> 5.0.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.3.1'
gem 'jbuilder', '~> 2.7.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'sdoc', '~> 0.4.2', group: :doc
gem 'web-console', '~> 2.0', group: :development
gem 'quiet_assets', group: :development
gem 'web-console', '~> 3.5.1', group: :development
# Use Coveralls for coverage documentation
gem 'coveralls', '~> 0.8.2', require: false
gem 'coveralls', '~> 0.8.21', require: false
gem 'bootstrap-sass', '~> 3.3.6'
gem 'autoprefixer-rails'
gem 'bootstrap-sass', '~> 3.3.7'
gem 'autoprefixer-rails', '~> 7.1.6'
gem 'bh', '~> 1.3.4'
gem 'bh', '~> 1.3.6'
gem 'will_paginate', '~> 3.0.7'
gem 'will-paginate-i18n'
gem 'will_paginate-bootstrap'
gem 'will_paginate', '~> 3.1.6'
gem 'will-paginate-i18n', '~> 0.1.15'
gem 'will_paginate-bootstrap', '~> 1.0.1'
gem 'mathjax-rails'
gem 'mathjax-rails', '~> 2.6.1'
gem 'devise', '~> 3.5.2'
gem 'devise-bootstrap-views'
gem 'devise', '~> 4.3.0'
gem 'devise-bootstrap-views', '~> 0.0.11'
gem 'codemirror-rails'
gem 'codemirror-rails', '~> 5.16.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

View File

@ -1,228 +1,229 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.5)
actionpack (= 4.2.5)
actionview (= 4.2.5)
activejob (= 4.2.5)
actioncable (5.1.4)
actionpack (= 5.1.4)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.5)
actionview (= 4.2.5)
activesupport (= 4.2.5)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
actionpack (5.1.4)
actionview (= 5.1.4)
activesupport (= 5.1.4)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.5)
activesupport (= 4.2.5)
actionview (5.1.4)
activesupport (= 5.1.4)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.5)
activesupport (= 4.2.5)
globalid (>= 0.3.0)
activemodel (4.2.5)
activesupport (= 4.2.5)
builder (~> 3.1)
activerecord (4.2.5)
activemodel (= 4.2.5)
activesupport (= 4.2.5)
arel (~> 6.0)
activesupport (4.2.5)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.4)
activesupport (= 5.1.4)
globalid (>= 0.3.6)
activemodel (5.1.4)
activesupport (= 5.1.4)
activerecord (5.1.4)
activemodel (= 5.1.4)
activesupport (= 5.1.4)
arel (~> 8.0)
activesupport (5.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
autoprefixer-rails (6.1.1)
arel (8.0.0)
autoprefixer-rails (7.1.6)
execjs
json
bcrypt (3.1.10)
bh (1.3.4)
bcrypt (3.1.11)
bcrypt (3.1.11-x86-mingw32)
bh (1.3.6)
actionpack
activesupport
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bootstrap-sass (3.3.6)
bindex (0.5.0)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.2)
codemirror-rails (5.6)
railties (>= 3.0, < 5)
coffee-rails (4.1.0)
builder (3.2.3)
codemirror-rails (5.16.0)
railties (>= 3.0, < 6.0)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
railties (>= 4.0.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
coveralls (0.8.9)
json (~> 1.8)
rest-client (>= 1.6.8, < 2)
simplecov (~> 0.10.0)
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
coveralls (0.8.21)
json (>= 1.8, < 3)
simplecov (~> 0.14.1)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
tins (~> 1.6.0)
debug_inspector (0.0.2)
devise (3.5.2)
thor (~> 0.19.4)
tins (~> 1.6)
crass (1.0.3)
devise (4.3.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
railties (>= 4.1.0, < 5.2)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
devise-bootstrap-views (0.0.7)
devise-bootstrap-views (0.0.11)
docile (1.1.5)
domain_name (0.5.25)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
execjs (2.6.0)
ffi (1.9.10)
globalid (0.3.6)
activesupport (>= 4.1.0)
http-cookie (1.0.2)
domain_name (~> 0.5)
i18n (0.7.0)
jbuilder (2.3.2)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.5)
rails-dom-testing (~> 1.0)
erubi (1.7.0)
execjs (2.7.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
i18n (0.9.1)
concurrent-ruby (~> 1.0)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
loofah (2.0.3)
json (1.8.6)
loofah (2.1.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mathjax-rails (2.5.1)
mail (2.7.0)
mini_mime (>= 0.1.1)
mathjax-rails (2.6.1)
railties (>= 3.0)
mime-types (2.99)
mini_portile (0.6.2)
minitest (5.8.3)
multi_json (1.11.2)
netrc (0.11.0)
nokogiri (1.6.6.4)
mini_portile (~> 0.6.0)
method_source (0.9.0)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.10.3)
multi_json (1.12.2)
nio4r (2.1.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
nokogiri (1.8.1-x86-mingw32)
mini_portile2 (~> 2.3.0)
orm_adapter (0.5.0)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.5)
actionmailer (= 4.2.5)
actionpack (= 4.2.5)
actionview (= 4.2.5)
activejob (= 4.2.5)
activemodel (= 4.2.5)
activerecord (= 4.2.5)
activesupport (= 4.2.5)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.5)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
rack (2.0.3)
rack-test (0.8.2)
rack (>= 1.0, < 3)
rails (5.1.4)
actioncable (= 5.1.4)
actionmailer (= 5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
activemodel (= 5.1.4)
activerecord (= 5.1.4)
activesupport (= 5.1.4)
bundler (>= 1.3.0)
railties (= 5.1.4)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
actionview (~> 5.x, >= 5.0.1)
activesupport (~> 5.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.5)
actionpack (= 4.2.5)
activesupport (= 4.2.5)
railties (5.1.4)
actionpack (= 5.1.4)
activesupport (= 5.1.4)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
json (~> 1.4)
responders (2.1.0)
railties (>= 4.2.0, < 5)
rest-client (1.8.0)
ffi (~> 1.9)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rake (12.3.0)
rdoc (4.3.0)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
sass (3.4.19)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
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)
sdoc (0.4.1)
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
simplecov (0.10.0)
simplecov (0.14.1)
docile (~> 1.1.0)
json (~> 1.8)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
simplecov-html (0.10.2)
sprockets (3.4.1)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.11)
term-ansicolor (1.3.2)
sqlite3 (1.3.13)
sqlite3 (1.3.13-x86-mingw32)
term-ansicolor (1.6.0)
tins (~> 1.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
tins (1.6.0)
turbolinks (2.5.3)
coffee-rails
tzinfo (1.2.2)
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.8)
tins (1.15.1)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.3)
tzinfo (1.2.4)
thread_safe (~> 0.1)
tzinfo-data (1.2015.7)
tzinfo (>= 1.0.0)
uglifier (2.7.2)
execjs (>= 0.3.0)
json (>= 1.8.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
warden (1.2.3)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
warden (1.2.7)
rack (>= 1.0)
web-console (2.2.1)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
web-console (3.5.1)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
will-paginate-i18n (0.1.15)
will_paginate (3.0.7)
will_paginate (3.1.6)
will_paginate-bootstrap (1.0.1)
will_paginate (>= 3.0.3)
PLATFORMS
ruby
x86-mingw32
DEPENDENCIES
autoprefixer-rails
bh (~> 1.3.4)
bootstrap-sass (~> 3.3.6)
codemirror-rails
coffee-rails (~> 4.1.0)
coveralls (~> 0.8.2)
devise (~> 3.5.2)
devise-bootstrap-views
jbuilder (~> 2.3.1)
jquery-rails
mathjax-rails
quiet_assets
rails (= 4.2.5)
sass-rails (~> 5.0.4)
sdoc (~> 0.4.0)
sqlite3
turbolinks
autoprefixer-rails (~> 7.1.6)
bh (~> 1.3.6)
bootstrap-sass (~> 3.3.7)
codemirror-rails (~> 5.16.0)
coffee-rails (~> 4.2.2)
coveralls (~> 0.8.21)
devise (~> 4.3.0)
devise-bootstrap-views (~> 0.0.11)
jbuilder (~> 2.7.0)
jquery-rails (~> 4.3.1)
mathjax-rails (~> 2.6.1)
rails (= 5.1.4)
rails-controller-testing
sass-rails (~> 5.0.7)
sdoc (~> 0.4.2)
sqlite3 (~> 1.3.13)
turbolinks (~> 5.0.1)
tzinfo-data
uglifier (~> 2.7.2)
web-console (~> 2.0)
will-paginate-i18n
will_paginate (~> 3.0.7)
will_paginate-bootstrap
uglifier (~> 3.2.0)
web-console (~> 3.5.1)
will-paginate-i18n (~> 0.1.15)
will_paginate (~> 3.1.6)
will_paginate-bootstrap (~> 1.0.1)
BUNDLED WITH
1.16.0

View File

@ -0,0 +1,2 @@
class ApplicationJob < ActiveJob::Base
end

View File

@ -1,4 +1,4 @@
class Admin < ActiveRecord::Base
class Admin < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,

View File

@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end

View File

@ -1,6 +1,6 @@
class Problem < ActiveRecord::Base
class Problem < ApplicationRecord
# TODO Check whether there is a better relation for this
belongs_to :translation
belongs_to :translation, optional: true
delegate :title, :content, to: :translation
has_many :translations, inverse_of: :problem

View File

@ -1,4 +1,4 @@
class Translation < ActiveRecord::Base
class Translation < ApplicationRecord
belongs_to :problem, inverse_of: :translations
validates :title, :content, :problem_id, presence: true

View File

@ -1,4 +1,4 @@
#!/usr/bin/env ruby.exe
APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'

View File

@ -1,29 +1,38 @@
#!/usr/bin/env ruby.exe
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install"
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system "bin/rake db:setup"
system! 'bin/rails db:setup'
puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
system! 'bin/rails restart'
end

29
bin/update Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env ruby.exe
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "\n== Updating database =="
system! 'bin/rails db:migrate'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end

11
bin/yarn Normal file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env ruby.exe
VENDOR_PATH = File.expand_path('..', __dir__)
Dir.chdir(VENDOR_PATH) do
begin
exec "yarnpkg #{ARGV.join(" ")}"
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end

View File

@ -1,4 +1,4 @@
require File.expand_path('../boot', __FILE__)
require_relative 'boot'
require 'rails/all'
@ -8,6 +8,9 @@ Bundler.require(*Rails.groups)
module Projekteuler
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
@ -20,8 +23,5 @@ module Projekteuler
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
config.i18n.available_locales = :de
config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
end
end

View File

@ -1,3 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.

10
config/cable.yml Normal file
View File

@ -0,0 +1,10 @@
development:
adapter: async
test:
adapter: async
production:
adapter: redis
url: redis://localhost:6379/1
channel_prefix: projekteuler_production

View File

@ -1,5 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!

View File

@ -9,13 +9,28 @@ Rails.application.configure do
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
# Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
@ -27,15 +42,13 @@ Rails.application.configure do
# number of complex assets.
config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations
config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end

View File

@ -14,15 +14,14 @@ Rails.application.configure do
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
# `config/secrets.yml.key`.
config.read_encrypted_secrets = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
@ -31,16 +30,20 @@ Rails.application.configure do
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
@ -49,16 +52,15 @@ Rails.application.configure do
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "projekteuler_#{Rails.env}"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
@ -74,6 +76,16 @@ Rails.application.configure do
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end

View File

@ -12,9 +12,11 @@ Rails.application.configure do
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
}
# Show full error reports and disable caching.
config.consider_all_requests_local = true
@ -25,15 +27,13 @@ Rails.application.configure do
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Randomize the order test cases are executed.
config.active_support.test_order = :random
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr

View File

@ -0,0 +1,8 @@
# Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# end

View File

@ -3,9 +3,12 @@
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

View File

@ -1,3 +1,5 @@
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.1 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# Make `form_with` generate non-remote forms.
Rails.application.config.action_view.form_with_generates_remote_forms = false
# Unknown asset fallback will return the path passed in when the given
# asset is not present in the asset pipeline.
# Rails.application.config.assets.unknown_asset_fallback = false

View File

@ -5,7 +5,7 @@
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.

56
config/puma.rb Normal file
View File

@ -0,0 +1,56 @@
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
# preload_app!
# If you are preloading your application and using Active Record, it's
# recommended that you close any connections to the database before workers
# are forked to prevent connection leakage.
#
# before_fork do
# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
# end
# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted, this block will be run. If you are using the `preload_app!`
# option, you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, as Ruby
# cannot share connections between processes.
#
# on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
#
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

View File

@ -66,4 +66,5 @@ Rails.application.routes.draw do
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end

View File

@ -5,18 +5,28 @@
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# You can use `rails secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
# Shared secrets are available across all environments.
# shared:
# api_key: a1B2c3D4e5F6
# Environmental secrets are only available for that specific environment.
development:
secret_key_base: 6c2640a4cd5352d96caea5bfb073ec7b827ad609f5a5a99680dbd56f2506dc0aecfe568404a0a63fc19529f7c7a38ac403635f83497580b3dec2afc16b7972b4
secret_key_base: ceb25f25a0e73150d84c213c7b303dc7091b6eaea001bc986067e5bf6642913c2d0e83c8c93b1e975cae11f2812d05602e1341e9a48687b7b23bed7976992890
test:
secret_key_base: 1b2d1b8c35dc3bcc8327819d95a1e635c64ae5038d25c4630463514a945c710da4923f2b8489f81021511fb59ee258e19735e50fb0df3c7efc3f06dc294c748f
secret_key_base: eb1a45af35f2aa8c17790252820d8071be124f6a50f1e3112c873fe9d0e4aa49159c53759f381fe224e22aead60623bd82455fba509eb99e07117b98bcd41d4d
# Do not keep production secrets in the unencrypted secrets file.
# Instead, either read values from the environment.
# Or, use `bin/rails secrets:setup` to configure encrypted secrets
# and move the `production:` environment over there.
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

View File

@ -1,4 +1,4 @@
class CreateProblems < ActiveRecord::Migration
class CreateProblems < ActiveRecord::Migration[4.2]
def change
create_table :problems do |t|
t.string :title

View File

@ -1,4 +1,4 @@
class RenameProblemsTableToTranslations < ActiveRecord::Migration
class RenameProblemsTableToTranslations < ActiveRecord::Migration[4.2]
def change
rename_table :problems, :translations
end

View File

@ -1,4 +1,4 @@
class CreateProblemsAgain < ActiveRecord::Migration
class CreateProblemsAgain < ActiveRecord::Migration[4.2]
def change
create_table :problems do |t|
t.timestamps null: true

View File

@ -1,4 +1,4 @@
class AddTranslationToProblem < ActiveRecord::Migration
class AddTranslationToProblem < ActiveRecord::Migration[4.2]
def change
add_reference :problems, :translation, index: true
end

View File

@ -1,4 +1,4 @@
class AddProblemToTranslation < ActiveRecord::Migration
class AddProblemToTranslation < ActiveRecord::Migration[4.2]
def change
add_reference :translations, :problem, index: true
end

View File

@ -1,4 +1,4 @@
class DeviseCreateAdmins < ActiveRecord::Migration
class DeviseCreateAdmins < ActiveRecord::Migration[4.2]
def change
create_table(:admins) do |t|
## Database authenticatable

View File

@ -40,7 +40,7 @@ ActiveRecord::Schema.define(version: 20150131103802) do
add_index "problems", ["translation_id"], name: "index_problems_on_translation_id"
create_table "translations", force: :cascade do |t|
t.string "title", limit: 255
t.string "title"
t.text "content"
t.datetime "created_at"
t.datetime "updated_at"

View File

@ -1,7 +1,7 @@
require 'test_helper'
class Admin::DashboardControllerTest < ActionController::TestCase
include Devise::TestHelpers
include Devise::Test::ControllerHelpers
setup do
login
@ -13,13 +13,13 @@ class Admin::DashboardControllerTest < ActionController::TestCase
end
test "should post new problem count" do
post :update_problem_count, problem_count: 15
post :update_problem_count, params: { problem_count: 15 }
assert_redirected_to controller: 'admin/dashboard', action: 'index'
assert_equal 15, Problem.count
end
test "should fail incorrect problem count" do
post :update_problem_count, problem_count: 2
post :update_problem_count, params: { problem_count: 2 }
assert_redirected_to controller: 'admin/dashboard', action: 'index'
assert_equal 3, Problem.count
end

View File

@ -1,7 +1,7 @@
require 'test_helper'
class Admin::TranslationsControllerTest < ActionController::TestCase
include Devise::TestHelpers
include Devise::Test::ControllerHelpers
setup do
login
@ -14,7 +14,7 @@ class Admin::TranslationsControllerTest < ActionController::TestCase
end
test "should show translation" do
get :show, id: @translation
get :show, params: { id: @translation }
assert_response :success
end

View File

@ -1,7 +1,7 @@
require 'test_helper'
class ProblemsControllerTest < ActionController::TestCase
include Devise::TestHelpers
include Devise::Test::ControllerHelpers
test "should get index" do
get :index
@ -9,12 +9,12 @@ class ProblemsControllerTest < ActionController::TestCase
end
test "should get show" do
get :show, id: 1
get :show, params: { id: 1 }
assert_response :success
end
test "should get untranslated problem" do
get :show, id: 3
get :show, params: { id: 3 }
assert_response :success
end

View File

@ -1,7 +1,7 @@
require 'test_helper'
class TranslationsControllerTest < ActionController::TestCase
include Devise::TestHelpers
include Devise::Test::ControllerHelpers
setup do
@update = {
@ -15,18 +15,18 @@ class TranslationsControllerTest < ActionController::TestCase
end
test "should get new for translated problem" do
get :new, problem_id: 1
get :new, params: { problem_id: 1 }
assert_response :success
end
test "should get new for untranslated problem" do
get :new, problem_id: 3
get :new, params: { problem_id: 3 }
assert_response :success
end
test "should create translation" do
assert_difference('Translation.count') do
post :create, problem_id: 1, translation: @update
post :create, params: { problem_id: 1, translation: @update }
end
assert_redirected_to problem_path(id: 1)
@ -34,7 +34,7 @@ class TranslationsControllerTest < ActionController::TestCase
test "should not create incorrect translation" do
assert_no_difference('Translation.count') do
post :create, problem_id: 1, translation: @incorrect
post :create, params: { problem_id: 1, translation: @incorrect }
end
end
end