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>
This commit is contained in:
parent
d50fffb713
commit
d4a0ecc59b
|
@ -41,7 +41,7 @@ module ContextModulesHelper
|
|||
if item.nil?
|
||||
''
|
||||
elsif (item.content_type_class == 'wiki_page')
|
||||
item.content.url
|
||||
"page_id:#{item.content.id}"
|
||||
else
|
||||
(item.content && item.content.respond_to?(:published?) ? item.content.id : item.id)
|
||||
end
|
||||
|
|
|
@ -189,6 +189,9 @@ class Wiki < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def find_page(param)
|
||||
if (match = param.match(/\Apage_id:(\d+)\z/))
|
||||
return self.wiki_pages.where(id: match[1].to_i).first
|
||||
end
|
||||
self.wiki_pages.not_deleted.where(url: param.to_s).first ||
|
||||
self.wiki_pages.not_deleted.where(url: param.to_url).first ||
|
||||
self.wiki_pages.not_deleted.where(id: param.to_i).first
|
||||
|
|
|
@ -380,6 +380,30 @@ describe "context_modules" do
|
|||
@assignment.context_module_tags.each { |tag| expect(tag.title).to eq 'again' }
|
||||
end
|
||||
|
||||
it "should not create a duplicate page if you publish after renaming" do
|
||||
mod = @course.context_modules.create! name: 'TestModule'
|
||||
page = @course.wiki.wiki_pages.create title: 'A Page'
|
||||
page.workflow_state = 'unpublished'
|
||||
page.save!
|
||||
page_count = @course.wiki.wiki_pages.count
|
||||
tag = mod.add_item({:id => page.id, :type => 'wiki_page'})
|
||||
|
||||
get "/courses/#{@course.id}/modules"
|
||||
wait_for_modules_ui
|
||||
|
||||
item = f("#context_module_item_#{tag.id}")
|
||||
edit_module_item(item) do |edit_form|
|
||||
replace_content(edit_form.find_element(:id, 'content_tag_title'), 'Renamed!')
|
||||
end
|
||||
|
||||
item = f("#context_module_item_#{tag.id}")
|
||||
item.find_element(:css, '.publish-icon').click
|
||||
wait_for_ajax_requests
|
||||
|
||||
expect(@course.wiki.wiki_pages.count).to eq page_count
|
||||
expect(page.reload).to be_published
|
||||
end
|
||||
|
||||
it "should add the 'with-completion-requirements' class to rows that have requirements" do
|
||||
mod = @course.context_modules.create! name: 'TestModule'
|
||||
tag = mod.add_item({:id => @assignment.id, :type => 'assignment'})
|
||||
|
|
Loading…
Reference in New Issue