Verified Commit b7c28f1b authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

put generator into utility module, because it is going to be used in other tests as well

parent 87102e1c
Pipeline #22980 canceled with stage
in 13 minutes and 25 seconds
require 'test_helper'
class HourTest < ActiveSupport::TestCase
include SemesterScopesGenerators
test 'hour can only be valid with hourable relation' do
assignment = create :assignment, volunteer: create(:volunteer)
hour = Hour.new(volunteer: assignment.volunteer, hours: 1, meeting_date: 10.days.ago)
......@@ -17,9 +19,9 @@ class HourTest < ActiveSupport::TestCase
this_hour1: hour_for_meeting_date(time_z(2016, 12, 1), assignment),
this_hour2: hour_for_meeting_date(time_z(2017, 4, 10), assignment),
this_hour3: hour_for_meeting_date(time_z(2017, 5, 31), assignment),
prev_hour1: hour_for_meeting_date(time_z(2016, 11, 15), assignment),
prev_hour1: hour_for_meeting_date(time_z(2016, 11, 30), assignment),
prev_hour2: hour_for_meeting_date(time_z(2016, 10, 1), assignment),
prev_hour3: hour_for_meeting_date(time_z(2016, 7, 1), assignment),
prev_hour3: hour_for_meeting_date(time_z(2016, 6, 1), assignment),
two_prev_hour1: hour_for_meeting_date(time_z(2015, 12, 1), assignment),
two_prev_hour2: hour_for_meeting_date(time_z(2016, 4, 10), assignment),
two_prev_hour3: hour_for_meeting_date(time_z(2016, 5, 31), assignment),
......@@ -68,9 +70,4 @@ class HourTest < ActiveSupport::TestCase
assert_includes all_semester_hours, hour
end
end
def hour_for_meeting_date(meeting_date, assignment)
create :hour, volunteer: assignment.volunteer, hours: 1, meeting_date: meeting_date,
hourable: assignment
end
end
module SemesterScopesGenerators
def hour_for_meeting_date(meeting_date, hourable, hours = 1.0)
create :hour, volunteer: hourable.volunteer, hours: hours.to_f, meeting_date: meeting_date,
hourable: hourable.polymorph_url_object
end
end
Supports Markdown
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