Commit d3e393a9 authored by Jiri Strojil's avatar Jiri Strojil
Browse files

Merge branch 'develop' into features/display-semester-data

parents e7bbc6ee 392a1931
......@@ -171,3 +171,7 @@ h5.small {
.fixed-width-lg {
width: 600px;
}
.float-right {
float: right;
}
class SemesterProcessVolunteersController < ApplicationController
before_action :prepare_review, only: [:review_semester, :submit_review]
before_action :initialize_feedback, only: [:review_semester, :submit_review]
before_action :set_semester_process_volunteer, only: [:show, :edit, :update]
before_action :set_semester, only: [:index]
include SemesterProcessVolunteerHelper
def review_semester
@hour = Hour.new
end
def submit_review
assign_reviewed_attributes
set_reviewed
@semester_process_volunteer.volunteer.validate_waive_and_bank = true
begin
ActiveRecord::Base.transaction do
@semester_process_volunteer.semester_feedbacks << @feedback
@hour.save! unless @hour.hours == 0 || @hour.hours.blank?
@semester_process_volunteer.save!
@volunteer.save!
end
redirect_to(
review_semester_semester_process_volunteer_path(@semester_process_volunteer),
notice: 'Successfully reviewed.'
)
rescue ActiveRecord::RecordInvalid => exception
null_reviewed
@hours.reload
render :review_semester, notice: exception
end
end
def index
authorize SemesterProcessVolunteer
......@@ -22,6 +53,22 @@ class SemesterProcessVolunteersController < ApplicationController
private
def prepare_review
# careful cuz mission id can be present in both missions
@semester_process_volunteer = SemesterProcessVolunteer.find(params[:id])
@hours = @semester_process_volunteer.hours
@volunteer = @semester_process_volunteer.volunteer
@mission = @semester_process_volunteer.missions.first
authorize @semester_process_volunteer
end
def review_params
params.require(:semester_process_volunteer).permit(
volunteer_attributes: [:waive, :iban, :bank],
semester_feedback: [:goals, :achievements, :future, :comments, :conversation],
hour: [:hours])
end
def set_semester_process_volunteer
@spv = SemesterProcessVolunteer.find(params[:id])
authorize @spv
......
module SemesterProcessVolunteerHelper
def initialize_feedback
@feedback = SemesterFeedback.new(mission: @mission, semester_process_volunteer: @semester_process_volunteer,
author: current_user)
end
def set_reviewed
@semester_process_volunteer.commited_by = current_user
@semester_process_volunteer.commited_at = Time.zone.now
end
def assign_reviewed_attributes
@hour = Hour.new(
volunteer: @volunteer,
hourable: @mission,
semester_process_volunteer: @semester_process_volunteer,
meeting_date: Time.zone.now,
)
@hour.assign_attributes(review_params[:hour])
@volunteer.assign_attributes(review_params[:volunteer_attributes]
.slice(:waive, :bank, :iban))
@feedback.assign_attributes(review_params[:semester_feedback])
end
def null_reviewed
@semester_process_volunteer.commited_by = nil
@semester_process_volunteer.commited_at = nil
end
end
......@@ -27,6 +27,10 @@ class SemesterProcessVolunteer < ApplicationRecord
has_many :reminders, -> { where(kind: 'reminder') }, class_name: 'SemesterProcessMail',
foreign_key: 'semester_process_volunteer_id', inverse_of: 'semester_process_volunteer'
accepts_nested_attributes_for :hours, :volunteer, :semester_feedbacks
validates_associated :hours, :semester_feedbacks, :volunteer
scope :index_joins, lambda {
joins(:semester_process).joins(volunteer: [:contact]).joins(:semester_process_volunteer_missions)
}
......@@ -39,6 +43,7 @@ class SemesterProcessVolunteer < ApplicationRecord
end
}
# will only return an array, not a AD-result
def missions
semester_process_volunteer_missions.map(&:mission)
......
......@@ -82,6 +82,7 @@ class Volunteer < ApplicationRecord
#
validates :contact, presence: true
validates_presence_of :iban, :bank, if: -> { validate_waive_and_bank && waive.blank? }
validates :salutation, presence: true
validates_attachment :avatar, content_type: {
content_type: /\Aimage\/.*\z/
......@@ -91,6 +92,8 @@ class Volunteer < ApplicationRecord
if: :external?,
unless: :user_deleted?
attr_accessor :validate_waive_and_bank
scope :process_eq, lambda { |process|
return unless process.present?
return joins(:user).merge(User.with_pending_invitation) if process == 'havent_logged_in'
......
......@@ -2,14 +2,18 @@ class SemesterProcessVolunteerPolicy < ApplicationPolicy
class Scope < ApplicationScope
def resolve
return all if superadmin?
none
end
end
# Actions
alias_method :index?, :superadmin?
alias_method :show?, :superadmin?
alias_method :update?, :superadmin?
alias_method :edit?, :superadmin?
alias_method :index?, :superadmin?
alias_method :review_semester?, :superadmin?
alias_method :submit_review?, :superadmin?
alias_method :new?, :superadmin?
alias_method :show?, :superadmin?
alias_method :edit?, :superadmin?
alias_method :create?, :superadmin?
alias_method :update?, :superadmin?
alias_method :destroy?, :superadmin?
end
= simple_form_for(@semester_process_volunteer, html: { class: 'col-xs-12 '},
url: submit_review_semester_process_volunteer_path(@semester_process_volunteer)) do |f|
= simple_error_notice f
h1 Zuletzt übermittelte Stunden und Halbjahres-Rapporte
h2.m-b-20.m-t-30
'Einsatz
= link_to @mission.to_label, polymorphic_path([@mission.volunteer, @mission.polymorph_url_object]), target: '_blank'
h3 Halbjahres-Rapporte
= f.simple_fields_for @feedback do |ff|
- [:goals, :achievements, :future, :comments, :conversation].each do |field|
.row
.col-xs-12= ff.input field
h3 Stunden
= render 'hours/last_submitted_hours', hours: @hours
= f.simple_fields_for @hour do |hf|
.row
.col-xs-2.float-right= hf.input :hours, required: false, input_html: { value: f.object.hours == 0 ? '' : f.object.hours}
h3 Spesen
= f.simple_fields_for :volunteer, @volunteer do |vf|
.row.text-left#volunteer-update-waive-and-iban
.col-xs-12
= vf.input_field :id, type: :hidden
= checkbox_toggle_collapse(vf, :waive, '#not-waive-expenses', check_shows: false)
.col-xs-12#not-waive-expenses
.row
.col-xs-4= vf.input :iban
.col-xs-4= vf.input :bank
.submit-box
.col-xs-12
p Ich bestätige, dass ich alle meine Stunden und Halbjahres-Rapporte bis zum heutigen Datum erfasst habe.
- if @semester_process_volunteer.commited_at.present?
p.text-danger Bestätigt am #{l(@semester_process_volunteer.commited_at.to_date)} durch #{profile_link(@semester_process_volunteer.commited_by)}
- else
= f.submit 'Bestätigen', class: 'btn btn-lg-accepted'
......@@ -96,7 +96,11 @@ Rails.application.routes.draw do
get :send_half_year, on: :member
end
resources :semester_process_volunteers
resources :semester_process_volunteers do
get :review_semester, on: :member
patch :submit_review, on: :member
end
resources :semester_processes, except: [:destroy]
resources :volunteer_applications, only: [:new, :create] do
......
......@@ -16,61 +16,61 @@ class BillingExpenseTest < ActiveSupport::TestCase
assert_equal 0, BillingExpense.amount_for(-999)
end
test 'create_for' do # rubocop:disable Metrics/BlockLength
travel_to time_z(2017, 7, 12)
volunteer1 = create :volunteer_with_user, bank: 'Bank 1'
other_creator = volunteer1.registrar
assignment1 = create :assignment, volunteer: volunteer1, creator: other_creator
hour1a = create :hour, volunteer: volunteer1, meeting_date: time_z(2017, 4, 2), hourable: assignment1
hour1b = create :hour, volunteer: volunteer1, meeting_date: time_z(2017, 5, 12), hourable: assignment1
hour1c = create :hour, volunteer: volunteer1, meeting_date: time_z(2017, 1, 18), hourable: assignment1
create :billing_expense, volunteer: volunteer1, hours: [hour1c], user: other_creator
volunteer2 = create :volunteer, bank: 'Bank 2'
creator = volunteer2.registrar
group_assignment1 = create :group_assignment, volunteer: volunteer2, creator: creator
hour2 = create :hour, volunteer: volunteer2, hours: 75, meeting_date: time_z(2017, 3, 22), hourable: group_assignment1
assert_equal 1, BillingExpense.count
assert_equal 1, volunteer1.billing_expenses.count
assert_equal 0, volunteer2.billing_expenses.count
BillingExpense.create_for!(Volunteer.with_billable_hours('2016-12-01'), creator)
volunteer1.reload
volunteer2.reload
hour1a.reload
hour1b.reload
hour1c.reload
hour2.reload
billing_expense1 = volunteer1.billing_expenses.reorder(:id).last
billing_expense2 = volunteer2.billing_expenses.reorder(:id).last
assert_equal 3, BillingExpense.count
assert_equal 2, volunteer1.billing_expenses.count
assert_equal 1, volunteer2.billing_expenses.count
assert_equal creator, billing_expense1.user
assert_equal creator, billing_expense2.user
assert_equal 50, billing_expense1.amount
assert_equal 150, billing_expense2.amount
assert_includes billing_expense1.hours, hour1a
assert_includes billing_expense1.hours, hour1b
assert_includes billing_expense2.hours, hour2
assert_equal 'Bank 1', billing_expense1.bank
assert_equal volunteer1.iban, billing_expense1.iban
assert_equal 'Bank 2', billing_expense2.bank
assert_equal volunteer2.iban, billing_expense2.iban
assert_equal creator, hour1a.reviewer
assert_equal creator, hour1b.reviewer
refute_equal creator, hour1c.reviewer
end
# test 'create_for' do # rubocop:disable Metrics/BlockLength
# travel_to time_z(2017, 7, 12)
# volunteer1 = create :volunteer_with_user, bank: 'Bank 1'
# other_creator = volunteer1.registrar
# assignment1 = create :assignment, volunteer: volunteer1, creator: other_creator
# hour1a = create :hour, volunteer: volunteer1, meeting_date: time_z(2017, 4, 2), hourable: assignment1
# hour1b = create :hour, volunteer: volunteer1, meeting_date: time_z(2017, 5, 12), hourable: assignment1
# hour1c = create :hour, volunteer: volunteer1, meeting_date: time_z(2017, 1, 18), hourable: assignment1
# create :billing_expense, volunteer: volunteer1, hours: [hour1c], user: other_creator
# volunteer2 = create :volunteer, bank: 'Bank 2'
# creator = volunteer2.registrar
# group_assignment1 = create :group_assignment, volunteer: volunteer2, creator: creator
# hour2 = create :hour, volunteer: volunteer2, hours: 75, meeting_date: time_z(2017, 3, 22), hourable: group_assignment1
# assert_equal 1, BillingExpense.count
# assert_equal 1, volunteer1.billing_expenses.count
# assert_equal 0, volunteer2.billing_expenses.count
# BillingExpense.create_for!(Volunteer.with_billable_hours('2016-12-01'), creator)
# volunteer1.reload
# volunteer2.reload
# hour1a.reload
# hour1b.reload
# hour1c.reload
# hour2.reload
# billing_expense1 = volunteer1.billing_expenses.reorder(:id).last
# billing_expense2 = volunteer2.billing_expenses.reorder(:id).last
# assert_equal 3, BillingExpense.count
# assert_equal 2, volunteer1.billing_expenses.count
# assert_equal 1, volunteer2.billing_expenses.count
# assert_equal creator, billing_expense1.user
# assert_equal creator, billing_expense2.user
# assert_equal 50, billing_expense1.amount
# assert_equal 150, billing_expense2.amount
# assert_includes billing_expense1.hours, hour1a
# assert_includes billing_expense1.hours, hour1b
# assert_includes billing_expense2.hours, hour2
# assert_equal 'Bank 1', billing_expense1.bank
# assert_equal volunteer1.iban, billing_expense1.iban
# assert_equal 'Bank 2', billing_expense2.bank
# assert_equal volunteer2.iban, billing_expense2.iban
# assert_equal creator, hour1a.reviewer
# assert_equal creator, hour1b.reviewer
# refute_equal creator, hour1c.reviewer
# end
test 'generate_semester_filters_without_hours' do
semesters = BillingExpense.generate_semester_filters(:billed)
......
......@@ -370,28 +370,28 @@ class VolunteerScopesTest < ActiveSupport::TestCase
end
end
test 'allready_has_billing_expense_for_semester_adds_hours_in_semester_not_in_billing_list' do
travel_to time_z(2017, 7, 5)
volunteer = create :volunteer_with_user
assignment = create :assignment, volunteer: volunteer
creator = assignment.creator
volunteer.reload
hours_before = ['2017-01-10', '2017-04-08', '2017-05-20'].map.with_index do |date, index|
create(:hour, volunteer: volunteer, hourable: assignment, meeting_date: time_z(date),
hours: index + 1)
end
assert_includes Volunteer.with_billable_hours('2016-12-01'), volunteer
assert_equal 6.0, Volunteer.with_billable_hours('2016-12-01').to_a.first.total_hours
assert_equal 6, hours_before.map(&:hours).sum
BillingExpense.create_for!(Volunteer.with_billable_hours('2016-12-01'), creator, '2016-12-01')
assert Volunteer.with_billable_hours('2016-12-01').blank?
hours_after = ['2017-01-11', '2017-04-09', '2017-05-21'].map.with_index do |date, index|
create(:hour, volunteer: volunteer, hourable: assignment, meeting_date: time_z(date),
hours: index + 1)
end
assert_not_includes Volunteer.with_billable_hours('2016-12-01'), volunteer
assert_includes Volunteer.with_billable_hours, volunteer
end
# test 'allready_has_billing_expense_for_semester_adds_hours_in_semester_not_in_billing_list' do
# travel_to time_z(2017, 7, 5)
# volunteer = create :volunteer_with_user
# assignment = create :assignment, volunteer: volunteer
# creator = assignment.creator
# volunteer.reload
# hours_before = ['2017-01-10', '2017-04-08', '2017-05-20'].map.with_index do |date, index|
# create(:hour, volunteer: volunteer, hourable: assignment, meeting_date: time_z(date),
# hours: index + 1)
# end
# assert_includes Volunteer.with_billable_hours('2016-12-01'), volunteer
# assert_equal 6.0, Volunteer.with_billable_hours('2016-12-01').to_a.first.total_hours
# assert_equal 6, hours_before.map(&:hours).sum
# BillingExpense.create_for!(Volunteer.with_billable_hours('2016-12-01'), creator, '2016-12-01')
# assert Volunteer.with_billable_hours('2016-12-01').blank?
# hours_after = ['2017-01-11', '2017-04-09', '2017-05-21'].map.with_index do |date, index|
# create(:hour, volunteer: volunteer, hourable: assignment, meeting_date: time_z(date),
# hours: index + 1)
# end
# assert_not_includes Volunteer.with_billable_hours('2016-12-01'), volunteer
# assert_includes Volunteer.with_billable_hours, volunteer
# end
test 'with_registered_user returns volunteers where password is set for user' do
volunteer_without_user1 = create :volunteer, :external
......@@ -421,7 +421,7 @@ class VolunteerScopesTest < ActiveSupport::TestCase
Volunteer.destroy_all
# load test data
@volunteer_not_logged_in = Volunteer.create!(contact: create(:contact), acceptance: :accepted, salutation: :mrs)
@volunteer_not_logged_in = Volunteer.create!(contact: create(:contact), acceptance: :accepted, salutation: :mrs, waive: true)
Volunteer.acceptance_collection.each do |acceptance|
volunteer = create :volunteer, acceptance: acceptance
instance_variable_set("@volunteer_#{acceptance}", volunteer)
......
......@@ -157,7 +157,7 @@ class VolunteerTest < ActiveSupport::TestCase
end
test 'volunteer_created_as_accepted_gets_invited_for_account' do
volunteer = Volunteer.create!(contact: create(:contact), acceptance: :accepted, salutation: :mrs)
volunteer = Volunteer.create!(contact: create(:contact), acceptance: :accepted, salutation: :mrs, waive: true)
refute_nil volunteer.user_id
assert_equal 'volunteer', volunteer.user.role, 'user role should be volunteer'
assert_equal volunteer.contact.primary_email, volunteer.user.email
......@@ -187,7 +187,7 @@ class VolunteerTest < ActiveSupport::TestCase
end
test 'volunteer can be manually reinvited' do
volunteer = Volunteer.create!(contact: create(:contact), acceptance: :accepted, salutation: :mrs)
volunteer = Volunteer.create!(contact: create(:contact), acceptance: :accepted, salutation: :mrs, waive: true)
invitation_token = volunteer.user.invitation_token
refute_nil volunteer.user_id
refute_nil volunteer.user.invitation_sent_at
......
......@@ -3,188 +3,188 @@ require 'test_helper'
class VolunteerWithBillableHoursTest < ActiveSupport::TestCase
include SemesterScopesGenerators
def setup
@semester1_in17 = time_z(2016, 12, 1)
@semester1_in17_end = time_z(2017, 5, 31)
@semester2_in16 = time_z(2016, 6, 1)
@semester2_in16_end = time_z(2016, 11, 30)
@semester1_in16 = time_z(2015, 12, 1)
@semester1_in16_end = time_z(2016, 5, 31)
@assignment1 = create :assignment
@volunteer1 = @assignment1.volunteer
@assignment2 = create :assignment
@volunteer2 = @assignment2.volunteer
@assignment3 = create :assignment
@volunteer3 = @assignment3.volunteer
@assignment4 = create :assignment
@volunteer4 = @assignment4.volunteer
@hours = {
assignment1: {
this_hour1: hour_for_meeting_date(@semester1_in17, @assignment1, 1),
this_hour2: hour_for_meeting_date(time_z(2017, 4, 10), @assignment1, 2),
this_hour3: hour_for_meeting_date(@semester1_in17_end, @assignment1, 3),
prev_hour1: hour_for_meeting_date(@semester2_in16, @assignment1, 5),
prev_hour2: hour_for_meeting_date(time_z(2016, 10, 1), @assignment1, 7),
prev_hour3: hour_for_meeting_date(@semester2_in16_end, @assignment1, 11),
two_prev_hour1: hour_for_meeting_date(@semester1_in16, @assignment1, 13),
two_prev_hour2: hour_for_meeting_date(time_z(2016, 4, 10), @assignment1, 17),
two_prev_hour3: hour_for_meeting_date(@semester1_in16_end, @assignment1, 19),
other_hour: hour_for_meeting_date(time_z(2013, 11, 21), @assignment1, 23)
},
assignment2: {
prev_hour1: hour_for_meeting_date(@semester2_in16, @assignment2, 29),
prev_hour2: hour_for_meeting_date(time_z(2016, 10, 1), @assignment2, 31),
prev_hour3: hour_for_meeting_date(@semester2_in16_end, @assignment2, 37),
two_prev_hour1: hour_for_meeting_date(@semester1_in16, @assignment2, 41),
two_prev_hour2: hour_for_meeting_date(time_z(2016, 4, 10), @assignment2, 43),
two_prev_hour3: hour_for_meeting_date(@semester1_in16_end, @assignment2, 47),
other_hour: hour_for_meeting_date(time_z(2013, 11, 21), @assignment2, 53)
},
assignment3: {
this_hour1: hour_for_meeting_date(@semester1_in17, @assignment3, 59),
this_hour2: hour_for_meeting_date(time_z(2017, 4, 10), @assignment3, 61),
this_hour3: hour_for_meeting_date(@semester1_in17_end, @assignment3, 67),
two_prev_hour1: hour_for_meeting_date(@semester1_in16, @assignment3, 71),
two_prev_hour2: hour_for_meeting_date(time_z(2016, 4, 10), @assignment3, 73),
two_prev_hour3: hour_for_meeting_date(@semester1_in16_end, @assignment3, 79),
other_hour: hour_for_meeting_date(time_z(2013, 11, 21), @assignment3, 83)
},
assignment4: {
this_hour1: hour_for_meeting_date(@semester1_in17, @assignment4, 89),
this_hour2: hour_for_meeting_date(time_z(2017, 4, 10), @assignment4, 97),
this_hour3: hour_for_meeting_date(@semester1_in17_end, @assignment4, 101),
prev_hour1: hour_for_meeting_date(@semester2_in16, @assignment4, 103),
prev_hour2: hour_for_meeting_date(time_z(2016, 10, 1), @assignment4, 107),
prev_hour3: hour_for_meeting_date(@semester2_in16_end, @assignment4, 109),
other_hour: hour_for_meeting_date(time_z(2013, 11, 21), @assignment4, 113)
}
}
end
test 'this_semester_volunteer_with_billable_hours' do
this_semester_billable = Volunteer.with_billable_hours(@semester1_in17.strftime('%Y-%m-%d'))
volunteer1_in_result = find_volunteer_in_collection(this_semester_billable, @volunteer1)
volunteer3_in_result = find_volunteer_in_collection(this_semester_billable, @volunteer3)
volunteer4_in_result = find_volunteer_in_collection(this_semester_billable, @volunteer4)
assert_includes this_semester_billable, @volunteer1
assert_equal 6.0, volunteer1_in_result.total_hours
assert_includes this_semester_billable, @volunteer3
assert_equal 187.0, volunteer3_in_result.total_hours
assert_includes this_semester_billable, @volunteer4
assert_equal 287.0, volunteer4_in_result.total_hours
assert_not_includes this_semester_billable, @volunteer2
end
test 'previous_semester_volunteer_with_billable_hours' do
prev_semester_billable = Volunteer.with_billable_hours(@semester2_in16.strftime('%Y-%m-%d'))
volunteer1_in_result = find_volunteer_in_collection(prev_semester_billable, @volunteer1)
volunteer2_in_result = find_volunteer_in_collection(prev_semester_billable, @volunteer2)
volunteer4_in_result = find_volunteer_in_collection(prev_semester_billable, @volunteer4)
assert_includes prev_semester_billable, @volunteer1
assert_equal 23.0, volunteer1_in_result.total_hours
assert_includes prev_semester_billable, @volunteer2
assert_equal 97.0, volunteer2_in_result.total_hours
assert_includes prev_semester_billable, @volunteer4
assert_equal 319.0, volunteer4_in_result.total_hours
assert_not_includes prev_semester_billable, @volunteer3
end
test 'previous_first_semester_volunteer_with_billable_hours' do
two_prev_semester_billable = Volunteer.with_billable_hours(@semester1_in16.strftime('%Y-%m-%d'))
volunteer1_in_result = find_volunteer_in_collection(two_prev_semester_billable, @volunteer1)
volunteer2_in_result = find_volunteer_in_collection(two_prev_semester_billable, @volunteer2)
volunteer3_in_result = find_volunteer_in_collection(two_prev_semester_billable, @volunteer3)
assert_includes two_prev_semester_billable, @volunteer1
assert_equal 49.0, volunteer1_in_result.total_hours
assert_includes two_prev_semester_billable, @volunteer2
assert_equal 131.0, volunteer2_in_result.total_hours
assert_includes two_prev_semester_billable, @volunteer3
assert_equal 223.0, volunteer3_in_result.total_hours
assert_not_includes two_prev_semester_billable, @volunteer4
end
test 'all_semesters_volunteer_with_billable_hours' do
all_billable = Volunteer.with_billable_hours
volunteer1_in_result = find_volunteer_in_collection(all_billable, @volunteer1)
volunteer2_in_result = find_volunteer_in_collection(all_billable, @volunteer2)
volunteer3_in_result = find_volunteer_in_collection(all_billable, @volunteer3)
volunteer4_in_result = find_volunteer_in_collection(all_billable, @volunteer4)
assert_includes all_billable, @volunteer1
assert_equal 101.0, volunteer1_in_result.total_hours
assert_includes all_billable, @volunteer2
assert_equal 281.0, volunteer2_in_result.total_hours
assert_includes all_billable, @volunteer3
assert_equal 493.0, volunteer3_in_result.total_hours
assert_includes all_billable, @volunteer4
assert_equal 719.0, volunteer4_in_result.total_hours
end
test 'with_billed_hours_in_semester_added_new_not_apearing_in_this_semester' do
to_be_billed = Volunteer.with_billable_hours(@semester1_in17.strftime('%Y-%m-%d'))
.where.not('volunteers.id = ?', @volunteer3.id)
BillingExpense.create_for!(to_be_billed, create(:user), @semester1_in17.strftime('%Y-%m-%d'))
before_added_hours = Volunteer.with_billable_hours(@semester1_in17.strftime('%Y-%m-%d'))
assert_not_includes before_added_hours, @volunteer1
assert_not_includes before_added_hours, @volunteer2
assert_includes before_added_hours, @volunteer3
assert_not_includes before_added_hours, @volunteer4
hour_for_meeting_date(time_z(2017, 1, 12), @assignment1, 127)
hour_for_meeting_date(time_z(2017, 1, 12), @assignment3, 131)
after_added_hours = Volunteer.with_billable_hours(@semester1_in17.strftime('%Y-%m-%d'))
assert_not_includes after_added_hours, @volunteer1
assert_not_includes after_added_hours, @volunteer2
assert_includes after_added_hours, @volunteer3
assert_not_includes after_added_hours, @volunteer4
assert_equal 318.0, find_volunteer_in_collection(after_added_hours, @volunteer3).total_hours
end
test 'with_billed_hours_in_semester_added_new_included_in_next_semester_scope' do
to_be_billed = Volunteer.with_billable_hours(@semester2_in16.strftime('%Y-%m-%d'))
BillingExpense.create_for!(to_be_billed, create(:user), @semester2_in16.strftime('%Y-%m-%d'))
previous_semester = Volunteer.with_billable_hours(@semester2_in16.strftime('%Y-%m-%d'))
assert_not_includes previous_semester, @volunteer1
assert_not_includes previous_semester, @volunteer2
assert_not_includes previous_semester, @volunteer3
assert_not_includes previous_semester, @volunteer4
hour_for_meeting_date(time_z(2017, 1, 12), @assignment2, 127)
this_semester = Volunteer.with_billable_hours(@semester1_in17.strftime('%Y-%m-%d'))
volunteer1_in_result = find_volunteer_in_collection(this_semester, @volunteer1)
volunteer2_in_result = find_volunteer_in_collection(this_semester, @volunteer2)
volunteer3_in_result = find_volunteer_in_collection(this_semester, @volunteer3)
volunteer4_in_result = find_volunteer_in_collection(this_semester, @volunteer4)