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 issue #2101 #2202

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
code style corrections
  • Loading branch information
juryghidinelli committed Oct 25, 2021
commit 11c7c468c0f9b6f0cfd47698e389d2f7eec8e09e
2 changes: 1 addition & 1 deletion app/models/alchemy/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def copy_children_to(new_parent)
new_child = Page.copy(child, {
language_id: new_parent.language_id,
language_code: new_parent.language_code,
parent_id: new_parent.id
parent_id: new_parent.id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should already be handled by move_to_child of. Also move_to_child sets the appropriate lft and rgt values the nested set needs.

})
new_child.move_to_child_of(new_parent)
child.copy_children_to(new_child) unless child.children.blank?
Expand Down
5 changes: 2 additions & 3 deletions spec/models/alchemy/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ class AnotherUrlPathClass; end
subject { source.copy_children_to(new_parent) }

it "should copy the source page with the given name to the new parent" do
child = mock_model("Page",children:[])
child = mock_model("Page", children: [])
new_child = mock_model("Page")

expect(new_child).to receive(:move_to_child_of).with(new_parent)
Expand All @@ -774,12 +774,11 @@ class AnotherUrlPathClass; end
expect(Page).to receive(:copy).with(child, {
parent_id: new_parent.id,
language_id: new_parent.language_id,
language_code: new_parent.language_code
language_code: new_parent.language_code,
}).and_return(new_child )
subject
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of testing the implementation we should test the result. For that we need to create a page with children and verify the children end up on the new parent. That way we can check if the issue is actually in the missing parent_id or not.

end


end

describe "#public_version" do
Expand Down