diff --git a/app/models/alchemy/publishable/timestamp_resolver.rb b/app/models/alchemy/publishable/timestamp_resolver.rb index 4568e33394..69120a7d30 100644 --- a/app/models/alchemy/publishable/timestamp_resolver.rb +++ b/app/models/alchemy/publishable/timestamp_resolver.rb @@ -52,7 +52,7 @@ def scheduled?(at: Current.preview_time) # A record is publishable if a +public_on+ timestamp is set and not # expired yet. def publishable? - !publishable.public_on.nil? && still_public_for? + !publishable.public_on.nil? && still_public_for?(at: Time.current) end private diff --git a/spec/models/alchemy/publishable/timestamp_resolver_spec.rb b/spec/models/alchemy/publishable/timestamp_resolver_spec.rb index b308232a92..b9acf580e7 100644 --- a/spec/models/alchemy/publishable/timestamp_resolver_spec.rb +++ b/spec/models/alchemy/publishable/timestamp_resolver_spec.rb @@ -159,5 +159,15 @@ it { expect(resolver.publishable?).to be(false) } end + + context "when Current.preview_time is set to a future time" do + let(:public_on) { Time.current - 1.day } + let(:public_until) { Time.current + 1.day } + + it "uses Time.current instead of the preview_time" do + Alchemy::Current.preview_time = Time.current + 1.week + expect(resolver.publishable?).to be(true) + end + end end end