Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix page re-publishing for page with nested elements #2043

Merged
Merged
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/page/publisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(page)
def publish!(public_on:)
Page.transaction do
version = public_version(public_on)
version.elements.destroy_all
version.elements.not_nested.destroy_all

# We must not use .find_each here to not mess up the order of elements
page.draft_version.elements.not_nested.available.each do |element|
Expand Down
4 changes: 4 additions & 0 deletions spec/models/alchemy/page/publisher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
create(:alchemy_page_version, :with_elements, element_count: 3, public_on: Date.yesterday.to_time, page: page)
end

let!(:nested_element) do
create(:alchemy_element, page_version: public_version, parent_element: public_version.elements.first)
end

it "does not change current public versions public on date" do
expect { publish }.to_not change(page.public_version, :public_on)
end
Expand Down