diff --git a/.travis.yml b/.travis.yml index 0d78a134..39b4f959 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ branches: - master rvm: - 2.3.3 + - 2.3.4 + - 2.4.1 services: - postgresql env: diff --git a/Gemfile b/Gemfile index d4e963d8..54fa99ab 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'rails', '5.0.3' +gem 'rails', '5.1.1' gem 'rails-i18n', '~> 5.0.0' gem 'dotenv-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 5de4ce52..932e1d72 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,39 +1,39 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.0.3) - actionpack (= 5.0.3) - nio4r (>= 1.2, < 3.0) + actioncable (5.1.1) + actionpack (= 5.1.1) + nio4r (~> 2.0) websocket-driver (~> 0.6.1) - actionmailer (5.0.3) - actionpack (= 5.0.3) - actionview (= 5.0.3) - activejob (= 5.0.3) + actionmailer (5.1.1) + actionpack (= 5.1.1) + actionview (= 5.1.1) + activejob (= 5.1.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.0.3) - actionview (= 5.0.3) - activesupport (= 5.0.3) + actionpack (5.1.1) + actionview (= 5.1.1) + activesupport (= 5.1.1) rack (~> 2.0) rack-test (~> 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.0.3) - activesupport (= 5.0.3) + actionview (5.1.1) + activesupport (= 5.1.1) builder (~> 3.1) - erubis (~> 2.7.0) + erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.0.3) - activesupport (= 5.0.3) + activejob (5.1.1) + activesupport (= 5.1.1) globalid (>= 0.3.6) - 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) + activemodel (5.1.1) + activesupport (= 5.1.1) + activerecord (5.1.1) + activemodel (= 5.1.1) + activesupport (= 5.1.1) + arel (~> 8.0) + activesupport (5.1.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) @@ -44,7 +44,7 @@ GEM public_suffix (~> 2.0, >= 2.0.2) airbrussh (1.2.0) sshkit (>= 1.6.1, != 1.7.0) - arel (7.1.4) + arel (8.0.0) bcrypt (3.1.11) bindex (0.5.0) bootstrap-kaminari-views (0.0.5) @@ -89,6 +89,7 @@ GEM dotenv-rails (2.2.1) dotenv (= 2.2.1) railties (>= 3.2, < 5.2) + erubi (1.6.0) erubis (2.7.0) execjs (2.7.0) factory_girl (4.8.0) @@ -166,17 +167,17 @@ GEM rack (2.0.3) rack-test (0.6.3) rack (>= 1.0) - rails (5.0.3) - actioncable (= 5.0.3) - actionmailer (= 5.0.3) - actionpack (= 5.0.3) - actionview (= 5.0.3) - activejob (= 5.0.3) - activemodel (= 5.0.3) - activerecord (= 5.0.3) - activesupport (= 5.0.3) + rails (5.1.1) + actioncable (= 5.1.1) + actionmailer (= 5.1.1) + actionpack (= 5.1.1) + actionview (= 5.1.1) + activejob (= 5.1.1) + activemodel (= 5.1.1) + activerecord (= 5.1.1) + activesupport (= 5.1.1) bundler (>= 1.3.0, < 2.0) - railties (= 5.0.3) + railties (= 5.1.1) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -186,9 +187,9 @@ GEM rails-i18n (5.0.4) i18n (~> 0.7) railties (~> 5.0) - railties (5.0.3) - actionpack (= 5.0.3) - activesupport (= 5.0.3) + railties (5.1.1) + actionpack (= 5.1.1) + activesupport (= 5.1.1) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) @@ -289,7 +290,7 @@ DEPENDENCIES paperclip pg puma (~> 3.0) - rails (= 5.0.3) + rails (= 5.1.1) rails-i18n (~> 5.0.0) redcarpet rspec-rails (~> 3.4) diff --git a/app/models/playlist.rb b/app/models/playlist.rb index e000342d..5f0848f4 100644 --- a/app/models/playlist.rb +++ b/app/models/playlist.rb @@ -25,7 +25,7 @@ class Playlist < ApplicationRecord validates_attachment :card, content_type: { content_type: /\Aimage\/.*\z/ } has_many :videos, -> { order(position: :asc) } - belongs_to :topic + belongs_to :topic, required: false def total_length videos.map { |v| v.duration }.reduce(0, :+) diff --git a/bin/setup b/bin/setup index e620b4da..78c4e861 100755 --- a/bin/setup +++ b/bin/setup @@ -18,6 +18,10 @@ chdir APP_ROOT do system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') # cp 'config/database.yml.sample', 'config/database.yml' diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 00000000..c2bacef8 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +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 diff --git a/config/application.rb b/config/application.rb index 8a6ead6a..bb45482b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -8,6 +8,9 @@ module Makigas 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. diff --git a/config/cable.yml b/config/cable.yml index 0bbde6f7..c08223c2 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -7,3 +7,4 @@ test: production: adapter: redis url: redis://localhost:6379/1 + channel_prefix: makigas_production diff --git a/config/environments/development.rb b/config/environments/development.rb index 3f3418f4..d1ccc695 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -18,7 +18,7 @@ config.cache_store = :memory_store config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=172800' + 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" } else config.action_controller.perform_caching = false @@ -28,6 +28,7 @@ # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + config.action_mailer.perform_caching = false config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } @@ -50,7 +51,6 @@ # 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 - + config.file_watcher = ActiveSupport::EventedFileUpdateChecker Paperclip.options[:command_path] = "/usr/local/bin/" end diff --git a/config/environments/production.rb b/config/environments/production.rb index 1b6ce1a7..66e17ad2 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,6 +14,11 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = 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.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? @@ -79,7 +84,7 @@ if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) + config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. diff --git a/config/environments/test.rb b/config/environments/test.rb index 006c1cad..4fc9260b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -15,7 +15,7 @@ # 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=3600' + 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" } # Show full error reports and disable caching. diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index d9e1f142..bb77deb7 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -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. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. Rails.application.config.assets.precompile += %w( dashboard/dashboard.css dashboard/dashboard.js ) diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb deleted file mode 100644 index f6e72335..00000000 --- a/config/initializers/new_framework_defaults.rb +++ /dev/null @@ -1,23 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 5.0 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Rails 5.0 release notes for more info on each option. - -# Enable per-form CSRF tokens. Previous versions had false. -Rails.application.config.action_controller.per_form_csrf_tokens = false - -# Enable origin-checking CSRF mitigation. Previous versions had false. -Rails.application.config.action_controller.forgery_protection_origin_check = false - -# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. -# Previous versions had false. -ActiveSupport.to_time_preserves_timezone = false - -# Require `belongs_to` associations by default. Previous versions had false. -Rails.application.config.active_record.belongs_to_required_by_default = false - -# Do not halt callback chains when a callback returns false. Previous versions had true. -ActiveSupport.halt_callback_chains_on_return_false = true diff --git a/config/locales/en.yml b/config/locales/en.yml index 06539571..decc5a85 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -16,6 +16,16 @@ # # This would use the information in config/locales/es.yml. # +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# # To learn more, please read the Rails Internationalization guide # available at http://guides.rubyonrails.org/i18n.html. diff --git a/config/puma.rb b/config/puma.rb index af3c36d9..ac8b7a8b 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,16 +1,60 @@ -workers ENV.fetch("WEB_CONCURRENCY") { 2 } -threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i +# 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 preload_app! +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } -port ENV.fetch("PORT") { 3000 } -environment ENV.fetch("RAILS_ENV") { 'development' } +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } bind 'unix://tmp/sockets/puma.sock' pidfile 'tmp/pids/puma.pid' state_path 'tmp/pids/puma.state' +# 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 } -on_worker_boot do - ActiveRecord::Base.establish_connection -end \ No newline at end of file +# 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 diff --git a/config/routes.rb b/config/routes.rb index c71e991b..92c0de68 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html devise_for :users, controllers: { sessions: 'users/sessions', passwords: 'users/passwords' diff --git a/config/secrets.yml b/config/secrets.yml index 75ab7f28..690f9e3f 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -5,19 +5,29 @@ # 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: 1e8a4cca01a58ab35d8817afadd5021e074916cf50d5421ebc52bff8363c7cd3460d2568edc6e60f1802652bb9e65a988abba2a3446bcca17c09f9911946287d + secret_key_base: 4286070ac3ad69be6836eb7722800b9433bb1048e2de0caab5ae80aa99938ad230f1c3410f5f73594eaf43d3df7a89a35c75a6a5380d09199d70a17ae2336ba1 test: - secret_key_base: e7142a718c21b0f391ebe8290ab1a7f5e32bb48ad1fc6079cc0f7afd69893a45655e28b9819f1499557d888956e1537abc892b59e813024075ffa0a3622a1d0f + secret_key_base: cbbbf582e854f7504fc5f3eb30b2d039e4cfe85178b6c5dbc107388de2f3a9e252e5b7c70376c1dc362e0bb85491dfad40a3b078a65bda3da33bd8dd5ac3d5f4 + +# 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"] %> analytics_key: <%= ENV["GOOGLE_ANALYTICS_KEY"] %> diff --git a/spec/helpers/dashboard/opinions_helper_spec.rb b/spec/helpers/dashboard/opinions_helper_spec.rb deleted file mode 100644 index a907c1e2..00000000 --- a/spec/helpers/dashboard/opinions_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the Dashboard::OpinionsHelper. For example: -# -# describe Dashboard::OpinionsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe Dashboard::OpinionsHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end