File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
app/controllers/pageflow_scrolled/editor
spec/controllers/pageflow_scrolled/editor Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments