Skip to content

Commit d4a0ecc

Browse files
committed
fix publishing wiki page after renaming on modules page
test plan: - have a module with an unpublished wiki page - from the modules page, rename the wiki page via the gear menu and "edit" item - without reloading the page, click the cloud icon to publish the wiki page - go to the Pages tab and ensure only the new name appears (publishing the page didn't create a new published page with the old name, leaving the renamed page unpublished) fixes CNVS-18693 Change-Id: I1a1995f81dfe1d02cebc558bbaee716e930c8354 Reviewed-on: https://gerrit.instructure.com/49593 Tested-by: Jenkins QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com> Reviewed-by: James Williams <jamesw@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
1 parent d50fffb commit d4a0ecc

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

app/helpers/context_modules_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def module_item_publishable_id(item)
4141
if item.nil?
4242
''
4343
elsif (item.content_type_class == 'wiki_page')
44-
item.content.url
44+
"page_id:#{item.content.id}"
4545
else
4646
(item.content && item.content.respond_to?(:published?) ? item.content.id : item.id)
4747
end

app/models/wiki.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ def build_wiki_page(user, opts={})
189189
end
190190

191191
def find_page(param)
192+
if (match = param.match(/\Apage_id:(\d+)\z/))
193+
return self.wiki_pages.where(id: match[1].to_i).first
194+
end
192195
self.wiki_pages.not_deleted.where(url: param.to_s).first ||
193196
self.wiki_pages.not_deleted.where(url: param.to_url).first ||
194197
self.wiki_pages.not_deleted.where(id: param.to_i).first

spec/selenium/context_modules_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,30 @@ def test_relock
380380
@assignment.context_module_tags.each { |tag| expect(tag.title).to eq 'again' }
381381
end
382382

383+
it "should not create a duplicate page if you publish after renaming" do
384+
mod = @course.context_modules.create! name: 'TestModule'
385+
page = @course.wiki.wiki_pages.create title: 'A Page'
386+
page.workflow_state = 'unpublished'
387+
page.save!
388+
page_count = @course.wiki.wiki_pages.count
389+
tag = mod.add_item({:id => page.id, :type => 'wiki_page'})
390+
391+
get "/courses/#{@course.id}/modules"
392+
wait_for_modules_ui
393+
394+
item = f("#context_module_item_#{tag.id}")
395+
edit_module_item(item) do |edit_form|
396+
replace_content(edit_form.find_element(:id, 'content_tag_title'), 'Renamed!')
397+
end
398+
399+
item = f("#context_module_item_#{tag.id}")
400+
item.find_element(:css, '.publish-icon').click
401+
wait_for_ajax_requests
402+
403+
expect(@course.wiki.wiki_pages.count).to eq page_count
404+
expect(page.reload).to be_published
405+
end
406+
383407
it "should add the 'with-completion-requirements' class to rows that have requirements" do
384408
mod = @course.context_modules.create! name: 'TestModule'
385409
tag = mod.add_item({:id => @assignment.id, :type => 'assignment'})

0 commit comments

Comments
 (0)