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 { :path => "/", :method => :post },
15 { :controller => "site", :action => "index" }
18 { :controller => "site", :action => "index" },
19 { :path => "/index.html", :method => :get }
22 { :path => "/edit", :method => :get },
23 { :controller => "site", :action => "edit" }
26 { :controller => "site", :action => "edit", :format => "html" },
27 { :path => "/edit.html", :method => :get }
30 { :path => "/copyright", :method => :get },
31 { :controller => "site", :action => "copyright" }
34 { :path => "/copyright/locale", :method => :get },
35 { :controller => "site", :action => "copyright", :copyright_locale => "locale" }
38 { :path => "/export", :method => :get },
39 { :controller => "site", :action => "export" }
42 { :controller => "site", :action => "export", :format => "html" },
43 { :path => "/export.html", :method => :get }
46 { :path => "/offline", :method => :get },
47 { :controller => "site", :action => "offline" }
50 { :path => "/key", :method => :post },
51 { :controller => "site", :action => "key" }
54 { :path => "/go/shortcode", :method => :get },
55 { :controller => "site", :action => "permalink", :code => "shortcode" }
58 { :path => "/preview/formatname", :method => :get },
59 { :controller => "site", :action => "preview", :format => "formatname" }
63 ## Lets check that we can get all the pages without any errors
67 assert_response :success
68 assert_template 'index'
75 # Should be redirected
76 assert_redirected_to :controller => :user, :action => 'login', :referer => "/edit"
82 assert_response :success
83 assert_template 'index'
90 assert_response :success
91 assert_template 'offline'
92 assert_site_partials 0
95 def assert_site_partials(count = 1)
96 assert_template :partial => '_search', :count => count
97 assert_template :partial => '_key', :count => count
98 assert_template :partial => '_sidebar', :count => count
101 # test the right editor gets used when the user hasn't set a preference
102 def test_edit_without_preference
103 @request.cookies["_osm_username"] = users(:public_user).display_name
105 get(:edit, nil, { 'user' => users(:public_user).id })
106 assert_response :success
107 assert_template :partial => "_#{DEFAULT_EDITOR}", :count => 1
110 # and when they have...
111 def test_edit_with_preference
112 @request.cookies["_osm_username"] = users(:public_user).display_name
114 user = users(:public_user)
115 user.preferred_editor = "potlatch"
118 get(:edit, nil, { 'user' => user.id })
119 assert_response :success
120 assert_template :partial => "_potlatch", :count => 1
122 user = users(:public_user)
123 user.preferred_editor = "remote"
126 get(:edit, nil, { 'user' => user.id })
127 assert_response :success
128 assert_template "index"