From 981b0c92928691b9bc818ff3851f3344c1f3924b Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Tue, 4 Feb 2014 13:50:12 -0300 Subject: [PATCH] rails3: fix cms_controller tests --- app/controllers/my_profile/cms_controller.rb | 5 ++--- app/controllers/public/content_viewer_controller.rb | 2 +- config/application.rb | 2 ++ test/functional/cms_controller_test.rb | 14 +++++--------- test/functional/content_viewer_controller_test.rb | 90 +++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------- vendor/plugins/xss_terminate/lib/xss_terminate.rb | 3 ++- 6 files changed, 57 insertions(+), 59 deletions(-) diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index d747c5b..f0beb16 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -45,8 +45,7 @@ class CmsController < MyProfileController conditions = ['type != ?', 'RssFeed'] end - @articles = @article.children.paginate( - :order => "case when type = 'Folder' then 0 when type ='Blog' then 1 else 2 end, updated_at DESC", + @articles = @article.children.reorder("case when type = 'Folder' then 0 when type ='Blog' then 1 else 2 end, updated_at DESC, name").paginate( :conditions => conditions, :per_page => per_page, :page => params[:npage] @@ -188,7 +187,7 @@ class CmsController < MyProfileController if request.post? @article.destroy session[:notice] = _("\"#{@article.name}\" was removed.") - referer = ActionController::Routing::Routes.recognize_path URI.parse(request.referer).path rescue nil + referer = Rails.application.routes.recognize_path URI.parse(request.referer).path rescue nil if referer and referer[:controller] == 'cms' redirect_to referer elsif @article.parent diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index ebd33c9..031c09d 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -88,7 +88,7 @@ class ContentViewerController < ApplicationController blog_with_translation = @page.blog? && @page.display_posts_in_current_language? posts = posts.native_translations if blog_with_translation - @posts = posts.paginate({ :page => params[:npage], :per_page => @page.posts_per_page }.merge(Article.display_filter(user, profile))) + @posts = posts.paginate({ :page => params[:npage], :per_page => @page.posts_per_page }.merge(Article.display_filter(user, profile))).to_a if blog_with_translation @posts.replace @posts.map{ |p| p.get_translation_to(FastGettext.locale) }.compact diff --git a/config/application.rb b/config/application.rb index f4f2556..0da906e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -25,6 +25,8 @@ module Noosfero # Adds custom tags to the Set of allowed html tags for the #sanitize helper config.action_view.sanitized_allowed_tags = 'object', 'embed', 'param', 'table', 'tr', 'th', 'td', 'applet', 'comment', 'iframe', 'audio', 'video', 'source' + config.action_controller.include_all_helpers = false + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index f826ced..cc7e247 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -12,10 +12,6 @@ class CmsControllerTest < ActionController::TestCase def setup super - @controller = CmsController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @profile = create_user_with_permission('testinguser', 'post_content') login_as :testinguser end @@ -137,7 +133,7 @@ class CmsControllerTest < ActionController::TestCase a.save! profile.description = 'a' * 600 - profile.save(false) + profile.save(:validate => false) assert !profile.valid? assert_not_equal a, profile.home_page @@ -403,7 +399,7 @@ class CmsControllerTest < ActionController::TestCase get :view, :profile => profile.identifier, :id => article.id assert_response :success assert_template 'view' - assert_tag :tag => 'a', :attributes => { :title => 'New content', :href => "/myprofile/#{profile.identifier}/cms/new?cms=true&parent_id=#{article.id}"} + assert_tag :tag => 'a', :attributes => { :title => 'New content', :href => "/myprofile/#{profile.identifier}/cms/new?cms=true&parent_id=#{article.id}"} end should 'offer to create children' do @@ -414,7 +410,7 @@ class CmsControllerTest < ActionController::TestCase article.save! get :new, :profile => profile.identifier, :parent_id => article.id, :cms => true - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}&type=TextileArticle"} + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}&type=TextileArticle"} end should 'not offer to create children if article does not accept them' do @@ -559,7 +555,7 @@ class CmsControllerTest < ActionController::TestCase f = Folder.new(:name => 'f'); profile.articles << f; f.save! get :new, :profile => profile.identifier, :parent_id => f.id, :cms => true - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{f.id}&type=Folder" } + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{f.id}&type=Folder" } end should 'redirect to article after creating top-level article' do @@ -1512,7 +1508,7 @@ class CmsControllerTest < ActionController::TestCase should 'update file and be redirect to cms' do file = UploadedFile.create!(:profile => @profile, :uploaded_data => fixture_file_upload('files/test.txt', 'text/plain')) post :edit, :profile => @profile.identifier, :id => file.id, :article => { } - assert_redirected_to :controller => 'cms', :profile => profile.identifier, :action => 'index' + assert_redirected_to :controller => 'cms', :profile => profile.identifier, :action => 'index', :id => nil end should 'update file and be redirect to cms folder' do diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 8aa518f..7c9f23c 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -330,20 +330,20 @@ class ContentViewerControllerTest < ActionController::TestCase should 'redirect to new article path under an old path' do p = create_user('test_user').person a = p.articles.create(:name => 'old-name') - old_path = a.explode_path + old_path = a.path a.name = 'new-name' a.save! get :view_page, :profile => p.identifier, :page => old_path assert_response :redirect - assert_redirected_to :host => p.default_hostname, :controller => 'content_viewer', :action => 'view_page', :profile => p.identifier, :page => a.explode_path + assert_redirected_to :host => p.default_hostname, :controller => 'content_viewer', :action => 'view_page', :profile => p.identifier, :page => a.path end should 'load new article name equal of another article old name' do p = create_user('test_user').person a1 = p.articles.create!(:name => 'old-name') - old_path = a1.explode_path + old_path = a1.path a1.name = 'new-name' a1.save! a2 = p.articles.create!(:name => 'old-name') @@ -356,7 +356,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'redirect to article with most recent version with the name if there is no article with the name' do p = create_user('test_user').person a1 = p.articles.create!(:name => 'old-name') - old_path = a1.explode_path + old_path = a1.path a1.name = 'new-name' a1.save! a2 = p.articles.create!(:name => 'old-name') @@ -366,13 +366,13 @@ class ContentViewerControllerTest < ActionController::TestCase get :view_page, :profile => p.identifier, :page => old_path assert_response :redirect - assert_redirected_to :host => p.default_hostname, :controller => 'content_viewer', :action => 'view_page', :profile => p.identifier, :page => a2.explode_path + assert_redirected_to :host => p.default_hostname, :controller => 'content_viewer', :action => 'view_page', :profile => p.identifier, :page => a2.path end should 'not return an article of a different user' do p1 = create_user('test_user').person a = p1.articles.create!(:name => 'old-name') - old_path = a.explode_path + old_path = a.path a.name = 'new-name' a.save! @@ -514,7 +514,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'not display delete button for homepage' do login_as(profile.identifier) page = profile.home_page - xhr :get, :view_page, :profile => profile.identifier, :page => page.explode_path, :toolbar => true + xhr :get, :view_page, :profile => profile.identifier, :page => page.path, :toolbar => true assert_no_tag :tag => 'a', :content => 'Delete', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/destroy/#{page.id}" } end @@ -542,7 +542,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'render html for image when view' do file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile) - get :view_page, :profile => profile.identifier, :page => file.explode_path, :view => true + get :view_page, :profile => profile.identifier, :page => file.path, :view => true assert_response :success assert_template 'view_page' @@ -550,7 +550,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'download data for image when not view' do file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile) - get :view_page, :profile => profile.identifier, :page => file.explode_path + get :view_page, :profile => profile.identifier, :page => file.path assert_response :success assert_template nil @@ -559,7 +559,7 @@ class ContentViewerControllerTest < ActionController::TestCase should "display 'Upload files' when create children of image gallery" do login_as(profile.identifier) f = Gallery.create!(:name => 'gallery', :profile => profile) - xhr :get, :view_page, :profile => profile.identifier, :page => f.explode_path, :toolbar => true + xhr :get, :view_page, :profile => profile.identifier, :page => f.path, :toolbar => true assert_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{f.id}/} end @@ -568,7 +568,7 @@ class ContentViewerControllerTest < ActionController::TestCase folder1 = Gallery.create!(:name => 'gallery1', :profile => profile) folder1.children << folder2 = Folder.new(:name => 'gallery2', :profile => profile) - xhr :get, :view_page, :profile => profile.identifier, :page => folder2.explode_path, :toolbar => true + xhr :get, :view_page, :profile => profile.identifier, :page => folder2.path, :toolbar => true assert_tag :tag => 'a', :content => 'New article', :attributes => {:href =>/parent_id=#{folder2.id}/} end @@ -576,14 +576,14 @@ class ContentViewerControllerTest < ActionController::TestCase login_as(profile.identifier) folder = Gallery.create!(:name => 'gallery', :profile => profile) file = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) - xhr :get, :view_page, :profile => profile.identifier, :page => file.explode_path, :view => true, :toolbar => true + xhr :get, :view_page, :profile => profile.identifier, :page => file.path, :view => true, :toolbar => true assert_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{folder.id}/} end should 'render slideshow template' do f = Folder.create!(:name => 'gallery', :profile => profile) - get :view_page, :profile => profile.identifier, :page => f.explode_path, :slideshow => true + get :view_page, :profile => profile.identifier, :page => f.path, :slideshow => true assert_template 'slideshow' end @@ -595,7 +595,7 @@ class ContentViewerControllerTest < ActionController::TestCase image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) image2 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) - get :view_page, :profile => profile.identifier, :page => folder.explode_path, :slideshow => true + get :view_page, :profile => profile.identifier, :page => folder.path, :slideshow => true assert_equal 2, assigns(:images).size end @@ -606,7 +606,7 @@ class ContentViewerControllerTest < ActionController::TestCase folder = Gallery.create!(:name => 'gallery', :profile => owner) image1 = UploadedFile.create!(:profile => owner, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg'), :published => false) login_as('unauthorized') - get :view_page, :profile => owner.identifier, :page => folder.explode_path, :slideshow => true + get :view_page, :profile => owner.identifier, :page => folder.path, :slideshow => true assert_response :success assert_equal 0, assigns(:images).length end @@ -617,7 +617,7 @@ class ContentViewerControllerTest < ActionController::TestCase folder = Gallery.create!(:name => 'gallery', :profile => owner) image1 = UploadedFile.create!(:profile => owner, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg'), :published => false) login_as('unauthorized') - get :view_page, :profile => owner.identifier, :page => folder.explode_path + get :view_page, :profile => owner.identifier, :page => folder.path assert_response :success assert_select '.image-gallery-item', 0 end @@ -629,7 +629,7 @@ class ContentViewerControllerTest < ActionController::TestCase image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) - get :view_page, :profile => profile.identifier, :page => folder.explode_path, :slideshow => true + get :view_page, :profile => profile.identifier, :page => folder.path, :slideshow => true assert_tag :tag => 'img', :attributes => {:src => /\/images\/icons-app\/image-loading-display.png/} end @@ -641,7 +641,7 @@ class ContentViewerControllerTest < ActionController::TestCase image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) process_delayed_job_queue - get :view_page, :profile => profile.identifier, :page => folder.explode_path, :slideshow => true + get :view_page, :profile => profile.identifier, :page => folder.path, :slideshow => true assert_tag :tag => 'img', :attributes => {:src => /other-pic_display.jpg/} end @@ -652,7 +652,7 @@ class ContentViewerControllerTest < ActionController::TestCase image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) - get :view_page, :profile => profile.identifier, :page => folder.explode_path + get :view_page, :profile => profile.identifier, :page => folder.path assert_tag :tag => 'a', :attributes => {:class => 'image', :style => /background-image: url\(\/images\/icons-app\/image-loading-thumb.png\)/} end @@ -664,7 +664,7 @@ class ContentViewerControllerTest < ActionController::TestCase image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) process_delayed_job_queue - get :view_page, :profile => profile.identifier, :page => folder.explode_path + get :view_page, :profile => profile.identifier, :page => folder.path assert_tag :tag => 'a', :attributes => {:class => 'image', :style => /background-image: url\(.*\/other-pic_thumb.jpg\)/} end @@ -690,7 +690,7 @@ class ContentViewerControllerTest < ActionController::TestCase should "not display 'Upload files' when viewing blog" do login_as(profile.identifier) b = Blog.create!(:name => 'article folder', :profile => profile) - xhr :get, :view_page, :profile => profile.identifier, :page => b.explode_path, :toolbar => true + xhr :get, :view_page, :profile => profile.identifier, :page => b.path, :toolbar => true assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/} end @@ -698,7 +698,7 @@ class ContentViewerControllerTest < ActionController::TestCase login_as(profile.identifier) b = Blog.create!(:name => 'article folder', :profile => profile) blog_post = TextileArticle.create!(:name => 'children-article', :profile => profile, :parent => b) - xhr :get, :view_page, :profile => profile.identifier, :page => blog_post.explode_path, :toolbar => true + xhr :get, :view_page, :profile => profile.identifier, :page => blog_post.path, :toolbar => true assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/} end @@ -707,7 +707,7 @@ class ContentViewerControllerTest < ActionController::TestCase folder = fast_create(Gallery, :profile_id => profile.id) file = UploadedFile.create!(:title => 'my img title', :profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) - get :view_page, :profile => profile.identifier, :page => folder.explode_path + get :view_page, :profile => profile.identifier, :page => folder.path assert_tag :tag => 'li', :attributes => {:title => 'my img title', :class => 'image-gallery-item'}, :child => {:tag => 'span', :content => 'my img title'} end @@ -717,7 +717,7 @@ class ContentViewerControllerTest < ActionController::TestCase folder = fast_create(Gallery, :profile_id => profile.id) file = UploadedFile.create!(:title => 'my img title', :profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) - get :view_page, :profile => profile.identifier, :page => folder.explode_path + get :view_page, :profile => profile.identifier, :page => folder.path assert_tag :tag => 'li', :attributes => {:title => 'my img title', :class => 'image-gallery-item'}, :child => {:tag => 'span', :content => 'my img title'} end @@ -728,7 +728,7 @@ class ContentViewerControllerTest < ActionController::TestCase login_as u.identifier a = create(Article, :profile => c, :name => 'test-article', :last_changed_by => u, :published => false) - get :view_page, :profile => c.identifier, :page => a.explode_path + get :view_page, :profile => c.identifier, :page => a.path assert_response :success assert_template 'view_page' @@ -740,7 +740,7 @@ class ContentViewerControllerTest < ActionController::TestCase login_as u.identifier a = create(Article, :profile => c, :name => 'test-article', :last_changed_by => profile, :published => true) - xhr :get, :view_page, :profile => c.identifier, :page => a.explode_path, :toolbar => true + xhr :get, :view_page, :profile => c.identifier, :page => a.path, :toolbar => true assert_tag :tag => 'a', :content => 'New article' end @@ -751,7 +751,7 @@ class ContentViewerControllerTest < ActionController::TestCase comment = article.comments.create(:author => to_be_removed, :title => 'Test Comment', :body => 'My author does not exist =(') to_be_removed.destroy - get :view_page, :profile => profile.identifier, :page => article.explode_path + get :view_page, :profile => profile.identifier, :page => article.path assert_tag :tag => 'span', :content => '(removed user)', :attributes => {:class => 'comment-user-status icon-user-removed'} end @@ -763,7 +763,7 @@ class ContentViewerControllerTest < ActionController::TestCase blog.posts << TinyMceArticle.create!(:name => 'first post', :parent => blog, :profile => profile, :body => '

Content to be displayed.

Anything') - get :view_page, :profile => profile.identifier, :page => blog.explode_path + get :view_page, :profile => profile.identifier, :page => blog.path assert_tag :tag => 'div', :attributes => { :class => 'short-post'}, :content => /Content to be displayed./ assert_no_tag :tag => 'div', :attributes => { :class => 'short-post'}, :content => /Anything/ @@ -772,7 +772,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'display link to edit blog for allowed' do blog = fast_create(Blog, :profile_id => profile.id, :path => 'blog') login_as(profile.identifier) - xhr :get, :view_page, :profile => profile.identifier, :page => blog.explode_path, :toolbar => true + xhr :get, :view_page, :profile => profile.identifier, :page => blog.path, :toolbar => true assert_tag :tag => 'div', :attributes => { :id => 'article-actions' }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/edit/#{blog.id}" }, :content => 'Configure blog' } end @@ -895,7 +895,7 @@ class ContentViewerControllerTest < ActionController::TestCase should "not display 'Upload files' when viewing forum" do login_as(profile.identifier) b = Forum.create!(:name => 'article folder', :profile => profile) - xhr :get, :view_page, :profile => profile.identifier, :page => b.explode_path, :toolbar => true + xhr :get, :view_page, :profile => profile.identifier, :page => b.path, :toolbar => true assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/} end @@ -903,35 +903,35 @@ class ContentViewerControllerTest < ActionController::TestCase login_as(profile.identifier) b = Forum.create!(:name => 'article folder', :profile => profile) forum_post = TextileArticle.create!(:name => 'children-article', :profile => profile, :parent => b) - xhr :get, :view_page, :profile => profile.identifier, :page => forum_post.explode_path, :toolbar => true + xhr :get, :view_page, :profile => profile.identifier, :page => forum_post.path, :toolbar => true assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/} end should 'display link to edit forum for allowed' do forum = fast_create(Forum, :profile_id => profile.id, :path => 'forum') login_as(profile.identifier) - xhr :get, :view_page, :profile => profile.identifier, :page => forum.explode_path, :toolbar => true + xhr :get, :view_page, :profile => profile.identifier, :page => forum.path, :toolbar => true assert_tag :tag => 'div', :attributes => { :id => 'article-actions' }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/edit/#{forum.id}" }, :content => 'Configure forum' } end should 'display add translation link if article is translatable' do login_as @profile.identifier textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') - xhr :get, :view_page, :profile => @profile.identifier, :page => textile.explode_path, :toolbar => true - assert_tag :a, :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?article%5Btranslation_of_id%5D=#{textile.id}&type=#{TextileArticle}" } + xhr :get, :view_page, :profile => @profile.identifier, :page => textile.path, :toolbar => true + assert_tag :a, :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?article%5Btranslation_of_id%5D=#{textile.id}&type=#{TextileArticle}" } end should 'not display add translation link if article is not translatable' do login_as @profile.identifier blog = fast_create(Blog, :profile_id => @profile.id, :path => 'blog') - xhr :get, :view_page, :profile => @profile.identifier, :page => blog.explode_path, :toolbar => true + xhr :get, :view_page, :profile => @profile.identifier, :page => blog.path, :toolbar => true assert_no_tag :a, :attributes => { :content => 'Add translation', :class => /icon-locale/ } end should 'not display add translation link if article hasnt a language defined' do login_as @profile.identifier textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile') - xhr :get, :view_page, :profile => @profile.identifier, :page => textile.explode_path, :toolbar => true + xhr :get, :view_page, :profile => @profile.identifier, :page => textile.path, :toolbar => true assert_no_tag :a, :attributes => { :content => 'Add translation', :class => /icon-locale/ } end @@ -939,7 +939,7 @@ class ContentViewerControllerTest < ActionController::TestCase login_as @profile.identifier textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') translation = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'translation', :language => 'es', :translation_of_id => textile) - xhr :get, :view_page, :profile => @profile.identifier, :page => textile.explode_path, :toolbar => true + xhr :get, :view_page, :profile => @profile.identifier, :page => textile.path, :toolbar => true assert_tag :a, :attributes => { :class => /article-translations-menu/, :onmouseover => /toggleSubmenu/ } end @@ -948,7 +948,7 @@ class ContentViewerControllerTest < ActionController::TestCase es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) @request.env['HTTP_REFERER'] = "http://localhost:3000/#{@profile.identifier}/#{es_article.path}" FastGettext.stubs(:locale).returns('es') - get :view_page, :profile => @profile.identifier, :page => es_article.explode_path + get :view_page, :profile => @profile.identifier, :page => es_article.path assert_response :success assert_equal es_article, assigns(:page) end @@ -956,7 +956,7 @@ class ContentViewerControllerTest < ActionController::TestCase should 'not be redirected if article does not have a language' do FastGettext.stubs(:locale).returns('es') article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'article') - get :view_page, :profile => @profile.identifier, :page => article.explode_path + get :view_page, :profile => @profile.identifier, :page => article.path assert_response :success assert_equal article, assigns(:page) end @@ -966,7 +966,7 @@ class ContentViewerControllerTest < ActionController::TestCase es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) @request.env['HTTP_REFERER'] = "http://localhost:3000/#{@profile.identifier}/#{es_article.path}" FastGettext.stubs(:locale).returns('es') - get :view_page, :profile => @profile.identifier, :page => en_article.explode_path + get :view_page, :profile => @profile.identifier, :page => en_article.path assert_response :success assert_equal en_article, assigns(:page) end @@ -976,7 +976,7 @@ class ContentViewerControllerTest < ActionController::TestCase es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) FastGettext.stubs(:locale).returns('es') @request.env['HTTP_REFERER'] = "http://localhost/myprofile/#{@profile.identifier}/cms/edit/#{en_article.id}" - get :view_page, :profile => @profile.identifier, :page => es_article.explode_path + get :view_page, :profile => @profile.identifier, :page => es_article.path assert_response :success assert_equal es_article, assigns(:page) end @@ -986,7 +986,7 @@ class ContentViewerControllerTest < ActionController::TestCase es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) FastGettext.stubs(:locale).returns('es') @request.env['HTTP_REFERER'] = "http://localhost/myprofile/#{@profile.identifier}/cms/new" - get :view_page, :profile => @profile.identifier, :page => es_article.explode_path + get :view_page, :profile => @profile.identifier, :page => es_article.path assert_response :success assert_equal es_article, assigns(:page) end @@ -999,7 +999,7 @@ class ContentViewerControllerTest < ActionController::TestCase en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) - get :view_page, :profile => @profile.identifier, :page => blog.explode_path + get :view_page, :profile => @profile.identifier, :page => blog.path assert_tag :div, :attributes => { :id => "post-#{es_article.id}" } assert_no_tag :div, :attributes => { :id => "post-#{en_article.id}" } end @@ -1017,7 +1017,7 @@ class ContentViewerControllerTest < ActionController::TestCase es_article2 = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article2) - get :view_page, :profile => @profile.identifier, :page => blog.explode_path + get :view_page, :profile => @profile.identifier, :page => blog.path assert_equal [pt_article], assigns(:posts) end @@ -1042,7 +1042,7 @@ class ContentViewerControllerTest < ActionController::TestCase es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) blog.posts = [en_article, es_article] - get :view_page, :profile => @profile.identifier, :page => blog.explode_path + get :view_page, :profile => @profile.identifier, :page => blog.path assert_equal [es_article], assigns(:posts) end diff --git a/vendor/plugins/xss_terminate/lib/xss_terminate.rb b/vendor/plugins/xss_terminate/lib/xss_terminate.rb index edec7f0..3566d85 100644 --- a/vendor/plugins/xss_terminate/lib/xss_terminate.rb +++ b/vendor/plugins/xss_terminate/lib/xss_terminate.rb @@ -59,7 +59,8 @@ module XssTerminate else value = self.send("#{field}") return unless value - self.send("#{field}=", sanitizer.sanitize(value)) + value = sanitizer.sanitize(value) + self.send("#{field}=", value) if with == :full self.send("#{field}=", CGI.escapeHTML(value)) -- libgit2 0.21.2