1 require File.dirname(__FILE__) + '/../test_helper'
3 class SiteControllerTest < ActionController::TestCase
7 # test all routes which lead to this controller
10 { :path => "/", :method => :get },
11 { :controller => "site", :action => "index" }
14 { :controller => "site", :action => "index" },
15 { :path => "/index.html", :method => :get }
18 { :path => "/edit", :method => :get },
19 { :controller => "site", :action => "edit" }
22 { :controller => "site", :action => "edit", :format => "html" },
23 { :path => "/edit.html", :method => :get }
26 { :path => "/copyright", :method => :get },
27 { :controller => "site", :action => "copyright" }
30 { :path => "/copyright/locale", :method => :get },
31 { :controller => "site", :action => "copyright", :copyright_locale => "locale" }
34 { :path => "/export", :method => :get },
35 { :controller => "site", :action => "export" }
38 { :controller => "site", :action => "export", :format => "html" },
39 { :path => "/export.html", :method => :get }
42 { :path => "/offline", :method => :get },
43 { :controller => "site", :action => "offline" }
46 { :path => "/key", :method => :post },
47 { :controller => "site", :action => "key" }
50 { :path => "/go/shortcode", :method => :get },
51 { :controller => "site", :action => "permalink", :code => "shortcode" }
55 ## Lets check that we can get all the pages without any errors
59 assert_response :success
60 assert_template 'index'
67 # Should be redirected
68 assert_redirected_to :controller => :user, :action => 'login', :referer => "/edit"
74 assert_response :success
75 assert_template 'index'
82 assert_response :success
83 assert_template 'offline'
84 assert_site_partials 0
87 def assert_site_partials(count = 1)
88 assert_template :partial => '_search', :count => count
89 assert_template :partial => '_key', :count => count
90 assert_template :partial => '_sidebar', :count => count
93 # test the right editor gets used when the user hasn't set a preference
94 def test_edit_without_preference
95 @request.cookies["_osm_username"] = users(:public_user).display_name
97 get(:edit, nil, { 'user' => users(:public_user).id })
98 assert_response :success
99 assert_template :partial => "_#{DEFAULT_EDITOR}", :count => 1
102 # and when they have...
103 def test_edit_with_preference
104 @request.cookies["_osm_username"] = users(:public_user).display_name
106 user = users(:public_user)
107 user.preferred_editor = "potlatch"
110 get(:edit, nil, { 'user' => user.id })
111 assert_response :success
112 assert_template :partial => "_potlatch", :count => 1
114 user = users(:public_user)
115 user.preferred_editor = "remote"
118 get(:edit, nil, { 'user' => user.id })
119 assert_response :success
120 assert_template "index"