Commit b924e05f77591aa126e5e0009f87ddaa2429c689

Authored by Moises Machado
Committed by Antonio Terceiro
1 parent 475bffce

ActionItem929: fixed commenting on images

app/views/content_viewer/_comment_form.rhtml
... ... @@ -17,7 +17,7 @@
17 17  
18 18 <h4><%= content_tag('a', '', :name => 'comment_form') + _('Post a comment') %></h4>
19 19  
20   -<% form_tag( @page.url, { :id => comment_form_id } ) do %>
  20 +<% form_tag( @page.url.merge(:view => params[:view]), { :id => comment_form_id } ) do %>
21 21  
22 22 <%= required_fields_message %>
23 23  
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -250,7 +250,7 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase
250 250  
251 251 should "point to article's url in comment form" do
252 252 page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text')
253   - Article.any_instance.stubs(:url).returns('http://www.mysite.com/person/article')
  253 + Article.any_instance.stubs(:url).returns({:host => 'www.mysite.com', :controller => 'content_viewer', :action => 'view_page', :profile => 'person', :page => ['article']})
254 254  
255 255 get :view_page, :profile => profile.identifier, :page => [ 'myarticle' ]
256 256  
... ... @@ -699,4 +699,22 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase
699 699  
700 700 assert_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{folder.id}/}
701 701 end
  702 +
  703 + should 'have a link to properly post a comment' do
  704 + login_as(profile.identifier)
  705 + file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'))
  706 + get :view_page, :profile => profile.identifier, :page => file.explode_path, :view => true
  707 +
  708 + assert_tag :tag => 'input', :attributes => {:type => 'submit', :value => 'Post comment'}, :ancestor => {:tag => 'form', :attributes => {:action => /#{file.slug}.*view=true/}}
  709 + end
  710 +
  711 + should 'post comment in a image' do
  712 + login_as(profile.identifier)
  713 + image = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'))
  714 + comment_count = image.comments.count
  715 + post :view_page, :profile => profile.identifier, :page => image.explode_path, :view => true
  716 + assert_equal comment_count, image.reload.comments.count
  717 + assert_template 'view_page'
  718 + end
  719 +
702 720 end
... ...