Skip to content

Commit

Permalink
Trying to fix travis yml (#164)
Browse files Browse the repository at this point in the history
* Trying to fix travis yml

Adding role create and fake password in database.yml

Another go-round with fixes.

Removing duplicate schema:load

Moving config/database.yml back to password w/o fallback for test.

* Removing comments out of database.yml.travis

* Frozen string literal updates

bundle exec rubocop -a

* More updates for rubocop
  • Loading branch information
rylanb committed May 24, 2018
1 parent 41deee3 commit 40f86c6
Show file tree
Hide file tree
Showing 227 changed files with 474 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ script:
services:
- postgresql
before_script:
- psql -c 'create database bfr_webapp_db_test;' -U postgres
- psql -c 'CREATE DATABASE bfr_webapp_db_test;' -U postgres
- cp config/database.yml.travis config/database.yml
env:
- SECRET_KEY_BASE=fb47a2efcd8645d903faa139247ad88179cd91a07548e2f126034efc867c6bed082c6313a4568006f391630c4896f119e94d74887b102c1b2f12d8bdc0ea53df
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

ruby File.read('.ruby-version').strip
Expand Down
2 changes: 2 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# A sample Guardfile
# More info at https://github.com/guard/guard#readme

Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env rake
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/absences_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class AbsencesController < ApplicationController
before_filter :authenticate_volunteer!
before_filter :admin_only, only: [:all]
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'food_robot'

class ApplicationController < ActionController::Base
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class AssignmentsController < ApplicationController
before_filter :authenticate_volunteer!
before_filter :admin_only
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/cell_carriers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CellCarriersController < ApplicationController
before_filter :authenticate_volunteer!

Expand Down
4 changes: 3 additions & 1 deletion app/controllers/locations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class LocationsController < ApplicationController
before_filter :authenticate_volunteer!, except: [:hud]

Expand All @@ -8,7 +10,7 @@ def hud
@logs = if @location.donor?
Log.at(@location).last(500)
else
Log.at(@location).last(500).keep_if{ |x| x.weight_sum.to_f > 0 }
Log.at(@location).last(500).keep_if{ |x| x.weight_sum.to_f.positive? }
end
render :hud
else
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/logs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'prawn/table'

class LogsController < ApplicationController
Expand Down Expand Up @@ -399,7 +401,7 @@ def export

def parse_and_create_log_parts(params, log)
ret = []
params['log_parts'].each{ |_dc, lpdata|
params['log_parts']&.each{ |_dc, lpdata|
lpdata['weight'] = nil if lpdata['weight'].strip == ''
lpdata['count'] = nil if lpdata['count'].strip == ''
next if lpdata['id'].nil? and lpdata['weight'].nil? and lpdata['count'].nil?
Expand All @@ -411,7 +413,7 @@ def parse_and_create_log_parts(params, log)
log_part.weight = lpdata['weight'].to_f
ret.push log_part
log_part.save
} unless params['log_parts'].nil?
}
ret
end

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/region_admin/donors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RegionAdmin
class DonorsController < ApplicationController
before_filter :authenticate_volunteer!
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/region_admin/food_types_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RegionAdmin
class FoodTypesController < ApplicationController
before_filter :authenticate_volunteer!
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/regions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class RegionsController < ApplicationController
before_filter :authenticate_volunteer!

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/scale_types_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ScaleTypesController < ApplicationController
before_filter :authenticate_volunteer!

Expand Down
32 changes: 14 additions & 18 deletions app/controllers/schedule_chains_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ScheduleChainsController < ApplicationController
before_filter :authenticate_volunteer!
before_filter :admin_only, :only => [:today, :tomorrow, :yesterday]
Expand Down Expand Up @@ -35,7 +37,7 @@ def show
# prep the google maps embed request
embed_parameters = ''
first_last_schedules = [schedules.first, schedules.last]
trimmed_stops = schedules.select { |stop| !(first_last_schedules.include?(stop)) }
trimmed_stops = schedules.select { |stop| !first_last_schedules.include?(stop) }

unless schedules.empty? || schedules.first.location.nil?
sched = schedules.first
Expand All @@ -55,7 +57,7 @@ def show
end
end

@embed_request_url = ("https://www.google.com/maps/embed/v1/directions?key=#{ENV['GMAPS_API_KEY']}#{embed_parameters}&mode=bicycling")
@embed_request_url = "https://www.google.com/maps/embed/v1/directions?key=#{ENV['GMAPS_API_KEY']}#{embed_parameters}&mode=bicycling"

# This can apparently be nil, so have to do a funky sort fix
@sorted_related_shifts = @schedule.related_shifts.sort{ |x, y|
Expand Down Expand Up @@ -136,34 +138,28 @@ def update
authorize! :update, @schedule_chain

delete_schedules = []
unless params[:schedule_chain]['schedules_attributes'].nil?
params[:schedule_chain]['schedules_attributes'].collect{ |_k, v|
delete_schedules << v['id'].to_i if v['food_type_ids'].nil?
}
end
params[:schedule_chain]['schedules_attributes']&.collect{ |_k, v|
delete_schedules << v['id'].to_i if v['food_type_ids'].nil?
}

delete_volunteers = []
unless params[:schedule_chain]['schedule_volunteers_attributes'].nil?
params[:schedule_chain]['schedule_volunteers_attributes'].collect{ |_k, v|
delete_volunteers << v['id'].to_i if v['volunteer_id'].nil?
}
end
params[:schedule_chain]['schedule_volunteers_attributes']&.collect{ |_k, v|
delete_volunteers << v['id'].to_i if v['volunteer_id'].nil?
}

if @schedule_chain.update_attributes(params[:schedule_chain])
@schedule_chain.schedules.each do |schedule|
schedule.delete if delete_schedules.include?(schedule.id)
end

@schedule_chain.schedule_volunteers.each do |scheduled_vol|
if delete_volunteers.include?(scheduled_vol.id)
scheduled_vol.update_attributes({ active: false })
Log.upcoming_for(scheduled_vol.id).each do |log|
log.log_volunteers.destroy_all
end
next unless delete_volunteers.include?(scheduled_vol.id)
scheduled_vol.update_attributes({ active: false })
Log.upcoming_for(scheduled_vol.id).each do |log|
log.log_volunteers.destroy_all
end
end


flash[:notice] = 'Updated Successfully'
index
else
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class SessionsController < Devise::SessionsController
respond_to :json

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/transport_types_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class TransportTypesController < ApplicationController
before_filter :authenticate_volunteer!

Expand Down
4 changes: 3 additions & 1 deletion app/controllers/volunteers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class VolunteersController < ApplicationController
before_filter :authenticate_volunteer!
before_filter :admin_only, :only => [:knight, :unassigned, :shiftless, :shiftless_old, :admin, :switch_user, :stats]
Expand All @@ -24,7 +26,7 @@ def assign
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 unless message.nil?
message&.deliver
end
volunteer.save
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/waivers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class WaiversController < ApplicationController
before_filter :authenticate_volunteer!

Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationHelper

def all_admin_region_volunteer_tuples(whom)
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/devise_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module DeviseHelper

def devise_error_messages!
Expand Down
4 changes: 3 additions & 1 deletion app/helpers/locations_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module LocationsHelper

def readable_hours location
Expand All @@ -7,7 +9,7 @@ def readable_hours location
private

def readable_simple_hours loc
loc.hours.gsub("\n", '<br>').html_safe unless loc.hours.nil?
loc.hours&.gsub("\n", '<br>')&.html_safe
end

def readable_detailed_hours location
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/regions_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RegionsHelper

def region_logo_column(record)
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/volunteers_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module VolunteersHelper
def volunteer_photo_column(record)
return '' if record.photo_file_name.nil?
Expand Down
2 changes: 2 additions & 0 deletions app/interactors/reactivate_volunteer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ReactivateVolunteer
include Interactor

Expand Down
2 changes: 2 additions & 0 deletions app/interactors/region_admin/create_food_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RegionAdmin
class CreateFoodType
include Interactor
Expand Down
2 changes: 2 additions & 0 deletions app/interactors/region_admin/delete_food_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RegionAdmin
class DeleteFoodType
include Interactor
Expand Down
2 changes: 2 additions & 0 deletions app/interactors/region_admin/update_food_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RegionAdmin
class UpdateFoodType
include Interactor
Expand Down
2 changes: 2 additions & 0 deletions app/interactors/sign_waiver.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class SignWaiver
include Interactor

Expand Down
2 changes: 2 additions & 0 deletions app/interactors/toggle_super_admin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ToggleSuperAdmin
include Interactor

Expand Down
2 changes: 2 additions & 0 deletions app/mailers/notifier.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Notifier < ActionMailer::Base
add_template_helper(ApplicationHelper)
default from: 'robot@boulderfoodrescue.org'
Expand Down
2 changes: 2 additions & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Ability
include CanCan::Ability

Expand Down
2 changes: 2 additions & 0 deletions app/models/absence.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Absence < ActiveRecord::Base
belongs_to :volunteer
has_and_belongs_to_many :logs
Expand Down
2 changes: 2 additions & 0 deletions app/models/assignment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Assignment < ActiveRecord::Base
belongs_to :volunteer
belongs_to :region
Expand Down
2 changes: 2 additions & 0 deletions app/models/cell_carrier.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CellCarrier < ActiveRecord::Base
attr_accessible :format, :name
end
2 changes: 2 additions & 0 deletions app/models/food_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class FoodType < ActiveRecord::Base
belongs_to :region

Expand Down
2 changes: 2 additions & 0 deletions app/models/location.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Location < ActiveRecord::Base

# MOVE TO ENUM
Expand Down
2 changes: 2 additions & 0 deletions app/models/log.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Log < ActiveRecord::Base
WHY_ZER0 = {1 => 'No Food', 2 => "Didn't Happen"}

Expand Down
2 changes: 2 additions & 0 deletions app/models/log_part.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class LogPart < ActiveRecord::Base
belongs_to :log
belongs_to :food_type
Expand Down
2 changes: 2 additions & 0 deletions app/models/log_recipient.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class LogRecipient < ActiveRecord::Base

belongs_to :log
Expand Down
2 changes: 2 additions & 0 deletions app/models/log_volunteer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class LogVolunteer < ActiveRecord::Base
belongs_to :log
belongs_to :volunteer
Expand Down
2 changes: 2 additions & 0 deletions app/models/region.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Region < ActiveRecord::Base
has_many :assignments
has_many :volunteers, through: :assignments
Expand Down
2 changes: 2 additions & 0 deletions app/models/scale_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ScaleType < ActiveRecord::Base
attr_accessible :name, :region_id, :weight_unit
has_many :logs
Expand Down
2 changes: 2 additions & 0 deletions app/models/schedule.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Schedule < ActiveRecord::Base
include RankedModel

Expand Down
4 changes: 3 additions & 1 deletion app/models/schedule_chain.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ScheduleChain < ActiveRecord::Base
default_scope { where(active: true) }

Expand Down Expand Up @@ -100,7 +102,7 @@ def food_types
end

def volunteers?
volunteers.count > 0
volunteers.count.positive?
end

def no_volunteers?
Expand Down
2 changes: 2 additions & 0 deletions app/models/schedule_part.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class SchedulePart < ActiveRecord::Base
belongs_to :schedule
belongs_to :food_type
Expand Down
Loading

0 comments on commit 40f86c6

Please sign in to comment.