Don't show the banner if enterprises are not required to accepte ToS

This commit is contained in:
Gaetan Craig-Riou
2023-11-17 13:56:32 +11:00
committed by Konrad
parent 6226067846
commit 8371eada23
2 changed files with 17 additions and 0 deletions

View File

@@ -117,6 +117,8 @@ module Spree
return unless spree_user_signed_in?
return if Spree::Config.enterprises_require_tos == false
return if accepted_tos?
@terms_of_service_banner = true

View File

@@ -25,6 +25,8 @@ describe "/admin", type: :request do
# The banner will show on all admin page, we are just testing it here
describe "terms of service updated banner" do
context "when terms of service has been updated" do
before { Spree::Config.enterprises_require_tos = true }
it "shows accept new ToS banner" do
enterprise_user.update(terms_of_service_accepted_at: nil)
@@ -53,6 +55,19 @@ describe "/admin", type: :request do
expect(response.body).to 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
enterprise_user.update(terms_of_service_accepted_at: nil)
end
it "doesn't show accept new ToS banner" do
get "/admin"
expect(response.body).to_not include("Terms of Service have been updated")
end
end
end
end
end