admin_panel_controller_test.rb
2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require File.dirname(__FILE__) + '/../test_helper'
require 'admin_panel_controller'
# Re-raise errors caught by the controller.
class AdminPanelController; def rescue_action(e) raise e end; end
class AdminPanelControllerTest < Test::Unit::TestCase
all_fixtures
def setup
@controller = AdminPanelController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
login_as(create_admin_user(Environment.default))
end
def test_local_files_reference
assert_local_files_reference
end
def test_valid_xhtml
assert_valid_xhtml
end
should 'link to site_info editing page' do
get :index
assert_tag :tag => 'a', :attributes => { :href => '/admin/admin_panel/site_info' }
end
should 'link to cateogries editing' do
get :index
assert_tag :tag => 'a', :attributes => { :href => '/admin/categories' }
end
should 'link to design editor' do
get :index
assert_tag :tag => 'a', :attributes => { :href => '/admin/environment_design' }
end
should 'link to features editing screen' do
get :index
assert_tag :tag => 'a', :attributes => { :href => '/admin/features' }
end
should 'link to role editing screen' do
get :index
assert_tag :tag => 'a', :attributes => { :href => '/admin/role' }
end
should 'link to region validator screen' do
get :index
assert_tag :tag => 'a', :attributes => { :href => '/admin/region_validators' }
end
should 'display form for editing site info' do
get :site_info
assert_template 'site_info'
assert_tag :tag => 'textarea', :attributes => { :name => 'environment[description]'}
end
should 'save site description' do
post :site_info, :environment => { :description => "This is my new environment" }
assert_redirected_to :action => 'index'
assert_equal "This is my new environment", Environment.default.description
end
should 'sanitize description with white_list' do
post :site_info, :environment => { :description => "This <strong>is</strong> <scrypt>alert('alow')</script>my new environment" }
assert_redirected_to :action => 'index'
assert_equal "This <strong>is</strong> alert('alow')my new environment", Environment.default.description
end
end