From f0f667bb0323eb47b8eab8c3bd1c53e42e08d623 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Wed, 14 Jan 2015 20:43:41 -0300 Subject: [PATCH] cms-controller: fix media gallery tests --- test/functional/cms_controller_test.rb | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 6b150fb..44ee878 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -1588,44 +1588,19 @@ class CmsControllerTest < ActionController::TestCase end should 'upload media by AJAX' do - post :media_upload, :profile => profile.identifier, :file1 => fixture_file_upload('/files/test.txt', 'text/plain'), :file2 => fixture_file_upload('/files/rails.png', 'image/png'), :file3 => '' - assert_match 'test.txt', @response.body - assert_equal 'text/plain', @response.content_type - - data = parse_json_response - - assert_equal 'test.txt', data[0]['title'] - assert_match /\/testinguser\/test.txt$/, data[0]['url'] - assert_match /text/, data[0]['icon'] - assert_match /text/, data[0]['content_type'] - assert_nil data[0]['error'] - - assert_equal 'rails.png', data[1]['title'] - assert_no_match /\/public\/articles\/.*\/rails.png$/, data[1]['url'] - assert_match /png$/, data[1]['icon'] - assert_match /image/, data[1]['content_type'] - assert_nil data[1]['error'] - + assert_difference 'UploadedFile.count', 1 do + post :media_upload, :format => 'js', :profile => profile.identifier, :file => fixture_file_upload('/files/test.txt', 'text/plain') + end end should 'not when media upload via AJAX contains empty files' do post :media_upload, :profile => @profile.identifier end - should 'mark unsuccessfull uploads' do + should 'mark unsuccessfull upload' do file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('files/rails.png', 'image/png')) - - post :media_upload, :profile => profile.identifier, :media_listing => true, :file1 => fixture_file_upload('files/rails.png', 'image/png'), :file2 => fixture_file_upload('/files/test.txt', 'text/plain') - - assert_equal 'text/plain', @response.content_type - data = parse_json_response - - assert_equal 'rails.png', data[0]['title'] - assert_not_nil data[0]['error'] - assert_match /rails.png/, data[0]['error'] - - assert_equal 'test.txt', data[1]['title'] - assert_nil data[1]['error'] + post :media_upload, :profile => profile.identifier, :media_listing => true, :file => fixture_file_upload('files/rails.png', 'image/png') + assert_response :bad_request end should 'make RawHTMLArticle available only to environment admins' do -- libgit2 0.21.2