From: Jean-Philippe Lang Date: Thu, 19 Jul 2012 18:13:08 +0000 (+0000) Subject: Removes RJS from WikisController. X-Git-Tag: 2.1.0~269 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dee586e9eb9674ebb969243be8c4f31024a8aece;p=redmine.git Removes RJS from WikisController. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10051 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb index a6f051587..5f40bb934 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -24,7 +24,6 @@ class WikisController < ApplicationController @wiki = @project.wiki || Wiki.new(:project => @project) @wiki.safe_attributes = params[:wiki] @wiki.save if request.post? - render(:update) {|page| page.replace_html "tab-content-wiki", :partial => 'projects/settings/wiki'} end # Delete a project's wiki diff --git a/app/views/wikis/edit.js.erb b/app/views/wikis/edit.js.erb new file mode 100644 index 000000000..3d2d5b385 --- /dev/null +++ b/app/views/wikis/edit.js.erb @@ -0,0 +1 @@ +Element.update('tab-content-wiki', '<%= escape_javascript(render :partial => 'projects/settings/wiki') %>'); diff --git a/test/functional/wikis_controller_test.rb b/test/functional/wikis_controller_test.rb index 9566c18d9..fefaea1dc 100644 --- a/test/functional/wikis_controller_test.rb +++ b/test/functional/wikis_controller_test.rb @@ -34,13 +34,47 @@ class WikisControllerTest < ActionController::TestCase def test_create @request.session[:user_id] = 1 assert_nil Project.find(3).wiki - post :edit, :id => 3, :wiki => { :start_page => 'Start page' } - assert_response :success + + assert_difference 'Wiki.count' do + xhr :post, :edit, :id => 3, :wiki => { :start_page => 'Start page' } + assert_response :success + assert_template 'edit' + assert_equal 'text/javascript', response.content_type + end + wiki = Project.find(3).wiki assert_not_nil wiki assert_equal 'Start page', wiki.start_page end + def test_create_with_failure + @request.session[:user_id] = 1 + + assert_no_difference 'Wiki.count' do + xhr :post, :edit, :id => 3, :wiki => { :start_page => '' } + assert_response :success + assert_template 'edit' + assert_equal 'text/javascript', response.content_type + end + + assert_include 'errorExplanation', response.body + assert_include 'Start page can\\\'t be blank', response.body + end + + def test_update + @request.session[:user_id] = 1 + + assert_no_difference 'Wiki.count' do + xhr :post, :edit, :id => 1, :wiki => { :start_page => 'Other start page' } + assert_response :success + assert_template 'edit' + assert_equal 'text/javascript', response.content_type + end + + wiki = Project.find(1).wiki + assert_equal 'Other start page', wiki.start_page + end + def test_destroy @request.session[:user_id] = 1 post :destroy, :id => 1, :confirm => 1