Sha256: 48962a31ffeedaa9ae399825751949b28b9942f272f1307d0e743dfc93149a2e

Contents?: true

Size: 1.79 KB

Versions: 31

Compression:

Stored size: 1.79 KB

Contents

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

class FailableActionOptionsTest < Test::Unit::TestCase
  def setup
    @controller = PostsController.new
    @create = ResourceController::FailableActionOptions.new
  end
  
  should "have success and fails" do
    assert ResourceController::ActionOptions, @create.success.class
    assert ResourceController::ActionOptions, @create.fails.class
  end
  
  %w(before).each do |accessor|
    should "have a block accessor for #{accessor}" do
      @create.send(accessor) do
        "return_something"
      end
    
      assert_equal "return_something", @create.send(accessor).first.call(nil)
    end
  end
  
  should "delegate flash to success" do
    @create.flash "Successfully created."
    assert_equal "Successfully created.", @create.success.flash
  end
  
  should "delegate after to success" do
    @create.after do
      "something"
    end
    
    assert_equal "something", @create.success.after.first.call
  end
  
  should "delegate response to success" do
    @create.response do |wants|
      wants.html
    end
    
    assert @create.wants[:html]
  end
  
  should "delegate wants to success" do
    @create.wants.html
    
    assert @create.wants[:html]
  end
  
  context "duplication" do
    setup do
      @opts = ResourceController::FailableActionOptions.new
      @opts.wants.js
      @opts.failure.wants.js
      @opts.before {}
      
      @dup = @opts.dup
    end

    should "duplicate success" do
      assert !@dup.success.equal?(@opts.success)
      assert @dup.success.wants[:js]
    end
    
    should "duplicate failure" do
      assert !@dup.failure.equal?(@opts.failure)
      assert @dup.failure.wants[:js]
    end
    
    should "duplicate before" do
      assert !@dup.before.equal?(@opts.before)
      assert @dup.before
    end
  end
  
end

Version data entries

31 entries across 31 versions & 7 rubygems

Version Path
akitaonrails-resource_controller-0.5.2 test/test/unit/failable_action_options_test.rb
akitaonrails-resource_controller-0.5.3 test/test/unit/failable_action_options_test.rb
giraffesoft-resource_controller-0.4.10 test/test/unit/failable_action_options_test.rb
giraffesoft-resource_controller-0.4.12 test/test/unit/failable_action_options_test.rb
giraffesoft-resource_controller-0.4.9 test/test/unit/failable_action_options_test.rb
giraffesoft-resource_controller-0.5.2 test/test/unit/failable_action_options_test.rb
giraffesoft-resource_controller-0.5.3 test/test/unit/failable_action_options_test.rb
korin-resource_controller-0.5.3 test/test/unit/failable_action_options_test.rb
nileshtrivedi-lp_resource_builder-0.5.1 test/test/unit/failable_action_options_test.rb
nileshtrivedi-lp_resource_builder-0.5.3 test/test/unit/failable_action_options_test.rb
nileshtrivedi-safe_resource-0.5.3 test/test/unit/failable_action_options_test.rb
spree-0.11.4 vendor/plugins/resource_controller/test/test/unit/failable_action_options_test.rb
spree-0.11.3 vendor/plugins/resource_controller/test/test/unit/failable_action_options_test.rb
spree-0.8.4 vendor/plugins/resource_controller/test/test/unit/failable_action_options_test.rb
spree-0.8.5 vendor/plugins/resource_controller/test/test/unit/failable_action_options_test.rb
resource_controller-0.4.9 test/test/unit/failable_action_options_test.rb
resource_controller-0.5.3 test/test/unit/failable_action_options_test.rb
resource_controller-0.5.2 test/test/unit/failable_action_options_test.rb
resource_controller-0.5.1 test/test/unit/failable_action_options_test.rb
resource_controller-0.5.0 test/test/unit/failable_action_options_test.rb