redirect to wiki context on wiki revision rollback
fixes #9693 the redirect that occurerd after rolling a wiki page back to a previous versioin assumed that it was a course wiki, so group wiki page rollbacks worked correctly but redirected to the wrong place. test plan: - make a group wiki page, edit and save a few times - roll back to a previous version - you should be redirected back to the right wiki page Change-Id: Ic7ad6cc3802f39577fad0a08fcfbe78ee6941980 Reviewed-on: https://gerrit.instructure.com/12752 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
c0f35383ba
commit
41bd8214a0
app/controllers
spec/controllers
|
@ -74,9 +74,10 @@ class WikiPageRevisionsController < ApplicationController
|
|||
def update
|
||||
if authorized_action(@page, @current_user, :update)
|
||||
@revision = @page.versions.find(params[:id])
|
||||
@page.revert_to_version @revision
|
||||
except_fields = [:id] + WikiPage.new.attributes.keys - WikiPage.accessible_attributes.to_a
|
||||
@page.revert_to_version @revision, :except => except_fields
|
||||
flash[:notice] = t('notices.page_rolled_back', 'Page was successfully rolled-back to previous version.')
|
||||
redirect_to course_wiki_page_url( @context.id, @page)
|
||||
redirect_to polymorphic_url([@context, @page])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
#
|
||||
# Copyright (C) 2011 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
||||
|
||||
describe WikiPageRevisionsController do
|
||||
describe "PUT 'update'" do
|
||||
it "should redirect to the right course wiki page" do
|
||||
course_with_teacher_logged_in(:active_all => true)
|
||||
@page = @course.wiki.wiki_pages.create!(:title => "a page")
|
||||
@page.title = "a better page title"
|
||||
@page.save!
|
||||
|
||||
@version = @page.reload.versions.first
|
||||
put 'update', :course_id => @course.id, :wiki_page_id => @page.id, :id => @version.id
|
||||
response.should be_redirect
|
||||
response.location.should match(%r{/courses/#{@course.id}/wiki})
|
||||
end
|
||||
|
||||
it "should redirect to the right group wiki page" do
|
||||
course_with_teacher_logged_in(:active_all => true)
|
||||
gcs = @course.group_categories.create!
|
||||
@group = gcs.groups.create(:context => @course)
|
||||
@page = @group.wiki.wiki_pages.create!(:title => "a page")
|
||||
@page.title = "a better page title"
|
||||
@page.save!
|
||||
|
||||
@version = @page.reload.versions.first
|
||||
put 'update', :group_id => @group.id, :wiki_page_id => @page.id, :id => @version.id
|
||||
response.should be_redirect
|
||||
response.location.should match(%r{/groups/#{@group.id}/wiki})
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue