From 6cf4717ab36771e40cfd8e02b3c31d405dee507f Mon Sep 17 00:00:00 2001 From: Urban Rotnik Date: Wed, 16 Jan 2019 15:02:23 +0100 Subject: [PATCH] Add envirnoments to run app without docker, reorder Gemfile - Reorder Gemfile into alphabet order (rule by Rubocop) - Add extra ENV variable for custom DB settings locally - Add extra ENV for disable spoof check on Paperclip --- .gitignore | 3 + Gemfile | 104 ++++++++++++++++--------------- config/database.yml | 8 +-- config/initializers/paperclip.rb | 6 +- 4 files changed, 63 insertions(+), 58 deletions(-) diff --git a/.gitignore b/.gitignore index 72baa3d50..c75412598 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,6 @@ features/addons spec/addons !features/addons/.gitkeep !spec/addons/.gitkeep + +# RVM/rbenv ruby version for local development +.ruby-version diff --git a/Gemfile b/Gemfile index 72e09a076..2fe9e3e77 100644 --- a/Gemfile +++ b/Gemfile @@ -1,20 +1,22 @@ +# frozen_string_literal: true + source 'http://rubygems.org' ruby '2.4.5' -gem 'rails', '5.1.6' -gem 'webpacker', '~> 2.0' -gem 'figaro' -gem 'pg', '~> 0.18' +gem 'bootstrap-sass', '~> 3.3.7' +gem 'bootstrap_form' gem 'devise', '~> 4.3.0' gem 'devise_invitable' -gem 'simple_token_authentication', '~> 1.15.1' # Token authentication for Devise -gem 'bootstrap-sass', '~> 3.3.7' -gem 'sass-rails', '~> 5.0.6' -gem 'bootstrap_form' -gem 'yomu' +gem 'figaro' +gem 'pg', '~> 0.18' +gem 'rails', '5.1.6' gem 'recaptcha', require: 'recaptcha/rails' gem 'sanitize', '~> 4.4' +gem 'sass-rails', '~> 5.0.6' +gem 'simple_token_authentication', '~> 1.15.1' # Token authentication for Devise +gem 'webpacker', '~> 2.0' +gem 'yomu' # Gems for OAuth2 subsystem gem 'doorkeeper', '>= 4.6' @@ -36,97 +38,97 @@ gem 'bootstrap3-datetimepicker-rails', '~> 4.15.35' gem 'bootstrap-select-rails', '~> 1.12.4' gem 'uglifier', '>= 1.3.0' # jQuery & plugins +gem 'autosize-rails' # jQuery autosize plugin +gem 'hammerjs-rails' gem 'jquery-rails' -gem 'jquery-ui-rails' gem 'jquery-scrollto-rails', git: 'https://github.com/biosistemika/jquery-scrollto-rails' -gem 'hammerjs-rails' +gem 'jquery-ui-rails' gem 'js_cookie_rails' # Simple JS API for cookies gem 'spinjs-rails' -gem 'autosize-rails' # jQuery autosize plugin -gem 'underscore-rails' -gem 'turbolinks', '~> 5.1.1' -gem 'sdoc', '~> 1.0', group: :doc -gem 'bcrypt', '~> 3.1.10' -gem 'logging', '~> 2.0.0' -gem 'aspector' # Aspect-oriented programming for Rails -gem 'rgl' # Graph framework for project diagram calculations -gem 'nested_form_fields' +gem 'activerecord-import' gem 'ajax-datatables-rails', '~> 0.3.1' -gem 'commit_param_routing' # Enables different submit actions in the same form to route to different actions in controller -gem 'i18n-js', '~> 3.0' # Localization in javascript files -gem 'roo', '~> 2.7.1' # Spreadsheet parser -gem 'wicked_pdf', '~> 1.1.0' -gem 'silencer' # Silence certain Rails logs -gem 'wkhtmltopdf-heroku' -gem 'faker' # Generate fake data -gem 'auto_strip_attributes', '~> 2.1' # Removes unnecessary whitespaces from ActiveRecord or ActiveModel attributes +gem 'aspector' # Aspect-oriented programming for Rails +gem 'auto_strip_attributes', '~> 2.1' # Removes unnecessary whitespaces AR +gem 'bcrypt', '~> 3.1.10' +gem 'commit_param_routing' # Enables different submit actions in the same form gem 'deface', '~> 1.0' -gem 'nokogiri', '~> 1.8.1' # HTML/XML parser -gem 'sneaky-save', git: 'https://github.com/einzige/sneaky-save' -gem 'rails_autolink', '~> 1.1', '>= 1.1.6' gem 'delayed_paperclip', git: 'https://github.com/jrgifford/delayed_paperclip.git', ref: 'fcf574c' -gem 'rubyzip' +gem 'faker' # Generate fake data +gem 'i18n-js', '~> 3.0' # Localization in javascript files gem 'jbuilder' # JSON structures via a Builder-style DSL -gem 'activerecord-import' +gem 'logging', '~> 2.0.0' +gem 'nested_form_fields' +gem 'nokogiri', '~> 1.8.1' # HTML/XML parser +gem 'rails_autolink', '~> 1.1', '>= 1.1.6' +gem 'rgl' # Graph framework for project diagram calculations +gem 'roo', '~> 2.7.1' # Spreadsheet parser +gem 'rubyzip' gem 'scenic', '~> 1.4' +gem 'sdoc', '~> 1.0', group: :doc +gem 'silencer' # Silence certain Rails logs +gem 'sneaky-save', git: 'https://github.com/einzige/sneaky-save' +gem 'turbolinks', '~> 5.1.1' +gem 'underscore-rails' +gem 'wicked_pdf', '~> 1.1.0' +gem 'wkhtmltopdf-heroku' -gem 'paperclip', '~> 5.3' # File attachment, image attachment library gem 'aws-sdk', '~> 2' +gem 'paperclip', '~> 5.3' # File attachment, image attachment library gem 'delayed_job_active_record' gem 'devise-async', - git: 'https://github.com/mhfs/devise-async.git', - branch: 'devise-4.x' + git: 'https://github.com/mhfs/devise-async.git', + branch: 'devise-4.x' gem 'discard', '~> 1.0' gem 'ruby-graphviz', '~> 1.2' # Graphviz for rails gem 'tinymce-rails', '~> 4.7.13' # Rich text editor - SEE BELOW -# Any time you update tinymce-rails Gem, also update the cache_suffix parameter in -# sitewide/tiny_mce.js - to prevent browsers from loading old, cached .js +# Any time you update tinymce-rails Gem, also update the cache_suffix parameter +# in sitewide/tiny_mce.js - to prevent browsers from loading old, cached .js # TinyMCE files which might cause errors gem 'base62' # Used for smart annotations -gem 'newrelic_rpm' gem 'devise_security_extension', git: 'https://github.com/phatworx/devise_security_extension.git', ref: 'b2ee978' +gem 'newrelic_rpm' # Permission helper Gem gem 'canaid', git: 'https://github.com/biosistemika/canaid', branch: 'master' group :development, :test do - gem 'listen', '~> 3.0' + gem 'awesome_print' + gem 'better_errors' + gem 'binding_of_caller' + gem 'bullet' gem 'byebug' + gem 'factory_bot_rails' + gem 'listen', '~> 3.0' gem 'pry' gem 'pry-byebug' gem 'pry-rails' - gem 'factory_bot_rails' gem 'rails-controller-testing' gem 'rspec-rails' - gem 'better_errors' - gem 'binding_of_caller' - gem 'awesome_print' gem 'rubocop', '>= 0.59.0', require: false gem 'scss_lint', require: false gem 'starscope', require: false - gem 'bullet' end group :test do - gem 'shoulda-matchers' - gem 'cucumber-rails', '~> 1.5', require: false - gem 'database_cleaner' gem 'capybara' gem 'capybara-email' - gem 'poltergeist' - gem 'phantomjs', require: 'phantomjs/poltergeist' - gem 'simplecov', require: false + gem 'cucumber-rails', '~> 1.5', require: false + gem 'database_cleaner' gem 'json_matchers' + gem 'phantomjs', require: 'phantomjs/poltergeist' + gem 'poltergeist' + gem 'shoulda-matchers' + gem 'simplecov', require: false end group :production do diff --git a/config/database.yml b/config/database.yml index c11677eac..a3f75e69c 100644 --- a/config/database.yml +++ b/config/database.yml @@ -19,15 +19,13 @@ default: &default encoding: unicode database: postgres pool: 5 - username: postgres - password: mysecretpassword - host: db + # For details on connection pooling, see rails configuration guide # http://guides.rubyonrails.org/configuring.html#database-pooling development: <<: *default - database: scinote_development + url: <%= ENV['DATABASE_DEV_URL'] || 'postgresql://postgres:mysecretpassword@db/scinote_development' %> # The specified database role being used to connect to postgres. # To create additional roles in postgres see `$ createuser --help`. @@ -60,7 +58,7 @@ development: # Do not set this db to the same as development or production. test: &test <<: *default - database: scinote_test + url: <%= ENV['DATABASE_TEST_URL'] || 'postgresql://postgres:mysecretpassword@db/scinote_test' %> # As with config/secrets.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 8e65d0ee7..246c01f07 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -66,6 +66,8 @@ module Paperclip # Checks file for spoofing class MediaTypeSpoofDetector def spoofed? + return false if ENV['DISABLE_SPOOF_CHECKING'] + if has_name? && has_extension? && (media_type_mismatch? || mapping_override_mismatch?) Paperclip.log("Content Type Spoof: Filename #{File.basename(@name)} "\ @@ -121,8 +123,8 @@ module Paperclip end end @type_from_file_command - rescue Cocaine::CommandLineError - '' + rescue StandardError => e + puts e end # Determine file media type from it's content (file and mimetype command)