diff --git a/Gemfile b/Gemfile
index 50ea0a6f..634d67c8 100755
--- a/Gemfile
+++ b/Gemfile
@@ -6,18 +6,17 @@ ruby File.read('.ruby-version').strip
# the base rails libraries
gem 'pg', '~> 0.21.0'
-gem 'rails', '~> 3.2.16'
+gem 'rails', '~> 4.0.13'
gem 'rails_12factor'
-gem 'thin'
+gem 'puma'
# for handling json objects with ruby
gem 'json'
-
-gem 'bootstrap-sass', '~> 3.2.0'
-gem 'coffee-rails', '~> 3.2.1'
+gem 'protected_attributes'
+gem 'bootstrap-sass', '~> 3.4.0'
gem 'font-awesome-sass', '~> 4.4.0'
gem 'jquery-rails', '2.1.4'
-gem 'sass-rails', '~> 3.2.6'
+gem 'sass-rails', '~> 5.0'
gem 'simple_form'
gem 'therubyracer', platforms: :ruby
gem 'twitter-bootstrap-rails'
@@ -46,17 +45,14 @@ end
group :test do
gem 'capybara'
gem 'capybara-screenshot'
- gem 'factory_girl_rails'
+ gem 'factory_bot_rails'
gem 'poltergeist', '~> 1.12'
gem 'rack-test'
gem 'rspec-rails', '~> 3.5'
end
-# Temporary fix: https://stackoverflow.com/questions/13828889/rails-3-heroku-cannot-load-such-file-test-unit-testcase-loaderror
-# Remove after upgrade of Rails from 3.2 is complete.
-gem 'test-unit', '~> 3.0'
# dynamic in-place editing for some admin tables
-gem 'active_scaffold'
+gem 'active_scaffold', '~> 3.4.43'
# handles authentication
gem 'devise', '~> 3.2.0'
@@ -71,7 +67,7 @@ gem 'paperclip', git: 'https://github.com/thoughtbot/paperclip',
ref: '523bd46c768226893f23889079a7aa9c73b57d68'
# generate pdfs
-gem 'prawn', '~> 2.1.0'
+gem 'prawn', '~> 2.2.0'
gem 'prawn-table', '~> 0.2.2'
# used to geo-locate locations
@@ -89,12 +85,13 @@ gem 'jquery-datatables-rails', git: 'https://github.com/rweng/jquery-datatables-
gem 'cocoon'
# set timezone to browser timezone
-gem 'browser-timezone-rails', '~> 0.2.00'
+gem 'browser-timezone-rails', '~> 1.0'
+gem 'js_cookie_rails'
gem 'ranked-model'
# Send email when exception occurs.
-gem 'exception_notification', '~> 3.0.1'
-gem 'exception_notification-rake', '~> 0.0.6'
+gem 'exception_notification', '~> 4.0.1'
+gem 'exception_notification-rake', '~> 0.1.3'
gem 'cancancan', '~> 1.15.0'
gem 'interactor'
diff --git a/Gemfile.lock b/Gemfile.lock
index bd3b9d3f..3829ac98 100755
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -23,39 +23,38 @@ GIT
GEM
remote: https://rubygems.org/
specs:
- actionmailer (3.2.22.5)
- actionpack (= 3.2.22.5)
- mail (~> 2.5.4)
- actionpack (3.2.22.5)
- activemodel (= 3.2.22.5)
- activesupport (= 3.2.22.5)
- builder (~> 3.0.0)
+ actionmailer (4.0.13)
+ actionpack (= 4.0.13)
+ mail (~> 2.5, >= 2.5.4)
+ actionpack (4.0.13)
+ activesupport (= 4.0.13)
+ builder (~> 3.1.0)
erubis (~> 2.7.0)
- journey (~> 1.0.4)
- rack (~> 1.4.5)
- rack-cache (~> 1.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.2.1)
+ rack (~> 1.5.2)
+ rack-test (~> 0.6.2)
active_scaffold (3.4.43)
rails (>= 3.2.22.2, < 5)
- activemodel (3.2.22.5)
- activesupport (= 3.2.22.5)
- builder (~> 3.0.0)
- activerecord (3.2.22.5)
- activemodel (= 3.2.22.5)
- activesupport (= 3.2.22.5)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activeresource (3.2.22.5)
- activemodel (= 3.2.22.5)
- activesupport (= 3.2.22.5)
- activesupport (3.2.22.5)
- i18n (~> 0.6, >= 0.6.4)
- multi_json (~> 1.0)
+ activemodel (4.0.13)
+ activesupport (= 4.0.13)
+ builder (~> 3.1.0)
+ activerecord (4.0.13)
+ activemodel (= 4.0.13)
+ activerecord-deprecated_finders (~> 1.0.2)
+ activesupport (= 4.0.13)
+ arel (~> 4.0.0)
+ activerecord-deprecated_finders (1.0.4)
+ activesupport (4.0.13)
+ i18n (~> 0.6, >= 0.6.9)
+ minitest (~> 4.2)
+ multi_json (~> 1.3)
+ thread_safe (~> 0.1)
+ tzinfo (~> 0.3.37)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
- arel (3.0.3)
+ arel (4.0.2)
ast (2.4.0)
+ autoprefixer-rails (9.4.8)
+ execjs
awesome_print (1.8.0)
aws-sdk (2.11.227)
aws-sdk-resources (= 2.11.227)
@@ -72,15 +71,15 @@ GEM
rack (>= 0.9.0)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
- bootstrap-sass (3.2.0.2)
- sass (~> 3.2)
- browser-timezone-rails (0.2.00)
- jquery-cookie-rails
- jquery-rails
- jstz-rails
+ bootstrap-sass (3.4.1)
+ autoprefixer-rails (>= 5.2.1)
+ sassc (>= 2.0.0)
+ browser-timezone-rails (1.0.3)
+ js_cookie_rails
+ jstz-rails3-plus
rails (>= 3.1)
buftok (0.2.0)
- builder (3.0.4)
+ builder (3.1.4)
byebug (11.0.0)
cancancan (1.15.0)
capybara (2.18.0)
@@ -100,16 +99,8 @@ GEM
climate_control (>= 0.0.3, < 1.0)
cocoon (1.2.12)
coderay (1.1.2)
- coffee-rails (3.2.2)
- coffee-script (>= 2.2.0)
- railties (~> 3.2.0)
- coffee-script (2.4.1)
- coffee-script-source
- execjs
- coffee-script-source (1.12.2)
commonjs (0.2.7)
concurrent-ruby (1.1.4)
- daemons (1.3.1)
debug_inspector (0.0.3)
devise (3.2.4)
bcrypt (~> 3.0)
@@ -127,21 +118,21 @@ GEM
equalizer (0.0.11)
erubi (1.8.0)
erubis (2.7.0)
- eventmachine (1.2.7)
- exception_notification (3.0.1)
+ exception_notification (4.0.1)
actionmailer (>= 3.0.4)
- exception_notification-rake (0.0.7)
- exception_notification (~> 3.0.1)
+ activesupport (>= 3.0.4)
+ exception_notification-rake (0.1.3)
+ exception_notification (~> 4.0.1)
rake (>= 0.9.0)
execjs (2.7.0)
- factory_girl (4.9.0)
+ factory_bot (4.11.1)
activesupport (>= 3.0.0)
- factory_girl_rails (4.9.0)
- factory_girl (~> 4.9.0)
+ factory_bot_rails (4.11.1)
+ factory_bot (~> 4.11.1)
railties (>= 3.0.0)
faker (1.7.3)
i18n (~> 0.5)
- ffi (1.10.0)
+ ffi (1.9.25)
font-awesome-sass (4.4.0)
sass (>= 3.2)
formatador (0.2.5)
@@ -163,7 +154,6 @@ GEM
rspec (>= 2.99.0, < 4.0)
highcharts-rails (3.0.10)
railties (>= 3.1)
- hike (1.2.3)
http (3.3.0)
addressable (~> 2.3)
http-cookie (~> 1.0)
@@ -179,38 +169,40 @@ GEM
interception (0.5)
jaro_winkler (1.5.2)
jmespath (1.4.0)
- journey (1.0.4)
- jquery-cookie-rails (1.3.1.1)
- railties (>= 3.2.0, < 5.0)
jquery-rails (2.1.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
+ js_cookie_rails (2.2.0)
+ railties (>= 3.1)
json (2.2.0)
- jstz-rails (1.0.4.1)
- railties (~> 3.1)
+ jstz-rails3-plus (1.0.5)
+ railties (>= 3.1)
launchy (2.4.3)
addressable (~> 2.3)
less (2.6.0)
commonjs (~> 0.2.7)
- less-rails (2.6.0)
- actionpack (>= 3.1)
+ less-rails (4.0.0)
+ actionpack (>= 4)
less (~> 2.6.0)
+ sprockets (>= 2)
libv8 (3.16.14.19)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
lumberjack (1.0.13)
- mail (2.5.5)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
+ mail (2.7.1)
+ mini_mime (>= 0.1.1)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
method_source (0.9.2)
- mime-types (1.25.1)
+ mime-types (3.2.2)
+ mime-types-data (~> 3.2015)
+ mime-types-data (3.2018.0812)
mimemagic (0.3.0)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
+ minitest (4.7.5)
multi_json (1.13.1)
multipart-post (2.0.0)
naught (1.1.0)
@@ -225,20 +217,20 @@ GEM
parallel (1.13.0)
parser (2.6.0.0)
ast (~> 2.4.0)
- pdf-core (0.6.1)
+ pdf-core (0.7.0)
pg (0.21.0)
poltergeist (1.18.1)
capybara (>= 2.1, < 4)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
- polyglot (0.3.5)
- power_assert (1.1.3)
powerpack (0.1.2)
- prawn (2.1.0)
- pdf-core (~> 0.6.1)
- ttfunk (~> 1.4.0)
+ prawn (2.2.2)
+ pdf-core (~> 0.7.0)
+ ttfunk (~> 1.5)
prawn-table (0.2.2)
prawn (>= 1.3.0, < 3.0.0)
+ protected_attributes (1.1.4)
+ activemodel (>= 4.0.1, < 5.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
@@ -255,21 +247,18 @@ GEM
pry (>= 0.12.0)
psych (3.1.0)
public_suffix (3.0.3)
- rack (1.4.7)
- rack-cache (1.8.0)
- rack (>= 0.4)
- rack-ssl (1.3.4)
- rack
+ puma (3.12.0)
+ rack (1.5.5)
rack-test (0.6.3)
rack (>= 1.0)
- rails (3.2.22.5)
- actionmailer (= 3.2.22.5)
- actionpack (= 3.2.22.5)
- activerecord (= 3.2.22.5)
- activeresource (= 3.2.22.5)
- activesupport (= 3.2.22.5)
- bundler (~> 1.0)
- railties (= 3.2.22.5)
+ rails (4.0.13)
+ actionmailer (= 4.0.13)
+ actionpack (= 4.0.13)
+ activerecord (= 4.0.13)
+ activesupport (= 4.0.13)
+ bundler (>= 1.3.0, < 2.0)
+ railties (= 4.0.13)
+ sprockets-rails (~> 2.0)
rails-erd (1.5.2)
activerecord (>= 3.2)
activesupport (>= 3.2)
@@ -280,13 +269,11 @@ GEM
rails_stdout_logging
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
- railties (3.2.22.5)
- actionpack (= 3.2.22.5)
- activesupport (= 3.2.22.5)
- rack-ssl (~> 1.3.2)
+ railties (4.0.13)
+ actionpack (= 4.0.13)
+ activesupport (= 4.0.13)
rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (>= 0.14.6, < 2.0)
+ thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
rake (12.3.2)
ranked-model (0.4.1)
@@ -294,7 +281,6 @@ GEM
rb-fsevent (0.9.8)
rb-inotify (0.10.0)
ffi (~> 1.0)
- rdoc (3.9.5)
ref (2.0.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
@@ -334,38 +320,36 @@ GEM
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
- sass-rails (3.2.6)
- railties (~> 3.2.0)
- sass (>= 3.1.10)
- tilt (~> 1.3)
+ sass-rails (5.0.7)
+ railties (>= 4.0.0, < 6)
+ sass (~> 3.1)
+ sprockets (>= 2.8, < 4.0)
+ sprockets-rails (>= 2.0, < 4.0)
+ tilt (>= 1.1, < 3)
+ sassc (2.0.0)
+ ffi (~> 1.9.6)
+ rake
shellany (0.0.1)
- simple_form (2.1.3)
- actionpack (~> 3.0)
- activemodel (~> 3.0)
+ simple_form (4.0.0)
+ actionpack (> 4)
+ activemodel (> 4)
simple_oauth (0.3.1)
slop (3.6.0)
- sprockets (2.2.3)
- hike (~> 1.2)
- multi_json (~> 1.0)
- rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
+ sprockets (3.7.2)
+ concurrent-ruby (~> 1.0)
+ rack (> 1, < 3)
+ sprockets-rails (2.3.3)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ sprockets (>= 2.8, < 4.0)
sqlite3 (1.4.0)
- test-unit (3.3.0)
- power_assert
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
- thin (1.7.2)
- daemons (~> 1.0, >= 1.0.9)
- eventmachine (~> 1.0, >= 1.0.4)
- rack (>= 1, < 3)
thor (0.20.3)
thread_safe (0.3.6)
- tilt (1.4.1)
- treetop (1.4.15)
- polyglot
- polyglot (>= 0.3.1)
- ttfunk (1.4.0)
+ tilt (2.0.9)
+ ttfunk (1.5.1)
twitter (6.2.0)
addressable (~> 2.3)
buftok (~> 0.2.0)
@@ -404,24 +388,23 @@ PLATFORMS
ruby
DEPENDENCIES
- active_scaffold
+ active_scaffold (~> 3.4.43)
addressable
awesome_print
aws-sdk (~> 2.3)
better_errors
binding_of_caller
- bootstrap-sass (~> 3.2.0)
- browser-timezone-rails (~> 0.2.00)
+ bootstrap-sass (~> 3.4.0)
+ browser-timezone-rails (~> 1.0)
cancancan (~> 1.15.0)
capybara
capybara-screenshot
cocoon
- coffee-rails (~> 3.2.1)
devise (~> 3.2.0)
dotenv-rails
- exception_notification (~> 3.0.1)
- exception_notification-rake (~> 0.0.6)
- factory_girl_rails
+ exception_notification (~> 4.0.1)
+ exception_notification-rake (~> 0.1.3)
+ factory_bot_rails
faker (~> 1.7.3)
font-awesome-sass (~> 4.4.0)
geocoder
@@ -431,31 +414,32 @@ DEPENDENCIES
interactor
jquery-datatables-rails!
jquery-rails (= 2.1.4)
+ js_cookie_rails
json
newrelic_rpm
paperclip!
pg (~> 0.21.0)
poltergeist (~> 1.12)
- prawn (~> 2.1.0)
+ prawn (~> 2.2.0)
prawn-table (~> 0.2.2)
+ protected_attributes
pry-byebug
pry-rails
pry-remote
pry-rescue
+ puma
rack-test
- rails (~> 3.2.16)
+ rails (~> 4.0.13)
rails-erd
rails_12factor
ranked-model
rb-fsevent (~> 0.9.0)
rspec-rails (~> 3.5)
rubocop
- sass-rails (~> 3.2.6)
+ sass-rails (~> 5.0)
simple_form
sqlite3
- test-unit (~> 3.0)
therubyracer
- thin
twitter
twitter-bootstrap-rails
uglifier (>= 1.0.3)
diff --git a/Procfile b/Procfile
index 91f8d1f6..c2c566e8 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-web: bundle exec rails server thin -p \$PORT -e \$RACK_ENV
+web: bundle exec puma -C config/puma.rb
diff --git a/Procfile.dev b/Procfile.dev
index 1110b7e0..4b593b4d 100644
--- a/Procfile.dev
+++ b/Procfile.dev
@@ -1,2 +1,2 @@
-web: bundle exec thin start -p $PORT
+web: bundle exec puma -C config/puma.rb
rails: tail -f log/development.log
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 352ccb83..4013d0fd 100755
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -12,11 +12,11 @@
//
//= require jquery
//= require jquery_ujs
-//= require jquery.cookie
//= require bootstrap-sprockets
//= require dataTables/jquery.dataTables
//= require highcharts
//= require active_scaffold
+//= require js.cookie
//= require jstz
//= require browser_timezone_rails/set_time_zone
//= require cocoon
diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.scss
similarity index 55%
rename from app/assets/stylesheets/application.css.scss
rename to app/assets/stylesheets/application.scss
index c7b6589c..d2b104b5 100755
--- a/app/assets/stylesheets/application.css.scss
+++ b/app/assets/stylesheets/application.scss
@@ -16,6 +16,15 @@
@import "font-awesome-sprockets";
@import "font-awesome";
-@import "modules/**";
+@import "modules/buttons";
+@import "modules/charts";
+@import "modules/day_times";
+@import "modules/footer";
+@import "modules/forms";
+@import "modules/header";
+@import "modules/scrollbars";
+@import "modules/select2_bootstrap";
+@import "modules/tables";
+@import "modules/typography";
-@import "pages/**";
+@import "pages/home";
diff --git a/app/assets/stylesheets/base/_bootstrap_and_overrides.css.scss b/app/assets/stylesheets/base/_bootstrap_and_overrides.scss
similarity index 100%
rename from app/assets/stylesheets/base/_bootstrap_and_overrides.css.scss
rename to app/assets/stylesheets/base/_bootstrap_and_overrides.scss
diff --git a/app/assets/stylesheets/modules/_day_times.css.scss b/app/assets/stylesheets/modules/_day_times.scss
similarity index 100%
rename from app/assets/stylesheets/modules/_day_times.css.scss
rename to app/assets/stylesheets/modules/_day_times.scss
diff --git a/app/assets/stylesheets/pages/home.css.scss b/app/assets/stylesheets/pages/home.scss
similarity index 100%
rename from app/assets/stylesheets/pages/home.css.scss
rename to app/assets/stylesheets/pages/home.scss
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 845cfae6..63e34c71 100755
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -8,6 +8,9 @@ class ApplicationController < ActionController::Base
before_filter :authenticate_user_from_token!
respond_to :html, :json
+ layout :layout_by_resource
+
+ alias_method :current_user, :current_volunteer
def setup_headers
headers['Access-Control-Allow-Origin'] = '*'
@@ -35,18 +38,11 @@ def setup_headers
end
end
- alias_method :current_user, :current_volunteer
-
- layout :layout_by_resource
-
protected
def layout_by_resource
- if devise_controller?
- 'custom_devise'
- else
- 'application'
- end
+ return 'custom_devise' if devise_controller?
+ 'application'
end
private
@@ -54,8 +50,8 @@ def layout_by_resource
# add in the variables needed by the form partial for schedules and logs
def set_vars_for_form(region)
@volunteers = Volunteer.all_for_region(region.id).collect{ |v| [v.name, v.id] }
- @donors = Location.donors.where(:region_id=>region.id).collect{ |d| [d.name, d.id] }
- @recipients = Location.recipients.where(:region_id=>region.id).collect{ |r| [r.name, r.id] }
+ @donors = Location.donors.where(region_id: region.id).collect{ |d| [d.name, d.id] }
+ @recipients = Location.recipients.where(region_id: region.id).collect{ |r| [r.name, r.id] }
@transport_types = TransportType.all.collect{ |tt| [tt.name, tt.id] }
@food_types = region.food_types.collect { |food_type| [food_type.name, food_type.id] }
diff --git a/app/controllers/volunteers_controller.rb b/app/controllers/volunteers_controller.rb
index afd947bd..8e68d0e0 100755
--- a/app/controllers/volunteers_controller.rb
+++ b/app/controllers/volunteers_controller.rb
@@ -25,8 +25,7 @@ def assign
else
Assignment.add_volunteer_to_region(volunteer, region)
unless params[:send_welcome_email].nil? || params[:send_welcome_email].to_i != 1
- message = Notifier.region_welcome_email(region, volunteer)
- message&.deliver
+ Notifier.region_welcome_email(region, volunteer)&.deliver
end
volunteer.save
end
@@ -34,7 +33,8 @@ def assign
end
def shiftless
- @volunteers = Volunteer.active_but_shiftless(current_volunteer.region_ids)
+ @volunteers = Volunteer.includes(:absences, :transport_type, :regions)
+ .active_but_shiftless(current_volunteer.region_ids)
@header = 'Shiftless Volunteers'
render :index
end
@@ -52,7 +52,8 @@ def inactive
end
def need_training
- @volunteers = Volunteer.not_super_admin.needing_training(current_volunteer.region_ids)
+ @volunteers = Volunteer.not_super_admin
+ .needing_training(current_volunteer.region_ids)
@header = 'Volunteers Needing Training'
render :index
end
diff --git a/app/models/log.rb b/app/models/log.rb
index d24182a4..a3bc1e9e 100755
--- a/app/models/log.rb
+++ b/app/models/log.rb
@@ -10,10 +10,8 @@ class Log < ActiveRecord::Base
belongs_to :region
has_many :log_volunteers
- has_many :volunteers, through: :log_volunteers,
- conditions: {'log_volunteers.active' => true}
- has_many :inactive_volunteers, through: :log_volunteers,
- conditions: {'log_volunteers.active' => false}
+ has_many :volunteers, -> { where(log_volunteers: { active: true }) }, through: :log_volunteers
+ has_many :inactive_volunteers, -> { where(log_volunteers: { active: false }) }, through: :log_volunteers
has_many :log_recipients
has_many :recipients, through: :log_recipients
has_many :log_parts
@@ -27,14 +25,14 @@ class Log < ActiveRecord::Base
accepts_nested_attributes_for :log_volunteers
accepts_nested_attributes_for :schedule_chain
- validates :notes, presence: { if: Proc.new{ |a| a.complete and a.summed_weight == 0 and a.summed_count == 0 and a.why_zero == 2 },
+ validates :notes, presence: { if: Proc.new{ |a| a.complete && a.summed_weight == 0 && a.summed_count == 0 && a.why_zero == 2 },
message: "can't be blank if weights/counts are all zero: let us know what happened!" }
validates :transport_type_id, presence: { if: :complete }
validates :donor_id, presence: { if: :complete }
validates :scale_type_id, presence: { if: :complete }
validates :when, presence: true
validates :hours_spent, presence: { if: :complete }
- validates :why_zero, presence: { if: Proc.new{ |a| a.complete and a.summed_weight == 0 and a.summed_count == 0 } }
+ validates :why_zero, presence: { if: Proc.new{ |a| a.complete && a.summed_weight == 0 && a.summed_count == 0 } }
attr_accessible :region_id, :donor_id, :why_zero,
:food_type_id, :transport_type_id, :flag_for_admin, :notes,
@@ -46,7 +44,7 @@ class Log < ActiveRecord::Base
# units conversion on scale type --- we always store in lbs in the database
before_save { |record|
return if record.region.nil?
- record.scale_type = record.region.scale_types.first if record.scale_type.nil? and record.region.scale_types.length == 1
+ record.scale_type = record.region.scale_types.first if record.scale_type.nil? && record.region.scale_types.length == 1
unless record.scale_type.nil?
record.weight_unit = record.scale_type.weight_unit if record.weight_unit.nil?
record.log_parts.each{ |lp|
diff --git a/app/models/schedule.rb b/app/models/schedule.rb
index c77c934c..b23404cb 100755
--- a/app/models/schedule.rb
+++ b/app/models/schedule.rb
@@ -2,13 +2,13 @@
class Schedule < ActiveRecord::Base
include RankedModel
+ default_scope { order(position: :asc) }
has_many :logs
belongs_to :location
belongs_to :schedule_chain
ranks :position, with_same: :schedule_chain_id
- default_scope order('position ASC')
has_many :schedule_parts
has_many :food_types, through: :schedule_parts
diff --git a/app/models/schedule_chain.rb b/app/models/schedule_chain.rb
index 0b0a06bc..db47cb3f 100755
--- a/app/models/schedule_chain.rb
+++ b/app/models/schedule_chain.rb
@@ -8,8 +8,7 @@ class ScheduleChain < ActiveRecord::Base
belongs_to :region
has_many :schedule_volunteers
- has_many :volunteers, through: :schedule_volunteers,
- conditions: { 'schedule_volunteers.active' => true }
+ has_many :volunteers, -> { where(schedule_volunteers: { active: true }) }, through: :schedule_volunteers
has_many :schedules
has_many :locations, through: :schedules
diff --git a/app/models/schedule_volunteer.rb b/app/models/schedule_volunteer.rb
index 907fc9b7..9c315f9e 100755
--- a/app/models/schedule_volunteer.rb
+++ b/app/models/schedule_volunteer.rb
@@ -7,4 +7,5 @@ class ScheduleVolunteer < ActiveRecord::Base
attr_accessible :schedule_chain_id, :volunteer_id, :active
accepts_nested_attributes_for :volunteer
+ scope :active, -> { where(active: true) }
end
diff --git a/app/models/volunteer.rb b/app/models/volunteer.rb
index 5c4c1351..01c42941 100755
--- a/app/models/volunteer.rb
+++ b/app/models/volunteer.rb
@@ -25,22 +25,13 @@ class Volunteer < ActiveRecord::Base
has_many :regions, through: :assignments
has_many :schedule_volunteers
- has_many :schedule_chains, through: :schedule_volunteers,
- conditions: { 'schedule_volunteers.active' => true }
- has_many :prior_schedules, through: :schedule_volunteers,
- conditions: { 'schedule_volunteers.active' => false },
- class_name: 'ScheduleChain'
+ has_many :schedule_chains, -> { where(schedule_volunteers: { active: true }) }, through: :schedule_volunteers
+ has_many :prior_schedules, -> { where(schedule_volunteers: { active: false }) }, through: :schedule_volunteers, class_name: 'ScheduleChain'
has_many :log_volunteers
- has_many :logs, through: :log_volunteers,
- conditions: { log_volunteers: { active: true } }
- has_many :completed_logs, through: :log_volunteers,
- conditions: { logs: { complete: true } },
- class_name: 'Log', source: :log
-
- has_many :prior_logs, through: :log_volunteers,
- conditions: { 'log_volunteers.active' => false },
- class_name: 'Log'
+ has_many :logs, -> { where(log_volunteers: { active: true }) }, through: :log_volunteers
+ has_many :completed_logs, -> { where(logs: { complete: true }) }, through: :log_volunteers, class_name: 'Log', source: :log
+ has_many :prior_logs, -> { where(log_volunteers: { active: false }) }, through: :log_volunteers, class_name: 'Log', source: :log
attr_accessible :pre_reminders_too, :region_ids, :password,
:password_confirmation, :remember_me, :admin_notes, :email,
diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb
index fe620ef4..04922601 100755
--- a/app/views/devise/passwords/edit.html.erb
+++ b/app/views/devise/passwords/edit.html.erb
@@ -1,6 +1,6 @@
Change your password
-<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
+<%= form_for(resource, as: resource_name, url: password_path(resource_name), method: :put) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb
index 8288825b..86113515 100755
--- a/app/views/devise/registrations/edit.html.erb
+++ b/app/views/devise/registrations/edit.html.erb
@@ -1,10 +1,10 @@
Edit <%= resource_name.to_s.humanize %>
-<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
+<%= form_for(resource, as: resource_name, url: registration_path(resource_name), method: :put) do |f| %>
<%= devise_error_messages! %>
<%= f.label :password, "New Password" %>
- <%= f.password_field :password, :autocomplete => "off" %>
+ <%= f.password_field :password, autocomplete: "off" %>
<%= f.label :password_confirmation , "New Password Confirmation"%>
<%= f.password_field :password_confirmation %>
@@ -17,6 +17,6 @@
Unhappy?
-<%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>
+<%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
<%= link_to "Back", :back %>
diff --git a/app/views/layouts/custom_devise.html.erb b/app/views/layouts/custom_devise.html.erb
index 1e5c3492..8e29e3c5 100755
--- a/app/views/layouts/custom_devise.html.erb
+++ b/app/views/layouts/custom_devise.html.erb
@@ -5,7 +5,7 @@
- <%= stylesheet_link_tag "application", :media => "all" %>
+ <%= stylesheet_link_tag "application", media: "all" %>
<%= csrf_meta_tags %>
@@ -31,7 +31,7 @@
Facts
- <% cache("login_page_stats",:expires_in => 12.hours) do %>
+ <% cache("login_page_stats", expires_in: 12.hours) do %>
Number of Cities Using the Robot:
diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb
index 65f22f90..f9c74bd5 100755
--- a/app/views/locations/index.html.erb
+++ b/app/views/locations/index.html.erb
@@ -65,7 +65,7 @@
edit
<% end %>
- <%= link_to loc, confirm: "Are you sure?", method: :delete, class: 'btn btn-danger' do %>
+ <%= link_to loc, data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger' do %>
delete
<% end %>
diff --git a/app/views/logs/index.html.erb b/app/views/logs/index.html.erb
index 99340848..a65de867 100755
--- a/app/views/logs/index.html.erb
+++ b/app/views/logs/index.html.erb
@@ -141,7 +141,7 @@
<% shift.logs.each do |log| %>
<%= link_to "edit log #{log.id}", edit_log_path(log), class: 'btn btn-primary' %>
- <%= link_to "delete log #{log.id}", log, class: 'btn btn-danger', confirm: "Are you sure you want to delete this shift's log?", method: :delete %>
+ <%= link_to "delete log #{log.id}", log, class: 'btn btn-danger', data: { confirm: "Are you sure you want to delete this shift's log?" }, method: :delete %>
<% end %>
<% end %>
diff --git a/app/views/region_admin/donors/index.html.erb b/app/views/region_admin/donors/index.html.erb
index b45ef68f..0e28a57c 100644
--- a/app/views/region_admin/donors/index.html.erb
+++ b/app/views/region_admin/donors/index.html.erb
@@ -39,7 +39,7 @@
<%= link_to 'Hud', hud_location_path(location, key: location.receipt_key) %>
<% end %>
<%= link_to "Edit", edit_location_url(location) %>
- <%= link_to "Delete", location_url(location), confirm: "Are you sure?", method: :delete %>
+ <%= link_to "Delete", location_url(location), data: { confirm: "Are you sure?" }, method: :delete %>
<% end %>
diff --git a/app/views/region_admin/food_types/index.html.erb b/app/views/region_admin/food_types/index.html.erb
index 82a2e444..cb05a679 100755
--- a/app/views/region_admin/food_types/index.html.erb
+++ b/app/views/region_admin/food_types/index.html.erb
@@ -32,7 +32,7 @@
<% end %>
- <%= link_to region_admin_food_type_url(food_type), confirm: "Are you sure?", method: :delete, class: 'btn btn-danger' do %>
+ <%= link_to region_admin_food_type_url(food_type), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger' do %>
Delete
<% end %>
diff --git a/app/views/regions/index.html.erb b/app/views/regions/index.html.erb
index 71bca8de..e4ba7124 100755
--- a/app/views/regions/index.html.erb
+++ b/app/views/regions/index.html.erb
@@ -60,7 +60,7 @@
<%= link_to edit_region_url(region), class: 'btn btn-primary' do %>
<% end %>
- <%= link_to region_url(region), class: 'btn btn-danger', confirm: "Are you sure?", method: :delete do %>
+ <%= link_to region_url(region), class: 'btn btn-danger', data: { confirm: "Are you sure?" }, method: :delete do %>
<% end %>
diff --git a/app/views/schedule_chains/index.html.erb b/app/views/schedule_chains/index.html.erb
index 3ac5c43c..564b9ad8 100755
--- a/app/views/schedule_chains/index.html.erb
+++ b/app/views/schedule_chains/index.html.erb
@@ -136,7 +136,7 @@
<% if current_volunteer.any_admin? %>
<%= link_to 'edit', edit_schedule_chain_path(schedule) %>
- <%= link_to "delete", schedule, confirm: "Are you sure?", method: :delete %>
+ <%= link_to "delete", schedule, data: { confirm: "Are you sure?" }, method: :delete %>
<% end %>
diff --git a/app/views/schedule_chains/show.html.erb b/app/views/schedule_chains/show.html.erb
index e1fdd53a..d5cbe204 100755
--- a/app/views/schedule_chains/show.html.erb
+++ b/app/views/schedule_chains/show.html.erb
@@ -61,7 +61,7 @@
<% if @chain.volunteers.count == 0 %>
No volunteers yet...
- <%= link_to take_schedule_chains_path(id: @chain), confirm: "Are you sure you want to sign up for this weekly pickup?", class: 'btn btn-primary' do %>
+ <%= link_to take_schedule_chains_path(id: @chain), data: { confirm: "Are you sure you want to sign up for this weekly pickup?" }, class: 'btn btn-primary' do %>
Signup for this weekly pickup now!
<% end %>
diff --git a/app/views/volunteers/index.html.erb b/app/views/volunteers/index.html.erb
index c18d38d5..a594f322 100755
--- a/app/views/volunteers/index.html.erb
+++ b/app/views/volunteers/index.html.erb
@@ -53,7 +53,7 @@
<%= link_to edit_volunteer_path(v), class: 'btn btn-primary' do %>
<% end %>
- <%= link_to v, confirm: "Are you sure?", method: :delete, class: 'btn btn-danger' do %>
+ <%= link_to v, data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger' do %>
<% end %>
<% unless v.active %>
diff --git a/app/views/volunteers/unassigned.html.erb b/app/views/volunteers/unassigned.html.erb
index d4505db6..c13db986 100755
--- a/app/views/volunteers/unassigned.html.erb
+++ b/app/views/volunteers/unassigned.html.erb
@@ -55,7 +55,7 @@
<%= submit_tag("Assign", class: 'btn btn-primary') %>
- <%= link_to "Delete", volunteer, confirm: "Are you sure?", method: :delete, class: 'btn btn-danger' %>
+ <%= link_to "Delete", volunteer, data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger' %>
<% end # form end tag %>
diff --git a/bin/bundle b/bin/bundle
new file mode 100755
index 00000000..66e9889e
--- /dev/null
+++ b/bin/bundle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+load Gem.bin_path('bundler', 'bundle')
diff --git a/bin/guard b/bin/guard
new file mode 100755
index 00000000..bcb966f4
--- /dev/null
+++ b/bin/guard
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'guard' 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)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("guard", "guard")
diff --git a/bin/pry b/bin/pry
new file mode 100755
index 00000000..bfcc3d48
--- /dev/null
+++ b/bin/pry
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'pry' 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)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("pry", "pry")
diff --git a/bin/pry-remote b/bin/pry-remote
new file mode 100755
index 00000000..34d1ea16
--- /dev/null
+++ b/bin/pry-remote
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'pry-remote' 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)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("pry-remote", "pry-remote")
diff --git a/bin/puma b/bin/puma
new file mode 100755
index 00000000..880935b2
--- /dev/null
+++ b/bin/puma
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'puma' 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)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("puma", "puma")
diff --git a/bin/pumactl b/bin/pumactl
new file mode 100755
index 00000000..b698e6e9
--- /dev/null
+++ b/bin/pumactl
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'pumactl' 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)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("puma", "pumactl")
diff --git a/bin/rackup b/bin/rackup
new file mode 100755
index 00000000..3ac4a5a7
--- /dev/null
+++ b/bin/rackup
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'rackup' 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)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("rack", "rackup")
diff --git a/bin/rails b/bin/rails
new file mode 100755
index 00000000..728cd85a
--- /dev/null
+++ b/bin/rails
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require_relative '../config/boot'
+require 'rails/commands'
diff --git a/bin/rake b/bin/rake
new file mode 100755
index 00000000..17240489
--- /dev/null
+++ b/bin/rake
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+require_relative '../config/boot'
+require 'rake'
+Rake.application.run
diff --git a/bin/support/bootstrap-database.rb b/bin/support/bootstrap-database.rb
old mode 100644
new mode 100755
diff --git a/bin/support/create-dot-env.rb b/bin/support/create-dot-env.rb
old mode 100644
new mode 100755
diff --git a/config.ru b/config.ru
index 0c7f17cd..85d3c784 100755
--- a/config.ru
+++ b/config.ru
@@ -2,5 +2,6 @@
# This file is used by Rack-based servers to start the application.
-require ::File.expand_path('../config/environment', __FILE__)
+require_relative 'config/environment'
+
run Webapp::Application
diff --git a/config/application.rb b/config/application.rb
index 1003c6d6..8a297abf 100755
--- a/config/application.rb
+++ b/config/application.rb
@@ -4,12 +4,7 @@
require 'rails/all'
-if defined?(Bundler)
- # If you precompile assets before deploying to production, use this line
- Bundler.require(*Rails.groups(:assets => %w(development test)))
- # If you want your assets lazily compiled in production, use this line
- # Bundler.require(:default, :assets, Rails.env)
-end
+Bundler.require(*Rails.groups)
module Webapp
class Application < Rails::Application
@@ -57,12 +52,6 @@ class Application < Rails::Application
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
- # Enforce whitelist mode for mass assignment.
- # This will create an empty whitelist of attributes available for mass-assignment for all models
- # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
- # parameters by using an attr_accessible or attr_protected declaration.
- config.active_record.whitelist_attributes = true
-
# Enable the asset pipeline
config.assets.enabled = true
diff --git a/config/environment.rb b/config/environment.rb
index f3c19b3b..97f0f011 100755
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# Load the rails application
-require File.expand_path('application', __dir__)
+require_relative 'application'
# Initialize the rails application
Webapp::Application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 257a573b..b3cf539a 100755
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -9,9 +9,6 @@
# session since you don't have to restart the web server when you make code changes.
config.cache_classes = false
- # Log error messages when you accidentally call methods on nil.
- config.whiny_nils = true
-
# Do not eager load code on boot.
config.eager_load = false
@@ -23,7 +20,7 @@
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :sendmail
config.action_mailer.perform_deliveries = true
- config.action_mailer.default_url_options = { :host => 'robot.boulderfoodrescue.org' }
+ config.action_mailer.default_url_options = { host: 'robot.boulderfoodrescue.org' }
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
@@ -31,16 +28,9 @@
# rotate logs
config.logger = Logger.new(Rails.root.join('log', Rails.env + '.log'), 3, 5*1024*1024)
- # Only use best-standards-support built into browsers
- config.action_dispatch.best_standards_support = :builtin
-
# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
- # 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
-
# Do not compress assets
config.assets.compress = true
@@ -61,4 +51,15 @@
# Show it all!
config.log_level = :debug
+
+ config.paperclip_defaults = {
+ storage: :s3,
+ s3_credentials: {
+ access_key_id: ENV['S3_ACCESS_KEY_ID'],
+ secret_access_key: ENV['S3_SECRET_ACCESS_KEY'],
+ s3_region: 'us-west-2'
+ },
+ url: ':s3_domain_url',
+ path: '/:class/:attachment/:id_partition/:style/:filename'
+ }
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index ef7f0e9f..1360c519 100755
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -17,7 +17,6 @@
password: ENV['SENDGRID_PASSWORD']
}
# ActionMailer Config
- # config.action_mailer.default_url_options = { :host => 'robot.boulderfoodrescue.org' }
config.action_mailer.default_url_options = { host: "#{ENV['DOMAIN_NAME']}" }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
@@ -25,6 +24,7 @@
# Code is not reloaded between requests
config.cache_classes = true
+ config.eager_load = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
@@ -84,10 +84,6 @@
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
- # 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
-
config.middleware.use ExceptionNotifier,
email_prefix: '[BFR ROBOT ERROR] ',
sender_address: %{"BFR Robot" },
diff --git a/config/environments/test.rb b/config/environments/test.rb
index bb5d9e42..66ea6179 100755
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -13,8 +13,7 @@
config.serve_static_assets = true
config.static_cache_control = 'public, max-age=3600'
- # Log error messages when you accidentally call methods on nil
- config.whiny_nils = true
+ config.eager_load = false
# Show full error reports and disable caching
config.consider_all_requests_local = true
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
index d8d5c34e..85b2d840 100755
--- a/config/initializers/wrap_parameters.rb
+++ b/config/initializers/wrap_parameters.rb
@@ -7,7 +7,7 @@
# 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]
end
# Disable root element in JSON by default.
diff --git a/config/puma.rb b/config/puma.rb
new file mode 100644
index 00000000..f668d606
--- /dev/null
+++ b/config/puma.rb
@@ -0,0 +1,34 @@
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers: a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum; this matches the default thread size of Active Record.
+#
+threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+threads threads_count, threads_count
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+#
+port ENV.fetch("PORT") { 5000 }
+
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked webserver processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory.
+#
+# preload_app!
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
diff --git a/config/routes.rb b/config/routes.rb
index 3872c648..c08ef8b7 100755
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
+
Webapp::Application.routes.draw do
resources :assignments, only: [] do
collection do
@@ -65,9 +66,6 @@
get :create
get :destroy
end
- # member do
- # get :show
- # end
end
resources :locations do
@@ -88,7 +86,7 @@
end
end
- devise_for :volunteers, :controllers => { :sessions => 'sessions' }
+ devise_for :volunteers, controllers: { sessions: 'sessions' }
resources :volunteers do
collection do
diff --git a/lib/assets/.gitkeep b/lib/assets/.gitkeep
deleted file mode 100755
index e69de29b..00000000
diff --git a/spec/factories/absences.rb b/spec/factories/absences.rb
index 6d4e706e..2c07b4d9 100755
--- a/spec/factories/absences.rb
+++ b/spec/factories/absences.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :absence do
start_date { Time.zone.today + 1.day }
stop_date { Time.zone.today + 5.days }
diff --git a/spec/factories/assignments.rb b/spec/factories/assignments.rb
index c50ec048..0ebc7d15 100755
--- a/spec/factories/assignments.rb
+++ b/spec/factories/assignments.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :assignment do
volunteer { (Volunteer.all.count >= 5 ? Volunteer.all.sample : create(:volunteer)) }
region { (Region.all.count >= 3 ? Region.all.sample : create(:region)) }
trait :admin do
- admin true
+ admin { true }
end
factory :admin_volunteer, traits: [:admin]
diff --git a/spec/factories/food_types.rb b/spec/factories/food_types.rb
index 4ce25b1d..289dbd0b 100755
--- a/spec/factories/food_types.rb
+++ b/spec/factories/food_types.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :food_type do
- name 'Some food!'
- region { (Region.all.count >= 5 ? Region.all.sample : create(:region)) }
+ name { 'Some food!' }
+ region { Region.all.count >= 5 ? Region.all.sample : FactoryBot.create(:region) }
end
end
diff --git a/spec/factories/locations.rb b/spec/factories/locations.rb
index 056389e8..97ecada8 100755
--- a/spec/factories/locations.rb
+++ b/spec/factories/locations.rb
@@ -1,33 +1,33 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :location do
address { '710 31st St., Boulder, CO, 80303' }
sequence(:name) { |n| "Some place #{n}" }
- contact 'Some dude'
- website 'http://foobar.com'
- admin_notes 'Some admin notes'
- public_notes 'Some public notes'
- hours 'Some hours'
+ contact { 'Some dude' }
+ website { 'http://foobar.com' }
+ admin_notes { 'Some admin notes' }
+ public_notes { 'Some public notes' }
+ hours { 'Some hours' }
region { (Region.all.count >= 5 ? Region.all.sample : create(:region)) }
sequence(:email) { |n| "location#{n}@gmail.com" }
- phone '555-555-5555'
- equipment_storage_info 'Or something'
- food_storage_info 'Or something else'
- entry_info 'Yeppers'
- exit_info 'Blah!'
- onsite_contact_info 'Some people'
+ phone { '555-555-5555' }
+ equipment_storage_info { 'Or something' }
+ food_storage_info { 'Or something else' }
+ entry_info { 'Yeppers' }
+ exit_info { 'Blah!' }
+ onsite_contact_info { 'Some people' }
factory :recipient do
- location_type Location::LOCATION_TYPES.invert['Recipient']
+ location_type { Location::LOCATION_TYPES.invert['Recipient'] }
end
factory :donor do
- location_type Location::LOCATION_TYPES.invert['Donor']
+ location_type { Location::LOCATION_TYPES.invert['Donor'] }
end
factory :hub do
- location_type Location::LOCATION_TYPES.invert['Hub']
+ location_type { Location::LOCATION_TYPES.invert['Hub'] }
end
end
end
diff --git a/spec/factories/log_parts.rb b/spec/factories/log_parts.rb
index d2b19e42..fef8fed8 100755
--- a/spec/factories/log_parts.rb
+++ b/spec/factories/log_parts.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :log_part do
- required false
+ required { false }
food_type { (FoodType.all.count >= 5 ? FoodType.all.sample : create(:food_type)) }
factory :complete_log_part do
- weight 42.0
- description 'Or something'
- self.count 5
+ weight { 42.0 }
+ description { 'Or something' }
+ self.count { 5 }
end
factory :required_log_part do
- required true
+ required { true }
end
end
end
diff --git a/spec/factories/log_volunteers.rb b/spec/factories/log_volunteers.rb
index c478566f..b413a40e 100755
--- a/spec/factories/log_volunteers.rb
+++ b/spec/factories/log_volunteers.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :log_volunteer do
association :volunteer
association :log
- active true
- covering false
+ active { true }
+ covering { false }
end
end
diff --git a/spec/factories/logs.rb b/spec/factories/logs.rb
index 919af4df..1d138f01 100755
--- a/spec/factories/logs.rb
+++ b/spec/factories/logs.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :log do
- notes 'Log Notes Testing123'
- weight_unit 'lb'
+ notes { 'Log Notes Testing123' }
+ weight_unit { 'lb' }
region { (Region.all.count >= 5 ? Region.all.sample : create(:region)) }
self.when { Date.today + (rand > 0.5 ? -1 : 1)*rand(10) } # have to do self. since when is a reserved word in ruby
donor { Location.donors.count >= 5 ? Location.donors.sample : create(:donor) }
diff --git a/spec/factories/regions.rb b/spec/factories/regions.rb
index 2841d1f6..1d03aa35 100755
--- a/spec/factories/regions.rb
+++ b/spec/factories/regions.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :region do
sequence(:title) { |n| "#{n.ordinalize} Title" }
sequence(:name) { |n| "#{n.ordinalize} Name" }
- address '123 Fake St., Beloxi, MS'
- handbook_url 'http://google.com'
- welcome_email_text 'Hello there!'
- splash_html 'Yep...'
- tax_id '12345'
- phone '555-555-5555'
- tagline 'Knowing is Half the Battle'
- notes 'Some notes'
+ address { '123 Fake St., Beloxi, MS' }
+ handbook_url { 'http://google.com' }
+ welcome_email_text { 'Hello there!' }
+ splash_html { 'Yep...' }
+ tax_id { '12345' }
+ phone { '555-555-5555' }
+ tagline { 'Knowing is Half the Battle' }
+ notes { 'Some notes' }
end
end
diff --git a/spec/factories/scale_types.rb b/spec/factories/scale_types.rb
index 45fb5310..0268c2e5 100755
--- a/spec/factories/scale_types.rb
+++ b/spec/factories/scale_types.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :scale_type do
- name 'Some scale'
- weight_unit 'lb'
+ name { 'Some scale' }
+ weight_unit { 'lb' }
region { (Region.all.count >= 5 ? Region.all.sample : create(:region)) }
end
end
diff --git a/spec/factories/schedule_chains.rb b/spec/factories/schedule_chains.rb
index 49b2a3df..b99ace54 100755
--- a/spec/factories/schedule_chains.rb
+++ b/spec/factories/schedule_chains.rb
@@ -1,25 +1,25 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :schedule_chain do
transport_type
- backup false
- temporary false
- irregular false
+ backup { false }
+ temporary { false }
+ irregular { false }
scale_type
region
- admin_notes 'some notes'
- public_notes 'some other notes'
+ admin_notes { 'some notes' }
+ public_notes { 'some other notes' }
expected_weight { rand(200) }
day_of_week { rand(6) }
- frequency 'weekly'
+ frequency { 'weekly' }
difficulty_rating { rand(3) }
hilliness { rand(3) }
trait :one_time do
- frequency 'one-time'
- day_of_week nil
- detailed_date Date.today + 4.days
+ frequency { 'one-time' }
+ day_of_week { nil }
+ detailed_date { Date.today + 4.days }
end
end
end
diff --git a/spec/factories/schedule_parts.rb b/spec/factories/schedule_parts.rb
index 7fe5a80a..438c54ba 100755
--- a/spec/factories/schedule_parts.rb
+++ b/spec/factories/schedule_parts.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :schedule_part do
association :schedule
association :food_type
- required false
+ required { false }
end
end
diff --git a/spec/factories/schedule_volunteers.rb b/spec/factories/schedule_volunteers.rb
index abaf4c8f..b1ff06b8 100755
--- a/spec/factories/schedule_volunteers.rb
+++ b/spec/factories/schedule_volunteers.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :schedule_volunteer do
association :volunteer
association :schedule_chain
- active true
+ active { true }
end
end
diff --git a/spec/factories/schedules.rb b/spec/factories/schedules.rb
index 9148916e..357832c0 100755
--- a/spec/factories/schedules.rb
+++ b/spec/factories/schedules.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :schedule do
- position 3
+ position { 3 }
location { Location.all.count >= 5 ? Location.all.sample : create(:location) }
factory :donation_schedule do
diff --git a/spec/factories/transport_types.rb b/spec/factories/transport_types.rb
index 584f6025..92ca7c49 100755
--- a/spec/factories/transport_types.rb
+++ b/spec/factories/transport_types.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :transport_type do
- name 'Camel'
+ name { 'Camel' }
end
end
diff --git a/spec/factories/volunteers.rb b/spec/factories/volunteers.rb
index 46e6ba9f..5bd3fb54 100755
--- a/spec/factories/volunteers.rb
+++ b/spec/factories/volunteers.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-FactoryGirl.define do
+FactoryBot.define do
factory :volunteer do
sequence(:name) { |n| "John Doe the #{n.ordinalize}" }
sequence(:email) { |n| "user#{n}@boulderfoodrescue.org" }
- phone '555-555-5555'
- password 'SomePassword'
- waiver_signed true
- waiver_signed_at Time.zone.now
+ phone { '555-555-5555' }
+ password { 'SomePassword' }
+ waiver_signed { true }
+ waiver_signed_at { Time.zone.now }
factory :volunteer_with_assignment do
after(:create) do |v|
@@ -19,8 +19,8 @@
end
trait :not_waived do
- waiver_signed false
- waiver_signed_at nil
+ waiver_signed { false }
+ waiver_signed_at { nil }
end
end
end
diff --git a/spec/models/schedule_spec.rb b/spec/models/schedule_spec.rb
index 020de7d0..4291e71a 100644
--- a/spec/models/schedule_spec.rb
+++ b/spec/models/schedule_spec.rb
@@ -3,10 +3,10 @@
require 'rails_helper'
RSpec.describe Schedule do
- describe 'this file needs to be completed' do
+ describe 'Schedule' do
let(:super_admin) { create(:volunteer, admin: true) }
- xit 'validates super_admin' do
+ it 'validates super_admin' do
expect(super_admin).to be_valid
end
end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index c41aa1a3..53970a41 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -39,7 +39,7 @@
Warden.test_reset!
end
- config.include FactoryGirl::Syntax::Methods
+ config.include FactoryBot::Syntax::Methods
config.include ActionDispatch::TestProcess
diff --git a/vendor/assets/javascripts/.gitkeep b/vendor/assets/javascripts/.gitkeep
deleted file mode 100755
index e69de29b..00000000
diff --git a/vendor/assets/stylesheets/.gitkeep b/vendor/assets/stylesheets/.gitkeep
deleted file mode 100755
index e69de29b..00000000