Skip to content

Commit a138aaa

Browse files
authored
Merge pull request #3866 from AlchemyCMS/fix-publishable-uses-preview-time
fix(TimestampResolver): Use Time.current in publishable?
2 parents 8178546 + 3e440df commit a138aaa

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

app/models/alchemy/publishable/timestamp_resolver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def scheduled?(at: Current.preview_time)
5252
# A record is publishable if a +public_on+ timestamp is set and not
5353
# expired yet.
5454
def publishable?
55-
!publishable.public_on.nil? && still_public_for?
55+
!publishable.public_on.nil? && still_public_for?(at: Time.current)
5656
end
5757

5858
private

spec/models/alchemy/publishable/timestamp_resolver_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,15 @@
159159

160160
it { expect(resolver.publishable?).to be(false) }
161161
end
162+
163+
context "when Current.preview_time is set to a future time" do
164+
let(:public_on) { Time.current - 1.day }
165+
let(:public_until) { Time.current + 1.day }
166+
167+
it "uses Time.current instead of the preview_time" do
168+
Alchemy::Current.preview_time = Time.current + 1.week
169+
expect(resolver.publishable?).to be(true)
170+
end
171+
end
162172
end
163173
end

0 commit comments

Comments
 (0)