Skip to content

Commit e011c19

Browse files
authored
Merge pull request #3675 from AlchemyCMS/set-public-until-on-public-false
Set `public_until` instead of clearing `public_on` when unpublishing elements
2 parents 70de0e6 + 73a290c commit e011c19

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app/models/alchemy/element.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,10 @@ def store_page(page)
234234
def public=(value)
235235
@public_on_explicitely_set = true
236236
if ActiveModel::Type::Boolean.new.cast(value)
237-
self.public_on ||= Time.current
237+
self.public_on = Time.current
238+
self.public_until = nil
238239
else
239-
self.public_on = nil
240+
self.public_until = Time.current
240241
end
241242
end
242243

spec/models/alchemy/page/publisher_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
shared_context "with elements" do
2929
let(:page) do
3030
create(:alchemy_page, autogenerate_elements: true).tap do |page|
31-
page.draft_version.elements.first.update!(public: false)
31+
page.draft_version.elements.first.update!(public_until: 1.minute.ago)
3232
end
3333
end
3434
end

0 commit comments

Comments
 (0)