Commit 8a363043 authored by Tugce Nur Tas's avatar Tugce Nur Tas

add journal entry with semester feedback id to spv index

parent 909120c7
Pipeline #31520 passed with stage
in 44 minutes and 53 seconds
...@@ -12,6 +12,7 @@ class JournalsController < ApplicationController ...@@ -12,6 +12,7 @@ class JournalsController < ApplicationController
def new def new
@journal = @journaled.journals.new @journal = @journaled.journals.new
handle_feedback_quote handle_feedback_quote
handle_semester_feedback_quote
authorize @journal authorize @journal
end end
...@@ -68,6 +69,17 @@ class JournalsController < ApplicationController ...@@ -68,6 +69,17 @@ class JournalsController < ApplicationController
end.compact.join("\n\n") end.compact.join("\n\n")
end end
def handle_semester_feedback_quote
return unless params[:semester_feedback_id]
@semester_feedback = SemesterFeedback.find_by(id: params[:semester_feedback_id])
return unless @semester_feedback
@journal.category = :feedback
@journal.title = "Semester Prozess Feedback vom #{I18n.l(@semester_feedback.created_at.to_date)}: "
@journal.body = @semester_feedback.slice(:goals, :achievements, :future, :comments).map do |key, sfb_quote|
"#{I18n.t("activerecord.attributes.feedback.#{key}")}:\n«#{sfb_quote}»" if sfb_quote.present?
end.compact.join("\n\n")
end
def journal_params def journal_params
params.require(:journal).permit( params.require(:journal).permit(
:category, :user_id, :body, :title, :client_id, :volunteer_id :category, :user_id, :body, :title, :client_id, :volunteer_id
......
...@@ -9,7 +9,7 @@ h1= t_title(:index) ...@@ -9,7 +9,7 @@ h1= t_title(:index)
thead thead
tr tr
th.hidden-print Aktionen th.hidden-print Aktionen
th.limit-width Stunden th.limit-width Journal / Stunden
th Status th Status
th.limit-width Freiwilige/r th.limit-width Freiwilige/r
th Einsätze th Einsätze
...@@ -27,6 +27,9 @@ h1= t_title(:index) ...@@ -27,6 +27,9 @@ h1= t_title(:index)
td.index-action-cell.hidden-print td.index-action-cell.hidden-print
= button_link icon_span(:edit), review_semester_semester_process_volunteer_path(spv), title: 'Bearbeiten' = button_link icon_span(:edit), review_semester_semester_process_volunteer_path(spv), title: 'Bearbeiten'
td.index-action-cell.hidden-print td.index-action-cell.hidden-print
= button_link icon_span(:journal), volunteer_journals_path(spv.volunteer), title: 'Journal'
= button_link icon_span(:journal_new), new_volunteer_journal_path(spv.volunteer,
semester_feedback_id: spv.semester_feedbacks.ids), title: 'Neuen Journal eintrag mit Zitat erstellen'
= button_link icon_span(:hours), volunteer_hours_path(spv.volunteer), title: 'Stunden' = button_link icon_span(:hours), volunteer_hours_path(spv.volunteer), title: 'Stunden'
td td
- if spv.commited_at.present? - if spv.commited_at.present?
......
...@@ -3,14 +3,14 @@ require 'test_helper' ...@@ -3,14 +3,14 @@ require 'test_helper'
class JournalsControllerTest < ActionDispatch::IntegrationTest class JournalsControllerTest < ActionDispatch::IntegrationTest
setup do setup do
@superadmin = create :user @superadmin = create :user
@reminder_mailing = create :reminder_mailing, :half_year @reminder_mailing = create :reminder_mailing, :trial_period
@assignment = @reminder_mailing.reminder_mailing_volunteers.first.reminder_mailable @assignment = @reminder_mailing.reminder_mailing_volunteers.first.reminder_mailable
@volunteer = @assignment.volunteer @volunteer = @assignment.volunteer
@feedback = create :feedback, feedbackable: @assignment, volunteer: @volunteer, author: @volunteer.user @feedback = create :feedback, feedbackable: @assignment, volunteer: @volunteer, author: @volunteer.user
login_as @superadmin
end end
test '#new prefilles with feedback quote if feedback_id param is passed' do test '#new prefilles with feedback quote if feedback_id param is passed for trial period' do
login_as @superadmin
get new_volunteer_journal_path(@volunteer, feedback_id: @feedback.id) get new_volunteer_journal_path(@volunteer, feedback_id: @feedback.id)
@journal = @controller.instance_variable_get(:@journal) @journal = @controller.instance_variable_get(:@journal)
assert_equal @journal.category, 'feedback' assert_equal @journal.category, 'feedback'
...@@ -20,4 +20,18 @@ class JournalsControllerTest < ActionDispatch::IntegrationTest ...@@ -20,4 +20,18 @@ class JournalsControllerTest < ActionDispatch::IntegrationTest
assert @journal.body.include? @feedback.future assert @journal.body.include? @feedback.future
assert @journal.body.include? @feedback.comments assert @journal.body.include? @feedback.comments
end end
test '#new prefilling for semester feedback quote if semester_feedback_id param is passed works also' do
@spv = create(:semester_process_volunteer, volunteer: @volunteer)
@semester_feedback = create(:semester_feedback, :no_mission, semester_process_volunteer: @spv, volunteer: @volunteer)
get new_volunteer_journal_path(@volunteer, semester_feedback_id: @semester_feedback.id)
@journal = @controller.instance_variable_get(:@journal)
assert_equal @journal.category, 'feedback'
assert_equal @journal.title, "Semester Prozess Feedback vom #{I18n.l(@semester_feedback.created_at.to_date)}: "
assert @journal.body.include? @semester_feedback.goals
assert @journal.body.include? @semester_feedback.achievements
assert @journal.body.include? @semester_feedback.future
assert @journal.body.include? @semester_feedback.comments
end
end end
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