diff --git a/bin/rails b/bin/rails
index 5191e6927..073966023 100755
--- a/bin/rails
+++ b/bin/rails
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
-APP_PATH = File.expand_path('../../config/application', __FILE__)
+APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
diff --git a/bin/setup b/bin/setup
index acdb2c138..f1b194644 100755
--- a/bin/setup
+++ b/bin/setup
@@ -1,29 +1,28 @@
#!/usr/bin/env ruby
-require 'pathname'
+require 'fileutils'
# path to your application root.
-APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+APP_ROOT = File.expand_path('..', __dir__)
-Dir.chdir APP_ROOT do
- # This script is a starting point to setup your application.
- # Add necessary setup steps to this file:
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
- puts "== Installing dependencies =="
- system "gem install bundler --conservative"
- system "bundle check || bundle install"
+FileUtils.chdir APP_ROOT do
+ # This script is a way to setup or update your development environment automatically.
+ # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
+ # Add necessary setup steps to this file.
- # puts "\n== Copying sample files =="
- # unless File.exist?("config/database.yml")
- # system "cp config/database.yml.sample config/database.yml"
- # end
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
puts "\n== Preparing database =="
- system "bin/rake db:setup"
+ system! 'bin/rails db:prepare'
puts "\n== Removing old logs and tempfiles =="
- system "rm -f log/*"
- system "rm -rf tmp/cache"
+ system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
- system "touch tmp/restart.txt"
+ system! 'bin/rails restart'
end
diff --git a/bin/unicorn b/bin/unicorn
deleted file mode 100755
index aa2ce9b6d..000000000
--- a/bin/unicorn
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env ruby
-#
-# This file was generated by Bundler.
-#
-# The application 'unicorn' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require "pathname"
-ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
- Pathname.new(__FILE__).realpath)
-
-require "rubygems"
-require "bundler/setup"
-
-load Gem.bin_path("unicorn", "unicorn")
diff --git a/bin/unicorn_rails b/bin/unicorn_rails
deleted file mode 100755
index 140d56f3c..000000000
--- a/bin/unicorn_rails
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env ruby
-#
-# This file was generated by Bundler.
-#
-# The application 'unicorn_rails' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require "pathname"
-ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
- Pathname.new(__FILE__).realpath)
-
-require "rubygems"
-require "bundler/setup"
-
-load Gem.bin_path("unicorn", "unicorn_rails")
diff --git a/config/application.rb b/config/application.rb
index 4edfc6c1d..916e96b79 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -8,13 +8,8 @@
module Timeoverflow
class Application < Rails::Application
- # 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.
-
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
- # config.time_zone = 'Central Time (US & Canada)'
+ # Initialize configuration defaults for originally generated Rails version.
+ config.load_defaults 6.0
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
@@ -23,9 +18,6 @@ class Application < Rails::Application
config.i18n.available_locales = [:es, :ca, :eu, :gl, :en, :'pt-BR']
config.i18n.fallbacks = true
- # Do not swallow errors in after_commit/after_rollback callbacks.
- config.active_record.raise_in_transactional_callbacks = true
-
# This tells Rails to serve error pages from the app itself, rather than using static error pages in public/
config.exceptions_app = self.routes
@@ -39,5 +31,9 @@ class Application < Rails::Application
# Use db/structure.sql with SQL as schema format
# This is needed to store in the schema SQL statements not covered by the ORM
config.active_record.schema_format = :sql
+
+ # Guard against DNS rebinding attacks by permitting hosts
+ config.hosts << /timeoverflow\.(local|org)/
+ config.hosts << "staging.timeoverflow.org"
end
end
diff --git a/config/boot.rb b/config/boot.rb
index 6b750f00b..30f5120df 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,3 +1,3 @@
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
diff --git a/config/deploy.rb b/config/deploy.rb
index ba4e81a33..d8c3cb40f 100644
--- a/config/deploy.rb
+++ b/config/deploy.rb
@@ -1,5 +1,5 @@
# config valid only for current version of Capistrano
-lock '3.4.1'
+lock '3.14.1'
set :application, 'timeoverflow'
set :repo_url, 'git@github.com:coopdevs/timeoverflow.git'
diff --git a/config/environment.rb b/config/environment.rb
index ee8d90dc6..426333bb4 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,5 +1,5 @@
# Load the Rails application.
-require File.expand_path('../application', __FILE__)
+require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index ef2d42c86..1d80b1c7b 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -9,12 +9,34 @@
# Do not eager load code on boot.
config.eager_load = false
- # Show full error reports and disable caching.
- config.consider_all_requests_local = true
- config.action_controller.perform_caching = false
+ # Show full error reports.
+ config.consider_all_requests_local = true
+
+ # Enable/disable caching. By default caching is disabled.
+ # Run rails dev:cache to toggle caching.
+ if Rails.root.join('tmp', 'caching-dev.txt').exist?
+ config.action_controller.perform_caching = true
+ config.action_controller.enable_fragment_cache_logging = true
+
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ 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 = true
+
+ config.action_mailer.perform_caching = false
+
+ config.action_mailer.delivery_method = :letter_opener
config.action_mailer.default_url_options = {
host: (ENV["MAIL_LINK_HOST"] || "localhost:3000")
}
@@ -25,25 +47,25 @@
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
- # 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 = true
+ # Highlight code that triggered database queries in logs.
+ config.active_record.verbose_query_logs = true
# 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
- # Suppresses logger output for asset requests
- config.assets.quiet = true
+ # 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 = 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
+ # Suppress logger output for asset requests.
+ config.assets.quiet = true
- # Raises error for missing translations
+ # Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
- config.action_mailer.delivery_method = :letter_opener
+ # 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
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index a08c2828b..f9b93e8fa 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -14,33 +14,40 @@
config.consider_all_requests_local = false
config.action_controller.perform_caching = 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
+ # 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.
- config.serve_static_files = true
+ config.public_file_server.enabled = true
- # Compress JavaScripts and CSS.
- config.assets.js_compressor = :uglifier
- # config.assets.css_compressor = :sass
+ # Compress CSS & JS using preprocessors.
+ config.assets.js_compressor = Uglifier.new(harmony: true)
+ config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
- config.assets.compile = true # false
+ config.assets.compile = true
# 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.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
+ # 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'
+ # 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
@@ -49,20 +56,20 @@
config.log_level = :debug
# Prepend all log lines with the following tags.
- # config.log_tags = [ :subdomain, :uuid ]
-
- # Use a different logger for distributed setups.
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
+ config.log_tags = [ :request_id ]
# 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'
+ # 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 = "timeoverflow_production"
+
+ config.action_mailer.perform_caching = false
# 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 = true
+ # config.action_mailer.raise_delivery_errors = false
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = {
@@ -90,6 +97,16 @@
# 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/staging.rb b/config/environments/staging.rb
index 1020fbbbf..cb080f68a 100644
--- a/config/environments/staging.rb
+++ b/config/environments/staging.rb
@@ -1,97 +1,2 @@
-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
-
- # 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 = true
-
- # 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 = true # 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
-
- # `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
-
- # 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 = [ :subdomain, :uuid ]
-
- # Use a different logger for distributed setups.
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
-
- # 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'
-
- # 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 = true
-
- config.action_mailer.delivery_method = :smtp
- config.action_mailer.default_url_options = {
- host: ENV["MAIL_LINK_HOST"],
- protocol: (ENV["MAIL_LINK_PROTO"] || "https")
- }
-
- # Retrieve SMTP configuration from environment variables
- # starting with `SMTP_`
- smtp_env = Hash[ENV.map do |k,v|
- if /^SMTP_(.*)$/ === k
- [$1.downcase.to_sym, YAML.load(v)]
- end
- end.compact]
-
- if smtp_env.present?
- config.action_mailer.smtp_settings = smtp_env
- end
-
- # 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
-
- # Do not dump schema after migrations.
- config.active_record.dump_schema_after_migration = false
-end
+# Use same settings we use for production
+require_relative "production"
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 5dfdff1c1..515e0aecc 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,10 +1,11 @@
+# The test environment is used exclusively to run your application's
+# test suite. You never need to work with it otherwise. Remember that
+# your test database is "scratch space" for the test suite and is wiped
+# and recreated between test runs. Don't rely on the data there!
+
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
- # your test database is "scratch space" for the test suite and is wiped
- # and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
@@ -12,13 +13,16 @@
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
- # Configure static file server for tests with Cache-Control for performance.
- config.serve_static_files = true
- config.static_cache_control = 'public, max-age=3600'
+ # 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=#{1.hour.to_i}"
+ }
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
+ config.cache_store = :null_store
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
@@ -26,25 +30,26 @@
# 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.default_url_options = { host: "localhost:3000" }
+ config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
- # 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
+ # Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
- # Avoid seeing all that stuff in tests
- config.log_level = :warn
-
# ActiveJob configuration
config.active_job.queue_adapter = :test
+
+ # Allow local ip for Acceptance tests
+ config.hosts << "127.0.0.1"
end
diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb
index 5763b151f..83b8198f6 100644
--- a/config/initializers/active_admin.rb
+++ b/config/initializers/active_admin.rb
@@ -1,9 +1,4 @@
-# encoding: utf-8
-
-# coding: utf-8
-
ActiveAdmin.setup do |config|
-
# == Site Title
#
# Set the title that is displayed on the main layout
@@ -144,8 +139,8 @@
# Active Admin resources and pages from here.
#
# config.before_filter :do_something_awesome
-
-
+
+
# == Setting a Favicon
#
# config.favicon = '/assets/favicon.ico'
@@ -248,6 +243,4 @@
# You can enable or disable them for all resources here.
#
# config.filters = true
-
-
end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index 109e3bc42..ee1f11b3a 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -3,11 +3,5 @@
# 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
-
-# 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( libs.css libs.js )
-
-Rails.application.config.assets.initialize_on_precompile = false
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb
index ac5f8b663..f51a497e1 100644
--- a/config/initializers/cookies_serializer.rb
+++ b/config/initializers/cookies_serializer.rb
@@ -1,3 +1,5 @@
# Be sure to restart your server when you modify this file.
-Rails.application.config.action_dispatch.cookies_serializer = :marshal
+# Specify a serializer for the signed and encrypted cookie jars.
+# Valid options are :json, :marshal, and :hybrid.
+Rails.application.config.action_dispatch.cookies_serializer = :hybrid
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
index 24dc90d49..4a994e1e7 100644
--- a/config/initializers/filter_parameter_logging.rb
+++ b/config/initializers/filter_parameter_logging.rb
@@ -1,4 +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, :assertion]
+Rails.application.config.filter_parameters += [:password]
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
index 007c0deff..bbfc3961b 100644
--- a/config/initializers/wrap_parameters.rb
+++ b/config/initializers/wrap_parameters.rb
@@ -5,10 +5,10 @@
# 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] if respond_to?(:wrap_parameters)
+ wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
-ActiveSupport.on_load(:active_record) do
- self.include_root_in_json = false
-end
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = true
+# end
diff --git a/db/seeds.rb b/db/seeds.rb
index 65dd95171..818dbdfff 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,20 +1,5 @@
-# encoding: utf-8
-
-# This file should contain all the record creation needed to seed the database
-# with its default values.
-# The data can then be loaded with the rake db:seed (or created alongside the
-# db with db:setup).
-#
-# Examples:
-#
-# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
-# Mayor.create(name: 'Emanuel', city: cities.first)
-
-Organization.find_or_create_by(name: "Banco de Tiempo Local") do |org|
-end
-
-Organization.find_or_create_by(name: "El otro Banco de Tiempo :)") do |org|
-end
+Organization.find_or_create_by(name: "Banco de Tiempo Local")
+Organization.find_or_create_by(name: "El otro Banco de Tiempo :)")
User.find_or_create_by(email: "admin@timeoverflow.org") do |user|
user.terms_accepted_at = DateTime.now.utc
@@ -214,7 +199,7 @@
Note that --- not considering the asterisk --- the actual text
content starts at 4-columns in.
- http://www.google.com
+ http://www.google.com
EOF
post.category_id = 5
post.user_id = 1
diff --git a/db/structure.sql b/db/structure.sql
index 5a2b8d516..fcb2d6336 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -12,7 +12,6 @@ SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
-SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
diff --git a/lib/assets/.gitkeep b/lib/assets/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/assets/.keep b/lib/assets/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/tasks/.gitkeep b/lib/tasks/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/tasks/deploy.rake b/lib/tasks/deploy.rake
deleted file mode 100644
index 72aa0bfea..000000000
--- a/lib/tasks/deploy.rake
+++ /dev/null
@@ -1,27 +0,0 @@
-require 'net/http'
-require 'rubygems'
-require 'json'
-
-namespace :rollbar do
-
- desc 'Send the deployment notification to Rollbar.'
- task :deploy do
- uri = URI.parse 'https://api.rollbar.com/api/1/deploy/'
- params = {
- :local_username => ENV['DEPLOY_AUTHOR'],
- :access_token => Rails.application.secrets.rollbar_access_token,
- :environment => ENV['RAILS_ENV'],
- :revision => ENV['DEPLOYED_REVISION'] }
-
- puts "Building Rollbar POST to #{uri} with #{params.inspect}"
-
- request = Net::HTTP::Post.new(uri.request_uri)
- request.body = JSON.dump(params)
-
- Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
- http.request(request)
- end
-
- puts 'Rollbar notification complete.'
- end
-end
diff --git a/spec/admin/organizations_controller_spec.rb b/spec/admin/organizations_controller_spec.rb
index c30dad8a5..cf0f77f2e 100644
--- a/spec/admin/organizations_controller_spec.rb
+++ b/spec/admin/organizations_controller_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
RSpec.describe Admin::OrganizationsController, type: :controller do
let(:organization) { Fabricate(:organization) }
let(:member) { Fabricate(:member, organization: organization) }
@@ -15,9 +13,9 @@
session[:current_organization_id] = organization.id
expect {
- delete :destroy, id: organization.id
+ delete :destroy, params: { id: organization.id }
}.to change { controller.current_user }.to(nil)
.and change { session[:current_organization_id] }.to(nil)
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 58f34db3a..ade414f43 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
RSpec.describe ApplicationController do
describe '#switch_lang' do
let(:original_locale) { I18n.locale }
@@ -16,7 +14,7 @@
new_locale = (I18n.available_locales - [original_locale]).sample
expect do
- get :switch_lang, locale: new_locale
+ get :switch_lang, params: { locale: new_locale }
end.to change(I18n, :locale).from(original_locale).to(new_locale)
expect(response).to redirect_to(root_path)
diff --git a/spec/controllers/device_tokens_controller_spec.rb b/spec/controllers/device_tokens_controller_spec.rb
index 5f2afde64..f97c6d62a 100644
--- a/spec/controllers/device_tokens_controller_spec.rb
+++ b/spec/controllers/device_tokens_controller_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
RSpec.describe DeviceTokensController do
let (:organization) { Fabricate(:organization) }
let (:member) { Fabricate(:member, organization: organization) }
@@ -18,7 +16,7 @@
login(member.user)
expect do
- post :create, token: 'xxx'
+ post :create, params: { token: 'xxx' }
end.to change(DeviceToken, :count).by(1)
end
end
diff --git a/spec/controllers/inquiries_controller_spec.rb b/spec/controllers/inquiries_controller_spec.rb
index f7bc2141e..0a78b1982 100644
--- a/spec/controllers/inquiries_controller_spec.rb
+++ b/spec/controllers/inquiries_controller_spec.rb
@@ -1,11 +1,9 @@
-require "spec_helper"
-
RSpec.describe InquiriesController do
- let(:test_organization) { Fabricate(:organization) }
- let(:member) { Fabricate(:member, organization: test_organization) }
- let(:another_member) { Fabricate(:member, organization: test_organization) }
- let(:test_category) { Fabricate(:category) }
- let!(:inquiry) do
+ let (:test_organization) { Fabricate(:organization) }
+ let (:member) { Fabricate(:member, organization: test_organization) }
+ let (:another_member) { Fabricate(:member, organization: test_organization) }
+ let (:test_category) { Fabricate(:category) }
+ let! (:inquiry) do
Fabricate(:inquiry,
user: member.user,
organization: test_organization,
@@ -29,7 +27,7 @@
it "assigns the requested inquiry to @inquiry" do
login(another_member.user)
- get "show", id: inquiry.id
+ get "show", params: { id: inquiry.id }
expect(assigns(:inquiry)).to eq(inquiry)
end
end
@@ -41,10 +39,11 @@
context "with a logged user" do
it "creates a new inquiry" do
login(another_member.user)
+
expect do
- post "create", inquiry: { user: another_member.user,
+ post "create", params: { inquiry: { user: another_member.user,
category_id: test_category.id,
- title: "New title" }
+ title: "New title" }}
end.to change(Inquiry, :count).by(1)
end
end
@@ -54,21 +53,24 @@
describe "PUT #update" do
context "with valid params" do
context "with a logged user" do
- before { login(member.user) }
-
it "located the requested @inquiry" do
- put "update", id: inquiry.id, inquiry: Fabricate.to_params(:inquiry)
+ login(member.user)
+
+ put "update", params: { id: inquiry.id, inquiry: Fabricate.to_params(:inquiry) }
expect(assigns(:inquiry)).to eq(inquiry)
end
it "changes @inquiry's attributes" do
- put "update",
- id: inquiry.id,
- inquiry: Fabricate.to_params(:inquiry,
- user: member,
- title: "New title",
- description: "New description",
- tag_list: ["foo"])
+ login(member.user)
+
+ put "update", params: {
+ id: inquiry.id,
+ inquiry: Fabricate.to_params(:inquiry,
+ user: member,
+ title: "New title",
+ description: "New description",
+ tag_list: ["foo"])
+ }
inquiry.reload
expect(inquiry.title).to eq("New title")
@@ -83,12 +85,13 @@
it "does not change @inquiry's attributes" do
login(member.user)
- put :update,
- id: inquiry.id,
- inquiry: Fabricate.to_params(:inquiry,
- user: nil,
- title: "New title",
- description: "New description")
+ put :update, params: {
+ id: inquiry.id,
+ inquiry: Fabricate.to_params(:inquiry,
+ user: nil,
+ title: "New title",
+ description: "New description")
+ }
expect(inquiry.title).not_to eq("New title")
expect(inquiry.description).not_to eq("New description")
@@ -98,17 +101,19 @@
end
describe "DELETE destroy" do
- before { login(member.user) }
-
it "toggle active field" do
- delete :destroy, id: inquiry.id
+ login(member.user)
+
+ delete :destroy, params: { id: inquiry.id }
inquiry.reload
expect(inquiry.active).to be false
end
it "redirects to inquiries#index" do
- delete :destroy, id: inquiry.id
+ login(member.user)
+
+ delete :destroy, params: { id: inquiry.id }
expect(response).to redirect_to inquiries_url
end
end
diff --git a/spec/controllers/multi_transfers_controller_spec.rb b/spec/controllers/multi_transfers_controller_spec.rb
index 1caa040c7..85378d33e 100644
--- a/spec/controllers/multi_transfers_controller_spec.rb
+++ b/spec/controllers/multi_transfers_controller_spec.rb
@@ -1,5 +1,3 @@
-require "spec_helper"
-
RSpec.describe MultiTransfersController, type: :controller do
let(:organization) { Fabricate(:organization) }
let(:admin) { Fabricate(:member, organization: organization, manager: true) }
@@ -18,31 +16,31 @@
expect do
login(admin.user)
- get :step, step: 1
+ get :step, params: { step: 1 }
params = {}
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 2,
type_of_transfer: :one_to_many
)
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 3,
from: [member.account].map(&:id)
)
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 4,
to: [another_member.account, yet_another_member.account].map(&:id)
)
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 5,
transfer: {amount: 3600, reason: 'because of reasons'}
)
- post :create, params
+ post :create, params: params
end.to change { Transfer.count }.by(2)
end
@@ -50,31 +48,31 @@
expect do
login(admin.user)
- get :step, step: 1
+ get :step, params: { step: 1 }
params = {}
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 2,
type_of_transfer: :many_to_one
)
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 3,
to: [another_member.account, yet_another_member.account].map(&:id)
)
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 4,
from: [member.account].map(&:id)
)
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 5,
transfer: {amount: 3600, reason: 'because of reasons'}
)
- post :create, params
+ post :create, params: params
end.to change { Transfer.count }.by(2)
end
@@ -83,31 +81,31 @@
expect do
login(admin.user)
- get :step, step: 1
+ get :step, params: { step: 1 }
params = {}
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 2,
type_of_transfer: :many_to_one
)
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 3,
to: [member.account].map(&:id)
)
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 4,
from: [another_member.account].map(&:id)
)
- post :step, params.merge!(
+ post :step, params: params.merge!(
step: 5,
transfer: {amount: 3600, reason: 'because of reasons'}
)
- post :create, params
+ post :create, params: params
end.to change { Transfer.count }.by(1)
end
end
@@ -116,7 +114,7 @@
it 'cannot access step route' do
login(member.user)
- get :step, step: 1
+ get :step, params: { step: 1 }
expect(response).not_to have_http_status(:success)
end
@@ -124,7 +122,7 @@
it 'cannot access create route' do
login(member.user)
- post :create, {}
+ post :create
response.should redirect_to('/')
end
diff --git a/spec/controllers/offers_controller_spec.rb b/spec/controllers/offers_controller_spec.rb
index d72c27610..e9b0184c3 100644
--- a/spec/controllers/offers_controller_spec.rb
+++ b/spec/controllers/offers_controller_spec.rb
@@ -1,5 +1,3 @@
-require "spec_helper"
-
RSpec.describe OffersController, type: :controller do
let(:organization) { Fabricate(:organization) }
let(:member) { Fabricate(:member, organization: organization) }
@@ -78,13 +76,13 @@
end
it "populates an array of offers" do
- get :index, q: 'compañeros'
+ get :index, params: { q: 'compañeros' }
expect(assigns(:offers)).to eq([offer])
end
it "allows to search by partial word" do
- get :index, q: 'compañ'
+ get :index, params: { q: 'compañ' }
expect(assigns(:offers)).to eq([offer])
end
@@ -132,7 +130,7 @@
end
it 'renders the 404 page' do
- get :show, id: offer.id
+ get :show, params: { id: offer.id }
expect(response.status).to eq(404)
end
end
@@ -145,24 +143,24 @@
end
it 'renders the 404 page' do
- get :show, id: offer.id
+ get :show, params: { id: offer.id }
expect(response.status).to eq(404)
end
end
context 'and the user that created the offer is active' do
it 'renders a successful response' do
- get :show, id: offer.id
+ get :show, params: { id: offer.id }
expect(response.status).to eq(200)
end
it 'assigns the requested offer to @offer' do
- get :show, id: offer.id
+ get :show, params: { id: offer.id }
expect(assigns(:offer)).to eq(offer)
end
it 'assigns the account destination of the transfer' do
- get :show, id: offer.id
+ get :show, params: { id: offer.id }
expect(assigns(:destination_account)).to eq(member.account)
end
end
@@ -179,7 +177,7 @@
end
it 'sets the offer\'s organization as user\'s current organization' do
- get :show, id: offer.id
+ get :show, params: { id: offer.id }
expect(session[:current_organization_id]).to eq(offer.organization_id)
expect(assigns(:current_organization)).to eq(offer.organization)
end
@@ -195,10 +193,10 @@
context 'when the user is not logged in' do
it 'assigns the requested offer to @offer' do
- get :show, id: offer.id
+ get :show, params: { id: offer.id }
expect(assigns(:offer)).to eq(offer)
end
-
+
end
end
@@ -209,9 +207,9 @@
login(another_member.user)
expect do
- post "create", offer: { user: another_member.user,
+ post "create", params: { offer: { user: another_member.user,
category_id: test_category,
- title: "New title" }
+ title: "New title" } }
end.to change(Offer, :count).by(1)
end
end
@@ -224,20 +222,18 @@
it "located the requested @offer" do
login(member.user)
- put "update", id: offer.id, offer: Fabricate.to_params(:offer)
+ put "update", params: { id: offer.id, offer: Fabricate.to_params(:offer) }
expect(assigns(:offer)).to eq(offer)
end
it "changes @offer's attributes" do
login(member.user)
- put "update",
- id: offer.id,
- offer: Fabricate.to_params(:offer,
+ put "update", params: { id: offer.id, offer: Fabricate.to_params(:offer,
user: member,
title: "New title",
description: "New description",
- tag_list: ["foo"])
+ tag_list: ["foo"]) }
offer.reload
expect(offer.title).to eq("New title")
@@ -252,12 +248,10 @@
it "does not change @offer's attributes" do
login(member.user)
- put :update,
- id: offer.id,
- offer: Fabricate.to_params(:offer,
+ put :update, params: { id: offer.id, offer: Fabricate.to_params(:offer,
user: nil,
title: "New title",
- description: "New description")
+ description: "New description") }
expect(offer.title).not_to eq("New title")
expect(offer.description).not_to eq("New description")
@@ -270,7 +264,7 @@
it "toggle active field" do
login(member.user)
- delete :destroy, id: offer.id
+ delete :destroy, params: { id: offer.id }
offer.reload
expect(offer.active).to be false
@@ -279,7 +273,7 @@
it "redirects to offers#index" do
login(member.user)
- delete :destroy, id: offer.id
+ delete :destroy, params: { id: offer.id }
expect(response).to redirect_to offers_url
end
end
diff --git a/spec/controllers/organizations_controller_spec.rb b/spec/controllers/organizations_controller_spec.rb
index fc4144bf6..1adb6f57b 100644
--- a/spec/controllers/organizations_controller_spec.rb
+++ b/spec/controllers/organizations_controller_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
RSpec.describe OrganizationsController do
let!(:organization) { Fabricate(:organization) }
let(:member) { Fabricate(:member, organization: organization) }
@@ -14,8 +12,8 @@
end
describe 'GET #show' do
- it 'displays the organization page' do
- get 'show', id: organization.id
+ it 'displays the organization page' do
+ get 'show', params: { id: organization.id }
expect(assigns(:organization)).to eq(organization)
expect(response.status).to eq(200)
@@ -27,7 +25,7 @@
login(member.user)
expect {
- post :create, organization: { name: 'New cool organization' }
+ post :create, params: { organization: { name: 'New cool organization' } }
}.not_to change { Organization.count }
end
end
@@ -39,7 +37,7 @@
it 'allows to update organization' do
login(member.user)
- post :update, id: organization.id, organization: { name: 'New org name' }
+ post :update, params: { id: organization.id, organization: { name: 'New org name' } }
organization.reload
expect(organization.name).to eq('New org name')
@@ -48,7 +46,7 @@
context 'without a logged user' do
it 'does not allow to update organization' do
- post :update, id: organization.id, organization: { name: 'New org name' }
+ post :update, params: { id: organization.id, organization: { name: 'New org name' } }
expect(response).to redirect_to(root_path)
expect(flash[:error]).to eq('You are not authorized to perform this action.')
@@ -60,7 +58,7 @@
before { login(user) }
it 'stores the given organization as current organization in session' do
- post 'set_current', id: organization.id
+ post 'set_current', params: { id: organization.id }
expect(session[:current_organization_id]).to eq(organization.id)
end
diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb
index dfbc512b8..eba90f4ed 100644
--- a/spec/controllers/pages_controller_spec.rb
+++ b/spec/controllers/pages_controller_spec.rb
@@ -1,15 +1,13 @@
-require 'spec_helper'
-
RSpec.describe PagesController do
describe '#show' do
it 'renders the page successfully' do
- get :show, page: :about
+ get :show, params: { page: :about }
expect(response).to render_template(:about)
end
it 'returns a 404 if the page does not exist' do
- get :show, page: :foo
+ get :show, params: { page: :foo }
expect(response.status).to eq(404)
end
diff --git a/spec/controllers/reports_controller_spec.rb b/spec/controllers/reports_controller_spec.rb
index ec0636bbc..078c0ef12 100644
--- a/spec/controllers/reports_controller_spec.rb
+++ b/spec/controllers/reports_controller_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
RSpec.describe ReportsController do
let (:test_organization) { Fabricate(:organization) }
let (:member1) { Fabricate(:member, organization: test_organization) }
@@ -30,7 +28,7 @@
it 'do NOT show the inactive members' do
login(member1.user)
- get 'post_list', type: 'offer'
+ get 'post_list', params: { type: 'offer' }
posts = assigns(:posts)[0][1]
expect(posts.size).to eq(active_organization_offers.size)
expect(posts.map(&:id)).to match_array(active_organization_offers.map(&:id))
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index d81029b6d..57254daf2 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
RSpec.describe SessionsController do
let(:user) do
Fabricate(:user, password: 'papapa22', password_confirmation: 'papapa22')
@@ -11,10 +9,10 @@
end
it 'does not show a notice flash message' do
- post :create, user: {
+ post :create, params: { user: {
email: user.email,
password: user.password
- }
+ } }
expect(flash[:notice]).to be_nil
end
end
@@ -22,10 +20,10 @@
describe '#destroy' do
before do
request.env["devise.mapping"] = Devise.mappings[:user]
- post :create, user: {
+ post :create, params: { user: {
email: user.email,
password: user.password
- }
+ } }
end
it 'does not show a notice flash message' do
diff --git a/spec/controllers/statistics_controller_spec.rb b/spec/controllers/statistics_controller_spec.rb
new file mode 100644
index 000000000..ac97a5cce
--- /dev/null
+++ b/spec/controllers/statistics_controller_spec.rb
@@ -0,0 +1,17 @@
+RSpec.describe StatisticsController do
+ let(:organization) { Fabricate(:organization) }
+ let(:member) { Fabricate(:member, organization: organization) }
+
+ before(:each) { login(member.user) }
+
+ describe '#statistics_all_transfers' do
+ it 'populates all transfers from current organization' do
+ transfer = Fabricate(:transfer, source: organization.account, destination: member.account)
+ transfer2 = Fabricate(:transfer)
+
+ get :statistics_all_transfers
+
+ expect(assigns(:transfers)).to eq([transfer])
+ end
+ end
+end
diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb
index a2192222a..18463048e 100644
--- a/spec/controllers/tags_controller_spec.rb
+++ b/spec/controllers/tags_controller_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
RSpec.describe TagsController do
let (:tags) { %w(foo bar baz) }
let (:organization) { Fabricate(:organization) }
@@ -16,8 +14,8 @@
it "returns http success" do
get 'index'
- expect(response).to be_success
- expect(response.content_type).to eq("application/json")
+ expect(response).to have_http_status(:ok)
+ expect(response.content_type).to match("application/json")
end
it "with no search term, returns all tags" do
@@ -26,7 +24,7 @@
end
it "with search term, returns filtered tags" do
- get 'index', term: "foo"
+ get 'index', params: { term: "foo" }
expect(assigns(:all_tags)).to eq(["foo"])
end
end
diff --git a/spec/controllers/transfers_controller_spec.rb b/spec/controllers/transfers_controller_spec.rb
index 453b861c9..ca81e45f4 100644
--- a/spec/controllers/transfers_controller_spec.rb
+++ b/spec/controllers/transfers_controller_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
RSpec.describe TransfersController do
let (:test_organization) { Fabricate(:organization) }
let (:member_admin) { Fabricate(:member, organization: test_organization, manager: true) }
@@ -23,39 +21,39 @@
end
it 'finds the accountable' do
- get :new, params
+ get :new, params: params
expect(response.body)
.to include("#{member_giver.display_name_with_uid}")
end
it 'finds the destination account' do
- get :new, params
- expect(response.body).to include("")
+ get :new, params: params
+ expect(response.body).to include("")
end
it 'builds a transfer with the id of the destination' do
- get :new, params
+ get :new, params: params
expect(response.body)
- .to include("")
+ .to include("")
end
context 'when the offer is specified' do
let(:offer) { Fabricate(:offer, organization: user.organizations.first) }
it 'finds the transfer offer' do
- get :new, params.merge(offer: offer.id)
+ get :new, params: params.merge(offer: offer.id)
expect(response.body).to include("
#{offer}
")
end
it 'builds a transfer with the offer as post' do
- get :new, params.merge(offer: offer.id)
- expect(response.body).to include("")
+ get :new, params: params.merge(offer: offer.id)
+ expect(response.body).to include("")
end
end
context 'when the offer is not specified' do
it 'does not find any offer' do
- get :new, params
+ get :new, params: params
expect(response.body).to include('