mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Don't show the banner if no ToS file uploaded
This commit is contained in:
committed by
Konrad
parent
17fa6b6168
commit
9609ba4268
@@ -7,6 +7,8 @@ module Admin
|
||||
|
||||
return false if Spree::Config.enterprises_require_tos == false
|
||||
|
||||
return false if TermsOfServiceFile.current.nil?
|
||||
|
||||
!accepted_tos?
|
||||
end
|
||||
|
||||
|
||||
@@ -13,7 +13,11 @@ describe "/admin", type: :request do
|
||||
|
||||
describe "GET /admin" do
|
||||
before do
|
||||
allow(TermsOfServiceFile).to receive(:updated_at).and_return(2.hours.ago)
|
||||
mocked_tos = double(TermsOfServiceFile, updated_at: 2.hours.ago)
|
||||
allow(TermsOfServiceFile).to receive(:current).and_return(mocked_tos)
|
||||
# Mock current_url so we don't have to set up a complicated TermsOfServiceFile mock
|
||||
# with attachement
|
||||
allow(TermsOfServiceFile).to receive(:current_url).and_return("tmp/tos.pdf")
|
||||
end
|
||||
|
||||
it "loads the dashboard page" do
|
||||
@@ -56,6 +60,16 @@ describe "/admin", type: :request do
|
||||
end
|
||||
end
|
||||
|
||||
context "when no ToS has been uploaded" do
|
||||
it "doesn't show accept new ToS banner" do
|
||||
allow(TermsOfServiceFile).to receive(:current).and_return(nil)
|
||||
|
||||
get "/admin"
|
||||
|
||||
expect(response.body).to_not include("Terms of Service have been updated")
|
||||
end
|
||||
end
|
||||
|
||||
context "when enterprises don't need to accept ToS" do
|
||||
before do
|
||||
Spree::Config.enterprises_require_tos = false
|
||||
|
||||
Reference in New Issue
Block a user