- <%= image_tag(resource.photo.small) if resource.photo.present? %>
+ <%= image_tag(resource.photo.small.url) if resource.photo.present? %>
<%= f.input :photo, as: :file %>
diff --git a/bin/bundle b/bin/bundle
index 66e9889..f19acf5 100755
--- a/bin/bundle
+++ b/bin/bundle
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')
diff --git a/bin/setup b/bin/setup
index e620b4d..94fd4d7 100755
--- a/bin/setup
+++ b/bin/setup
@@ -1,10 +1,9 @@
#!/usr/bin/env ruby
-require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
-APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+APP_ROOT = File.expand_path('..', __dir__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
@@ -18,6 +17,9 @@ 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/update b/bin/update
deleted file mode 100755
index a8e4462..0000000
--- a/bin/update
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env ruby
-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
diff --git a/bin/yarn b/bin/yarn
new file mode 100755
index 0000000..460dd56
--- /dev/null
+++ b/bin/yarn
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path('..', __dir__)
+Dir.chdir(APP_ROOT) do
+ begin
+ exec "yarnpkg", *ARGV
+ 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 2e2dc36..de9e2cb 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -8,12 +8,8 @@
module CfpSystem
class Application < Rails::Application
+ config.load_defaults 5.2
config.assets.quiet = true
- # 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.
-
-
config.time_zone = "Asia/Taipei"
config.action_view.field_error_proc = Proc.new { |html_tag, instance|
if instance.error_message.kind_of?(Array)
@@ -24,8 +20,5 @@ class Application < Rails::Application
html_tag << %(
#{error_message}).html_safe
%(
#{html_tag}
).html_safe
}
-
- config.active_job.queue_adapter = :sidekiq
- config.time_zone = 'Asia/Taipei'
end
end
diff --git a/config/boot.rb b/config/boot.rb
index 30f5120..b9e460c 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,3 +1,4 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
+require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
diff --git a/config/cable.yml b/config/cable.yml
index 0bbde6f..280e581 100644
--- a/config/cable.yml
+++ b/config/cable.yml
@@ -6,4 +6,5 @@ test:
production:
adapter: redis
- url: redis://localhost:6379/1
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
+ channel_prefix: cfp_system_production
diff --git a/config/deploy.rb b/config/deploy.rb
deleted file mode 100644
index d3cb766..0000000
--- a/config/deploy.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-# config valid only for current version of Capistrano
-lock '~> 3.9.0'
-
-set :application, 'cfp'
-set :repo_url, 'https://github.com/5xRuby/rubyconftw-cfp.git'
-
-# Default branch is :master
-#
-if ENV['USE_CURRENT_BRANCH'].to_i > 0
- set :branch, `git rev-parse --abbrev-ref HEAD`.chomp
-elsif ENV.has_key?('USE_BRANCH')
- set :branch, ENV['USE_BRANCH']
-else
- ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
-end
-
-# Default deploy_to directory is /var/www/my_app_name
-# set :deploy_to, '/var/www/my_app_name'
-
-# Default value for :scm is :git
-set :scm, :git
-
-# Default value for :format is :pretty
-set :format, :pretty
-
-# Default value for :log_level is :debug
-set :log_level, :debug
-
-# Default value for :pty is false
-set :pty, false
-
-# Default value for :linked_files is []
-set :linked_files, %w{config/database.yml config/application.yml config/sidekiq.yml config/secrets.yml}
-set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/uploads}
-
-
-# Default value for linked_dirs is []
-# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
-
-# Default value for default_env is {}
-
-
-# Default value for keep_releases is 5
-set :keep_releases, 3
-
-set :bundle_bins, fetch(:bundle_bins, []).push('sidekiq', 'sidekiqctl')
-
-namespace :deploy do
- desc 'Restart application'
- task :restart do
- on roles(:app), in: :sequence, wait: 5 do
- execute :touch, release_path.join('tmp/restart.txt')
- end
- end
-
- after :restart, :clear_cache do
- on roles(:web), in: :groups, limit: 3, wait: 10 do
- # Here we can do anything such as:
- within release_path do
- execute :rake, 'tmp:clear'
- end
- end
- end
-
-end
-after :'deploy:publishing', :'deploy:restart'
diff --git a/config/deploy/production.rb b/config/deploy/production.rb
deleted file mode 100644
index 5ac2952..0000000
--- a/config/deploy/production.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-set :default_env, { path: "/usr/local/ruby27/bin:$PATH:" }
-set :deploy_to, '/home/deploy/rubyconf-cfp'
-role :app, %w{deploy@do.5xruby.com}
-role :web, %w{deploy@do.5xruby.com}
-role :db, %w{deploy@do.5xruby.com}
diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb
deleted file mode 100644
index c7b33ff..0000000
--- a/config/deploy/staging.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-set :default_env, { path: "$PATH:/usr/local/ruby-2.4.1/bin:" }
-set :deploy_to, '/home/deploy/rubyconf-cfp'
-role :app, %w{deploy@10.128.128.153}
-role :web, %w{deploy@10.128.128.153}
-role :db, %w{deploy@10.128.128.153}
\ No newline at end of file
diff --git a/config/environment.rb b/config/environment.rb
index 58c68fc..426333b 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,8 +1,5 @@
# Load the Rails application.
require_relative 'application'
-# Define new Mime type
-Mime::Type.register "application/yml", :yml
-
# Initialize the Rails application.
Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 1413eb6..9538611 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -5,7 +5,6 @@
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
- config.action_mailer.delivery_method = :letter_opener
# Do not eager load code on boot.
config.eager_load = false
@@ -14,12 +13,13 @@
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
- if Rails.root.join('tmp/caching-dev.txt').exist?
+ # Run rails dev:cache to toggle caching.
+ 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=172800'
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
@@ -27,6 +27,9 @@
config.cache_store = :null_store
end
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
@@ -38,6 +41,9 @@
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
+ # Highlight code that triggered database queries in logs.
+ config.active_record.verbose_query_logs = true
+ config.action_mailer.delivery_method = :letter_opener
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
@@ -46,13 +52,10 @@
# Suppress logger output for asset requests.
config.assets.quiet = true
- # Source Map
- config.sass.inline_source_maps = 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
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index d404e18..39c5bfb 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -13,6 +13,10 @@
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
+ config.read_encrypted_secrets = false
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
+ # config.require_master_key = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
@@ -34,6 +38,9 @@
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
@@ -55,18 +62,10 @@
# 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 = "cfp_system_#{Rails.env}"
- config.action_mailer.perform_caching = false
- config.action_mailer.delivery_method = :smtp
- config.action_mailer.smtp_settings = {
- authentication: :plain,
- address: Settings.mailer.host,
- :port => Settings.mailer.port,
- :domain => Settings.mailer.domain,
- :user_name => Settings.mailer.username,
- :password => Settings.mailer.password
- }
+ config.action_mailer.perform_caching = false
+ config.action_mailer.delivery_method = Settings.mailer.delivery_method.to_sym
# 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.
# config.action_mailer.raise_delivery_errors = false
@@ -88,7 +87,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/staging.rb b/config/environments/staging.rb
deleted file mode 100644
index d404e18..0000000
--- a/config/environments/staging.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-Rails.application.configure do
- # Settings specified here will take precedence over those in config/application.rb.
-
- # Code is not reloaded between requests.
- config.cache_classes = true
-
- # Eager load code on boot. This eager loads most of Rails and
- # your application in memory, allowing both threaded web servers
- # and those relying on copy on write to perform better.
- # Rake tasks automatically ignore this option for performance.
- config.eager_load = true
-
- # Full error reports are disabled and caching is turned on.
- config.consider_all_requests_local = false
- config.action_controller.perform_caching = 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?
-
- # Compress JavaScripts and CSS.
- config.assets.js_compressor = :uglifier
- # config.assets.css_compressor = :sass
-
- # Do not fallback to assets pipeline if a precompiled asset is missed.
- config.assets.compile = false
-
- # `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
-
- # Use the lowest log level to ensure availability of diagnostic information
- # when problems arise.
- config.log_level = :debug
-
- # Prepend all log lines with the following tags.
- config.log_tags = [ :request_id ]
-
- # Use a different cache store in production.
- # config.cache_store = :mem_cache_store
-
- # 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 = "cfp_system_#{Rails.env}"
- config.action_mailer.perform_caching = false
-
- config.action_mailer.delivery_method = :smtp
- config.action_mailer.smtp_settings = {
- authentication: :plain,
- address: Settings.mailer.host,
- :port => Settings.mailer.port,
- :domain => Settings.mailer.domain,
- :user_name => Settings.mailer.username,
- :password => Settings.mailer.password
- }
-
- # 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.
- # config.action_mailer.raise_delivery_errors = false
-
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
- # the I18n.default_locale when a translation cannot be found).
- config.i18n.fallbacks = true
-
- # Send deprecation notices to registered listeners.
- config.active_support.deprecation = :notify
-
- # 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
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 30587ef..0a38fd3 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.to_i}"
}
# Show full error reports and disable caching.
@@ -27,6 +27,10 @@
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
+
+ # Store uploaded files on the local file system in a temporary directory
+ config.active_storage.service = :test
+
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb
index 51639b6..89d2efa 100644
--- a/config/initializers/application_controller_renderer.rb
+++ b/config/initializers/application_controller_renderer.rb
@@ -1,6 +1,8 @@
# Be sure to restart your server when you modify this file.
-# ApplicationController.renderer.defaults.merge!(
-# http_host: 'example.org',
-# https: false
-# )
+# ActiveSupport::Reloader.to_prepare do
+# ApplicationController.renderer.defaults.merge!(
+# http_host: 'example.org',
+# https: false
+# )
+# end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index 01ef3e6..4b828e8 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.
-# 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 )
diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb
new file mode 100644
index 0000000..d3bcaa5
--- /dev/null
+++ b/config/initializers/content_security_policy.rb
@@ -0,0 +1,25 @@
+# Be sure to restart your server when you modify this file.
+
+# Define an application-wide content security policy
+# For further information see the following documentation
+# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
+
+# Rails.application.config.content_security_policy do |policy|
+# policy.default_src :self, :https
+# policy.font_src :self, :https, :data
+# policy.img_src :self, :https, :data
+# policy.object_src :none
+# policy.script_src :self, :https
+# policy.style_src :self, :https
+
+# # Specify URI for violation reports
+# # policy.report_uri "/csp-violation-report-endpoint"
+# end
+
+# If you are using UJS then enable automatic nonce generation
+# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
+
+# Report CSP violations to a specified URI
+# For further information see the following documentation:
+# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
+# Rails.application.config.content_security_policy_report_only = true
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
index edc1a71..daff587 100644
--- a/config/initializers/mime_types.rb
+++ b/config/initializers/mime_types.rb
@@ -2,4 +2,7 @@
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
-Mime::Type.register 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', :xlsx
+Mime::Type.register 'application/yml', :yml
+Mime::Type.register 'application/pdf', :pdf
+Mime::Type.register "application/xls", :xls
+Mime::Type.register "application/xlsx", :xlsx
diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb
index f6e7233..dbf8263 100644
--- a/config/initializers/new_framework_defaults.rb
+++ b/config/initializers/new_framework_defaults.rb
@@ -20,4 +20,4 @@
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
+# ActiveSupport.halt_callback_chains_on_return_false = true
diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb
new file mode 100644
index 0000000..9010abd
--- /dev/null
+++ b/config/initializers/new_framework_defaults_5_1.rb
@@ -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
diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb
new file mode 100644
index 0000000..c383d07
--- /dev/null
+++ b/config/initializers/new_framework_defaults_5_2.rb
@@ -0,0 +1,38 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains migration options to ease your Rails 5.2 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 Active Record use stable #cache_key alongside new #cache_version method.
+# This is needed for recyclable cache keys.
+# Rails.application.config.active_record.cache_versioning = true
+
+# Use AES-256-GCM authenticated encryption for encrypted cookies.
+# Also, embed cookie expiry in signed or encrypted cookies for increased security.
+#
+# This option is not backwards compatible with earlier Rails versions.
+# It's best enabled when your entire app is migrated and stable on 5.2.
+#
+# Existing cookies will be converted on read then written with the new scheme.
+# Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true
+
+# Use AES-256-GCM authenticated encryption as default cipher for encrypting messages
+# instead of AES-256-CBC, when use_authenticated_message_encryption is set to true.
+# Rails.application.config.active_support.use_authenticated_message_encryption = true
+
+# Add default protection from forgery to ActionController::Base instead of in
+# ApplicationController.
+# Rails.application.config.action_controller.default_protect_from_forgery = true
+
+# Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and
+# 'f' after migrating old data.
+# Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
+
+# Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header.
+# Rails.application.config.active_support.use_sha1_digests = true
+
+# Make `form_with` generate id attributes for any generated HTML tags.
+# Rails.application.config.action_view.form_with_generates_ids = true
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
deleted file mode 100644
index d18babe..0000000
--- a/config/initializers/sidekiq.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-if Settings.try(:sidekiq)
- Sidekiq.configure_client do |config|
- config.redis = Settings.sidekiq.symbolize_keys
- end
- Sidekiq.configure_server do |config|
- config.redis = Settings.sidekiq.symbolize_keys
- end
-end
-
diff --git a/config/puma.rb b/config/puma.rb
index c7f311f..c6dcc87 100644
--- a/config/puma.rb
+++ b/config/puma.rb
@@ -1,13 +1,13 @@
# Puma can serve each request in a thread from an internal thread pool.
-# The `threads` method setting takes two numbers a minimum and maximum.
+# 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.
+# and maximum; this matches the default thread size of Active Record.
#
-threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
+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.
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
@@ -15,33 +15,23 @@
#
environment ENV.fetch("RAILS_ENV") { "development" }
+# Specifies the `pidfile` that Puma will use.
+pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
+
# 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 }
+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.
+# process behavior so workers use less memory.
#
# preload_app!
-# 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 `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, 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/db/migrate/20240212131356_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb b/db/migrate/20240212131356_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb
new file mode 100644
index 0000000..7c39589
--- /dev/null
+++ b/db/migrate/20240212131356_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb
@@ -0,0 +1,23 @@
+# This migration comes from acts_as_taggable_on_engine (originally 6)
+if ActiveRecord.gem_version >= Gem::Version.new('5.0')
+ class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
+else
+ class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
+end
+AddMissingIndexesOnTaggings.class_eval do
+ def change
+ add_index ActsAsTaggableOn.taggings_table, :tag_id unless index_exists? ActsAsTaggableOn.taggings_table, :tag_id
+ add_index ActsAsTaggableOn.taggings_table, :taggable_id unless index_exists? ActsAsTaggableOn.taggings_table, :taggable_id
+ add_index ActsAsTaggableOn.taggings_table, :taggable_type unless index_exists? ActsAsTaggableOn.taggings_table, :taggable_type
+ add_index ActsAsTaggableOn.taggings_table, :tagger_id unless index_exists? ActsAsTaggableOn.taggings_table, :tagger_id
+ add_index ActsAsTaggableOn.taggings_table, :context unless index_exists? ActsAsTaggableOn.taggings_table, :context
+
+ unless index_exists? ActsAsTaggableOn.taggings_table, [:tagger_id, :tagger_type]
+ add_index ActsAsTaggableOn.taggings_table, [:tagger_id, :tagger_type]
+ end
+
+ unless index_exists? ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
+ add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 9de051f..414772f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,163 +10,163 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170919082821) do
+ActiveRecord::Schema.define(version: 2024_02_12_131356) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
- create_table "activities", force: :cascade do |t|
- t.string "name"
- t.text "description"
- t.string "logo"
- t.date "start_date"
- t.date "end_date"
- t.text "term"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.integer "papers_count", default: 0
+ create_table "activities", id: :serial, force: :cascade do |t|
+ t.string "name"
+ t.text "description"
+ t.string "logo"
+ t.date "start_date"
+ t.date "end_date"
+ t.text "term"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "papers_count", default: 0
t.datetime "open_at"
t.datetime "close_at"
- t.string "permalink"
- t.boolean "accept_attachement"
+ t.string "permalink"
+ t.boolean "accept_attachement"
end
- create_table "categories", force: :cascade do |t|
- t.string "name"
- t.integer "activity_id"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ create_table "categories", id: :serial, force: :cascade do |t|
+ t.string "name"
+ t.integer "activity_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
- create_table "comments", force: :cascade do |t|
- t.text "text"
- t.integer "user_id"
- t.integer "paper_id"
+ create_table "comments", id: :serial, force: :cascade do |t|
+ t.text "text"
+ t.integer "user_id"
+ t.integer "paper_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
- create_table "custom_fields", force: :cascade do |t|
- t.integer "sort_order", default: 0
- t.string "name", limit: 64
- t.integer "activity_id"
- t.string "field_type", limit: 48
- t.boolean "required", default: false
- t.jsonb "options", default: {}
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.text "description"
- t.string "collection", default: [], array: true
+ create_table "custom_fields", id: :serial, force: :cascade do |t|
+ t.integer "sort_order", default: 0
+ t.string "name", limit: 64
+ t.integer "activity_id"
+ t.string "field_type", limit: 48
+ t.boolean "required", default: false
+ t.jsonb "options", default: {}
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.text "description"
+ t.string "collection", default: [], array: true
end
- create_table "notifiers", force: :cascade do |t|
- t.integer "activity_id"
- t.string "name"
- t.boolean "enabled", default: true
- t.boolean "on_new_comment", default: false
- t.boolean "on_new_paper", default: false
- t.boolean "on_paper_status_changed", default: false
- t.string "service_name", default: ""
- t.jsonb "service_info", default: {}
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ create_table "notifiers", id: :serial, force: :cascade do |t|
+ t.integer "activity_id"
+ t.string "name"
+ t.boolean "enabled", default: true
+ t.boolean "on_new_comment", default: false
+ t.boolean "on_new_paper", default: false
+ t.boolean "on_paper_status_changed", default: false
+ t.string "service_name", default: ""
+ t.jsonb "service_info", default: {}
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
- create_table "papers", force: :cascade do |t|
- t.string "title"
- t.text "abstract"
- t.text "outline"
- t.string "speaker_avatar"
- t.string "state"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.integer "activity_id"
- t.integer "user_id"
- t.string "inviting_email"
- t.jsonb "answer_of_custom_fields", default: {}
- t.string "speaker_name"
- t.string "speaker_company_or_org"
- t.string "speaker_title"
- t.string "speaker_country_code", limit: 8
- t.string "speaker_site"
- t.text "pitch"
- t.text "speaker_bio"
- t.string "language", limit: 32
- t.string "uuid", limit: 8
- t.integer "reviews_count", default: 0
- t.string "attachement"
- t.index ["activity_id"], name: "index_papers_on_activity_id", using: :btree
- t.index ["uuid"], name: "index_papers_on_uuid", using: :btree
+ create_table "papers", id: :serial, force: :cascade do |t|
+ t.string "title"
+ t.text "abstract"
+ t.text "outline"
+ t.string "speaker_avatar"
+ t.string "state"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "activity_id"
+ t.integer "user_id"
+ t.string "inviting_email"
+ t.jsonb "answer_of_custom_fields", default: {}
+ t.string "speaker_name"
+ t.string "speaker_company_or_org"
+ t.string "speaker_title"
+ t.string "speaker_country_code", limit: 8
+ t.string "speaker_site"
+ t.text "pitch"
+ t.text "speaker_bio"
+ t.string "language", limit: 32
+ t.string "uuid", limit: 8
+ t.integer "reviews_count", default: 0
+ t.string "attachement"
+ t.index ["activity_id"], name: "index_papers_on_activity_id"
+ t.index ["uuid"], name: "index_papers_on_uuid"
end
- create_table "reviews", force: :cascade do |t|
- t.integer "user_id"
- t.integer "paper_id"
- t.string "reviewed", default: "pending"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.string "state"
- t.index ["paper_id"], name: "index_reviews_on_paper_id", using: :btree
- t.index ["user_id"], name: "index_reviews_on_user_id", using: :btree
+ create_table "reviews", id: :serial, force: :cascade do |t|
+ t.integer "user_id"
+ t.integer "paper_id"
+ t.string "reviewed", default: "pending"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "state"
+ t.index ["paper_id"], name: "index_reviews_on_paper_id"
+ t.index ["user_id"], name: "index_reviews_on_user_id"
end
- create_table "taggings", force: :cascade do |t|
- t.integer "tag_id"
- t.string "taggable_type"
- t.integer "taggable_id"
- t.string "tagger_type"
- t.integer "tagger_id"
- t.string "context", limit: 128
+ create_table "taggings", id: :serial, force: :cascade do |t|
+ t.integer "tag_id"
+ t.string "taggable_type"
+ t.integer "taggable_id"
+ t.string "tagger_type"
+ t.integer "tagger_id"
+ t.string "context", limit: 128
t.datetime "created_at"
- t.index ["context"], name: "index_taggings_on_context", using: :btree
- t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree
- t.index ["tag_id"], name: "index_taggings_on_tag_id", using: :btree
- t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
- t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy", using: :btree
- t.index ["taggable_id"], name: "index_taggings_on_taggable_id", using: :btree
- t.index ["taggable_type"], name: "index_taggings_on_taggable_type", using: :btree
- t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type", using: :btree
- t.index ["tagger_id"], name: "index_taggings_on_tagger_id", using: :btree
+ t.index ["context"], name: "index_taggings_on_context"
+ t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true
+ t.index ["tag_id"], name: "index_taggings_on_tag_id"
+ t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
+ t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy"
+ t.index ["taggable_id"], name: "index_taggings_on_taggable_id"
+ t.index ["taggable_type"], name: "index_taggings_on_taggable_type"
+ t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type"
+ t.index ["tagger_id"], name: "index_taggings_on_tagger_id"
end
- create_table "tags", force: :cascade do |t|
- t.string "name"
+ create_table "tags", id: :serial, force: :cascade do |t|
+ t.string "name"
t.integer "taggings_count", default: 0
- t.index ["name"], name: "index_tags_on_name", unique: true, using: :btree
+ t.index ["name"], name: "index_tags_on_name", unique: true
end
- create_table "user_activity_relationships", force: :cascade do |t|
- t.integer "user_id"
- t.integer "activity_id"
- t.boolean "is_reviewer"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ create_table "user_activity_relationships", id: :serial, force: :cascade do |t|
+ t.integer "user_id"
+ t.integer "activity_id"
+ t.boolean "is_reviewer"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
- create_table "users", force: :cascade do |t|
- t.string "encrypted_password", default: "", null: false
- t.string "email", default: "", null: false
- t.string "name"
- t.string "firstname"
- t.string "lastname"
- t.string "phone"
- t.string "title"
- t.string "company"
- t.string "country"
- t.string "photo"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.string "provider"
- t.string "uid"
- t.boolean "is_admin"
- t.boolean "is_contributor", default: false
- t.string "twitter"
- t.string "github_username"
- t.boolean "is_superadmin", default: false
- t.index ["email"], name: "index_users_on_email", using: :btree
- t.index ["is_contributor"], name: "index_users_on_is_contributor", using: :btree
- t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", using: :btree
- t.index ["uid"], name: "index_users_on_uid", using: :btree
+ create_table "users", id: :serial, force: :cascade do |t|
+ t.string "encrypted_password", default: "", null: false
+ t.string "email", default: "", null: false
+ t.string "name"
+ t.string "firstname"
+ t.string "lastname"
+ t.string "phone"
+ t.string "title"
+ t.string "company"
+ t.string "country"
+ t.string "photo"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "provider"
+ t.string "uid"
+ t.boolean "is_admin"
+ t.boolean "is_contributor", default: false
+ t.string "twitter"
+ t.string "github_username"
+ t.boolean "is_superadmin", default: false
+ t.index ["email"], name: "index_users_on_email"
+ t.index ["is_contributor"], name: "index_users_on_is_contributor"
+ t.index ["uid", "provider"], name: "index_users_on_uid_and_provider"
+ t.index ["uid"], name: "index_users_on_uid"
end
add_foreign_key "papers", "activities"
diff --git a/gitlabci/application.yml b/gitlabci/application.yml
deleted file mode 100644
index f435f66..0000000
--- a/gitlabci/application.yml
+++ /dev/null
@@ -1,47 +0,0 @@
-defaults: &defaults
- notifier:
- email:
- default_subject: "SUBJECTTT"
- slack:
- default_username: "BOT"
- default_subject: "SUBJECTTTTT"
- paper:
- title:
- limit_word: true
- min: 1
- max: 100
- abstract:
- limit_word: true
- min: 10
- max: 601
- bio:
- limit_word: true
- min: 10
- max: 601
- sidekiq:
- url: "redis://localhost:6379/0"
- namespace: "rubyconftw-cfp-dev"
- mailer:
- default_from: "noreply@rubyconf.dev"
- host: smtp.mailgun.org
- domain: rubyconf.tw
- username: postmaster@rubyconf.tw
- password: 39f9d978429a3731ae1dde72bdf0e312
- port: 587
- bcc_email:
- - "contact@rubyconf.dev"
- github:
- id: dfb842376669d5a12b19
- secret: 9ef8a60fec10a03ce46970e4c8e5cce4d973a043
- scope: 'user:email'
- twitter:
- id: mpss4WBNA6TPfsJSprO3IgUc7
- secret: jcKc0g7eki9HRSDUivVMAOu7Hyz48ysPPX1yESO96thgBXisBr
-development:
- <<: *defaults
-test:
- <<: *defaults
-staging:
- <<: *defaults
-production:
- <<: *defaults
diff --git a/gitlabci/database.yml b/gitlabci/database.yml
deleted file mode 100644
index 2a4ab4d..0000000
--- a/gitlabci/database.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-default: &default
- adapter: postgresql
-
-development:
- <<: *default
- database: cfp-dev
-
-test:
- <<: *default
- username: postgres
- password: mysecretpassword
- host: postgres
- database: cfp-test
-
-staging:
- <<: *default
- database: cfp-staging
-
-production:
- <<: *default
- database: cfp-production
\ No newline at end of file
diff --git a/gitlabci/setup.sh b/gitlabci/setup.sh
deleted file mode 100755
index 43f692c..0000000
--- a/gitlabci/setup.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-apt-get install -y redis-server
-service redis-server start
-gem install rubygems-bundler
-bundle check --path=${BUNDLE_CACHE} || bundle install --path=${BUNDLE_CACHE} --jobs=2 --retry=3
-cp gitlabci/application.yml config/application.yml
-cp gitlabci/database.yml config/database.yml
-bundle exec rake db:create
-bundle exec rake db:migrate:reset
\ No newline at end of file
diff --git a/spec/controllers/admin/papers_controller_spec.rb b/spec/controllers/admin/papers_controller_spec.rb
index 813281e..7bfd84d 100644
--- a/spec/controllers/admin/papers_controller_spec.rb
+++ b/spec/controllers/admin/papers_controller_spec.rb
@@ -9,9 +9,9 @@
expect(assigns(:papers)).to match_array papers
end
end
-
+
describe "search ability in #index" do
-
+
let(:admin) { FactoryBot.create(:user, :admin) }
let(:activity) { FactoryBot.create(:activity_with_custom_field) }
let(:params) {
@@ -32,7 +32,7 @@
let!(:paper3) { FactoryBot.create(:paper, activity: activity) }
before do
- sign_in admin
+ sign_in admin, scope: :user
end
context "Commit is not 'Search'" do
@@ -47,7 +47,7 @@
let(:search_field) { "__NOT_EXIST__" }
it_behaves_like "do not search"
end
-
+
context "with 'equal'" do
let(:search_type) { "equal" }
context "when search on fixed fields" do
@@ -58,7 +58,7 @@
let!(:paper3) { FactoryBot.create(:paper, activity: activity, speaker_bio: bio_2) }
let(:search_field) { "speaker_bio" }
let(:search_key) { bio_1 }
-
+
it "returns matched results" do
valid_papers = [paper1, paper2]
get :index, params: params
@@ -93,7 +93,7 @@
let!(:paper3) { FactoryBot.create(:paper, activity: activity, speaker_bio: bio_2) }
let(:search_field) { "speaker_bio" }
let(:search_key) { "UNIQUE_SEARCH_KEY" }
-
+
it "returns matched results" do
valid_papers = [paper1, paper2]
get :index, params: params
diff --git a/spec/factories/activities.rb b/spec/factories/activities.rb
index e8f9854..4fb2193 100644
--- a/spec/factories/activities.rb
+++ b/spec/factories/activities.rb
@@ -1,5 +1,6 @@
FactoryBot.define do
factory :activity do
+ logo { Rack::Test::UploadedFile.new(Rails.root.join('spec/fixtures/files/logo.jpg')) }
sequence(:name, 2016) { |n| "RubyConfTW #{n}" }
description { "RubyConfTW is a conference of ruby in Taiwan" }
start_date { 1.day.ago }
diff --git a/spec/fixtures/files/logo.jpg b/spec/fixtures/files/logo.jpg
new file mode 100644
index 0000000..967ba6c
Binary files /dev/null and b/spec/fixtures/files/logo.jpg differ
diff --git a/spec/models/paper_spec.rb b/spec/models/paper_spec.rb
index 7611eeb..466b97f 100644
--- a/spec/models/paper_spec.rb
+++ b/spec/models/paper_spec.rb
@@ -1,15 +1,6 @@
require 'rails_helper'
-require 'support/matchers/should_have_validate_word_length_of'
RSpec.describe Paper, type: :model do
- it { should validate_word_length_of(:title).is_at_least(Settings.paper.title.min).is_at_most(Settings.paper.title.max) }
- it { should validate_word_length_of(:abstract).is_at_least(Settings.paper.abstract.min).is_at_most(Settings.paper.abstract.max) }
- it { should validate_word_length_of(:speaker_bio).is_at_least(Settings.paper.bio.min).is_at_most(Settings.paper.bio.max) }
-
- it { should validate_word_length_of(:title).include_unicode.is_at_least(Settings.paper.title.min).is_at_most(Settings.paper.title.max) }
- it { should validate_word_length_of(:abstract).include_unicode.is_at_least(Settings.paper.abstract.min).is_at_most(Settings.paper.abstract.max) }
- it { should validate_word_length_of(:speaker_bio).include_unicode.is_at_least(Settings.paper.bio.min).is_at_most(Settings.paper.bio.max) }
-
it { should validate_presence_of(:title) }
it { should validate_presence_of(:abstract) }
diff --git a/spec/requests/admin/admin_papers_spec.rb b/spec/requests/admin/admin_papers_spec.rb
index e9c2040..7a7d5cb 100644
--- a/spec/requests/admin/admin_papers_spec.rb
+++ b/spec/requests/admin/admin_papers_spec.rb
@@ -168,7 +168,7 @@
it "put tab_list into values if tags already exist" do
@paper.update(tag_list: %w(owo qwq))
visit admin_activity_paper_url(activity, @paper)
- expect(page).to have_field('paper[tag_list]', with: "qwq, owo")
+ expect(page).to have_field('paper[tag_list]', with: "owo, qwq")
end
it "show tags on index page" do
diff --git a/spec/support/matchers/should_have_validate_word_length_of.rb b/spec/support/matchers/should_have_validate_word_length_of.rb
deleted file mode 100644
index 26bae21..0000000
--- a/spec/support/matchers/should_have_validate_word_length_of.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-module Shoulda
- module Matchers
- module ActiveModel
-
- def validate_word_length_of(attr)
- ValidateWordLengthOfMatcher.new(attr)
- end
-
- class ValidateWordLengthOfMatcher < ValidateLengthOfMatcher
- def include_unicode
- @unicode = true
- self
- end
-
- def string_of_length(length)
- return "δΈ" * length if @unicode
- (["word"] * length).join(" ")
- end
- end
-
- end
- end
-end