Commit 981b0c92928691b9bc818ff3851f3344c1f3924b
1 parent
dd2b6081
Exists in
master
and in
29 other branches
rails3: fix cms_controller tests
Showing
6 changed files
with
57 additions
and
59 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -45,8 +45,7 @@ class CmsController < MyProfileController |
45 | 45 | conditions = ['type != ?', 'RssFeed'] |
46 | 46 | end |
47 | 47 | |
48 | - @articles = @article.children.paginate( | |
49 | - :order => "case when type = 'Folder' then 0 when type ='Blog' then 1 else 2 end, updated_at DESC", | |
48 | + @articles = @article.children.reorder("case when type = 'Folder' then 0 when type ='Blog' then 1 else 2 end, updated_at DESC, name").paginate( | |
50 | 49 | :conditions => conditions, |
51 | 50 | :per_page => per_page, |
52 | 51 | :page => params[:npage] |
... | ... | @@ -188,7 +187,7 @@ class CmsController < MyProfileController |
188 | 187 | if request.post? |
189 | 188 | @article.destroy |
190 | 189 | session[:notice] = _("\"#{@article.name}\" was removed.") |
191 | - referer = ActionController::Routing::Routes.recognize_path URI.parse(request.referer).path rescue nil | |
190 | + referer = Rails.application.routes.recognize_path URI.parse(request.referer).path rescue nil | |
192 | 191 | if referer and referer[:controller] == 'cms' |
193 | 192 | redirect_to referer |
194 | 193 | elsif @article.parent | ... | ... |
app/controllers/public/content_viewer_controller.rb
... | ... | @@ -88,7 +88,7 @@ class ContentViewerController < ApplicationController |
88 | 88 | blog_with_translation = @page.blog? && @page.display_posts_in_current_language? |
89 | 89 | posts = posts.native_translations if blog_with_translation |
90 | 90 | |
91 | - @posts = posts.paginate({ :page => params[:npage], :per_page => @page.posts_per_page }.merge(Article.display_filter(user, profile))) | |
91 | + @posts = posts.paginate({ :page => params[:npage], :per_page => @page.posts_per_page }.merge(Article.display_filter(user, profile))).to_a | |
92 | 92 | |
93 | 93 | if blog_with_translation |
94 | 94 | @posts.replace @posts.map{ |p| p.get_translation_to(FastGettext.locale) }.compact | ... | ... |
config/application.rb
... | ... | @@ -25,6 +25,8 @@ module Noosfero |
25 | 25 | # Adds custom tags to the Set of allowed html tags for the #sanitize helper |
26 | 26 | config.action_view.sanitized_allowed_tags = 'object', 'embed', 'param', 'table', 'tr', 'th', 'td', 'applet', 'comment', 'iframe', 'audio', 'video', 'source' |
27 | 27 | |
28 | + config.action_controller.include_all_helpers = false | |
29 | + | |
28 | 30 | # Settings in config/environments/* take precedence over those specified here. |
29 | 31 | # Application configuration should go into files in config/initializers |
30 | 32 | # -- all .rb files in that directory are automatically loaded. | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -12,10 +12,6 @@ class CmsControllerTest < ActionController::TestCase |
12 | 12 | |
13 | 13 | def setup |
14 | 14 | super |
15 | - @controller = CmsController.new | |
16 | - @request = ActionController::TestRequest.new | |
17 | - @response = ActionController::TestResponse.new | |
18 | - | |
19 | 15 | @profile = create_user_with_permission('testinguser', 'post_content') |
20 | 16 | login_as :testinguser |
21 | 17 | end |
... | ... | @@ -137,7 +133,7 @@ class CmsControllerTest < ActionController::TestCase |
137 | 133 | a.save! |
138 | 134 | |
139 | 135 | profile.description = 'a' * 600 |
140 | - profile.save(false) | |
136 | + profile.save(:validate => false) | |
141 | 137 | |
142 | 138 | assert !profile.valid? |
143 | 139 | assert_not_equal a, profile.home_page |
... | ... | @@ -403,7 +399,7 @@ class CmsControllerTest < ActionController::TestCase |
403 | 399 | get :view, :profile => profile.identifier, :id => article.id |
404 | 400 | assert_response :success |
405 | 401 | assert_template 'view' |
406 | - assert_tag :tag => 'a', :attributes => { :title => 'New content', :href => "/myprofile/#{profile.identifier}/cms/new?cms=true&parent_id=#{article.id}"} | |
402 | + assert_tag :tag => 'a', :attributes => { :title => 'New content', :href => "/myprofile/#{profile.identifier}/cms/new?cms=true&parent_id=#{article.id}"} | |
407 | 403 | end |
408 | 404 | |
409 | 405 | should 'offer to create children' do |
... | ... | @@ -414,7 +410,7 @@ class CmsControllerTest < ActionController::TestCase |
414 | 410 | article.save! |
415 | 411 | |
416 | 412 | get :new, :profile => profile.identifier, :parent_id => article.id, :cms => true |
417 | - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}&type=TextileArticle"} | |
413 | + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}&type=TextileArticle"} | |
418 | 414 | end |
419 | 415 | |
420 | 416 | should 'not offer to create children if article does not accept them' do |
... | ... | @@ -559,7 +555,7 @@ class CmsControllerTest < ActionController::TestCase |
559 | 555 | f = Folder.new(:name => 'f'); profile.articles << f; f.save! |
560 | 556 | get :new, :profile => profile.identifier, :parent_id => f.id, :cms => true |
561 | 557 | |
562 | - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{f.id}&type=Folder" } | |
558 | + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{f.id}&type=Folder" } | |
563 | 559 | end |
564 | 560 | |
565 | 561 | should 'redirect to article after creating top-level article' do |
... | ... | @@ -1512,7 +1508,7 @@ class CmsControllerTest < ActionController::TestCase |
1512 | 1508 | should 'update file and be redirect to cms' do |
1513 | 1509 | file = UploadedFile.create!(:profile => @profile, :uploaded_data => fixture_file_upload('files/test.txt', 'text/plain')) |
1514 | 1510 | post :edit, :profile => @profile.identifier, :id => file.id, :article => { } |
1515 | - assert_redirected_to :controller => 'cms', :profile => profile.identifier, :action => 'index' | |
1511 | + assert_redirected_to :controller => 'cms', :profile => profile.identifier, :action => 'index', :id => nil | |
1516 | 1512 | end |
1517 | 1513 | |
1518 | 1514 | should 'update file and be redirect to cms folder' do | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -330,20 +330,20 @@ class ContentViewerControllerTest < ActionController::TestCase |
330 | 330 | should 'redirect to new article path under an old path' do |
331 | 331 | p = create_user('test_user').person |
332 | 332 | a = p.articles.create(:name => 'old-name') |
333 | - old_path = a.explode_path | |
333 | + old_path = a.path | |
334 | 334 | a.name = 'new-name' |
335 | 335 | a.save! |
336 | 336 | |
337 | 337 | get :view_page, :profile => p.identifier, :page => old_path |
338 | 338 | |
339 | 339 | assert_response :redirect |
340 | - assert_redirected_to :host => p.default_hostname, :controller => 'content_viewer', :action => 'view_page', :profile => p.identifier, :page => a.explode_path | |
340 | + assert_redirected_to :host => p.default_hostname, :controller => 'content_viewer', :action => 'view_page', :profile => p.identifier, :page => a.path | |
341 | 341 | end |
342 | 342 | |
343 | 343 | should 'load new article name equal of another article old name' do |
344 | 344 | p = create_user('test_user').person |
345 | 345 | a1 = p.articles.create!(:name => 'old-name') |
346 | - old_path = a1.explode_path | |
346 | + old_path = a1.path | |
347 | 347 | a1.name = 'new-name' |
348 | 348 | a1.save! |
349 | 349 | a2 = p.articles.create!(:name => 'old-name') |
... | ... | @@ -356,7 +356,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
356 | 356 | should 'redirect to article with most recent version with the name if there is no article with the name' do |
357 | 357 | p = create_user('test_user').person |
358 | 358 | a1 = p.articles.create!(:name => 'old-name') |
359 | - old_path = a1.explode_path | |
359 | + old_path = a1.path | |
360 | 360 | a1.name = 'new-name' |
361 | 361 | a1.save! |
362 | 362 | a2 = p.articles.create!(:name => 'old-name') |
... | ... | @@ -366,13 +366,13 @@ class ContentViewerControllerTest < ActionController::TestCase |
366 | 366 | get :view_page, :profile => p.identifier, :page => old_path |
367 | 367 | |
368 | 368 | assert_response :redirect |
369 | - assert_redirected_to :host => p.default_hostname, :controller => 'content_viewer', :action => 'view_page', :profile => p.identifier, :page => a2.explode_path | |
369 | + assert_redirected_to :host => p.default_hostname, :controller => 'content_viewer', :action => 'view_page', :profile => p.identifier, :page => a2.path | |
370 | 370 | end |
371 | 371 | |
372 | 372 | should 'not return an article of a different user' do |
373 | 373 | p1 = create_user('test_user').person |
374 | 374 | a = p1.articles.create!(:name => 'old-name') |
375 | - old_path = a.explode_path | |
375 | + old_path = a.path | |
376 | 376 | a.name = 'new-name' |
377 | 377 | a.save! |
378 | 378 | |
... | ... | @@ -514,7 +514,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
514 | 514 | should 'not display delete button for homepage' do |
515 | 515 | login_as(profile.identifier) |
516 | 516 | page = profile.home_page |
517 | - xhr :get, :view_page, :profile => profile.identifier, :page => page.explode_path, :toolbar => true | |
517 | + xhr :get, :view_page, :profile => profile.identifier, :page => page.path, :toolbar => true | |
518 | 518 | assert_no_tag :tag => 'a', :content => 'Delete', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/destroy/#{page.id}" } |
519 | 519 | end |
520 | 520 | |
... | ... | @@ -542,7 +542,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
542 | 542 | |
543 | 543 | should 'render html for image when view' do |
544 | 544 | file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile) |
545 | - get :view_page, :profile => profile.identifier, :page => file.explode_path, :view => true | |
545 | + get :view_page, :profile => profile.identifier, :page => file.path, :view => true | |
546 | 546 | |
547 | 547 | assert_response :success |
548 | 548 | assert_template 'view_page' |
... | ... | @@ -550,7 +550,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
550 | 550 | |
551 | 551 | should 'download data for image when not view' do |
552 | 552 | file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile) |
553 | - get :view_page, :profile => profile.identifier, :page => file.explode_path | |
553 | + get :view_page, :profile => profile.identifier, :page => file.path | |
554 | 554 | |
555 | 555 | assert_response :success |
556 | 556 | assert_template nil |
... | ... | @@ -559,7 +559,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
559 | 559 | should "display 'Upload files' when create children of image gallery" do |
560 | 560 | login_as(profile.identifier) |
561 | 561 | f = Gallery.create!(:name => 'gallery', :profile => profile) |
562 | - xhr :get, :view_page, :profile => profile.identifier, :page => f.explode_path, :toolbar => true | |
562 | + xhr :get, :view_page, :profile => profile.identifier, :page => f.path, :toolbar => true | |
563 | 563 | assert_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{f.id}/} |
564 | 564 | end |
565 | 565 | |
... | ... | @@ -568,7 +568,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
568 | 568 | folder1 = Gallery.create!(:name => 'gallery1', :profile => profile) |
569 | 569 | folder1.children << folder2 = Folder.new(:name => 'gallery2', :profile => profile) |
570 | 570 | |
571 | - xhr :get, :view_page, :profile => profile.identifier, :page => folder2.explode_path, :toolbar => true | |
571 | + xhr :get, :view_page, :profile => profile.identifier, :page => folder2.path, :toolbar => true | |
572 | 572 | assert_tag :tag => 'a', :content => 'New article', :attributes => {:href =>/parent_id=#{folder2.id}/} |
573 | 573 | end |
574 | 574 | |
... | ... | @@ -576,14 +576,14 @@ class ContentViewerControllerTest < ActionController::TestCase |
576 | 576 | login_as(profile.identifier) |
577 | 577 | folder = Gallery.create!(:name => 'gallery', :profile => profile) |
578 | 578 | file = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
579 | - xhr :get, :view_page, :profile => profile.identifier, :page => file.explode_path, :view => true, :toolbar => true | |
579 | + xhr :get, :view_page, :profile => profile.identifier, :page => file.path, :view => true, :toolbar => true | |
580 | 580 | |
581 | 581 | assert_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{folder.id}/} |
582 | 582 | end |
583 | 583 | |
584 | 584 | should 'render slideshow template' do |
585 | 585 | f = Folder.create!(:name => 'gallery', :profile => profile) |
586 | - get :view_page, :profile => profile.identifier, :page => f.explode_path, :slideshow => true | |
586 | + get :view_page, :profile => profile.identifier, :page => f.path, :slideshow => true | |
587 | 587 | |
588 | 588 | assert_template 'slideshow' |
589 | 589 | end |
... | ... | @@ -595,7 +595,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
595 | 595 | image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) |
596 | 596 | image2 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
597 | 597 | |
598 | - get :view_page, :profile => profile.identifier, :page => folder.explode_path, :slideshow => true | |
598 | + get :view_page, :profile => profile.identifier, :page => folder.path, :slideshow => true | |
599 | 599 | |
600 | 600 | assert_equal 2, assigns(:images).size |
601 | 601 | end |
... | ... | @@ -606,7 +606,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
606 | 606 | folder = Gallery.create!(:name => 'gallery', :profile => owner) |
607 | 607 | image1 = UploadedFile.create!(:profile => owner, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg'), :published => false) |
608 | 608 | login_as('unauthorized') |
609 | - get :view_page, :profile => owner.identifier, :page => folder.explode_path, :slideshow => true | |
609 | + get :view_page, :profile => owner.identifier, :page => folder.path, :slideshow => true | |
610 | 610 | assert_response :success |
611 | 611 | assert_equal 0, assigns(:images).length |
612 | 612 | end |
... | ... | @@ -617,7 +617,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
617 | 617 | folder = Gallery.create!(:name => 'gallery', :profile => owner) |
618 | 618 | image1 = UploadedFile.create!(:profile => owner, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg'), :published => false) |
619 | 619 | login_as('unauthorized') |
620 | - get :view_page, :profile => owner.identifier, :page => folder.explode_path | |
620 | + get :view_page, :profile => owner.identifier, :page => folder.path | |
621 | 621 | assert_response :success |
622 | 622 | assert_select '.image-gallery-item', 0 |
623 | 623 | end |
... | ... | @@ -629,7 +629,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
629 | 629 | |
630 | 630 | image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) |
631 | 631 | |
632 | - get :view_page, :profile => profile.identifier, :page => folder.explode_path, :slideshow => true | |
632 | + get :view_page, :profile => profile.identifier, :page => folder.path, :slideshow => true | |
633 | 633 | |
634 | 634 | assert_tag :tag => 'img', :attributes => {:src => /\/images\/icons-app\/image-loading-display.png/} |
635 | 635 | end |
... | ... | @@ -641,7 +641,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
641 | 641 | image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) |
642 | 642 | |
643 | 643 | process_delayed_job_queue |
644 | - get :view_page, :profile => profile.identifier, :page => folder.explode_path, :slideshow => true | |
644 | + get :view_page, :profile => profile.identifier, :page => folder.path, :slideshow => true | |
645 | 645 | |
646 | 646 | assert_tag :tag => 'img', :attributes => {:src => /other-pic_display.jpg/} |
647 | 647 | end |
... | ... | @@ -652,7 +652,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
652 | 652 | |
653 | 653 | image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) |
654 | 654 | |
655 | - get :view_page, :profile => profile.identifier, :page => folder.explode_path | |
655 | + get :view_page, :profile => profile.identifier, :page => folder.path | |
656 | 656 | |
657 | 657 | assert_tag :tag => 'a', :attributes => {:class => 'image', :style => /background-image: url\(\/images\/icons-app\/image-loading-thumb.png\)/} |
658 | 658 | end |
... | ... | @@ -664,7 +664,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
664 | 664 | image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg')) |
665 | 665 | |
666 | 666 | process_delayed_job_queue |
667 | - get :view_page, :profile => profile.identifier, :page => folder.explode_path | |
667 | + get :view_page, :profile => profile.identifier, :page => folder.path | |
668 | 668 | |
669 | 669 | assert_tag :tag => 'a', :attributes => {:class => 'image', :style => /background-image: url\(.*\/other-pic_thumb.jpg\)/} |
670 | 670 | end |
... | ... | @@ -690,7 +690,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
690 | 690 | should "not display 'Upload files' when viewing blog" do |
691 | 691 | login_as(profile.identifier) |
692 | 692 | b = Blog.create!(:name => 'article folder', :profile => profile) |
693 | - xhr :get, :view_page, :profile => profile.identifier, :page => b.explode_path, :toolbar => true | |
693 | + xhr :get, :view_page, :profile => profile.identifier, :page => b.path, :toolbar => true | |
694 | 694 | assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/} |
695 | 695 | end |
696 | 696 | |
... | ... | @@ -698,7 +698,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
698 | 698 | login_as(profile.identifier) |
699 | 699 | b = Blog.create!(:name => 'article folder', :profile => profile) |
700 | 700 | blog_post = TextileArticle.create!(:name => 'children-article', :profile => profile, :parent => b) |
701 | - xhr :get, :view_page, :profile => profile.identifier, :page => blog_post.explode_path, :toolbar => true | |
701 | + xhr :get, :view_page, :profile => profile.identifier, :page => blog_post.path, :toolbar => true | |
702 | 702 | assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/} |
703 | 703 | end |
704 | 704 | |
... | ... | @@ -707,7 +707,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
707 | 707 | folder = fast_create(Gallery, :profile_id => profile.id) |
708 | 708 | file = UploadedFile.create!(:title => 'my img title', :profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
709 | 709 | |
710 | - get :view_page, :profile => profile.identifier, :page => folder.explode_path | |
710 | + get :view_page, :profile => profile.identifier, :page => folder.path | |
711 | 711 | |
712 | 712 | assert_tag :tag => 'li', :attributes => {:title => 'my img title', :class => 'image-gallery-item'}, :child => {:tag => 'span', :content => 'my img title'} |
713 | 713 | end |
... | ... | @@ -717,7 +717,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
717 | 717 | folder = fast_create(Gallery, :profile_id => profile.id) |
718 | 718 | file = UploadedFile.create!(:title => '<b>my img title</b>', :profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
719 | 719 | |
720 | - get :view_page, :profile => profile.identifier, :page => folder.explode_path | |
720 | + get :view_page, :profile => profile.identifier, :page => folder.path | |
721 | 721 | |
722 | 722 | assert_tag :tag => 'li', :attributes => {:title => 'my img title', :class => 'image-gallery-item'}, :child => {:tag => 'span', :content => 'my img title'} |
723 | 723 | end |
... | ... | @@ -728,7 +728,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
728 | 728 | login_as u.identifier |
729 | 729 | a = create(Article, :profile => c, :name => 'test-article', :last_changed_by => u, :published => false) |
730 | 730 | |
731 | - get :view_page, :profile => c.identifier, :page => a.explode_path | |
731 | + get :view_page, :profile => c.identifier, :page => a.path | |
732 | 732 | |
733 | 733 | assert_response :success |
734 | 734 | assert_template 'view_page' |
... | ... | @@ -740,7 +740,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
740 | 740 | login_as u.identifier |
741 | 741 | a = create(Article, :profile => c, :name => 'test-article', :last_changed_by => profile, :published => true) |
742 | 742 | |
743 | - xhr :get, :view_page, :profile => c.identifier, :page => a.explode_path, :toolbar => true | |
743 | + xhr :get, :view_page, :profile => c.identifier, :page => a.path, :toolbar => true | |
744 | 744 | |
745 | 745 | assert_tag :tag => 'a', :content => 'New article' |
746 | 746 | end |
... | ... | @@ -751,7 +751,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
751 | 751 | comment = article.comments.create(:author => to_be_removed, :title => 'Test Comment', :body => 'My author does not exist =(') |
752 | 752 | to_be_removed.destroy |
753 | 753 | |
754 | - get :view_page, :profile => profile.identifier, :page => article.explode_path | |
754 | + get :view_page, :profile => profile.identifier, :page => article.path | |
755 | 755 | |
756 | 756 | assert_tag :tag => 'span', :content => '(removed user)', :attributes => {:class => 'comment-user-status icon-user-removed'} |
757 | 757 | end |
... | ... | @@ -763,7 +763,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
763 | 763 | |
764 | 764 | blog.posts << TinyMceArticle.create!(:name => 'first post', :parent => blog, :profile => profile, :body => '<p>Content to be displayed.</p> Anything') |
765 | 765 | |
766 | - get :view_page, :profile => profile.identifier, :page => blog.explode_path | |
766 | + get :view_page, :profile => profile.identifier, :page => blog.path | |
767 | 767 | |
768 | 768 | assert_tag :tag => 'div', :attributes => { :class => 'short-post'}, :content => /Content to be displayed./ |
769 | 769 | assert_no_tag :tag => 'div', :attributes => { :class => 'short-post'}, :content => /Anything/ |
... | ... | @@ -772,7 +772,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
772 | 772 | should 'display link to edit blog for allowed' do |
773 | 773 | blog = fast_create(Blog, :profile_id => profile.id, :path => 'blog') |
774 | 774 | login_as(profile.identifier) |
775 | - xhr :get, :view_page, :profile => profile.identifier, :page => blog.explode_path, :toolbar => true | |
775 | + xhr :get, :view_page, :profile => profile.identifier, :page => blog.path, :toolbar => true | |
776 | 776 | assert_tag :tag => 'div', :attributes => { :id => 'article-actions' }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/edit/#{blog.id}" }, :content => 'Configure blog' } |
777 | 777 | end |
778 | 778 | |
... | ... | @@ -895,7 +895,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
895 | 895 | should "not display 'Upload files' when viewing forum" do |
896 | 896 | login_as(profile.identifier) |
897 | 897 | b = Forum.create!(:name => 'article folder', :profile => profile) |
898 | - xhr :get, :view_page, :profile => profile.identifier, :page => b.explode_path, :toolbar => true | |
898 | + xhr :get, :view_page, :profile => profile.identifier, :page => b.path, :toolbar => true | |
899 | 899 | assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/} |
900 | 900 | end |
901 | 901 | |
... | ... | @@ -903,35 +903,35 @@ class ContentViewerControllerTest < ActionController::TestCase |
903 | 903 | login_as(profile.identifier) |
904 | 904 | b = Forum.create!(:name => 'article folder', :profile => profile) |
905 | 905 | forum_post = TextileArticle.create!(:name => 'children-article', :profile => profile, :parent => b) |
906 | - xhr :get, :view_page, :profile => profile.identifier, :page => forum_post.explode_path, :toolbar => true | |
906 | + xhr :get, :view_page, :profile => profile.identifier, :page => forum_post.path, :toolbar => true | |
907 | 907 | assert_no_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{b.id}/} |
908 | 908 | end |
909 | 909 | |
910 | 910 | should 'display link to edit forum for allowed' do |
911 | 911 | forum = fast_create(Forum, :profile_id => profile.id, :path => 'forum') |
912 | 912 | login_as(profile.identifier) |
913 | - xhr :get, :view_page, :profile => profile.identifier, :page => forum.explode_path, :toolbar => true | |
913 | + xhr :get, :view_page, :profile => profile.identifier, :page => forum.path, :toolbar => true | |
914 | 914 | assert_tag :tag => 'div', :attributes => { :id => 'article-actions' }, :descendant => { :tag => 'a', :attributes => { :href => "/myprofile/testinguser/cms/edit/#{forum.id}" }, :content => 'Configure forum' } |
915 | 915 | end |
916 | 916 | |
917 | 917 | should 'display add translation link if article is translatable' do |
918 | 918 | login_as @profile.identifier |
919 | 919 | textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') |
920 | - xhr :get, :view_page, :profile => @profile.identifier, :page => textile.explode_path, :toolbar => true | |
921 | - assert_tag :a, :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?article%5Btranslation_of_id%5D=#{textile.id}&type=#{TextileArticle}" } | |
920 | + xhr :get, :view_page, :profile => @profile.identifier, :page => textile.path, :toolbar => true | |
921 | + assert_tag :a, :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?article%5Btranslation_of_id%5D=#{textile.id}&type=#{TextileArticle}" } | |
922 | 922 | end |
923 | 923 | |
924 | 924 | should 'not display add translation link if article is not translatable' do |
925 | 925 | login_as @profile.identifier |
926 | 926 | blog = fast_create(Blog, :profile_id => @profile.id, :path => 'blog') |
927 | - xhr :get, :view_page, :profile => @profile.identifier, :page => blog.explode_path, :toolbar => true | |
927 | + xhr :get, :view_page, :profile => @profile.identifier, :page => blog.path, :toolbar => true | |
928 | 928 | assert_no_tag :a, :attributes => { :content => 'Add translation', :class => /icon-locale/ } |
929 | 929 | end |
930 | 930 | |
931 | 931 | should 'not display add translation link if article hasnt a language defined' do |
932 | 932 | login_as @profile.identifier |
933 | 933 | textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile') |
934 | - xhr :get, :view_page, :profile => @profile.identifier, :page => textile.explode_path, :toolbar => true | |
934 | + xhr :get, :view_page, :profile => @profile.identifier, :page => textile.path, :toolbar => true | |
935 | 935 | assert_no_tag :a, :attributes => { :content => 'Add translation', :class => /icon-locale/ } |
936 | 936 | end |
937 | 937 | |
... | ... | @@ -939,7 +939,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
939 | 939 | login_as @profile.identifier |
940 | 940 | textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') |
941 | 941 | translation = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'translation', :language => 'es', :translation_of_id => textile) |
942 | - xhr :get, :view_page, :profile => @profile.identifier, :page => textile.explode_path, :toolbar => true | |
942 | + xhr :get, :view_page, :profile => @profile.identifier, :page => textile.path, :toolbar => true | |
943 | 943 | assert_tag :a, :attributes => { :class => /article-translations-menu/, :onmouseover => /toggleSubmenu/ } |
944 | 944 | end |
945 | 945 | |
... | ... | @@ -948,7 +948,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
948 | 948 | es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) |
949 | 949 | @request.env['HTTP_REFERER'] = "http://localhost:3000/#{@profile.identifier}/#{es_article.path}" |
950 | 950 | FastGettext.stubs(:locale).returns('es') |
951 | - get :view_page, :profile => @profile.identifier, :page => es_article.explode_path | |
951 | + get :view_page, :profile => @profile.identifier, :page => es_article.path | |
952 | 952 | assert_response :success |
953 | 953 | assert_equal es_article, assigns(:page) |
954 | 954 | end |
... | ... | @@ -956,7 +956,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
956 | 956 | should 'not be redirected if article does not have a language' do |
957 | 957 | FastGettext.stubs(:locale).returns('es') |
958 | 958 | article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'article') |
959 | - get :view_page, :profile => @profile.identifier, :page => article.explode_path | |
959 | + get :view_page, :profile => @profile.identifier, :page => article.path | |
960 | 960 | assert_response :success |
961 | 961 | assert_equal article, assigns(:page) |
962 | 962 | end |
... | ... | @@ -966,7 +966,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
966 | 966 | es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) |
967 | 967 | @request.env['HTTP_REFERER'] = "http://localhost:3000/#{@profile.identifier}/#{es_article.path}" |
968 | 968 | FastGettext.stubs(:locale).returns('es') |
969 | - get :view_page, :profile => @profile.identifier, :page => en_article.explode_path | |
969 | + get :view_page, :profile => @profile.identifier, :page => en_article.path | |
970 | 970 | assert_response :success |
971 | 971 | assert_equal en_article, assigns(:page) |
972 | 972 | end |
... | ... | @@ -976,7 +976,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
976 | 976 | es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) |
977 | 977 | FastGettext.stubs(:locale).returns('es') |
978 | 978 | @request.env['HTTP_REFERER'] = "http://localhost/myprofile/#{@profile.identifier}/cms/edit/#{en_article.id}" |
979 | - get :view_page, :profile => @profile.identifier, :page => es_article.explode_path | |
979 | + get :view_page, :profile => @profile.identifier, :page => es_article.path | |
980 | 980 | assert_response :success |
981 | 981 | assert_equal es_article, assigns(:page) |
982 | 982 | end |
... | ... | @@ -986,7 +986,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
986 | 986 | es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :translation_of_id => en_article) |
987 | 987 | FastGettext.stubs(:locale).returns('es') |
988 | 988 | @request.env['HTTP_REFERER'] = "http://localhost/myprofile/#{@profile.identifier}/cms/new" |
989 | - get :view_page, :profile => @profile.identifier, :page => es_article.explode_path | |
989 | + get :view_page, :profile => @profile.identifier, :page => es_article.path | |
990 | 990 | assert_response :success |
991 | 991 | assert_equal es_article, assigns(:page) |
992 | 992 | end |
... | ... | @@ -999,7 +999,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
999 | 999 | en_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'en_article', :language => 'en', :parent_id => blog.id) |
1000 | 1000 | es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) |
1001 | 1001 | |
1002 | - get :view_page, :profile => @profile.identifier, :page => blog.explode_path | |
1002 | + get :view_page, :profile => @profile.identifier, :page => blog.path | |
1003 | 1003 | assert_tag :div, :attributes => { :id => "post-#{es_article.id}" } |
1004 | 1004 | assert_no_tag :div, :attributes => { :id => "post-#{en_article.id}" } |
1005 | 1005 | end |
... | ... | @@ -1017,7 +1017,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
1017 | 1017 | es_article2 = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article2) |
1018 | 1018 | |
1019 | 1019 | |
1020 | - get :view_page, :profile => @profile.identifier, :page => blog.explode_path | |
1020 | + get :view_page, :profile => @profile.identifier, :page => blog.path | |
1021 | 1021 | |
1022 | 1022 | assert_equal [pt_article], assigns(:posts) |
1023 | 1023 | end |
... | ... | @@ -1042,7 +1042,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
1042 | 1042 | es_article = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'es_article', :language => 'es', :parent_id => blog.id, :translation_of_id => en_article) |
1043 | 1043 | blog.posts = [en_article, es_article] |
1044 | 1044 | |
1045 | - get :view_page, :profile => @profile.identifier, :page => blog.explode_path | |
1045 | + get :view_page, :profile => @profile.identifier, :page => blog.path | |
1046 | 1046 | assert_equal [es_article], assigns(:posts) |
1047 | 1047 | end |
1048 | 1048 | ... | ... |
vendor/plugins/xss_terminate/lib/xss_terminate.rb
... | ... | @@ -59,7 +59,8 @@ module XssTerminate |
59 | 59 | else |
60 | 60 | value = self.send("#{field}") |
61 | 61 | return unless value |
62 | - self.send("#{field}=", sanitizer.sanitize(value)) | |
62 | + value = sanitizer.sanitize(value) | |
63 | + self.send("#{field}=", value) | |
63 | 64 | |
64 | 65 | if with == :full |
65 | 66 | self.send("#{field}=", CGI.escapeHTML(value)) | ... | ... |