Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ def destroy

def order
chapter = Chapter.all_for_revision(@entry.draft).find(params[:chapter_id])
storyline = chapter.storyline

params.require(:ids).each_with_index do |id, index|
storyline.sections.find(id).update(chapter_id: chapter.id,
position: index)
Section.all_for_revision(@entry.draft).find(id).update(chapter_id: chapter.id,
position: index)
end

head :no_content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,27 @@ module PageflowScrolled
expect(section.reload.chapter).to eq(other_chapter)
end

it 'allows moving a section from a different storyline' do
entry = create(:entry, type_name: 'scrolled')
revision = entry.draft
storyline = create(:scrolled_storyline, revision:)
chapter = create(:scrolled_chapter, storyline:)
other_storyline = create(:scrolled_storyline, revision:)
other_chapter = create(:scrolled_chapter, storyline: other_storyline)
section = create(:section, chapter: other_chapter)

authorize_for_editor_controller(entry)
put(:order,
params: {
entry_type: 'scrolled',
entry_id: entry,
chapter_id: chapter,
ids: [section.id]
}, format: 'json')

expect(section.reload.chapter).to eq(chapter)
end

it 'does not allow moving a section to a chapter of another entry' do
entry = create(:entry, type_name: 'scrolled')
chapter = create(:scrolled_chapter, revision: entry.draft)
Expand Down
Loading