mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
spec TOS service object
This commit is contained in:
48
spec/services/terms_of_service_spec.rb
Normal file
48
spec/services/terms_of_service_spec.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe TermsOfService do
|
||||
let(:customer) { create(:customer) }
|
||||
let(:distributor) { create(:distributor_enterprise) }
|
||||
|
||||
context "a customer has not accepted the terms of service" do
|
||||
before do
|
||||
allow(customer).to receive(:terms_and_conditions_accepted_at) { nil }
|
||||
end
|
||||
|
||||
it "returns false" do
|
||||
expect(TermsOfService.tos_accepted?(customer)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context "a customer has accepted the platform terms of service" do
|
||||
before do
|
||||
allow(customer).to receive(:terms_and_conditions_accepted_at) { Time.zone.now - 1.week }
|
||||
allow(TermsOfServiceFile).to receive(:updated_at) { Time.zone.now - 2.weeks }
|
||||
end
|
||||
|
||||
it "should reflect whether the platform TOS have been accepted since the last update" do
|
||||
expect {
|
||||
allow(TermsOfServiceFile).to receive(:updated_at) { Time.zone.now }
|
||||
}.to change {
|
||||
TermsOfService.tos_accepted?(customer)
|
||||
}.from(true).to(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "a customer has accepted the distributor terms of service" do
|
||||
before do
|
||||
allow(customer).to receive(:terms_and_conditions_accepted_at) { Time.zone.now - 1.week }
|
||||
allow(distributor).to receive(:terms_and_conditions_updated_at) { Time.zone.now - 2.weeks }
|
||||
end
|
||||
|
||||
it "should reflect whether the platform TOS have been accepted since the last update" do
|
||||
expect {
|
||||
allow(distributor).to receive(:terms_and_conditions_updated_at) { Time.zone.now }
|
||||
}.to change {
|
||||
TermsOfService.tos_accepted?(customer, distributor)
|
||||
}.from(true).to(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user