Skip to content

Commit 59799de

Browse files
authored
Merge pull request #2349 from tf/move-to-excursion
Allow moving sections between storylines
2 parents fe0fd79 + 79178e7 commit 59799de

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

entry_types/scrolled/app/controllers/pageflow_scrolled/editor/sections_controller.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ def destroy
4141

4242
def order
4343
chapter = Chapter.all_for_revision(@entry.draft).find(params[:chapter_id])
44-
storyline = chapter.storyline
4544

4645
params.require(:ids).each_with_index do |id, index|
47-
storyline.sections.find(id).update(chapter_id: chapter.id,
48-
position: index)
46+
Section.all_for_revision(@entry.draft).find(id).update(chapter_id: chapter.id,
47+
position: index)
4948
end
5049

5150
head :no_content

entry_types/scrolled/spec/controllers/pageflow_scrolled/editor/sections_controller_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,27 @@ module PageflowScrolled
271271
expect(section.reload.chapter).to eq(other_chapter)
272272
end
273273

274+
it 'allows moving a section from a different storyline' do
275+
entry = create(:entry, type_name: 'scrolled')
276+
revision = entry.draft
277+
storyline = create(:scrolled_storyline, revision:)
278+
chapter = create(:scrolled_chapter, storyline:)
279+
other_storyline = create(:scrolled_storyline, revision:)
280+
other_chapter = create(:scrolled_chapter, storyline: other_storyline)
281+
section = create(:section, chapter: other_chapter)
282+
283+
authorize_for_editor_controller(entry)
284+
put(:order,
285+
params: {
286+
entry_type: 'scrolled',
287+
entry_id: entry,
288+
chapter_id: chapter,
289+
ids: [section.id]
290+
}, format: 'json')
291+
292+
expect(section.reload.chapter).to eq(chapter)
293+
end
294+
274295
it 'does not allow moving a section to a chapter of another entry' do
275296
entry = create(:entry, type_name: 'scrolled')
276297
chapter = create(:scrolled_chapter, revision: entry.draft)

0 commit comments

Comments
 (0)