From b924e05f77591aa126e5e0009f87ddaa2429c689 Mon Sep 17 00:00:00 2001 From: Moises Machado Date: Thu, 26 Feb 2009 13:19:30 -0300 Subject: [PATCH] ActionItem929: fixed commenting on images --- app/views/content_viewer/_comment_form.rhtml | 2 +- test/functional/content_viewer_controller_test.rb | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/views/content_viewer/_comment_form.rhtml b/app/views/content_viewer/_comment_form.rhtml index 081071b..c6731c1 100644 --- a/app/views/content_viewer/_comment_form.rhtml +++ b/app/views/content_viewer/_comment_form.rhtml @@ -17,7 +17,7 @@

<%= content_tag('a', '', :name => 'comment_form') + _('Post a comment') %>

-<% form_tag( @page.url, { :id => comment_form_id } ) do %> +<% form_tag( @page.url.merge(:view => params[:view]), { :id => comment_form_id } ) do %> <%= required_fields_message %> diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index f5f90e9..729777c 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -250,7 +250,7 @@ class ContentViewerControllerTest < Test::Unit::TestCase should "point to article's url in comment form" do page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text') - Article.any_instance.stubs(:url).returns('http://www.mysite.com/person/article') + Article.any_instance.stubs(:url).returns({:host => 'www.mysite.com', :controller => 'content_viewer', :action => 'view_page', :profile => 'person', :page => ['article']}) get :view_page, :profile => profile.identifier, :page => [ 'myarticle' ] @@ -699,4 +699,22 @@ class ContentViewerControllerTest < Test::Unit::TestCase assert_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{folder.id}/} end + + should 'have a link to properly post a comment' do + login_as(profile.identifier) + file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) + get :view_page, :profile => profile.identifier, :page => file.explode_path, :view => true + + assert_tag :tag => 'input', :attributes => {:type => 'submit', :value => 'Post comment'}, :ancestor => {:tag => 'form', :attributes => {:action => /#{file.slug}.*view=true/}} + end + + should 'post comment in a image' do + login_as(profile.identifier) + image = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) + comment_count = image.comments.count + post :view_page, :profile => profile.identifier, :page => image.explode_path, :view => true + assert_equal comment_count, image.reload.comments.count + assert_template 'view_page' + end + end -- libgit2 0.21.2