Commit ca1cd476 authored by Chrysanthi Lagodimou's avatar Chrysanthi Lagodimou
Browse files

Volunteer sees warning for unsubmitted semester feedback

parent 7cc9a101
Pipeline #30649 passed with stage
in 36 minutes and 11 seconds
......@@ -177,6 +177,14 @@ class Volunteer < ApplicationRecord
.active_semester_mission(semester)
end
def unsubmitted_semester_feedbacks?
false if semester_process_volunteers.blank?
semester_process_volunteers.each do |spv|
return true unless spv.commited_at?
end
false
end
## Activness Scopes
#
scope :will_take_more_assignments, (-> { where(take_more_assignments: true) })
......
......@@ -8,8 +8,8 @@ class SemesterProcessVolunteerPolicy < ApplicationPolicy
# Actions
alias_method :index?, :superadmin?
alias_method :review_semester?, :superadmin?
alias_method :submit_review?, :superadmin?
alias_method :review_semester?, :superadmin_or_volunteer_related?
alias_method :submit_review?, :superadmin_or_volunteer_related?
alias_method :new?, :superadmin?
alias_method :show?, :superadmin?
alias_method :edit?, :superadmin?
......
- if current_user.volunteer? && current_user.volunteer.unsubmitted_semester_feedbacks?
- message = 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
= notification_warning_bubble(message)
= render 'unsubmitted_semester_feedback_notification'
= render 'unsubmitted_semester_feedback_notification'
h1.m-b-20= @volunteer.contact.full_name
- if @volunteer.rejected?
- if @volunteer.rejection_type.present?
......
......@@ -14,14 +14,28 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
visit review_semester_semester_process_volunteer_path(@subject_volunteer)
end
test 'volunteer with unsubmitted feedback should see a warning' do
second_spv = create(:semester_process_volunteer, :with_mission, volunteer: @volunteer,
semester_process: @subject)
login_as @volunteer.user
visit volunteer_path(@volunteer)
assert page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
visit root_path
assert page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
submit_feedback(@subject_volunteer)
visit root_path
assert page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
submit_feedback(second_spv)
visit root_path
assert_not page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
end
test 'by default, you should have not accepted the data' do
assert_text 'Ich bestätige, dass ich alle meine Stunden und Halbjahres-Rapporte bis zum heutigen Datum erfasst habe.'
end
test 'accepting should remove submit button' do
check 'Ich verzichte auf die Auszahlung von Spesen.'
click_on 'Bestätigen', match: :first
@subject_volunteer.reload
submit_feedback(@subject_volunteer)
assert_text "Bestätigt am #{I18n.l(@subject_volunteer.commited_at.to_date)} durch #{(@subject_volunteer.commited_by.full_name)}"
end
......@@ -67,4 +81,11 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
{ goals: 'being on time', achievements: 'everything', future: 'continue', comments: 'nothing', conversation: true }.stringify_keys
assert_equal @subject_volunteer.hours.last.hours, 33
end
def submit_feedback(semester_process_volunteer)
visit review_semester_semester_process_volunteer_path(semester_process_volunteer)
check 'Ich verzichte auf die Auszahlung von Spesen.'
click_on 'Bestätigen', match: :first
semester_process_volunteer.reload
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