mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-07 07:36:58 +00:00
Replace Paperclip on TermsOfServeFile
This commit is contained in:
@@ -4,6 +4,7 @@ require 'spec_helper'
|
||||
|
||||
describe TermsOfServiceFile do
|
||||
let(:pdf) { File.open(Rails.root.join("public/Terms-of-service.pdf")) }
|
||||
let(:upload) { Rack::Test::UploadedFile.new(pdf, "application/pdf") }
|
||||
|
||||
describe ".current" do
|
||||
it "returns nil" do
|
||||
@@ -12,8 +13,8 @@ describe TermsOfServiceFile do
|
||||
|
||||
it "returns the last one" do
|
||||
existing = [
|
||||
TermsOfServiceFile.create!(attachment: pdf),
|
||||
TermsOfServiceFile.create!(attachment: pdf),
|
||||
TermsOfServiceFile.create!(attachment: upload),
|
||||
TermsOfServiceFile.create!(attachment: upload),
|
||||
]
|
||||
|
||||
expect(TermsOfServiceFile.current).to eq existing.last
|
||||
@@ -27,10 +28,10 @@ describe TermsOfServiceFile 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)
|
||||
it "points to a stored file" do
|
||||
file = TermsOfServiceFile.create!(attachment: upload)
|
||||
|
||||
expect(subject).to match %r{^/system/terms_of_service_files/attachments.*Terms-of-service\.pdf\?\d+$}
|
||||
expect(subject).to match /active_storage.*Terms-of-service\.pdf$/
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,7 +46,8 @@ describe TermsOfServiceFile do
|
||||
|
||||
it "returns the time when the terms were last updated" do
|
||||
update_time = 1.day.ago
|
||||
file = TermsOfServiceFile.create!(attachment: pdf, updated_at: update_time)
|
||||
file = TermsOfServiceFile.create!(attachment: upload)
|
||||
file.update(updated_at: update_time)
|
||||
|
||||
# The database isn't as precise as Ruby's time and rounds.
|
||||
expect(subject).to be_within(0.001).of(update_time)
|
||||
|
||||
Reference in New Issue
Block a user