*************** *** 35,41 **** def setup @library_url = ActionController::UrlRewriter.old_new(MockRequest.new( "http://", - "www.singlefile.com", 80, "/library/books/ISBN/0743536703/show", { "type" => "ISBN", "code" => "0743536703" } --- 35,41 ---- def setup @library_url = ActionController::UrlRewriter.old_new(MockRequest.new( "http://", + "www.example.com", 80, "/library/books/ISBN/0743536703/show", { "type" => "ISBN", "code" => "0743536703" } *************** *** 43,49 **** @library_url_using_module = ActionController::UrlRewriter.old_new(MockRequest.new( "http://", - "www.singlefile.com", 80, "/library/books/ISBN/0743536703/show", { "type" => "ISBN", "code" => "0743536703", "module" => "library" } --- 43,49 ---- @library_url_using_module = ActionController::UrlRewriter.old_new(MockRequest.new( "http://", + "www.example.com", 80, "/library/books/ISBN/0743536703/show", { "type" => "ISBN", "code" => "0743536703", "module" => "library" } *************** *** 51,57 **** @library_url_on_index = ActionController::UrlRewriter.old_new(MockRequest.new( "http://", - "www.singlefile.com", 80, "/library/books/ISBN/0743536703/", { "type" => "ISBN", "code" => "0743536703" } --- 51,57 ---- @library_url_on_index = ActionController::UrlRewriter.old_new(MockRequest.new( "http://", + "www.example.com", 80, "/library/books/ISBN/0743536703/", { "type" => "ISBN", "code" => "0743536703" } *************** *** 59,103 **** @clean_urls = [ ActionController::UrlRewriter.old_new(MockRequest.new( - "http://", "www.singlefile.com", 80, "/identity/", {} ), "identity", "index"), ActionController::UrlRewriter.old_new(MockRequest.new( - "http://", "www.singlefile.com", 80, "/identity", {} ), "identity", "index") ] @clean_url_with_id = ActionController::UrlRewriter.old_new(MockRequest.new( - "http://", "www.singlefile.com", 80, "/identity/show/5", { "id" => "5" } ), "identity", "show") @clean_url_with_same_action_and_controller_name = ActionController::UrlRewriter.old_new(MockRequest.new( - "http://", "www.singlefile.com", 80, "/login/login", { } ), "login", "login") @clean_url_with_same_action_and_controller_and_module_name = ActionController::UrlRewriter.old_new(MockRequest.new( - "http://", "www.singlefile.com", 80, "/login/login/login", { "module" => "login" } ), "login", "login") @clean_url_with_id_as_char = ActionController::UrlRewriter.old_new(MockRequest.new( - "http://", "www.singlefile.com", 80, "/teachers/show/t", { "id" => "t" } ), "teachers", "show") end def test_clean_action - assert_equal "http://www.singlefile.com/library/books/ISBN/0743536703/edit", @library_url.rewrite(:action => "edit") end def test_clean_action_to_another_host assert_equal( - "http://www.booksphere.com/library/books/ISBN/0743536703/edit", - @library_url.rewrite(:action => "edit", :host => "www.booksphere.com") ) end def test_clean_action_to_another_host_and_protocol assert_equal( - "https://www.booksphere.com/library/books/ISBN/0743536703/edit", - @library_url.rewrite(:action => "edit", :host => "www.booksphere.com", :protocol => "https://") ) end --- 59,103 ---- @clean_urls = [ ActionController::UrlRewriter.old_new(MockRequest.new( + "http://", "www.example.com", 80, "/identity/", {} ), "identity", "index"), ActionController::UrlRewriter.old_new(MockRequest.new( + "http://", "www.example.com", 80, "/identity", {} ), "identity", "index") ] @clean_url_with_id = ActionController::UrlRewriter.old_new(MockRequest.new( + "http://", "www.example.com", 80, "/identity/show/5", { "id" => "5" } ), "identity", "show") @clean_url_with_same_action_and_controller_name = ActionController::UrlRewriter.old_new(MockRequest.new( + "http://", "www.example.com", 80, "/login/login", { } ), "login", "login") @clean_url_with_same_action_and_controller_and_module_name = ActionController::UrlRewriter.old_new(MockRequest.new( + "http://", "www.example.com", 80, "/login/login/login", { "module" => "login" } ), "login", "login") @clean_url_with_id_as_char = ActionController::UrlRewriter.old_new(MockRequest.new( + "http://", "www.example.com", 80, "/teachers/show/t", { "id" => "t" } ), "teachers", "show") end def test_clean_action + assert_equal "http://www.example.com/library/books/ISBN/0743536703/edit", @library_url.rewrite(:action => "edit") end def test_clean_action_to_another_host assert_equal( + "http://www.example.com/library/books/ISBN/0743536703/edit", + @library_url.rewrite(:action => "edit", :host => "www.example.com") ) end def test_clean_action_to_another_host_and_protocol assert_equal( + "https://www.example.com/library/books/ISBN/0743536703/edit", + @library_url.rewrite(:action => "edit", :host => "www.example.com", :protocol => "https://") ) end *************** *** 106,246 **** end def test_action_from_index - assert_equal "http://www.singlefile.com/library/books/ISBN/0743536703/edit", @library_url_on_index.rewrite(:action => "edit") end def test_action_from_index_on_clean @clean_urls.each do |url| - assert_equal "http://www.singlefile.com/identity/edit", url.rewrite(:action => "edit") end end def test_action_without_prefix - assert_equal "http://www.singlefile.com/library/books/", @library_url.rewrite(:action => "index", :action_prefix => "") end def test_action_with_prefix assert_equal( - "http://www.singlefile.com/library/books/XTC/123/show", @library_url.rewrite(:action => "show", :action_prefix => "XTC/123") ) end def test_action_prefix_alone assert_equal( - "http://www.singlefile.com/library/books/XTC/123/", @library_url.rewrite(:action_prefix => "XTC/123") ) end def test_action_with_suffix assert_equal( - "http://www.singlefile.com/library/books/show/XTC/123", @library_url.rewrite(:action => "show", :action_prefix => "", :action_suffix => "XTC/123") ) end def test_clean_controller - assert_equal "http://www.singlefile.com/library/settings/", @library_url.rewrite(:controller => "settings") end def test_clean_controller_prefix - assert_equal "http://www.singlefile.com/shop/", @library_url.rewrite(:controller_prefix => "shop") end def test_clean_controller_with_module - assert_equal "http://www.singlefile.com/shop/purchases/", @library_url.rewrite(:module => "shop", :controller => "purchases") end def test_getting_out_of_a_module - assert_equal "http://www.singlefile.com/purchases/", @library_url_using_module.rewrite(:module => false, :controller => "purchases") end def test_controller_and_action - assert_equal "http://www.singlefile.com/library/settings/show", @library_url.rewrite(:controller => "settings", :action => "show") end def test_controller_and_action_and_anchor assert_equal( - "http://www.singlefile.com/library/settings/show#5", @library_url.rewrite(:controller => "settings", :action => "show", :anchor => "5") ) end def test_controller_and_action_and_empty_overwrite_params_and_anchor assert_equal( - "http://www.singlefile.com/library/settings/show?code=0743536703&type=ISBN#5", @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {}, :anchor => "5") ) end def test_controller_and_action_and_overwrite_params_and_anchor assert_equal( - "http://www.singlefile.com/library/settings/show?code=0000001&type=ISBN#5", @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {"code"=>"0000001"}, :anchor => "5") ) end def test_controller_and_action_and_overwrite_params_with_nil_value_and_anchor assert_equal( - "http://www.singlefile.com/library/settings/show?type=ISBN#5", @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {"code" => nil}, :anchor => "5") ) end def test_controller_and_action_params_and_overwrite_params_and_anchor assert_equal( - "http://www.singlefile.com/library/settings/show?code=0000001&version=5.0#5", @library_url.rewrite(:controller => "settings", :action => "show", :params=>{"version" => "5.0"}, :overwrite_params => {"code"=>"0000001"}, :anchor => "5") ) end def test_controller_and_action_and_params_anchor assert_equal( - "http://www.singlefile.com/library/settings/show?update=1#5", @library_url.rewrite(:controller => "settings", :action => "show", :params => { "update" => "1"}, :anchor => "5") ) end def test_controller_and_index_action - assert_equal "http://www.singlefile.com/library/settings/", @library_url.rewrite(:controller => "settings", :action => "index") end def test_same_controller_and_action_names - assert_equal "http://www.singlefile.com/login/logout", @clean_url_with_same_action_and_controller_name.rewrite(:action => "logout") end def xtest_same_module_and_controller_and_action_names - assert_equal "http://www.singlefile.com/login/login/logout", @clean_url_with_same_action_and_controller_and_module_name.rewrite(:action => "logout") end def test_controller_and_action_with_same_name_as_controller @clean_urls.each do |url| - assert_equal "http://www.singlefile.com/anything/identity", url.rewrite(:controller => "anything", :action => "identity") end end def test_controller_and_index_action_without_controller_prefix assert_equal( - "http://www.singlefile.com/settings/", @library_url.rewrite(:controller => "settings", :action => "index", :controller_prefix => "") ) end def test_controller_and_index_action_with_controller_prefix assert_equal( - "http://www.singlefile.com/fantastic/settings/show", @library_url.rewrite(:controller => "settings", :action => "show", :controller_prefix => "fantastic") ) end def test_path_parameters - assert_equal "http://www.singlefile.com/library/books/EXBC/0743536703/show", @library_url.rewrite(:path_params => {"type" => "EXBC"}) end def test_parameters assert_equal( - "http://www.singlefile.com/library/books/ISBN/0743536703/show?delete=1&name=David", @library_url.rewrite(:params => {"delete" => "1", "name" => "David"}) ) end --- 106,246 ---- end def test_action_from_index + assert_equal "http://www.example.com/library/books/ISBN/0743536703/edit", @library_url_on_index.rewrite(:action => "edit") end def test_action_from_index_on_clean @clean_urls.each do |url| + assert_equal "http://www.example.com/identity/edit", url.rewrite(:action => "edit") end end def test_action_without_prefix + assert_equal "http://www.example.com/library/books/", @library_url.rewrite(:action => "index", :action_prefix => "") end def test_action_with_prefix assert_equal( + "http://www.example.com/library/books/XTC/123/show", @library_url.rewrite(:action => "show", :action_prefix => "XTC/123") ) end def test_action_prefix_alone assert_equal( + "http://www.example.com/library/books/XTC/123/", @library_url.rewrite(:action_prefix => "XTC/123") ) end def test_action_with_suffix assert_equal( + "http://www.example.com/library/books/show/XTC/123", @library_url.rewrite(:action => "show", :action_prefix => "", :action_suffix => "XTC/123") ) end def test_clean_controller + assert_equal "http://www.example.com/library/settings/", @library_url.rewrite(:controller => "settings") end def test_clean_controller_prefix + assert_equal "http://www.example.com/shop/", @library_url.rewrite(:controller_prefix => "shop") end def test_clean_controller_with_module + assert_equal "http://www.example.com/shop/purchases/", @library_url.rewrite(:module => "shop", :controller => "purchases") end def test_getting_out_of_a_module + assert_equal "http://www.example.com/purchases/", @library_url_using_module.rewrite(:module => false, :controller => "purchases") end def test_controller_and_action + assert_equal "http://www.example.com/library/settings/show", @library_url.rewrite(:controller => "settings", :action => "show") end def test_controller_and_action_and_anchor assert_equal( + "http://www.example.com/library/settings/show#5", @library_url.rewrite(:controller => "settings", :action => "show", :anchor => "5") ) end def test_controller_and_action_and_empty_overwrite_params_and_anchor assert_equal( + "http://www.example.com/library/settings/show?code=0743536703&type=ISBN#5", @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {}, :anchor => "5") ) end def test_controller_and_action_and_overwrite_params_and_anchor assert_equal( + "http://www.example.com/library/settings/show?code=0000001&type=ISBN#5", @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {"code"=>"0000001"}, :anchor => "5") ) end def test_controller_and_action_and_overwrite_params_with_nil_value_and_anchor assert_equal( + "http://www.example.com/library/settings/show?type=ISBN#5", @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {"code" => nil}, :anchor => "5") ) end def test_controller_and_action_params_and_overwrite_params_and_anchor assert_equal( + "http://www.example.com/library/settings/show?code=0000001&version=5.0#5", @library_url.rewrite(:controller => "settings", :action => "show", :params=>{"version" => "5.0"}, :overwrite_params => {"code"=>"0000001"}, :anchor => "5") ) end def test_controller_and_action_and_params_anchor assert_equal( + "http://www.example.com/library/settings/show?update=1#5", @library_url.rewrite(:controller => "settings", :action => "show", :params => { "update" => "1"}, :anchor => "5") ) end def test_controller_and_index_action + assert_equal "http://www.example.com/library/settings/", @library_url.rewrite(:controller => "settings", :action => "index") end def test_same_controller_and_action_names + assert_equal "http://www.example.com/login/logout", @clean_url_with_same_action_and_controller_name.rewrite(:action => "logout") end def xtest_same_module_and_controller_and_action_names + assert_equal "http://www.example.com/login/login/logout", @clean_url_with_same_action_and_controller_and_module_name.rewrite(:action => "logout") end def test_controller_and_action_with_same_name_as_controller @clean_urls.each do |url| + assert_equal "http://www.example.com/anything/identity", url.rewrite(:controller => "anything", :action => "identity") end end def test_controller_and_index_action_without_controller_prefix assert_equal( + "http://www.example.com/settings/", @library_url.rewrite(:controller => "settings", :action => "index", :controller_prefix => "") ) end def test_controller_and_index_action_with_controller_prefix assert_equal( + "http://www.example.com/fantastic/settings/show", @library_url.rewrite(:controller => "settings", :action => "show", :controller_prefix => "fantastic") ) end def test_path_parameters + assert_equal "http://www.example.com/library/books/EXBC/0743536703/show", @library_url.rewrite(:path_params => {"type" => "EXBC"}) end def test_parameters assert_equal( + "http://www.example.com/library/books/ISBN/0743536703/show?delete=1&name=David", @library_url.rewrite(:params => {"delete" => "1", "name" => "David"}) ) end *************** *** 248,254 **** def test_parameters_with_id @clean_urls.each do |url| assert_equal( - "http://www.singlefile.com/identity/show?name=David&id=5", url.rewrite( :action => "show", :params => { "id" => "5", "name" => "David" } --- 248,254 ---- def test_parameters_with_id @clean_urls.each do |url| assert_equal( + "http://www.example.com/identity/show?name=David&id=5", url.rewrite( :action => "show", :params => { "id" => "5", "name" => "David" } *************** *** 260,266 **** def test_parameters_with_array @clean_urls.each do |url| assert_equal( - "http://www.singlefile.com/identity/show?id[]=3&id[]=5&id[]=10", url.rewrite( :action => "show", :params => { 'id' => [ 3, 5, 10 ] } ) --- 260,266 ---- def test_parameters_with_array @clean_urls.each do |url| assert_equal( + "http://www.example.com/identity/show?id[]=3&id[]=5&id[]=10", url.rewrite( :action => "show", :params => { 'id' => [ 3, 5, 10 ] } ) *************** *** 270,276 **** def test_action_with_id assert_equal( - "http://www.singlefile.com/identity/show/7", @clean_url_with_id.rewrite( :action => "show", :id => 7 --- 270,276 ---- def test_action_with_id assert_equal( + "http://www.example.com/identity/show/7", @clean_url_with_id.rewrite( :action => "show", :id => 7 *************** *** 278,284 **** ) @clean_urls.each do |url| assert_equal( - "http://www.singlefile.com/identity/index/7", url.rewrite(:id => 7) ) end --- 278,284 ---- ) @clean_urls.each do |url| assert_equal( + "http://www.example.com/identity/index/7", url.rewrite(:id => 7) ) end *************** *** 286,292 **** def test_parameters_with_id_and_away assert_equal( - "http://www.singlefile.com/identity/show/25?name=David", @clean_url_with_id.rewrite( :path_params => { "id" => "25" }, :params => { "name" => "David" } --- 286,292 ---- def test_parameters_with_id_and_away assert_equal( + "http://www.example.com/identity/show/25?name=David", @clean_url_with_id.rewrite( :path_params => { "id" => "25" }, :params => { "name" => "David" } *************** *** 297,303 **** def test_parameters_with_index_and_id @clean_urls.each do |url| assert_equal( - "http://www.singlefile.com/identity/index/25?name=David", url.rewrite( :path_params => { "id" => "25" }, :params => { "name" => "David" } --- 297,303 ---- def test_parameters_with_index_and_id @clean_urls.each do |url| assert_equal( + "http://www.example.com/identity/index/25?name=David", url.rewrite( :path_params => { "id" => "25" }, :params => { "name" => "David" } *************** *** 308,314 **** def test_action_going_away_from_id assert_equal( - "http://www.singlefile.com/identity/list", @clean_url_with_id.rewrite( :action => "list" ) --- 308,314 ---- def test_action_going_away_from_id assert_equal( + "http://www.example.com/identity/list", @clean_url_with_id.rewrite( :action => "list" ) *************** *** 317,323 **** def test_parameters_with_direct_id_and_away assert_equal( - "http://www.singlefile.com/identity/show/25?name=David", @clean_url_with_id.rewrite( :id => "25", :params => { "name" => "David" } --- 317,323 ---- def test_parameters_with_direct_id_and_away assert_equal( + "http://www.example.com/identity/show/25?name=David", @clean_url_with_id.rewrite( :id => "25", :params => { "name" => "David" } *************** *** 327,333 **** def test_parameters_with_direct_id_and_away assert_equal( - "http://www.singlefile.com/store/open/25?name=David", @clean_url_with_id.rewrite( :controller => "store", :action => "open", --- 327,333 ---- def test_parameters_with_direct_id_and_away assert_equal( + "http://www.example.com/store/open/25?name=David", @clean_url_with_id.rewrite( :controller => "store", :action => "open", *************** *** 341,347 **** @clean_urls.each do |url| %w(show index).each do |action| assert_equal( - "http://www.singlefile.com/identity/#{action}/25?name=David", url.rewrite( :action => action, :path_params => { "id" => "25" }, --- 341,347 ---- @clean_urls.each do |url| %w(show index).each do |action| assert_equal( + "http://www.example.com/identity/#{action}/25?name=David", url.rewrite( :action => action, :path_params => { "id" => "25" }, *************** *** 354,360 **** def test_parameters_from_id assert_equal( - "http://www.singlefile.com/identity/", @clean_url_with_id.rewrite( :action => "index" ) --- 354,360 ---- def test_parameters_from_id assert_equal( + "http://www.example.com/identity/", @clean_url_with_id.rewrite( :action => "index" ) *************** *** 363,369 **** def test_id_as_char_and_part_of_controller assert_equal( - "http://www.singlefile.com/teachers/skill/5", @clean_url_with_id_as_char.rewrite( :action => "skill", :id => 5 --- 363,369 ---- def test_id_as_char_and_part_of_controller assert_equal( + "http://www.example.com/teachers/skill/5", @clean_url_with_id_as_char.rewrite( :action => "skill", :id => 5 *************** *** 374,380 **** def test_from_clean_to_library @clean_urls.each do |url| assert_equal( - "http://www.singlefile.com/library/books/ISBN/0743536703/show?delete=1&name=David", url.rewrite( :controller_prefix => "library", :controller => "books", --- 374,380 ---- def test_from_clean_to_library @clean_urls.each do |url| assert_equal( + "http://www.example.com/library/books/ISBN/0743536703/show?delete=1&name=David", url.rewrite( :controller_prefix => "library", :controller => "books", *************** *** 388,394 **** def test_from_library_to_clean assert_equal( - "http://www.singlefile.com/identity/", @library_url.rewrite( :controller => "identity", :controller_prefix => "" ) --- 388,394 ---- def test_from_library_to_clean assert_equal( + "http://www.example.com/identity/", @library_url.rewrite( :controller => "identity", :controller_prefix => "" ) *************** *** 398,411 **** def test_from_another_port @library_url = ActionController::UrlRewriter.old_new(MockRequest.new( "http://", - "www.singlefile.com", 8080, "/library/books/ISBN/0743536703/show", { "type" => "ISBN", "code" => "0743536703" } ), "books", "show") assert_equal( - "http://www.singlefile.com:8080/identity/", @library_url.rewrite( :controller => "identity", :controller_prefix => "" ) --- 398,411 ---- def test_from_another_port @library_url = ActionController::UrlRewriter.old_new(MockRequest.new( "http://", + "www.example.com", 8080, "/library/books/ISBN/0743536703/show", { "type" => "ISBN", "code" => "0743536703" } ), "books", "show") assert_equal( + "http://www.example.com:8080/identity/", @library_url.rewrite( :controller => "identity", :controller_prefix => "" ) *************** *** 465,487 **** end def test_clean_application_prefix - assert_equal "http://www.singlefile.com/namespace/library/books/ISBN/0743536703/show", @library_url.rewrite(:application_prefix => "/namespace") end def test_clean_application_prefix_with_controller_prefix - assert_equal "http://www.singlefile.com/namespace/shop/", @library_url.rewrite(:application_prefix => "/namespace", :controller_prefix => "shop" ) end def test_blank_application_prefix - assert_equal "http://www.singlefile.com/library/books/ISBN/0743536703/show", @library_url.rewrite(:application_prefix => "") end def test_nil_application_prefix - assert_equal "http://www.singlefile.com/library/books/ISBN/0743536703/show", @library_url.rewrite(:application_prefix => nil) end end --- 465,487 ---- end def test_clean_application_prefix + assert_equal "http://www.example.com/namespace/library/books/ISBN/0743536703/show", @library_url.rewrite(:application_prefix => "/namespace") end def test_clean_application_prefix_with_controller_prefix + assert_equal "http://www.example.com/namespace/shop/", @library_url.rewrite(:application_prefix => "/namespace", :controller_prefix => "shop" ) end def test_blank_application_prefix + assert_equal "http://www.example.com/library/books/ISBN/0743536703/show", @library_url.rewrite(:application_prefix => "") end def test_nil_application_prefix + assert_equal "http://www.example.com/library/books/ISBN/0743536703/show", @library_url.rewrite(:application_prefix => nil) end end