Sha256: 96f53f2017dc97834442e49976b4eea69fdffb535a186d1845eefb55d96a3d7b

Contents?: true

Size: 1.59 KB

Versions: 32

Compression:

Stored size: 1.59 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'
require 'tags_controller'

# Re-raise errors caught by the controller.
class TagsController; def rescue_action(e) raise e end; end

class TagsControllerTest < Test::Unit::TestCase
  def setup
    @controller = TagsController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
    @tag        = Tag.find 1
  end
  
  context "with photo as parent" do
    context "get to :index" do
      setup do
        get :index, :photo_id => 1
      end

      should_assign_to :products
      should_render_template "index"
      should_respond_with :success
      
      should "respond with html" do
        assert_equal 'text/html', @response.content_type
      end
    end
    
    context "xhr to :index" do
      setup do
        xhr :get, :index, :photo_id => 1
      end

      should_assign_to :products
      should_respond_with :success

      should "respond with rjs" do
        assert_equal 'text/javascript', @response.content_type
      end
    end
    
    context "post to create" do
      setup do
        post :create, :photo_id => 1, :tag => {:name => "Hello!"}
      end

      should "add tag to photo" do
        assert assigns(:photo).tags.include?(assigns(:tag)), "photo does not include new tag"
      end
    end
  end
  
  context "without photo as parent" do
    should_be_restful do |resource|
      resource.formats = [:html]
    end
    
    should "render text for a missing object" do
      get :show, :id => 50000
      assert @response.body.match(/not found/i), @response.body
    end
  end
end

Version data entries

32 entries across 32 versions & 8 rubygems

Version Path
akitaonrails-resource_controller-0.5.2 test/test/functional/tags_controller_test.rb
akitaonrails-resource_controller-0.5.3 test/test/functional/tags_controller_test.rb
giraffesoft-resource_controller-0.4.10 test/test/functional/tags_controller_test.rb
giraffesoft-resource_controller-0.4.12 test/test/functional/tags_controller_test.rb
giraffesoft-resource_controller-0.4.9 test/test/functional/tags_controller_test.rb
giraffesoft-resource_controller-0.5.2 test/test/functional/tags_controller_test.rb
giraffesoft-resource_controller-0.5.3 test/test/functional/tags_controller_test.rb
korin-resource_controller-0.5.3 test/test/functional/tags_controller_test.rb
nileshtrivedi-lp_resource_builder-0.5.1 test/test/functional/tags_controller_test.rb
nileshtrivedi-lp_resource_builder-0.5.3 test/test/functional/tags_controller_test.rb
nileshtrivedi-safe_resource-0.5.3 test/test/functional/tags_controller_test.rb
pager-resource_controller-1.0.20080513 test/test/functional/tags_controller_test.rb
spree-0.11.4 vendor/plugins/resource_controller/test/test/functional/tags_controller_test.rb
spree-0.11.3 vendor/plugins/resource_controller/test/test/functional/tags_controller_test.rb
spree-0.8.4 vendor/plugins/resource_controller/test/test/functional/tags_controller_test.rb
spree-0.8.5 vendor/plugins/resource_controller/test/test/functional/tags_controller_test.rb
resource_controller-0.4.9 test/test/functional/tags_controller_test.rb
resource_controller-0.5.1 test/test/functional/tags_controller_test.rb
resource_controller-0.5.2 test/test/functional/tags_controller_test.rb
resource_controller-0.5.3 test/test/functional/tags_controller_test.rb