Verified Commit f71aa759 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider
Browse files

linter fix

parent 36151962
......@@ -7,7 +7,8 @@ class HoursController < ApplicationController
q_params = params.to_unsafe_hash[:q] || {}
if params[:semester]
q_params[:meeting_date_gteq] = params[:semester]
q_params[:meeting_date_lteq] = Date.parse(params[:semester]).advance(months: BillingExpense::SEMESTER_LENGTH)
q_params[:meeting_date_lteq] = Date.parse(params[:semester])
.advance(months: BillingExpense::SEMESTER_LENGTH)
end
@q = @volunteer.hours.ransack(q_params)
@q.sorts = ['meeting_date desc'] if @q.sorts.empty?
......
......@@ -66,11 +66,13 @@ module BillingExpenseSemesterUtils
semesters
end
# rubocop:disable Metrics/AbcSize
def self.semester_back_filters
min_meeting_date = Hour.billable.minimum(:meeting_date)
return [semester_filter_hash(current_semester_start)] unless min_meeting_date
first_semester = dates_semester_start(min_meeting_date < 2.years.ago ? 2.years.ago : min_meeting_date)
min_date = min_meeting_date < 2.years.ago ? 2.years.ago : min_meeting_date
first_semester = dates_semester_start(min_date)
last_semester = dates_semester_start(Hour.billable.maximum(:meeting_date))
semester_filters = [semester_filter_hash(last_semester)]
semester_back_count(first_semester.to_time, last_semester.to_time).times do
......@@ -79,6 +81,7 @@ module BillingExpenseSemesterUtils
end
semester_filters
end
# rubocop:enable Metrics/AbcSize
def self.semester_filter_hash(date)
{ q: :semester, value: date.strftime('%Y-%m-%d'),
......
......@@ -92,8 +92,8 @@ class BillingExpenseTest < ActiveSupport::TestCase
really_destroy_with_deleted(BillingExpense, Hour)
hourable = create(:assignment)
create :billing_expense, hours: [
hour_for_meeting_date(time_z(2014, 2, 3), hourable),
hour_for_meeting_date(time_z(2015, 2, 3), hourable)
hour_for_meeting_date(time_z(2014, 2, 3), hourable),
hour_for_meeting_date(time_z(2015, 2, 3), hourable)
]
assert_equal [
......@@ -111,16 +111,16 @@ class BillingExpenseTest < ActiveSupport::TestCase
test 'semester_scope' do
hourable = create(:assignment)
billing_expense1 = create :billing_expense,
hours: [hour_for_meeting_date(time_z(2017, 1, 12), hourable)]
hours: [hour_for_meeting_date(time_z(2017, 1, 12), hourable)]
billing_expense2 = create :billing_expense,
hours: [
hour_for_meeting_date(time_z(2017, 2, 1), hourable),
hour_for_meeting_date(time_z(2017, 5, 12), hourable)
]
hours: [
hour_for_meeting_date(time_z(2017, 2, 1), hourable),
hour_for_meeting_date(time_z(2017, 5, 12), hourable)
]
create :billing_expense,
hours: [hour_for_meeting_date(time_z(2016, 11, 30), hourable)]
hours: [hour_for_meeting_date(time_z(2016, 11, 30), hourable)]
assert_includes BillingExpense.semester('2016-12-01'), billing_expense1
assert_includes BillingExpense.semester('2016-12-01'), billing_expense2
......
......@@ -2,7 +2,8 @@ module SemesterScopesGenerators
def hour_for_meeting_date(meeting_date, hourable, hours = 1.0)
before = Time.zone.now
travel_to meeting_date
hour = create :hour, volunteer: hourable.volunteer, hours: hours.to_f, meeting_date: meeting_date,
hour = create :hour, volunteer: hourable.volunteer, hours: hours.to_f,
meeting_date: meeting_date,
hourable: hourable.polymorph_url_object
travel_to before
hour
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment