mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-23 09:16:10 +01:00
Upgraded to Rails 2.1. This can have wide ranging consequences, so please help track down any issues introduced by the upgrade. Requires environment.rb modifications.
Changes you will need to make: * In your environment.rb, you will need to update references to a few files per environment.rb.tmpl * In your environment.rb, you will need to specify the local time zone of the computer that is running your Tracks install. Other notes on my changes: * Modified our code to take advantage of Rails 2.1's slick time zone support. * Upgraded will_paginate for compatibility * Hacked the Selenium on Rails plugin, which has not been updated in some time and does not support Rails 2.1 * Verified that all tests pass on my machine, including Selenium tests -- I'd like confirmation from others, too.
This commit is contained in:
parent
f3bae73868
commit
901a58f8a3
1086 changed files with 51452 additions and 19526 deletions
|
|
@ -1,4 +1,4 @@
|
|||
require File.dirname(__FILE__) + '/../abstract_unit'
|
||||
require 'abstract_unit'
|
||||
|
||||
ActionController::UrlRewriter
|
||||
|
||||
|
|
@ -149,27 +149,91 @@ class UrlWriterTests < Test::Unit::TestCase
|
|||
)
|
||||
end
|
||||
|
||||
def test_named_route
|
||||
def test_trailing_slash
|
||||
add_host!
|
||||
options = {:controller => 'foo', :trailing_slash => true, :action => 'bar', :id => '33'}
|
||||
assert_equal('http://www.basecamphq.com/foo/bar/33/', W.new.url_for(options) )
|
||||
end
|
||||
|
||||
def test_trailing_slash_with_protocol
|
||||
add_host!
|
||||
options = { :trailing_slash => true,:protocol => 'https', :controller => 'foo', :action => 'bar', :id => '33'}
|
||||
assert_equal('https://www.basecamphq.com/foo/bar/33/', W.new.url_for(options) )
|
||||
assert_equal 'https://www.basecamphq.com/foo/bar/33/?query=string', W.new.url_for(options.merge({:query => 'string'}))
|
||||
end
|
||||
|
||||
def test_trailing_slash_with_only_path
|
||||
options = {:controller => 'foo', :trailing_slash => true}
|
||||
assert_equal '/foo/', W.new.url_for(options.merge({:only_path => true}))
|
||||
options.update({:action => 'bar', :id => '33'})
|
||||
assert_equal '/foo/bar/33/', W.new.url_for(options.merge({:only_path => true}))
|
||||
assert_equal '/foo/bar/33/?query=string', W.new.url_for(options.merge({:query => 'string',:only_path => true}))
|
||||
end
|
||||
|
||||
def test_trailing_slash_with_anchor
|
||||
options = {:trailing_slash => true, :controller => 'foo', :action => 'bar', :id => '33', :only_path => true, :anchor=> 'chapter7'}
|
||||
assert_equal '/foo/bar/33/#chapter7', W.new.url_for(options)
|
||||
assert_equal '/foo/bar/33/?query=string#chapter7', W.new.url_for(options.merge({:query => 'string'}))
|
||||
end
|
||||
|
||||
def test_trailing_slash_with_params
|
||||
url = W.new.url_for(:trailing_slash => true, :only_path => true, :controller => 'cont', :action => 'act', :p1 => 'cafe', :p2 => 'link')
|
||||
params = extract_params(url)
|
||||
assert_equal params[0], { :p1 => 'cafe' }.to_query
|
||||
assert_equal params[1], { :p2 => 'link' }.to_query
|
||||
end
|
||||
|
||||
def test_relative_url_root_is_respected
|
||||
orig_relative_url_root = ActionController::AbstractRequest.relative_url_root
|
||||
ActionController::AbstractRequest.relative_url_root = '/subdir'
|
||||
|
||||
add_host!
|
||||
assert_equal('https://www.basecamphq.com/subdir/c/a/i',
|
||||
W.new.url_for(:controller => 'c', :action => 'a', :id => 'i', :protocol => 'https')
|
||||
)
|
||||
ensure
|
||||
ActionController::AbstractRequest.relative_url_root = orig_relative_url_root
|
||||
end
|
||||
|
||||
def test_named_routes
|
||||
ActionController::Routing::Routes.draw do |map|
|
||||
map.no_args '/this/is/verbose', :controller => 'home', :action => 'index'
|
||||
map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index'
|
||||
map.connect ':controller/:action/:id'
|
||||
end
|
||||
|
||||
|
||||
# We need to create a new class in order to install the new named route.
|
||||
kls = Class.new { include ActionController::UrlWriter }
|
||||
controller = kls.new
|
||||
assert controller.respond_to?(:home_url)
|
||||
assert_equal 'http://www.basecamphq.com/home/sweet/home/again',
|
||||
controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again')
|
||||
|
||||
|
||||
assert_equal("/home/sweet/home/alabama", controller.send(:home_path, :user => 'alabama', :host => 'unused'))
|
||||
assert_equal("http://www.basecamphq.com/home/sweet/home/alabama", controller.send(:home_url, :user => 'alabama', :host => 'www.basecamphq.com'))
|
||||
assert_equal("http://www.basecamphq.com/this/is/verbose", controller.send(:no_args_url, :host=>'www.basecamphq.com'))
|
||||
ensure
|
||||
ActionController::Routing::Routes.load!
|
||||
end
|
||||
|
||||
|
||||
def test_relative_url_root_is_respected_for_named_routes
|
||||
orig_relative_url_root = ActionController::AbstractRequest.relative_url_root
|
||||
ActionController::AbstractRequest.relative_url_root = '/subdir'
|
||||
|
||||
ActionController::Routing::Routes.draw do |map|
|
||||
map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index'
|
||||
end
|
||||
|
||||
kls = Class.new { include ActionController::UrlWriter }
|
||||
controller = kls.new
|
||||
|
||||
assert_equal 'http://www.basecamphq.com/subdir/home/sweet/home/again',
|
||||
controller.send(:home_url, :host => 'www.basecamphq.com', :user => 'again')
|
||||
ensure
|
||||
ActionController::Routing::Routes.load!
|
||||
ActionController::AbstractRequest.relative_url_root = orig_relative_url_root
|
||||
end
|
||||
|
||||
def test_only_path
|
||||
ActionController::Routing::Routes.draw do |map|
|
||||
map.home '/home/sweet/home/:user', :controller => 'home', :action => 'index'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue