diff --git a/Dockerfile b/Dockerfile index 5973d9794..d2ec3fa08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,7 @@ ADD Gemfile.lock /app/ RUN bundle install --jobs 3 --deployment --without development test # Default environment settings +ENV RAILS_SERVE_STATIC_FILES true ENV LOG_TO_STDOUT true ENV INSTEDD_THEME //theme.instedd.org ENV RAILS_ENV production diff --git a/Gemfile b/Gemfile index 4a085f4ec..2209f66d1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' # framework -gem 'rails', '~> 4.1.15' +gem 'rails', '~> 4.2.11' # services gem "elasticsearch", '~> 1.0.17' @@ -49,6 +49,9 @@ gem 'treetop', '1.4.15' gem 'uuidtools' gem 'will_paginate' +# deprecated (to fix upgrades) +gem "loofah", "2.20.0" if RUBY_VERSION.to_f < 2.5 + # templates gem 'haml-rails', '~> 0.4' gem 'haml-magic-translations' diff --git a/Gemfile.lock b/Gemfile.lock index afa6873d8..88c8d9ed3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,47 +44,55 @@ GEM remote: https://rubygems.org/ remote: https://rails-assets.org/ specs: - actionmailer (4.1.16) - actionpack (= 4.1.16) - actionview (= 4.1.16) + actionmailer (4.2.11.3) + actionpack (= 4.2.11.3) + actionview (= 4.2.11.3) + activejob (= 4.2.11.3) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.16) - actionview (= 4.1.16) - activesupport (= 4.1.16) - rack (~> 1.5.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.11.3) + actionview (= 4.2.11.3) + activesupport (= 4.2.11.3) + rack (~> 1.6) rack-test (~> 0.6.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) actionpack-action_caching (1.2.2) actionpack (>= 4.0.0) actionpack-page_caching (1.2.4) actionpack (>= 4.0.0) - actionview (4.1.16) - activesupport (= 4.1.16) + actionview (4.2.11.3) + activesupport (= 4.2.11.3) builder (~> 3.1) erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.3) active_model_serializers (0.10.14) actionpack (>= 4.1) activemodel (>= 4.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activemodel (4.1.16) - activesupport (= 4.1.16) + activejob (4.2.11.3) + activesupport (= 4.2.11.3) + globalid (>= 0.3.0) + activemodel (4.2.11.3) + activesupport (= 4.2.11.3) builder (~> 3.1) - activerecord (4.1.16) - activemodel (= 4.1.16) - activesupport (= 4.1.16) - arel (~> 5.0.0) + activerecord (4.2.11.3) + activemodel (= 4.2.11.3) + activesupport (= 4.2.11.3) + arel (~> 6.0) activerecord-import (0.28.2) activerecord (>= 3.2) - activesupport (4.1.16) - i18n (~> 0.6, >= 0.6.9) - json (~> 1.7, >= 1.7.7) + activesupport (4.2.11.3) + i18n (~> 0.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) aes_key_wrap (1.1.0) - arel (5.0.1.20140414130214) + arel (6.0.4) attr_required (1.0.1) bcrypt (3.1.19) bindata (2.4.14) @@ -116,6 +124,7 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.2.2) + crass (1.0.6) dalli (2.7.11) database_cleaner (1.99.0) decent_exposure (2.3.3) @@ -156,6 +165,8 @@ GEM global_phone (1.0.1) global_phone_dbgen (1.0.0) nokogiri (~> 1.5) + globalid (0.4.2) + activesupport (>= 4.2.0) google-api-client (0.32.1) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.5, < 0.10.0) @@ -213,8 +224,8 @@ GEM railties (>= 3.1.0, < 5.0) thor (~> 0.14) json (1.8.6) - json-jwt (1.9.4) - activesupport + json-jwt (1.12.0) + activesupport (>= 4.2) aes_key_wrap bindata jsonapi-renderer (0.2.2) @@ -224,6 +235,9 @@ GEM locale (2.1.3) lodash-rails (2.4.1) railties (>= 3.1) + loofah (2.20.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) machinist (1.0.6) mail (2.7.1) mini_mime (>= 0.1.1) @@ -251,9 +265,9 @@ GEM json rest-client oj (2.15.1) - omniauth (1.4.2) - hashie (>= 1.2, < 4) - rack (>= 1.0, < 3) + omniauth (1.9.2) + hashie (>= 3.4.6) + rack (>= 1.6.2, < 3) omniauth-openid (1.0.1) omniauth (~> 1.0) rack-openid (~> 1.3.1) @@ -267,13 +281,13 @@ GEM polyglot (0.3.5) public_suffix (4.0.7) puma (3.11.4) - rack (1.5.5) - rack-oauth2 (1.10.0) + rack (1.6.13) + rack-oauth2 (1.12.0) activesupport attr_required httpclient - json-jwt (>= 1.9.0) - rack + json-jwt (>= 1.11.0) + rack (< 2.1) rack-openid (1.3.1) rack (>= 1.1.0) ruby-openid (>= 2.1.8) @@ -281,20 +295,29 @@ GEM rack rack-test (0.6.3) rack (>= 1.0) - rails (4.1.16) - actionmailer (= 4.1.16) - actionpack (= 4.1.16) - actionview (= 4.1.16) - activemodel (= 4.1.16) - activerecord (= 4.1.16) - activesupport (= 4.1.16) + rails (4.2.11.3) + actionmailer (= 4.2.11.3) + actionpack (= 4.2.11.3) + actionview (= 4.2.11.3) + activejob (= 4.2.11.3) + activemodel (= 4.2.11.3) + activerecord (= 4.2.11.3) + activesupport (= 4.2.11.3) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.16) - sprockets-rails (~> 2.0) + railties (= 4.2.11.3) + sprockets-rails rails-assets-knockout-sortable (1.1.0) - railties (4.1.16) - actionpack (= 4.1.16) - activesupport (= 4.1.16) + rails-deprecated_sanitizer (1.0.4) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.9) + activesupport (>= 4.2.0, < 5.0) + nokogiri (~> 1.6) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.4.4) + loofah (~> 2.19, >= 2.19.1) + railties (4.2.11.3) + actionpack (= 4.2.11.3) + activesupport (= 4.2.11.3) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (13.1.0) @@ -305,8 +328,9 @@ GEM declarative (< 0.1.0) declarative-option (< 0.2.0) uber (< 0.2.0) - responders (1.1.2) - railties (>= 3.2, < 4.2) + responders (2.4.1) + actionpack (>= 4.2.0, < 6.0) + railties (>= 4.2.0, < 6.0) resque (1.27.4) mono_logger (~> 1.0) multi_json (~> 1.0) @@ -454,6 +478,7 @@ DEPENDENCIES jquery-rails (~> 2.0.2) knockoutjs-rails (~> 3.2.0) lodash-rails + loofah (= 2.20.0) machinist (= 1.0.6) mini_magick msgpack (~> 0.7.5) @@ -465,7 +490,7 @@ DEPENDENCIES omniauth-openid (~> 1.0) paranoia (~> 2.0) puma (~> 3.11.4) - rails (~> 4.1.15) + rails (~> 4.2.11) rails-assets-knockout-sortable! redis (~> 3.1) resque (~> 1.25) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 2ae381a1a..fca4f3910 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -2,13 +2,13 @@ // 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 -// the compiled file. +// compiled file. // -// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD -// GO AFTER THE REQUIRES BELOW. +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. // //= require instedd-rails //= require jquery-ui diff --git a/app/workers/email_task.rb b/app/workers/email_task.rb index befd28839..8e45a0ec8 100644 --- a/app/workers/email_task.rb +++ b/app/workers/email_task.rb @@ -2,6 +2,6 @@ class EmailTask @queue = :email_queue def self.perform(users_email, message, email_subject) - SendMailer.notify_email(users_email, message, email_subject).deliver + SendMailer.notify_email(users_email, message, email_subject).deliver_now end end diff --git a/config/application.rb b/config/application.rb index d464aa676..cfb28e2d6 100644 --- a/config/application.rb +++ b/config/application.rb @@ -57,6 +57,9 @@ class Application < Rails::Application # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql + # Do not swallow errors in after_commit/after_rollback callbacks (Rails 4.2). + config.active_record.raise_in_transactional_callbacks = true + # Enable the asset pipeline config.assets.enabled = true diff --git a/config/environment.rb b/config/environment.rb index 409e2d7c9..ee8d90dc6 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ -# Load the rails application +# Load the Rails application. require File.expand_path('../application', __FILE__) -# Initialize the rails application -ResourceMap::Application.initialize! +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 89172ea9a..ae04e3bbb 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,5 +1,5 @@ -ResourceMap::Application.configure do - # Settings specified here will take precedence over those in config/application.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. gem 'devise' # In the development environment your application's code is reloaded on @@ -7,13 +7,14 @@ # since you don't have to restart the web server when you make code changes. config.cache_classes = false + # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching + # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false - # Don't care if the mailer can't send + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false config.action_mailer.default_url_options = { :host => Settings.host } if Settings.smtp.present? @@ -32,17 +33,34 @@ end end - # Print deprecation notices to the Rails logger + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin # Do not compress assets config.assets.compress = false - # Expands the lines which load the assets - config.assets.debug = false # if true, the thin server was too slow in docker environment + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = false + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true # Uncomment the following line to enable sample profiling (see https://github.com/tmm1/stackprof for details) # config.middleware.use StackProf::Middleware, enabled: true, mode: :cpu, interval: 100, save_every: 5 diff --git a/config/environments/production.rb b/config/environments/production.rb index b40dd8045..a77621831 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,62 +1,74 @@ -ResourceMap::Application.configure do - # Settings specified here will take precedence over those in config/application.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. - # Code is not reloaded between requests + # Code is not reloaded between requests. config.cache_classes = true - # Full error reports are disabled and caching is turned on + # 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 Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = true + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like + # NGINX, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? - # Compress JavaScripts and CSS - config.assets.compress = true + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass - # Don't fallback to assets pipeline if a precompiled asset is missed + # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Generate digests for assets URLs + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. config.assets.digest = true - config.eager_load = true - - # Defaults to Rails.root.join("public/assets") - # config.assets.manifest = YOUR_PATH + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb - # 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 + # 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 # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # See everything in the log (default is :info) + # 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 + # Prepend all log lines with the following tags. # config.log_tags = [ :subdomain, :uuid ] - # Use a different logger for distributed setups + # Use a different logger for distributed setups. if ENV["LOG_TO_STDOUT"].present? config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) STDOUT.sync = true end # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - # Use a different cache store in production + # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server - # config.action_controller.asset_host = "http://assets.example.com" + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - # config.assets.precompile += %w( search.js ) - - # Disable delivery errors, bad email addresses will be ignored + # 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 config.action_mailer.default_url_options = { :host => Settings.host } + if Settings.smtp.present? smtp_settings = {}.tap do |settings| settings[:address] = Settings.smtp["address"] if Settings.smtp["address"].present? @@ -77,12 +89,18 @@ # config.threadsafe! # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) + # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners + # 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 + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) # config.active_record.auto_explain_threshold_in_seconds = 0.5 diff --git a/config/environments/test.rb b/config/environments/test.rb index 1dcf486fd..f87c65418 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,5 +1,5 @@ -ResourceMap::Application.configure do - # Settings specified here will take precedence over those in config/application.rb +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that @@ -7,10 +7,9 @@ # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true - config.static_cache_control = "public, max-age=3600" - + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. config.eager_load = false # Disable concurrency during testing; should not be necessary after upgrading @@ -18,15 +17,19 @@ # See https://robots.thoughtbot.com/how-to-fix-circular-dependency-errors-in-rails-integration-tests config.allow_concurrency = false - # Show full error reports and disable caching + # Configure static file server for tests with Cache-Control for performance. + config.serve_static_files = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false - # Raise exceptions instead of rendering exception templates + # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false - # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the @@ -34,6 +37,12 @@ config.action_mailer.delivery_method = :test config.action_mailer.default_url_options = { :host => "localhost:3000" } - # Print deprecation notices to the stderr + # Randomize the order test cases are executed. + config.active_support.test_order = :random + + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 000000000..58814ff29 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +Dir[File.expand_path("../../../plugins/*/assets/*", __FILE__)].each do |asset_path| + next unless File.directory?(asset_path) + + # Add plugin assets directories to the load path: + Rails.application.config.assets.paths << asset_path + + Dir[File.join(asset_path, "**/*")].each do |asset_file_path| + next if File.directory?(asset_file_path) + next if File.extname(asset_file_path) == ".coffee" + + # Add individual asset file to the assets precompilation list: + Rails.application.config.assets.precompile << asset_file_path.gsub("#{asset_path}/", "") + end +end + +# Precompile plugin javascript assets: +# Rails.application.config.assets.precompile << "alerts.js" +# Rails.application.config.assets.precompile << "channels.js" +# Rails.application.config.assets.precompile << "fred_api.js" +# Rails.application.config.assets.precompile << "reminders.js" diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 000000000..4aee72dd5 --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +# Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 000000000..4a994e1e7 --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 5d8d9be23..ac033bf9d 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,15 +1,16 @@ # Be sure to restart your server when you modify this file. -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end -# + # These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections do |inflect| +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 72aca7e44..dc1899682 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -2,4 +2,3 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 003e67834..a08f41325 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,8 +1,8 @@ # Be sure to restart your server when you modify this file. -ResourceMap::Application.config.session_store :cookie_store, key: '_resource_map_session' +Rails.application.config.session_store :cookie_store, key: '_resource_map_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rails generate session_migration") -# ResourceMap::Application.config.session_store :active_record_store +# Rails.application.config.session_store :active_record_store diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 999df2018..124ca3121 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,11 +1,11 @@ # Be sure to restart your server when you modify this file. -# + # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) end # Disable root element in JSON by default. diff --git a/config/routes.rb b/config/routes.rb index 26f2f39dc..90094b1f7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ -ResourceMap::Application.routes.draw do +Rails.application.routes.draw do mount InsteddTelemetry::Engine => '/instedd_telemetry' # We need to define devise_for just omniauth_callbacks:uth_callbacks otherwise it does not work with scoped locales # see https://github.com/plataformatec/devise/issues/2813 diff --git a/docker-compose.yml b/docker-compose.yml index dde520fcc..18ae3bbf7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -67,19 +67,19 @@ services: resque: <<: *rails - command: rake resque:work TERM_CHILD=1 FORK_PER_JOB=false + command: bundle exec rake resque:work TERM_CHILD=1 FORK_PER_JOB=false ports: [] depends_on: [] resque_scheduler: <<: *rails - command: rake resque:scheduler + command: bundle exec rake resque:scheduler ports: [] depends_on: [] jasmine: <<: *rails - command: rake jasmine + command: bundle exec rake jasmine ports: - 8888:8888 depends_on: [] diff --git a/plugins/alerts/spec/controllers/thresholds_controller_spec.rb b/plugins/alerts/spec/controllers/thresholds_controller_spec.rb index 37a4016c9..a6ca110ab 100644 --- a/plugins/alerts/spec/controllers/thresholds_controller_spec.rb +++ b/plugins/alerts/spec/controllers/thresholds_controller_spec.rb @@ -40,7 +40,7 @@ it "should update threshold" do put :update, id: threshold.id, collection_id: collection.id, threshold: {ord: 2, "conditions"=>{"0"=>condition_attributes}, "sites" => {"0" => sites}} - expect(Threshold.find(threshold).ord).to eq(2) + expect(Threshold.find(threshold.id).ord).to eq(2) end it "should destroy threshold" do @@ -74,7 +74,7 @@ threshold.ord = 1 threshold.save! put :update, id: threshold.id, collection_id: collection.id, threshold: {ord: 2, "conditions"=>{"0"=>condition_attributes}, "sites" => {"0" => sites}} - expect(Threshold.find(threshold).ord).to eq(1) + expect(Threshold.find(threshold.id).ord).to eq(1) end it "should not destroy threshold" do diff --git a/plugins/reminders/models/repeat.rb b/plugins/reminders/models/repeat.rb index bcf3ec23d..459788d17 100644 --- a/plugins/reminders/models/repeat.rb +++ b/plugins/reminders/models/repeat.rb @@ -1,3 +1,3 @@ class Repeat < ActiveRecord::Base - serialize :rule, IceCube::Rule + serialize :rule, IceCube::ValidatedRule end diff --git a/plugins/reminders/spec/controllers/reminders_controller_spec.rb b/plugins/reminders/spec/controllers/reminders_controller_spec.rb index 0b7ce5053..ca380e7f0 100644 --- a/plugins/reminders/spec/controllers/reminders_controller_spec.rb +++ b/plugins/reminders/spec/controllers/reminders_controller_spec.rb @@ -26,7 +26,7 @@ it "should update reminder" do put :update, :id => reminder.id, :collection_id => collection.id, :reminder => { name: "foo" } - expect(Reminder.find(reminder).name).to eq("foo") + expect(reminder.reload.name).to eq("foo") end it "should destroy reminder" do @@ -37,7 +37,7 @@ it 'should update status' do post :set_status, :id => reminder.id, :collection_id => collection.id, :status => true - expect(Reminder.find(reminder).status).to eq(true) + expect(reminder.reload.status).to eq(true) end it "should not create reminder for guest" do @@ -64,7 +64,7 @@ reminder.name = "old" reminder.save! put :update, :id => reminder.id, :collection_id => collection.id, :reminder => { name: "foo" } - expect(Reminder.find(reminder).name).to eq("old") + expect(reminder.reload.name).to eq("old") end it "should not destroy reminder" do @@ -75,7 +75,7 @@ it 'should not update status' do post :set_status, :id => reminder.id, :collection_id => collection.id, :status => true - expect(Reminder.find(reminder).status).to eq(nil) + expect(reminder.reload.status).to eq(nil) end end end diff --git a/spec/controllers/collections_controller_spec.rb b/spec/controllers/collections_controller_spec.rb index aefba5bf1..660255f13 100644 --- a/spec/controllers/collections_controller_spec.rb +++ b/spec/controllers/collections_controller_spec.rb @@ -138,7 +138,7 @@ def make_public(collection) expect{ post :create, collection: { name: 'collection_1', icon: 'default'} }.to change{ - u = User.find user + u = User.find user.id u.collection_count }.from(0).to(1) end diff --git a/spec/controllers/gateways_controller_spec.rb b/spec/controllers/gateways_controller_spec.rb index 39de18790..06efd55a8 100644 --- a/spec/controllers/gateways_controller_spec.rb +++ b/spec/controllers/gateways_controller_spec.rb @@ -10,7 +10,7 @@ before(:each) {sign_in user} it "should turn on gateway" do post :status, id: gateway.id, status: true, format: 'json' - expect(Channel.find(gateway).is_enable).to eq(true) + expect(Channel.find(gateway.id).is_enable).to eq(true) end describe 'analytic' do @@ -18,7 +18,7 @@ expect { post :create, gateway: { name: 'default1', basic_setup: true, ticket_code: '2222', is_enable: true, user_id: user.id } }.to change{ - u = User.find user + u = User.find user.id u.gateway_count }.from(0).to(1) end diff --git a/spec/controllers/layers_controller_spec.rb b/spec/controllers/layers_controller_spec.rb index 23186c432..99fb3f287 100644 --- a/spec/controllers/layers_controller_spec.rb +++ b/spec/controllers/layers_controller_spec.rb @@ -58,7 +58,7 @@ expect { post :create, layer: { name: 'layer_01', fields: [], ord: 1}, collection_id: collection.id }.to change{ - u = User.find user + u = User.find user.id u.layer_count }.from(0).to(1) end diff --git a/spec/controllers/sites_controller_spec.rb b/spec/controllers/sites_controller_spec.rb index 0ff90ec5f..2799bd872 100644 --- a/spec/controllers/sites_controller_spec.rb +++ b/spec/controllers/sites_controller_spec.rb @@ -292,7 +292,7 @@ def validate_site_property_value(site, property, value) expect { post :create, site: "{\"name\":\"site_01\",\"lat\":8.932599568335238,\"lng\":99.27246091406255,\"properties\":{}}", collection_id: collection.id }.to change{ - u = User.find user + u = User.find user.id u.site_count }.from(0).to(1) end diff --git a/spec/mailers/send_mailer_spec.rb b/spec/mailers/send_mailer_spec.rb index c49ec40e3..7b9f67ceb 100644 --- a/spec/mailers/send_mailer_spec.rb +++ b/spec/mailers/send_mailer_spec.rb @@ -5,15 +5,15 @@ let(:message) {"testing"} let(:mail) { SendMailer.notify_email([users[0].email, users[1].email], message, "email from resourcemap") } it "has email in queue" do - mail.deliver + mail.deliver_now expect(ActionMailer::Base.deliveries.empty?).not_to be_truthy end it "send to correct email" do - mail.deliver + mail.deliver_now expect(mail.to).to eq(users.map(&:email)) end it "send a correct email" do - mail.deliver + mail.deliver_now expect(mail.body).to eq(message) end diff --git a/spec/models/activity_spec.rb b/spec/models/activity_spec.rb index fe37afebc..f9f9e3dcb 100644 --- a/spec/models/activity_spec.rb +++ b/spec/models/activity_spec.rb @@ -223,7 +223,7 @@ 'collection_id' => collection.id, 'user_id' => user.id, 'site_id' => site.id, - 'data' => {'name' => site.name, 'changes' => {'lat' => [10.0, 15.1234567], 'lng' => [20.0, 20.0]}}, + 'data' => {'name' => site.name, 'changes' => {'lat' => [10.0, 15.123457], 'lng' => [20.0, 20.0]}}, 'description' => "Site '#{site.name}' changed: location changed from (10.0, 20.0) to (15.123457, 20.0)" end @@ -241,7 +241,7 @@ 'collection_id' => collection.id, 'user_id' => user.id, 'site_id' => site.id, - 'data' => {'name' => site.name, 'changes' => {'lat' => [ nil, 15.1234567], 'lng' => [nil, 34.123456]}}, + 'data' => {'name' => site.name, 'changes' => {'lat' => [ nil, 15.123457], 'lng' => [nil, 34.123456]}}, 'description' => "Site '#{site.name}' changed: location changed from (nothing) to (15.123457, 34.123456)" end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b21a61674..c5c8c07cc 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -7,8 +7,8 @@ it "should be confirmed" do user = User.make confirmed_at: nil expect(user.confirmed?).to be_falsey - user.confirm! - expect(user.confirmed?).to be_truthy + user.confirm + expect(user.reload.confirmed?).to be_truthy end it "creates a collection" do