Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/alchemy/publishable/timestamp_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions spec/models/alchemy/publishable/timestamp_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading