mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-10 01:24:19 +01:00
Updated to svn tags/tracks-1.6
This commit is contained in:
parent
103fcb8049
commit
02496f2d44
2274 changed files with 0 additions and 0 deletions
52
vendor/plugins/simply_helpful/test/controller_extensions_test.rb
vendored
Normal file
52
vendor/plugins/simply_helpful/test/controller_extensions_test.rb
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
require File.dirname(__FILE__) + '/test_helper'
|
||||
require 'ostruct'
|
||||
|
||||
class RedirectionTestingController < ActionController::Base
|
||||
class MockResponse
|
||||
attr_accessor :redirected_to
|
||||
|
||||
def redirect(_)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def initialize
|
||||
super
|
||||
@response = MockResponse.new
|
||||
@request = OpenStruct.new
|
||||
@request.protocol= "http://"
|
||||
@request.host_with_port= "www.example.com"
|
||||
end
|
||||
|
||||
def response
|
||||
@response
|
||||
end
|
||||
|
||||
def request
|
||||
@request
|
||||
end
|
||||
|
||||
def post_url(p)
|
||||
"/posts/#{p.id}"
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
class ControllerExtensionsTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@record = Post.new
|
||||
@record.save
|
||||
@controller = RedirectionTestingController.new
|
||||
end
|
||||
|
||||
def test_redirect_to_record
|
||||
@controller.send :redirect_to, @record
|
||||
assert_equal "http://www.example.com/posts/1", @controller.response.redirected_to
|
||||
end
|
||||
|
||||
def test_redirect_to_string
|
||||
@controller.send :redirect_to, "http://www.yahoo.com"
|
||||
assert_equal "http://www.yahoo.com", @controller.response.redirected_to
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue