Sha256: db7947f56783ae53dc14331108f5e248d95a6c024ad19cf3a12317b01d4436dd

Contents?: true

Size: 934 Bytes

Versions: 11

Compression:

Stored size: 934 Bytes

Contents

require 'test_helper'

class Cms::ProductsControllerTest < ActionController::TestCase
  def setup
    @product = products :one
  end

  context "on POST to :create" do
    context "that succeeds" do
      setup do
        post :create, :product => {:name => "My Product"}
      end

      should assign_to(:product).with_kind_of(Product)
      should redirect_to("products page") { cms_product_url(assigns(:product)) }
      should set_the_flash.to "something"

      should "create the record" do
        assert Product.find_by_name("My Product")
      end
    end

    context "that fails" do
      setup do
        Product.any_instance.stubs(:save).returns(false)
        post :create, :product => {}
      end

      should assign_to(:product).with_kind_of(Product)
      should respond_with :success
      should render_with_layout :application
      should render_template :new
      should_not set_the_flash
    end
  end

end

Version data entries

11 entries across 11 versions & 3 rubygems

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