Commit e350df27 authored by Beat Seeliger's avatar Beat Seeliger
Browse files

Merge branch 'changes/show-notification-to-volunteer-to-submit-feedback' into 'develop'

Changes: Volunteer sees warning for unsubmitted semester feedback

See merge request !838
parents 7cc9a101 ae1ca5ad
Pipeline #30706 passed with stage
in 36 minutes and 20 seconds
......@@ -177,6 +177,15 @@ class Volunteer < ApplicationRecord
.active_semester_mission(semester)
end
def unsubmitted_semester_feedbacks
semester_process_volunteers.where(commited_at: nil)
end
def unsubmitted_semester_feedbacks?
return false if unsubmitted_semester_feedbacks.blank?
true
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?
- current_user.volunteer.unsubmitted_semester_feedbacks.each do |spv|
- message = 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
- message << "<a href='#{review_semester_semester_process_volunteer_path(spv)}'>Bitte klicken Sie hier um diesen zu bestätigen.</a>".html_safe
= 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?
......
......@@ -2,7 +2,6 @@ require 'application_system_test_case'
class SemesterFeedbackTest < ApplicationSystemTestCase
setup do
@superadmin = create :user
@volunteer = create :volunteer_with_user
@assignment = create :assignment, volunteer: @volunteer
@group_assignment = create :group_assignment, volunteer: @volunteer
......@@ -10,18 +9,36 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
@subject_volunteer = create(:semester_process_volunteer, :with_mission, volunteer: @volunteer,
semester_process: @subject)
@mission = @subject_volunteer.semester_process_volunteer_missions.first.assignment
login_as @superadmin
login_as @volunteer.user
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)
visit volunteer_path(@volunteer)
assert page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
assert page.has_link? 'Bitte klicken Sie hier um diesen zu bestätigen', count: 2
visit root_path
assert page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
assert page.has_link? 'Bitte klicken Sie hier um diesen zu bestätigen', count: 2
click_link 'Bitte klicken Sie hier um diesen zu bestätigen', match: :first
submit_feedback(@subject_volunteer)
visit root_path
assert page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
assert page.has_link? 'Bitte klicken Sie hier um diesen zu bestätigen', count: 1
click_link 'Bitte klicken Sie hier um diesen zu bestätigen'
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 +84,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