Sha256: e88b4ea267e4ff25e085049f6b204541e794774f7e8294a04685296fe118aa31

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

class TagsControllerTest < ActionController::TestCase
  def setup
    @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 "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

10 entries across 10 versions & 3 rubygems

Version Path
resources_controller-1.0.4 test/test/functional/tags_controller_test.rb
resources_controller-1.0.3 test/test/functional/tags_controller_test.rb
resources_controller-1.0.2 test/test/functional/tags_controller_test.rb
makandra_resource_controller-0.7.3 test/test/functional/tags_controller_test.rb
makandra_resource_controller-0.7.2 test/test/functional/tags_controller_test.rb
rd_resource_controller-1.0.1 test/test/functional/tags_controller_test.rb
rd_resource_controller-1.0.0 test/test/functional/tags_controller_test.rb
makandra_resource_controller-0.7.1 test/test/functional/tags_controller_test.rb
makandra_resource_controller-0.7.0 test/test/functional/tags_controller_test.rb
rd_resource_controller-1.0.0.rc test/test/functional/tags_controller_test.rb