mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Link to last uploaded Terms of service
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
module TermsAndConditionsHelper
|
||||
def link_to_platform_terms
|
||||
link_to(t("terms_of_service"), Spree::Config.footer_tos_url, target: "_blank")
|
||||
link_to(t("terms_of_service"), TermsOfServiceFile.current_url, target: "_blank")
|
||||
end
|
||||
|
||||
def render_terms_and_conditions
|
||||
|
||||
@@ -9,4 +9,8 @@ class TermsOfServiceFile < ApplicationRecord
|
||||
def self.current
|
||||
order(:id).last
|
||||
end
|
||||
|
||||
def self.current_url
|
||||
current&.attachment&.url || Spree::Config.footer_tos_url
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,4 +19,18 @@ describe TermsOfServiceFile do
|
||||
expect(TermsOfServiceFile.current).to eq existing.last
|
||||
end
|
||||
end
|
||||
|
||||
describe ".current_url" do
|
||||
let(:subject) { TermsOfServiceFile.current_url }
|
||||
|
||||
it "points to the old default" do
|
||||
expect(subject).to eq "/Terms-of-service.pdf"
|
||||
end
|
||||
|
||||
it "points to the last uploaded file with timestamp parameter" do
|
||||
file = TermsOfServiceFile.create!(attachment: pdf)
|
||||
|
||||
expect(subject).to match /^\/system\/terms_of_service_files\/attachments.*Terms-of-service\.pdf\?\d+$/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user