diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d447f4a..cc76af2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,7 @@ name: CI on: - push + jobs: test: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 759d2f78..e5da7ffc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,52 @@ +# Ignore application configuration /config/action_mailer.yml /config/code_ocean.yml +/config/content_security_policy.yml /config/database.yml +/config/docker.yml.erb /config/mnemosyne.yml /config/secrets.yml -/config/docker.yml.erb -/config/content_security_policy.yml +/config/settings.local.yml +/config/settings/*.local.yml +/config/environments/*.local.yml + +# Ignore temporary files /coverage -/log/*.* -/public/assets -/public/uploads +/log /rubocop.html /tmp -/vagrant/ -/.capistrano -/.vagrant -*.sublime-* -/.idea -/.vagrant -*.iml *.DS_Store + +## Ignore editor-specific artifacts +# Vagrant +/.vagrant +/vagrant +# Sublime +*.sublime-* +# IntelliJ +/.idea +*.iml + +## Environment normalisation: +/.bundle +/vendor/bundle + +# Ignore Byebug command history file. +.byebug_history + +# Ignore node_modules +node_modules/ + +# Ignore precompiled javascript packs /public/packs /public/packs-test -/node_modules +/public/assets + +# Ignore yarn files /yarn-error.log yarn-debug.log* .yarn-integrity + +# Ignore uploaded files in development +/storage +/public/uploads diff --git a/.rubocop/rspec.yml b/.rubocop/rspec.yml index 04226fd4..7df2d7d3 100644 --- a/.rubocop/rspec.yml +++ b/.rubocop/rspec.yml @@ -15,6 +15,7 @@ RSpec/DescribeClass: Enabled: false Exclude: - "spec/views/**/*_spec.rb" + - "spec/custom_matchers/*" RSpec/ExampleLength: Enabled: false diff --git a/Gemfile b/Gemfile index d0d32108..cea2e5c7 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,7 @@ source 'https://rubygems.org' gem 'bcrypt' +gem 'bootsnap', require: false gem 'bootstrap-will_paginate' gem 'carrierwave' gem 'charlock_holmes', require: 'charlock_holmes/string' @@ -66,7 +67,6 @@ end group :development, :staging do gem 'better_errors' gem 'binding_of_caller' - gem 'bootsnap', require: false gem 'letter_opener' gem 'listen' gem 'pry-byebug' diff --git a/README.md b/README.md index ca440f64..396de3e8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -CodeOcean -========== +# CodeOcean [![Build Status](https://github.com/openHPI/codeocean/workflows/CI/badge.svg)](https://github.com/openHPI/codeocean/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/openHPI/codeocean/branch/master/graph/badge.svg?token=imei686C2r)](https://codecov.io/gh/openHPI/codeocean) @@ -39,14 +38,12 @@ In order to execute code submissions using the [DockerContainerPool](https://git - is always writeable by the user executing the web server (in this case the `codeocean` user): `setfacl -Rdm user:codeocean:rwx /var/www/app/current/tmp/files`. ### Optional Steps - -- Use Docker Machine or vagrant if there is no native support for docker on your OS -- If you want to use the app without docker (and hence without code execution) comment the validation `validate :working_docker_image?` in `models/execution_environments.rb` otherwise the seed will fail (because of missing docker connection) -- Create seed data by executing `rake db:seed` +- Use Docker Machine or Vagrant if there is no native support for Docker on your OS +- If you want to use the app without Docker or a Runner management (and hence without code execution), comment the validation `validate :working_docker_image?` in `models/execution_environments.rb`. Otherwise the seed will fail. +- Create seed data by executing `rails db:seed` - If you already created a configuration for your local installation and want to use vagrant, too, be sure to log into the vagrant instance via ssh and add your database user manually to the database. Afterwards, create, migrate and seed. ## Production Setup - - We recommend using [Capistrano](https://capistranorb.com/) for deployment. - Once deployed, CodeOcean assumes to run exclusively under a (sub)domain. If you want to use it under a custom subpath, you can specify the desired path using an environment variable: `RAILS_RELATIVE_URL_ROOT=/codeocean`. Please ensure to rebuild all assets and restart the server to apply the new path. - When using [PgBouncer](https://www.pgbouncer.org), please make sure to correctly set the `intervalstyle` to `iso_8601` for the database. Otherwise, the application will not be able to parse timestamps correctly. See [a similar issue here](https://gitlab.com/gitlab-org/gitlab/-/issues/349912) and [our migration](./db/migrate/20221206221333_set_database_interval_style.rb) for more details. @@ -57,7 +54,6 @@ In order to execute code submissions using the [DockerContainerPool](https://git - The Prometheus Exporter must be started separately **before** running the Rails server via `bundle exec prometheus_exporter` - The InfluxDB data can be visualized using Grafana, for example. There is also an adapted [dashboard](docs/grafana/prometheus_exporter_grafana_dashboard.json) for this purpose - ## Additional Note - If you want to change the default port of the underlying rails server, you can use [authbind](https://www.mwells.org/coding/2016/authbind-port-80-443/) to bind it to the regular 80/443 port. diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 73e7c498..5a460b17 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -2,12 +2,12 @@ // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. // -// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // //= require turbolinks diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f6b67ead..4fbc9c02 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -17,4 +17,4 @@ * * app/assets *= require_tree . -*/ + */ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 21a2e726..19d92a6f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -33,6 +33,31 @@ class ApplicationController < ActionController::Base end helper_method :current_contributor + def welcome + # Show root page + redirect_to ping_index_path if MONITORING_USER_AGENT.match?(request.user_agent) + end + + private + + def require_user! + raise Pundit::NotAuthorizedError unless current_user + end + + def deny_access_from_render_host + raise Pundit::NotAuthorizedError if RENDER_HOST.present? && request.host == RENDER_HOST + end + + def load_embed_options + @embed_options = if session[:embed_options].present? && session[:embed_options].is_a?(Hash) + session[:embed_options].symbolize_keys + else + {} + end + Sentry.set_extras(@embed_options) + @embed_options + end + def find_or_login_current_user login_from_authentication_token || login_from_lti_session || @@ -40,21 +65,6 @@ class ApplicationController < ActionController::Base login_from_other_sources || nil end - private :find_or_login_current_user - - def require_user! - raise Pundit::NotAuthorizedError unless current_user - end - - def mnemosyne_trace - yield - ensure - if ::Mnemosyne::Instrumenter.current_trace.present? - ::Mnemosyne::Instrumenter.current_trace.meta['session_id'] = session[:session_id] - ::Mnemosyne::Instrumenter.current_trace.meta['csrf_token'] = session[:_csrf_token] - ::Mnemosyne::Instrumenter.current_trace.meta['external_user_id'] = session[:external_user_id] - end - end def login_from_lti_session return unless session[:external_user_id] @@ -81,12 +91,6 @@ class ApplicationController < ActionController::Base end end - def set_document_policy - # Instruct browsers to capture profiling data - response.set_header('Document-Policy', 'js-profiling') - end - private :set_document_policy - def set_sentry_context return if current_user.blank? @@ -96,17 +100,19 @@ class ApplicationController < ActionController::Base consumer: current_user.consumer&.name ) end - private :set_sentry_context + + def set_document_policy + # Instruct browsers to capture profiling data + response.set_header('Document-Policy', 'js-profiling') + end def render_csrf_error render_error t('sessions.expired'), :unprocessable_entity end - private :render_csrf_error def render_not_authorized render_error t('application.not_authorized'), :unauthorized end - private :render_not_authorized def render_not_found if current_user&.admin? @@ -115,7 +121,6 @@ class ApplicationController < ActionController::Base render_not_authorized end end - private :render_not_authorized def render_error(message, status) set_sentry_context @@ -134,7 +139,16 @@ class ApplicationController < ActionController::Base format.json { render json: {error: message}, status: } end end - private :render_error + + def mnemosyne_trace + yield + ensure + if ::Mnemosyne::Instrumenter.current_trace.present? + ::Mnemosyne::Instrumenter.current_trace.meta['session_id'] = session[:session_id] + ::Mnemosyne::Instrumenter.current_trace.meta['csrf_token'] = session[:_csrf_token] + ::Mnemosyne::Instrumenter.current_trace.meta['external_user_id'] = session[:external_user_id] + end + end def switch_locale(&) session[:locale] = sanitize_locale(params[:custom_locale] || params[:locale] || session[:locale]) @@ -142,27 +156,6 @@ class ApplicationController < ActionController::Base Sentry.set_extras(locale:) I18n.with_locale(locale, &) end - private :switch_locale - - def deny_access_from_render_host - raise Pundit::NotAuthorizedError if RENDER_HOST.present? && request.host == RENDER_HOST - end - - def welcome - # Show root page - redirect_to ping_index_path if MONITORING_USER_AGENT.match?(request.user_agent) - end - - def load_embed_options - @embed_options = if session[:embed_options].present? && session[:embed_options].is_a?(Hash) - session[:embed_options].symbolize_keys - else - {} - end - Sentry.set_extras(@embed_options) - @embed_options - end - private :load_embed_options # Sanitize given locale. # @@ -176,5 +169,4 @@ class ApplicationController < ActionController::Base locale end - private :sanitize_locale end diff --git a/app/errors/proformaxml/exercise_not_owned.rb b/app/errors/proformaxml/exercise_not_owned.rb index d27043eb..5aeab03e 100644 --- a/app/errors/proformaxml/exercise_not_owned.rb +++ b/app/errors/proformaxml/exercise_not_owned.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module ProformaXML - class ExerciseNotOwned < StandardError; end + class ExerciseNotOwned < ApplicationError; end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ef737f9f..1b56cf40 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -50,7 +50,7 @@ module ApplicationHelper end def render_markdown(markdown) - ActionController::Base.helpers.sanitize Kramdown::Document.new(markdown).to_html + ActionController::Base.helpers.sanitize Kramdown::Document.new(markdown).to_html.strip end def row(options = {}, &) diff --git a/app/helpers/error_template_attributes_helper.rb b/app/helpers/error_template_attributes_helper.rb deleted file mode 100644 index 708ba2c4..00000000 --- a/app/helpers/error_template_attributes_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -module ErrorTemplateAttributesHelper -end diff --git a/app/helpers/error_templates_helper.rb b/app/helpers/error_templates_helper.rb deleted file mode 100644 index 99320810..00000000 --- a/app/helpers/error_templates_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -module ErrorTemplatesHelper -end diff --git a/app/serializers/hash_as_jsonb_serializer.rb b/app/serializers/hash_as_jsonb_serializer.rb new file mode 100644 index 00000000..e30ec79d --- /dev/null +++ b/app/serializers/hash_as_jsonb_serializer.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# stolen from https://github.com/rails/rails/issues/25894#issuecomment-777516944 +# this serializer can be used by a model to make sure the hash from a jsonb field can be accessed with symbols instead of string-keys. +class HashAsJsonbSerializer + def self.dump(hash) + hash + end + + def self.load(hash) + hash.is_a?(Hash) ? hash.deep_symbolize_keys : {} + end +end diff --git a/app/views/application/_flash.html.slim b/app/views/application/_flash.html.slim index 2311318e..b3c74f6b 100644 --- a/app/views/application/_flash.html.slim +++ b/app/views/application/_flash.html.slim @@ -1,7 +1,7 @@ #flash-container.container #flash.container.fixed_error_messages data-message-failure=t('shared.message_failure') data-websocket-failure=t('shared.websocket_failure') - - %w[alert danger info notice success warning].each do |severity| - - flash_mapping = {'alert' => 'warning', 'notice' => 'success'} + - ApplicationController._flash_types.each do |severity| + - flash_mapping = {alert: :warning, notice: :success} div.alert.flash class="alert-#{flash_mapping.fetch(severity, severity)} alert-dismissible fade show" p.mb-0 id="flash-#{severity}" == flash[severity] button.btn-close type="button" data-bs-dismiss="alert" aria-label="Close" diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim index 37f8eba7..fc63b1f7 100644 --- a/app/views/layouts/application.html.slim +++ b/app/views/layouts/application.html.slim @@ -9,10 +9,10 @@ html lang="#{I18n.locale || I18n.default_locale}" data-default-locale="#{I18n.de = favicon_link_tag('/favicon.png', type: 'image/png') = favicon_link_tag('/favicon.png', rel: 'apple-touch-icon', type: 'image/png') = action_cable_meta_tag - = stylesheet_pack_tag('application', 'stylesheets', media: 'all', 'data-turbolinks-track': true, integrity: true, crossorigin: 'anonymous') - = stylesheet_link_tag('application', media: 'all', 'data-turbolinks-track': true, integrity: true, crossorigin: 'anonymous') - = javascript_pack_tag('application', 'data-turbolinks-track': true, defer: false, integrity: true, crossorigin: 'anonymous') - = javascript_include_tag('application', 'data-turbolinks-track': true, integrity: true, crossorigin: 'anonymous') + = stylesheet_pack_tag('application', 'stylesheets', media: 'all', 'data-turbolinks-track': 'reload', integrity: true, crossorigin: 'anonymous') + = stylesheet_link_tag('application', media: 'all', 'data-turbolinks-track': 'reload', integrity: true, crossorigin: 'anonymous') + = javascript_pack_tag('application', 'data-turbolinks-track': 'reload', defer: false, integrity: true, crossorigin: 'anonymous') + = javascript_include_tag('application', 'data-turbolinks-track': 'reload', integrity: true, crossorigin: 'anonymous') = yield(:head) = csrf_meta_tags meta name='sentry' data-enabled=SentryJavascript.active?.to_s data-release=SentryJavascript.release data-dsn=SentryJavascript.dsn data-environment=SentryJavascript.environment @@ -25,7 +25,7 @@ html lang="#{I18n.locale || I18n.default_locale}" data-default-locale="#{I18n.de .navbar-brand i.fa-solid.fa-code = application_name - button.navbar-toggler data-bs-target='#navbar-collapse' data-bs-toggle='collapse' type='button' aria-expanded='false' aria-label='Toggle navigation' + button.navbar-toggler data-bs-target='#navbar-collapse' data-bs-toggle='collapse' type='button' aria-expanded='false' aria-label='Toggle navigation' aria-controls='navbar-collapse' span.navbar-toggler-icon #navbar-collapse.collapse.navbar-collapse = render('navigation', cached: true) diff --git a/config/application.rb b/config/application.rb index 78736df8..99f448d5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -45,6 +45,9 @@ module CodeOcean config.action_cable.mount_path = "#{ENV.fetch('RAILS_RELATIVE_URL_ROOT', '')}/cable" + # Disable concurrent ActionCable workers to ensure ACE change events keep their order + config.action_cable.worker_pool_size = 1 + config.telegraf.tags = {application: 'codeocean'} config.after_initialize do @@ -55,13 +58,15 @@ module CodeOcean Runner.strategy_class.initialize_environment end + # Specify default options for Rails generators + config.generators do |g| + g.orm :active_record, primary_key_type: :uuid + end + # Allow tables in addition to existing default tags config.action_view.sanitized_allowed_tags = ActionView::Base.sanitized_allowed_tags + %w[table thead tbody tfoot td tr] # Extract Sentry-related parameters from WebSocket connection config.middleware.insert_before 0, Middleware::WebSocketSentryHeaders - - # Disable concurrent ActionCable workers to ensure ACE change events keep their order - config.action_cable.worker_pool_size = 1 end end diff --git a/config/database.yml.example b/config/database.yml.example index 3f970c19..019aa77e 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -13,6 +13,9 @@ production: <<: *default database: codeocean_production +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. test: <<: *default database: codeocean_test diff --git a/config/environments/development.rb b/config/environments/development.rb index 3e7bc170..b82b1393 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -5,6 +5,7 @@ require 'active_support/core_ext/integer/time' Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # Allowed IPs for the Vagrant setup config.web_console.allowed_ips = '192.168.0.0/16' # In the development environment your application's code is reloaded any time @@ -43,10 +44,6 @@ Rails.application.configure do # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false - # Perform deliveries via letter opener - config.action_mailer.perform_deliveries = true - config.action_mailer.delivery_method = :letter_opener - config.action_mailer.perform_caching = false # Print deprecation notices to the Rails logger. diff --git a/config/environments/production.rb b/config/environments/production.rb index fca0672b..8b828d7d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -22,6 +22,7 @@ Rails.application.configure do # 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 + config.read_encrypted_secrets = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. @@ -67,7 +68,7 @@ Rails.application.configure do # 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 = "code_ocean_production" + # config.active_job.queue_name_prefix = "codeocean_production" config.action_mailer.perform_caching = false diff --git a/config/environments/test.rb b/config/environments/test.rb index 2248474d..7f29399a 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -59,8 +59,8 @@ Rails.application.configure do config.active_support.disallowed_deprecation_warnings = [] # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true + config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true + config.action_view.annotate_rendered_view_with_filenames = true end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index f4556db3..6d56e439 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 6e1d16f0..be6fedc5 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb index 27283116..98562ffe 100644 --- a/config/initializers/rails_admin.rb +++ b/config/initializers/rails_admin.rb @@ -8,14 +8,13 @@ RailsAdmin.config do |config| # config.authenticate_with do # warden.authenticate! scope: :user # end - # config.current_user_method(&:current_user) + config.current_user_method(&:current_user) ## == CancanCan == # config.authorize_with :cancancan ## == Pundit == # config.authorize_with :pundit - config.parent_controller = '::RailsAdminController' config.authorize_with do # Important! We need to check the authorization here, we skip Pundit checks in the RailsAdminController. @@ -30,6 +29,9 @@ RailsAdmin.config do |config| ### More at https://github.com/sferik/rails_admin/wiki/Base-configuration + config.parent_controller = '::RailsAdminController' + config.excluded_models = %w[Generators::TestingFrameworkAdapterGenerator] + ## == Gravatar integration == ## To disable Gravatar integration in Navigation Bar set to false # config.show_gravatar = true @@ -51,8 +53,6 @@ RailsAdmin.config do |config| end end - config.excluded_models = %w[Generators::TestingFrameworkAdapterGenerator] - config.actions do # mandatory dashboard do diff --git a/config/shakapacker.yml b/config/shakapacker.yml index 3f43cc37..793a64d4 100644 --- a/config/shakapacker.yml +++ b/config/shakapacker.yml @@ -7,16 +7,16 @@ default: &default # Alternatively, you can use '/' to use the whole source_path directory. source_entry_path: / + # If nested_entries is true, then we'll pick up subdirectories within the source_entry_path. + # You cannot set this option to true if you set source_entry_path to '/' + nested_entries: false + # While using a File-System-based automated bundle generation feature, miscellaneous warnings suggesting css order # conflicts may arise due to the mini-css-extract-plugin. For projects where css ordering has been mitigated through # consistent use of scoping or naming conventions, the css order warnings can be disabled by setting # css_extract_ignore_order_warnings to true css_extract_ignore_order_warnings: false - # If nested_entries is true, then we'll pick up subdirectories within the source_entry_path. - # You cannot set this option to true if you set source_entry_path to '/' - nested_entries: false - public_root_path: public public_output_path: packs cache_path: tmp/shakapacker @@ -38,7 +38,7 @@ default: &default webpack_loader: 'babel' # Set to true to enable check for matching versions of shakapacker gem and NPM package - will raise an error if there is a mismatch or wildcard versioning is used - ensure_consistent_versioning: true + ensure_consistent_versioning: false # Select whether the compiler will use SHA digest ('digest' option) or most most recent modified timestamp ('mtime') to determine freshness compiler_strategy: digest @@ -60,10 +60,10 @@ development: # If HMR is on, CSS will by inlined by delivering it as part of the script payload via style-loader. Be sure # that you add style-loader to your project dependencies. # - # If you want to instead deliver CSS via with the mini-extract-css-plugin, set inline_css to false. + # If you want to instead deliver CSS via with the mini-css-extract-plugin, set inline_css to false. # In that case, style-loader is not needed as a dependency. # - # mini-extract-css-plugin is a required dependency in both cases. + # mini-css-extract-plugin is a required dependency in both cases. inline_css: true # Defaults to the inverse of hmr. Uncomment to manually set this. # live_reload: true diff --git a/config/webpack/webpack.config.js b/config/webpack/webpack.config.js index 619d8ee7..c187dcd1 100644 --- a/config/webpack/webpack.config.js +++ b/config/webpack/webpack.config.js @@ -20,7 +20,7 @@ const public_output_path = webpackConfig.output.publicPath; const envConfig = module.exports = { node: { - global: false, + global: false, }, module: { rules: [ diff --git a/db/seeds.rb b/db/seeds.rb index a57b49f9..fa5246b0 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,5 +1,13 @@ # frozen_string_literal: true +# Meta seed file that required depending on the Rails env different files from +# db/seeds/ Please put the seed in the best matching file +# +# * all: Objects are needed in every environment (production, development) +# * production: Objects are only needed for deployment +# * development: Only needed for local development +# + def find_factories_by_class(klass) FactoryBot.factories.select do |factory| factory.instance_variable_get(:@class_name).to_s == klass.to_s || factory.instance_variable_get(:@name) == klass.model_name.singular.to_sym @@ -22,12 +30,15 @@ end Rails.application.eager_load! (ApplicationRecord.descendants - [ActiveRecord::SchemaMigration, User]).each(&:delete_all) -# Set the default intervalstyle to iso_8601 -dbname = ApplicationRecord.connection.current_database -ApplicationRecord.connection.exec_query("ALTER DATABASE \"#{dbname}\" SET intervalstyle = 'iso_8601';") - # delete file uploads FileUtils.rm_rf(Rails.public_path.join('uploads')) -# load environment-dependent seeds -load(Rails.root.join("db/seeds/#{Rails.env}.rb")) +['all', Rails.env].each do |seed| + seed_file = Rails.root.join("db/seeds/#{seed}.rb") + if seed_file.exist? + puts "*** Loading \"#{seed}\" seed data" # rubocop:disable Rails/Output + load seed_file + else + puts "*** Skipping \"#{seed}\" seed data: \"#{seed_file}\" not found" # rubocop:disable Rails/Output + end +end diff --git a/postcss.config.js b/postcss.config.js deleted file mode 100644 index aa5998a8..00000000 --- a/postcss.config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - plugins: [ - require('postcss-import'), - require('postcss-flexbugs-fixes'), - require('postcss-preset-env')({ - autoprefixer: { - flexbox: 'no-2009' - }, - stage: 3 - }) - ] -} diff --git a/public/500.html b/public/500.html index a592f052..cbe07e5b 100644 --- a/public/500.html +++ b/public/500.html @@ -1,7 +1,7 @@ - Momentan nehmen wir Wartungs- und Optimierungsarbeiten vor. Probieren Sie es in Kürze noch einmal. + We're sorry, but something went wrong (500)