Commit 8fbf67eb3449da5a7664d668df46babd812a964c
Committed by
Antonio Terceiro
1 parent
41900a39
Exists in
master
and in
29 other branches
Fixing when an uploaded file is added as a blog post
(ActionItem1321)
Showing
2 changed files
with
22 additions
and
1 deletions
Show diff stats
app/helpers/blog_helper.rb
test/unit/blog_helper_test.rb
... | ... | @@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../test_helper' |
3 | 3 | class BlogHelperTest < Test::Unit::TestCase |
4 | 4 | |
5 | 5 | include BlogHelper |
6 | + include ContentViewerHelper | |
6 | 7 | |
7 | 8 | def setup |
8 | 9 | stubs(:show_date).returns('') |
... | ... | @@ -50,10 +51,30 @@ class BlogHelperTest < Test::Unit::TestCase |
50 | 51 | blog.children << article = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true) |
51 | 52 | expects(:article_title).with(article).returns('TITLE') |
52 | 53 | expects(:content_tag).with('p', article.to_html).returns(' TO_HTML') |
54 | + self.stubs(:params).returns({:npage => nil}) | |
53 | 55 | |
54 | 56 | assert_equal 'TITLE TO_HTML', display_post(article) |
55 | 57 | end |
56 | 58 | |
59 | + should 'display link to file if post is an uploaded_file' do | |
60 | + file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain'), :profile => profile, :published => true, :parent => blog) | |
61 | + | |
62 | + expects(:article_to_html).with(file).returns('TO HTML') | |
63 | + | |
64 | + result = display_post(file) | |
65 | + assert_tag_in_string result, :content => /TO HTML/ | |
66 | + end | |
67 | + | |
68 | + should 'display image if post is an image' do | |
69 | + file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile, :published => true, :parent => blog) | |
70 | + | |
71 | + self.stubs(:params).returns({:npage => nil}) | |
72 | + | |
73 | + result = display_post(file) | |
74 | + assert_tag_in_string result, :content => 'rails.png' | |
75 | + assert_tag_in_string result, :tag => 'img', :attributes => { :src => /#{file.public_filename(:display)}/ } | |
76 | + end | |
77 | + | |
57 | 78 | def will_paginate(arg1, arg2) |
58 | 79 | end |
59 | 80 | ... | ... |