From 6afc4db6bed3c32715314f10bc6f95c7e10a8ac4 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Fri, 12 Jul 2013 20:38:49 -0300 Subject: [PATCH] [comments-refactor-review] Cleaning up the code --- app/views/tasks/_approve_comment_accept_details.rhtml | 2 +- config/plugins/comment_actions | 1 - test/functional/comment_controller_test.rb | 2 +- test/functional/content_viewer_controller_test.rb | 65 +++++++++++------------------------------------------------------ test/unit/comment_helper_test.rb | 8 ++++---- 5 files changed, 17 insertions(+), 61 deletions(-) delete mode 120000 config/plugins/comment_actions diff --git a/app/views/tasks/_approve_comment_accept_details.rhtml b/app/views/tasks/_approve_comment_accept_details.rhtml index 74c7b9c..e2003e6 100644 --- a/app/views/tasks/_approve_comment_accept_details.rhtml +++ b/app/views/tasks/_approve_comment_accept_details.rhtml @@ -3,5 +3,5 @@ <%= task.comment.title %>

- <%= task.comment.body %> + <%= task.comment.body %>

diff --git a/config/plugins/comment_actions b/config/plugins/comment_actions deleted file mode 120000 index 93111b3..0000000 --- a/config/plugins/comment_actions +++ /dev/null @@ -1 +0,0 @@ -/home/81665687568/projetos/noosfero_development/plugins/comment_actions \ No newline at end of file diff --git a/test/functional/comment_controller_test.rb b/test/functional/comment_controller_test.rb index 0d0b7b8..b965c53 100644 --- a/test/functional/comment_controller_test.rb +++ b/test/functional/comment_controller_test.rb @@ -361,7 +361,7 @@ class CommentControllerTest < ActionController::TestCase should "render the root comment when a reply is made" do login_as profile.identifier page = profile.articles.create!(:name => 'myarticle') - + comment = fast_create(Comment, :body => 'some content', :source_id => page.id, :source_type => 'Article') xhr :post, :create, :profile => profile.identifier, :id => page.id, :comment => {:body => 'Some comment...', :reply_of_id => comment.id}, :confirm => 'true' diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 81aedb7..4ff7c30 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -83,34 +83,6 @@ class ContentViewerControllerTest < ActionController::TestCase assert_equal feed.data, @response.body end -#FIXME Leandro The link to remove comment changes. Fix this test -# should 'display remove comment button' do -# profile = create_user('testuser').person -# article = profile.articles.build(:name => 'test') -# article.save! -# comment = article.comments.build(:author => profile, :title => 'a comment', :body => 'lalala') -# comment.save! -# -# login_as 'testuser' -# get :view_page, :profile => 'testuser', :page => [ 'test' ] -# assert_tag :tag => 'a', :attributes => { :onclick => %r(/testuser/test\?remove_comment=#{comment.id}.quot) } -# end - -#FIXME Leandro The link to remove comment changes. Fix this test -# should 'display remove comment button with param view when image' do -# profile = create_user('testuser').person -# -# image = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) -# image.save! -# -# comment = image.comments.build(:author => profile, :title => 'a comment', :body => 'lalala') -# comment.save! -# -# login_as 'testuser' -# get :view_page, :profile => 'testuser', :page => [ image.filename ], :view => true -# assert_tag :tag => 'a', :attributes => { :onclick => %r(/testuser/#{image.filename}\?remove_comment=#{comment.id}.*amp;view=true.quot) } -# end - should "display current article's tags" do page = profile.articles.create!(:name => 'myarticle', :body => 'test article', :tag_list => 'tag1, tag2') @@ -209,18 +181,17 @@ class ContentViewerControllerTest < ActionController::TestCase assert_response :success end -#FIXME Leandro make this test woks -# should 'load the correct profile when using hosted domain' do -# profile = create_user('mytestuser').person -# profile.domains << Domain.create!(:name => 'micojones.net') -# profile.save! -# -# ActionController::TestRequest.any_instance.expects(:host).returns('www.micojones.net').at_least_once -# -# get :view_page, :page => [] -# -# assert_equal profile, assigns(:profile) -# end + should 'load the correct profile when using hosted domain' do + profile = create_user('mytestuser').person + profile.domains << Domain.create!(:name => 'micojones.net') + profile.save! + + ActionController::TestRequest.any_instance.expects(:host).returns('www.micojones.net').at_least_once + + get :view_page, :page => [] + + assert_equal profile, assigns(:profile) + end should 'give link to edit the article for owner' do login_as('testinguser') @@ -1082,20 +1053,6 @@ class ContentViewerControllerTest < ActionController::TestCase assert_no_tag :tag => 'ul', :attributes => { :class => 'comment-replies' } end -#FIXME Leandro make this test woks -# should 'show reply error' do -# profile = create_user('testuser').person -# article = profile.articles.build(:name => 'test') -# article.save! -# comment = article.comments.build(:author => profile, :title => 'root', :body => 'root') -# comment.save! -# login_as 'testuser' -# post :view_page, :profile => profile.identifier, :page => ['test'], :comment => { :title => '', :body => '', :reply_of_id => comment.id }, :confirm => 'true' -# assert_tag :tag => 'div', :attributes => { :class => /comment_reply/ }, :descendant => {:tag => 'div', :attributes => {:class => 'errorExplanation'} } -# assert_no_tag :tag => 'div', :attributes => { :id => 'page-comment-form' }, :descendant => {:tag => 'div', :attributes => {:class => 'errorExplanation'} } -# assert_tag :tag => 'div', :attributes => { :id => 'page-comment-form' }, :descendant => { :tag => 'div', :attributes => { :class => /post_comment_box closed/ } } -# end - should 'add an zero width space every 4 caracters of comment urls' do url = 'www.an.url.to.be.splited.com' a = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') diff --git a/test/unit/comment_helper_test.rb b/test/unit/comment_helper_test.rb index a2b1b2f..479c7f7 100644 --- a/test/unit/comment_helper_test.rb +++ b/test/unit/comment_helper_test.rb @@ -23,14 +23,14 @@ class CommentHelperTest < ActiveSupport::TestCase menu = comment_actions(comment) assert menu end - + should 'do not show menu if it has no actions' do comment = Comment.new self.stubs(:links_for_comment_actions).returns([]) menu = comment_actions(comment) assert !menu end - + should 'do not show menu if it has nil actions only' do comment = Comment.new self.stubs(:link_for_report_abuse).returns(nil) @@ -59,14 +59,14 @@ class CommentHelperTest < ActiveSupport::TestCase assert_includes links, {:link => 'plugin_action'} assert_includes links, {:link => 'plugin_action2'} end - + should 'return link for report abuse action when comment has a author' do comment = Comment.new comment.author = user link = link_for_report_abuse(comment) assert link end - + should 'do not return link for report abuse action when comment has no author' do comment = Comment.new link = link_for_report_abuse(comment) -- libgit2 0.21.2