Sha256: 5f76d885816550c1cb17382e470e485beb743955e82545abea71f85ba72e1ad1

Contents?: true

Size: 1.29 KB

Versions: 9

Compression:

Stored size: 1.29 KB

Contents

require 'test_helper'

ActionController::Base.extend Responders::ControllerMethod

module FooResponder
  def to_html
    @resource << "foo"
    super
  end
end

module BarResponder
  def to_html
    @resource << "bar"
    super
  end
end

module PeopleResponder
  def to_html
    @resource << "baz"
    super
  end
end

class PeopleController < ApplicationController
  responders :foo, BarResponder

  def index
    @array = []
    respond_with(@array) do |format|
      format.html { render :text => "Success!" }
    end
  end
end

class SpecialPeopleController < PeopleController
  responders :people
end

class ControllerMethodTest < ActionController::TestCase
  tests PeopleController

  def setup
    @controller.stubs(:polymorphic_url).returns("/")
  end

  def test_foo_responder_gets_added
    get :index
    assert assigns(:array).include? "foo"
  end

  def test_bar_responder_gets_added
    get :index
    assert assigns(:array).include? "bar"
  end
end

class ControllerMethodInheritanceTest < ActionController::TestCase
  tests SpecialPeopleController

  def setup
    @controller.stubs(:polymorphic_url).returns("/")
  end

  def test_responder_is_inherited
    get :index
    assert assigns(:array).include? "foo"
    assert assigns(:array).include? "bar"
    assert assigns(:array).include? "baz"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
responders-1.1.2 test/controller_method_test.rb
responders-2.0.1 test/responders/controller_method_test.rb
responders-1.1.1 test/controller_method_test.rb
responders-2.0.0 test/responders/controller_method_test.rb
responders-1.1.0 test/controller_method_test.rb
responders-1.0.0 test/controller_method_test.rb
responders-1.0.0.rc test/controller_method_test.rb
responders-0.9.3 test/controller_method_test.rb
responders-0.9.2 test/controller_method_test.rb