Sha256: 848dc0ba4b569ffc70649a7e04fcec2aeebf74a1ca1d2197c9122ab46b128f9d

Contents?: true

Size: 1.88 KB

Versions: 15

Compression:

Stored size: 1.88 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
require 'admin/images_controller'

class Admin::ImagesController; def rescue_action(e) raise e end; end

class ImagesControllerTest < ActionController::TestCase

  fixtures :users, :images

  def setup
    @controller = Admin::ImagesController.new
    users(:quentin).add_role(:refinery)
    login_as(:quentin)
  end

  def test_should_get_index
    get :index
    assert_response :success
    assert_not_nil assigns(:images)
    assert_equal assigns(:images).size, Image.count
  end

  def test_new_image_form
    get :new
    assert_not_nil assigns(:image)
    assert_not_nil assigns(:url_override)
  end

  def test_should_require_login_and_redirect
    logout

    get :index
    assert_response :redirect
    assert_nil assigns(:images)
  end

  def test_edit
    get :edit, :id => images(:the_world).id

    assert_response :success

    assert_not_nil assigns(:image)
    assert_equal images(:the_world), assigns(:image)
  end

  def test_insert
    get :insert

    assert_not_nil assigns(:image)
    assert_not_nil assigns(:url_override)
  end

  def test_update
    put :update, :id => images(:the_world).id, :image => {}
    assert_redirected_to admin_images_path
  end

  def test_create_with_errors
    post :create # didn't provide an image to upload
    assert_not_nil assigns(:image)
    assert_response :success
  end

  def test_successful_create
    # This needs to be sorted out yet. I'm not sure how to upload
    # a file through tests

    # assert_difference('Image.count', +1) do
    #   post :create, :post => {} # didn't provide an image to upload
    #   assert_not_nil assigns(:image)
    #   assert_redirected_to admin_images_path
    # end
  end

  def test_destroy
    assert_difference('Image.count', -1) do
      delete :destroy, :id => images(:the_world).id
    end

    assert_redirected_to admin_images_path
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
refinerycms-0.9.7.15 test/functional/images_controller_test.rb
refinerycms-0.9.7.14 test/functional/images_controller_test.rb
refinerycms-0.9.7.13 test/functional/images_controller_test.rb
refinerycms-0.9.7.11 test/functional/images_controller_test.rb
refinerycms-0.9.7.10 test/functional/images_controller_test.rb
refinerycms-0.9.7.9 test/functional/images_controller_test.rb
refinerycms-0.9.7.8 test/functional/images_controller_test.rb
refinerycms-0.9.7.7 test/functional/images_controller_test.rb
refinerycms-0.9.7.6 test/functional/images_controller_test.rb
refinerycms-0.9.7.5 test/functional/images_controller_test.rb
refinerycms-0.9.7.4 test/functional/images_controller_test.rb
refinerycms-0.9.7.3 test/functional/images_controller_test.rb
refinerycms-0.9.7.2 test/functional/images_controller_test.rb
refinerycms-0.9.7.1 test/functional/images_controller_test.rb
refinerycms-0.9.7 test/functional/images_controller_test.rb