Commit ab8ebb55 authored by Chrysanthi Lagodimou's avatar Chrysanthi Lagodimou

Hours should appear in asc order in review form

parent 2fc9f1e9
Pipeline #32834 passed with stage
in 38 minutes and 13 seconds
......@@ -44,7 +44,7 @@ Style/GuardClause:
MinBodyLength: 5
Metrics/LineLength:
Max: 100
Max: 140
Exclude:
- 'db/seeds.rb'
- 'app/policies/**/*'
......
......@@ -20,6 +20,7 @@ class Hour < ApplicationRecord
scope :billable, (-> { where(billing_expense: nil) })
scope :billed, (-> { where.not(billing_expense: nil) })
scope :order_by_meeting_date, (-> { order(meeting_date: :asc) })
scope :semester, lambda { |date = nil|
return all if date.blank?
date = Time.zone.parse(date) unless date.is_a? Time
......@@ -33,7 +34,7 @@ class Hour < ApplicationRecord
}
scope :within_semester, lambda { |semester|
where(meeting_date: semester.begin...semester.end.advance(days: 1))
where(meeting_date: semester.begin...semester.end.advance(days: 1)).order_by_meeting_date
}
scope :since_last_submitted, lambda { |submitted_at|
......@@ -51,9 +52,9 @@ class Hour < ApplicationRecord
attr_reader :spv_mission_id
def spv_mission_id= id
spv_mission = SemesterProcessVolunteerMission.find(id)
self.hourable = spv_mission.mission.group_assignment? ? spv_mission.mission.group_offer : spv_mission.mission
def spv_mission_id=(id)
spv_mission = SemesterProcessVolunteerMission.find(id)
self.hourable = spv_mission.mission.group_assignment? ? spv_mission.mission.group_offer : spv_mission.mission
end
def assignment?
......
......@@ -6,6 +6,7 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
@subject = create :semester_process
@spv = create(:semester_process_volunteer, :with_mission, :with_mail, volunteer: @volunteer,
semester_process: @subject)
@spv.reload
login_as @volunteer.user
visit review_semester_semester_process_volunteer_path(@spv)
end
......@@ -39,6 +40,15 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
assert_not page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
end
test 'volunteer hours should appear in asc order' do
create :hour, volunteer: @volunteer, meeting_date: @spv.semester.begin, hours: 1, hourable: @spv.missions.last
create :hour, volunteer: @volunteer, meeting_date: @spv.semester.end, hours: 2, hourable: @spv.missions.last
visit review_semester_semester_process_volunteer_path(@spv)
within 'tbody tr:last-child' do
assert page.has_text? I18n.l(@spv.semester.end)
end
end
test 'submit form should not display warning' do
visit root_path
assert page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
......
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