Sha256: 4f67bf27e4a7cc1dac387d62506b391c7897472df9842ec14303d6aa6d17cdd3

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

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

class Machine;
  def self.human_name; 'Machine'; end
end

class MachinesController < InheritedResources::Base

  def create
    create!('http://test.host/')
  end

  def update
    update!('http://test.host/')
  end

  def destroy
    destroy!('http://test.host/')
  end

end

class RedirectToTest < ActionController::TestCase
  tests MachinesController

  def test_redirect_to_the_given_url_on_create
    Machine.stubs(:new).returns(mock_machine(:save => true))
    @controller.expects(:resource_url).times(0)
    post :create
    assert_redirected_to 'http://test.host/'
  end

  def test_redirect_to_the_given_url_on_update
    Machine.stubs(:find).returns(mock_machine(:update_attributes => true))
    @controller.expects(:resource_url).times(0)
    put :update
    assert_redirected_to 'http://test.host/'
  end

  def test_redirect_to_the_given_url_on_destroy
    Machine.stubs(:find).returns(mock_machine(:destroy => true))
    @controller.expects(:collection_url).times(0)
    put :destroy
    assert_redirected_to 'http://test.host/'
  end

  protected
    def mock_machine(stubs={})
      @mock_machine ||= mock(stubs)
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
josevalim-inherited_resources-0.6.0 test/redirect_to_test.rb
josevalim-inherited_resources-0.6.1 test/redirect_to_test.rb
josevalim-inherited_resources-0.6.2 test/redirect_to_test.rb
josevalim-inherited_resources-0.6.3 test/redirect_to_test.rb
josevalim-inherited_resources-0.7.0 test/redirect_to_test.rb
josevalim-inherited_resources-0.7.1 test/redirect_to_test.rb