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

Merge branch 'BugFix/Warning-for-unsubmitted-feedback' into 'develop'

BugFix/Warning for unsubmitted feedback

See merge request !864
parents df4493b0 b474a2b9
Pipeline #31802 passed with stage
in 38 minutes and 39 seconds
module NotificationHelper module NotificationHelper
def notification_warning_bubble(text) def notification_bubble(text, type)
tag.div(class: 'alert alert-warning alert-dismissible', role: 'alert') do tag.div(class: "alert #{type} alert-dismissible", role: 'alert') do
concat notification_close_button concat notification_close_button
concat raw(text) concat raw(text)
end end
......
- if alert.present? - if alert.present?
= notification_warning_bubble(alert) = notification_bubble(alert, 'alert-warning')
- elsif notice.present? - elsif notice.present?
- if notice.is_a? String - if notice.is_a? String
= notification_warning_bubble(notice) = notification_bubble(notice, 'alert-warning')
- elsif notice.is_a? Hash - elsif notice.is_a? Hash
= render 'notification_alert_with_action', notice: notice = render 'notification_alert_with_action', notice: notice
- elsif @custom_notice.present? - elsif @custom_notice.present?
......
- if current_user.volunteer? && current_user.volunteer.unsubmitted_semester_feedbacks? - if !current_user.nil? && current_user.volunteer? && current_user.volunteer.unsubmitted_semester_feedbacks?
- current_user.volunteer.unsubmitted_semester_feedbacks.each do |spv| - current_user.volunteer.unsubmitted_semester_feedbacks.each do |spv|
- message = 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.' - 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 - 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) = notification_bubble(message, 'alert-danger')
= render 'unsubmitted_semester_feedback_notification'
...@@ -25,6 +25,7 @@ html ...@@ -25,6 +25,7 @@ html
= render 'navigation' = render 'navigation'
.container-fluid .container-fluid
= render 'notification' = render 'notification'
= render 'unsubmitted_semester_feedback_notification'
= yield = yield
= render 'modal_truncate' = render 'modal_truncate'
......
= render 'unsubmitted_semester_feedback_notification'
h1.m-b-20= @volunteer.contact.full_name h1.m-b-20= @volunteer.contact.full_name
- if @volunteer.rejected? - if @volunteer.rejected?
- if @volunteer.rejection_type.present? - if @volunteer.rejection_type.present?
......
...@@ -3,14 +3,11 @@ require 'application_system_test_case' ...@@ -3,14 +3,11 @@ require 'application_system_test_case'
class SemesterFeedbackTest < ApplicationSystemTestCase class SemesterFeedbackTest < ApplicationSystemTestCase
setup do setup do
@volunteer = create :volunteer_with_user @volunteer = create :volunteer_with_user
@assignment = create :assignment, volunteer: @volunteer
@group_assignment = create :group_assignment, volunteer: @volunteer
@subject = create :semester_process @subject = create :semester_process
@subject_volunteer = create(:semester_process_volunteer, :with_mission, volunteer: @volunteer, @spv = create(:semester_process_volunteer, :with_mission, volunteer: @volunteer,
semester_process: @subject) semester_process: @subject)
@mission = @subject_volunteer.semester_process_volunteer_missions.first.assignment
login_as @volunteer.user login_as @volunteer.user
visit review_semester_semester_process_volunteer_path(@subject_volunteer) visit review_semester_semester_process_volunteer_path(@spv)
end end
def submit_feedback(semester_process_volunteer) def submit_feedback(semester_process_volunteer)
...@@ -28,21 +25,16 @@ class SemesterFeedbackTest < ApplicationSystemTestCase ...@@ -28,21 +25,16 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
end end
test 'volunteer with unsubmitted feedback should see a warning' do 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) visit volunteer_path(@volunteer)
assert page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.' 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 assert page.has_link? 'Bitte klicken Sie hier um diesen zu bestätigen'
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 visit root_path
assert page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.' 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 assert page.has_link? 'Bitte klicken Sie hier um diesen zu bestätigen'
click_link 'Bitte klicken Sie hier um diesen zu bestätigen' click_link 'Bitte klicken Sie hier um diesen zu bestätigen'
submit_feedback(second_spv) submit_feedback(@spv)
visit volunteer_path(@volunteer)
assert_not page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
visit root_path visit root_path
assert_not page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.' assert_not page.has_text? 'Sie haben einen ausstehenden Halbjahres-Rapport für dieses Semester.'
end end
...@@ -52,18 +44,18 @@ class SemesterFeedbackTest < ApplicationSystemTestCase ...@@ -52,18 +44,18 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
end end
test 'accepting should remove submit button' do test 'accepting should remove submit button' do
submit_feedback(@subject_volunteer) submit_feedback(@spv)
assert_text "Bestätigt am #{I18n.l(@subject_volunteer.commited_at.to_date)} durch #{(@subject_volunteer.commited_by.full_name)}" assert_text "Bestätigt am #{I18n.l(@spv.commited_at.to_date)} durch #{@spv.commited_by.full_name}"
end end
test 'you should be able to add hours on run' do test 'you should be able to add hours on run' do
fill_in_required_feedback_fields fill_in_required_feedback_fields
assert_equal @subject_volunteer.hours.count, 0 assert_equal @spv.hours.count, 0
fill_in 'Stunden', with: 10 fill_in 'Stunden', with: 10
check 'Ich verzichte auf die Auszahlung von Spesen.' check 'Ich verzichte auf die Auszahlung von Spesen.'
click_on 'Bestätigen', match: :first click_on 'Bestätigen', match: :first
@subject_volunteer.reload @spv.reload
assert_equal @subject_volunteer.hours.first.hours, 10 assert_equal @spv.hours.first.hours, 10
within '.table.table-striped.hours-table' do within '.table.table-striped.hours-table' do
assert_text "#{I18n.l(Time.zone.now.to_date)} 10.0" assert_text "#{I18n.l(Time.zone.now.to_date)} 10.0"
end end
...@@ -91,12 +83,12 @@ class SemesterFeedbackTest < ApplicationSystemTestCase ...@@ -91,12 +83,12 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
fill_in 'IBAN', with: 'CH59 2012 0767 0052 0024 0' fill_in 'IBAN', with: 'CH59 2012 0767 0052 0024 0'
fill_in 'Name der Bank', with: 'Bank' fill_in 'Name der Bank', with: 'Bank'
click_on 'Bestätigen' click_on 'Bestätigen'
@subject_volunteer.reload @spv.reload
assert_equal @subject_volunteer.volunteer.slice(:iban, :bank, :waive), assert_equal @spv.volunteer.slice(:iban, :bank, :waive),
{ iban: 'CH59 2012 0767 0052 0024 0', bank: 'Bank', waive: false }.stringify_keys { iban: 'CH59 2012 0767 0052 0024 0', bank: 'Bank', waive: false }.stringify_keys
assert_equal @subject_volunteer.semester_feedbacks.last.slice(:goals, :achievements, :future, :comments, :conversation), assert_equal @spv.semester_feedbacks.last.slice(:goals, :achievements, :future, :comments, :conversation),
{ goals: 'being on time', achievements: 'everything', future: 'continue', comments: 'nothing', conversation: true }.stringify_keys { goals: 'being on time', achievements: 'everything', future: 'continue', comments: 'nothing', conversation: true }.stringify_keys
assert_equal @subject_volunteer.hours.last.hours, 33 assert_equal @spv.hours.last.hours, 33
end end
test 'truncate_modal_shows_all_text' do test 'truncate_modal_shows_all_text' do
...@@ -107,7 +99,7 @@ class SemesterFeedbackTest < ApplicationSystemTestCase ...@@ -107,7 +99,7 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
@superadmin = create :user @superadmin = create :user
login_as @superadmin login_as @superadmin
visit review_semester_semester_process_volunteer_path(@subject_volunteer) visit review_semester_semester_process_volunteer_path(@spv)
fill_in 'Was waren die wichtigsten Inhalte (oder Ziele) Ihres Einsatzes in den letzten Monaten?', with: goals fill_in 'Was waren die wichtigsten Inhalte (oder Ziele) Ihres Einsatzes in den letzten Monaten?', with: goals
fill_in 'Was konnte in den letzten Monaten erreicht werden?', with: achievements fill_in 'Was konnte in den letzten Monaten erreicht werden?', with: achievements
...@@ -117,7 +109,7 @@ class SemesterFeedbackTest < ApplicationSystemTestCase ...@@ -117,7 +109,7 @@ class SemesterFeedbackTest < ApplicationSystemTestCase
# submit feedback without revisiting review form # submit feedback without revisiting review form
check 'Ich verzichte auf die Auszahlung von Spesen.' check 'Ich verzichte auf die Auszahlung von Spesen.'
click_on 'Bestätigen', match: :first click_on 'Bestätigen', match: :first
@subject_volunteer.reload @spv.reload
visit semester_process_volunteers_path visit semester_process_volunteers_path
page.find('td', text: goals.truncate(300)).click page.find('td', text: goals.truncate(300)).click
......
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