Commit f0f667bb0323eb47b8eab8c3bd1c53e42e08d623

Authored by Rodrigo Souto
1 parent fb2821eb

cms-controller: fix media gallery tests

Showing 1 changed file with 6 additions and 31 deletions   Show diff stats
test/functional/cms_controller_test.rb
... ... @@ -1588,44 +1588,19 @@ class CmsControllerTest < ActionController::TestCase
1588 1588 end
1589 1589  
1590 1590 should 'upload media by AJAX' do
1591   - 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 => ''
1592   - assert_match 'test.txt', @response.body
1593   - assert_equal 'text/plain', @response.content_type
1594   -
1595   - data = parse_json_response
1596   -
1597   - assert_equal 'test.txt', data[0]['title']
1598   - assert_match /\/testinguser\/test.txt$/, data[0]['url']
1599   - assert_match /text/, data[0]['icon']
1600   - assert_match /text/, data[0]['content_type']
1601   - assert_nil data[0]['error']
1602   -
1603   - assert_equal 'rails.png', data[1]['title']
1604   - assert_no_match /\/public\/articles\/.*\/rails.png$/, data[1]['url']
1605   - assert_match /png$/, data[1]['icon']
1606   - assert_match /image/, data[1]['content_type']
1607   - assert_nil data[1]['error']
1608   -
  1591 + assert_difference 'UploadedFile.count', 1 do
  1592 + post :media_upload, :format => 'js', :profile => profile.identifier, :file => fixture_file_upload('/files/test.txt', 'text/plain')
  1593 + end
1609 1594 end
1610 1595  
1611 1596 should 'not when media upload via AJAX contains empty files' do
1612 1597 post :media_upload, :profile => @profile.identifier
1613 1598 end
1614 1599  
1615   - should 'mark unsuccessfull uploads' do
  1600 + should 'mark unsuccessfull upload' do
1616 1601 file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('files/rails.png', 'image/png'))
1617   -
1618   - 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')
1619   -
1620   - assert_equal 'text/plain', @response.content_type
1621   - data = parse_json_response
1622   -
1623   - assert_equal 'rails.png', data[0]['title']
1624   - assert_not_nil data[0]['error']
1625   - assert_match /rails.png/, data[0]['error']
1626   -
1627   - assert_equal 'test.txt', data[1]['title']
1628   - assert_nil data[1]['error']
  1602 + post :media_upload, :profile => profile.identifier, :media_listing => true, :file => fixture_file_upload('files/rails.png', 'image/png')
  1603 + assert_response :bad_request
1629 1604 end
1630 1605  
1631 1606 should 'make RawHTMLArticle available only to environment admins' do
... ...