Permalink
Browse files

Add a test for file uploads

  • Loading branch information...
1 parent bd01189 commit 36fe67b30f477186ae179347ecdd10a7d11f21c2 Cody Fauser committed Sep 23, 2009
Showing with 18 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. BIN test/fixtures/files/element58.jpg
  3. +16 −0 test/functional/posts_controller_test.rb
View
@@ -18,3 +18,5 @@ recaptcha.yml
db/*.sqlite3
config/ultrasphinx/*.conf
+
+public/files
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -121,5 +121,21 @@ def test_destroy
assert_response :redirect
assert_equal count -1, Post.count
end
+
+ def test_post_with_file_upload
+
+ # Creates the image and a thumbnail
+ assert_difference "Image.count", 2 do
+ post :create,
+ :category_id => categories(:first),
+ :topic => posts(:first),
+ :comment => { :body => "My shop is broken, please fix!" },
+ :image => {
+ :uploaded_data => ActionController::TestUploadedFile.new(ActionController::TestCase.fixture_path + '/files/element58.jpg', 'image/jpg')
+ }
+
+ assert_response :redirect
+ end
+ end
end

0 comments on commit 36fe67b

Please sign in to comment.