routing_test.rb
4.35 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
require "#{File.dirname(__FILE__)}/../test_helper"
class RoutingTest < ActionController::IntegrationTest
# home page
################################################################
def test_homepage
assert_routing('/', :controller => 'home', :action => 'index')
end
# user-targeted controllers (account/*, cms/*, customize/*)
################################################################
def test_account_controller
assert_routing('/account', :controller => 'account', :action => 'index')
end
def test_enterprise_registration_controller
assert_routing('/enterprise_registration', :controller => 'enterprise_registration', :action => 'index')
assert_routing('/enterprise_registration/lala', :controller => 'enterprise_registration', :action => 'lala')
end
def test_new_password
assert_routing('/account/new_password/90dfhga7sadgd0as6saas', :controller => 'account', :action => 'new_password', :code => '90dfhga7sadgd0as6saas')
end
def test_cms
assert_routing('/myprofile/ze/cms', :profile => 'ze', :controller => 'cms', :action => 'index')
end
def test_edit_template
# FIXME: this is wrong
assert_routing('/admin/edit_template', :controller => 'edit_template', :action => 'index')
end
def test_profile_editor
assert_routing('/myprofile/ze', :profile => 'ze', :controller => 'profile_editor', :action => 'index')
end
# environment administrative controllers (admin/*)
################################################################
def test_admin_panel_controller
assert_routing('/admin', :controller => 'admin_panel', :action => 'index')
end
def test_features_controller
assert_routing('/admin/features', :controller => 'features', :action => 'index')
assert_routing('/admin/features/update', :controller => 'features', :action => 'update')
end
def test_categories_management
assert_routing('/admin/categories', :controller => 'categories', :action => 'index')
assert_routing('/admin/categories/new', :controller => 'categories', :action => 'new')
assert_routing('/admin/categories/edit/2', :controller => 'categories', :action => 'edit', :id => '2')
end
# platform administrative controllers (system/*)
################################################################
# external public controllers
################################################################
def test_content_viewer
# profile root:
assert_routing('/ze', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => [])
# some non-root page
assert_routing('/ze/work/2007', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => ['work', "2007"])
end
def test_category_browser
assert_routing('/cat/products/eletronics', :controller => 'search', :action => 'category_index', :category_path => [ 'products', 'eletronics'])
end
#FIXME remove this if design_blocks is not going to be used; or uncomment otherwise;
#def test_routing_to_controllers_inside_design_blocks_directory
# assert_routing('/block/cojones/favorite_links_profile/show/1', :profile => 'cojones', :controller => 'favorite_links_profile', :action => 'show', :id => '1')
# assert_routing('/block/cojones/favorite_links_profile/save', :profile => 'cojones', :controller => 'favorite_links_profile', :action => 'save')
# assert_routing('/block/cojones/list_block/show/1', :profile => 'cojones', :controller => 'list_block', :action => 'show', :id => '1')
#end
def test_tag_viewing
assert_routing('/tag', :controller => 'search', :action => 'tags')
assert_routing('/tag/umboraminhaporra', :controller => 'search', :action => 'tag', :tag => 'umboraminhaporra')
end
def test_profile_routing
assert_routing('/profile/ze', :controller => 'profile', :profile => 'ze', :action => 'index')
assert_routing('/profile/ze/friends', :controller => 'profile', :profile => 'ze', :action => 'friends')
end
def test_search_routing
assert_routing('/search', :controller => 'search', :action => 'index', :category_path => [])
end
def test_search_filter_routing
assert_routing('/search/filter/a/b', :controller => 'search', :action => 'filter', :category_path => ['a','b'])
end
def test_assets_routing
assert_routing('/assets/my-asset/a/b/c', :controller => 'search', :action => 'assets', :asset => 'my-asset', :category_path => ['a', 'b', 'c'])
end
end