Sha256: 9adaa3fa5dacef07f00161e81cad3268d340c10e07bd191c643d8250f60908e3

Contents?: true

Size: 1.86 KB

Versions: 29

Compression:

Stored size: 1.86 KB

Contents

require 'test/helper'

##
# Test polimorphic relationships using the relate & unrelate actions.
#
class Admin::AssetsControllerTest < ActionController::TestCase

  def setup
    typus_user = typus_users(:admin)
    @request.session[:typus_user_id] = typus_user.id
  end

  def test_should_test_polymorphic_relationship_message
    post_ = posts(:published)
    get :new, { :back_to => "/admin/posts/#{post_.id}/edit", :resource => post_.class.name, :resource_id => post_.id }
    assert_match "You're adding a new Asset to Post.", @response.body
  end

  def test_should_create_a_polymorphic_relationship

    post_ = posts(:published)

    assert_difference('post_.assets.count') do
      post :create, { :back_to => "/admin/posts/edit/#{post_.id}", :resource => post_.class.name, :resource_id => post_.id }
    end

    assert_response :redirect
    assert_redirected_to '/admin/posts/edit/1#assets'
    assert flash[:success]
    assert_equal 'Asset successfully assigned to Post.', flash[:success]

  end

  def test_should_test_polymorphic_relationship_edit_message
    post_ = posts(:published)
    asset_ = assets(:first)
    get :edit, { :id => asset_.id, :back_to => "/admin/posts/#{post_.id}/edit", :resource => post_.class.name, :resource_id => post_.id }
    assert_match "You're updating a Asset for Post.", @response.body
  end

  def test_should_return_to_back_to_url

    options = Typus::Configuration.options.merge(:index_after_save => true)
    Typus::Configuration.stubs(:options).returns(options)

    post_ = posts(:published)
    asset_ = assets(:first)

    post :update, { :back_to => "/admin/posts/#{post_.id}/edit", :resource => post_.class.name, :resource_id => post_.id, :id => asset_.id }
    assert_response :redirect
    assert_redirected_to '/admin/posts/1/edit#assets'
    assert flash[:success]
    assert_equal 'Asset successfully updated.', flash[:success]

  end

end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
fesplugas-typus-0.9.0 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.1 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.10 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.11 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.12 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.13 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.14 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.15 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.16 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.17 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.2 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.3 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.4 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.5 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.6 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.7 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.8 test/functional/admin/assets_controller_test.rb
fesplugas-typus-0.9.9 test/functional/admin/assets_controller_test.rb
typus-0.9.27 test/functional/admin/assets_controller_test.rb
typus-0.9.26 test/functional/admin/assets_controller_test.rb