Verified Commit e74855ca authored by Markus Koller's avatar Markus Koller 🦊

Display fixed date in group assignment PDF as well

parent 6c959880
Pipeline #20103 passed with stage
in 36 minutes and 37 seconds
......@@ -48,6 +48,10 @@ body {
height: $line-height-computed;
margin-bottom: 10px;
padding: 0 2px 0 2px;
&.no-border {
border: none;
}
}
.row-box,
......
......@@ -47,7 +47,10 @@ class AssignmentsController < ApplicationController
def show
respond_to do |format|
format.html
format.html do
@pdf_created_at = @assignment.pdf_updated_at || Time.zone.now
end
format.pdf do
render_pdf_attachment @assignment
end
......
- pdf_created_at = request.format.pdf? ? @assignment.pdf_updated_at : Time.zone.now
- @pdf_created_at ||= Time.zone.now
h3.m-b-10= t('assignment_pdf.title')
h4.m-b-10= t('assignment_pdf.volunteer_title')
......@@ -113,7 +113,7 @@ h4.m-b-10.m-t-20= t('assignment_pdf.creator_title')
.row-bottom
.col-xs-12
span= t('assignment_pdf.city_date')
'#{t('assignment_pdf.zurich')}, #{l pdf_created_at.to_date}
'#{t('assignment_pdf.zurich')}, #{l @pdf_created_at.to_date}
.signature-title-row
.col-xs-4
......
......@@ -85,7 +85,10 @@ h4.m-b-10= t('assignment_pdf.responsible_title')
.col-xs-6
.row
.col-xs-5= t('assignment_pdf.city_date')
.col-xs-7.col-input
.col-xs-7.col-input.no-border
= t 'assignment_pdf.zurich'
= ', '
= l Time.zone.today
.row
.col-xs-5= t('assignment_pdf.for_aoz')
.col-xs-7.col-input
......
......@@ -139,7 +139,7 @@ class AssignmentsTest < ApplicationSystemTestCase
pdf = load_pdf(page.body)
assert_equal 1, pdf.page_count
assert_match(/Ort, Datum: +Zürich, #{I18n.l(pdf_date.to_date)}/, pdf.pages.first.text)
assert_match(/Ort, Datum: +Zürich, #{I18n.l pdf_date.to_date}/, pdf.pages.first.text)
assert_match(/Wie oft\? +daily/, pdf.pages.first.text)
# changing a field doesn't automatically update the PDF
......@@ -169,7 +169,7 @@ class AssignmentsTest < ApplicationSystemTestCase
click_on 'Herunterladen', match: :first
pdf = load_pdf(page.body)
assert_match(/Ort, Datum: +Zürich, #{I18n.l(pdf_date.to_date)}/, pdf.pages.first.text)
assert_match(/Ort, Datum: +Zürich, #{I18n.l pdf_date.to_date}/, pdf.pages.first.text)
assert_match(/Wie oft\? +weekly/, pdf.pages.first.text)
# make sure the download link is displayed on the index as well
......@@ -177,5 +177,11 @@ class AssignmentsTest < ApplicationSystemTestCase
visit assignments_path
assert_link 'Herunterladen', count: 1
# make sure the HTML view also displays the PDF creation date
click_on 'Anzeigen'
assert_text "Ort, Datum:Zürich, #{I18n.l pdf_date.to_date}"
end
end
......@@ -279,6 +279,9 @@ class GroupOffersTest < ApplicationSystemTestCase
test 'creates/updates group assignment PDF when requested' do
use_rack_driver
pdf_date = 1.week.ago
travel_to pdf_date
group_offer = create :group_offer
group_assignment = create :group_assignment, group_offer: group_offer
login_as create(:user)
......@@ -302,6 +305,7 @@ class GroupOffersTest < ApplicationSystemTestCase
pdf = load_pdf(page.body)
assert_equal 1, pdf.page_count
assert_match(/Ort, Datum: +Zürich, #{I18n.l pdf_date.to_date}/, pdf.pages.first.text)
assert_match(/Wie oft\? +daily/, pdf.pages.first.text)
# changing a field doesn't automatically update the PDF
......@@ -323,6 +327,9 @@ class GroupOffersTest < ApplicationSystemTestCase
# request to update the PDF
pdf_date = 3.days.from_now
travel_to pdf_date
visit edit_group_assignment_path(group_assignment)
check 'Vereinbarung überschreiben'
click_on 'Begleitung aktualisieren', match: :first
......@@ -333,6 +340,7 @@ class GroupOffersTest < ApplicationSystemTestCase
click_on 'Herunterladen', match: :first
pdf = load_pdf(page.body)
assert_match(/Ort, Datum: +Zürich, #{I18n.l pdf_date.to_date}/, pdf.pages.first.text)
assert_match(/Wie oft\? +weekly/, pdf.pages.first.text)
# make sure the download link is displayed on the group offer as well
......
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