Patch #1901 ยป restful_urls_start.diff
| app/views/projects/changelog.rhtml | ||
|---|---|---|
| 26 | 26 |
<% end %> |
| 27 | 27 | |
| 28 | 28 |
<% content_for :sidebar do %> |
| 29 |
<% form_tag do %> |
|
| 29 |
<% form_tag({},:method => :get) do %>
|
|
| 30 | 30 |
<h3><%= l(:label_change_log) %></h3> |
| 31 | 31 |
<% @trackers.each do |tracker| %> |
| 32 | 32 |
<label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> |
| config/routes.rb | ||
|---|---|---|
| 10 | 10 |
map.signin 'login', :controller => 'account', :action => 'login' |
| 11 | 11 |
map.signout 'logout', :controller => 'account', :action => 'logout' |
| 12 | 12 |
|
| 13 |
map.connect 'wiki/:id/:page/:action', :controller => 'wiki', :page => nil |
|
| 14 | 13 |
map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' |
| 15 | 14 |
map.connect 'help/:ctrl/:page', :controller => 'help' |
| 16 | 15 |
#map.connect ':controller/:action/:id/:sort_key/:sort_order' |
| 17 | 16 |
|
| 18 |
map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations' |
|
| 17 |
map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
|
|
| 18 |
map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
|
|
| 19 |
map.with_options :controller => 'wiki' do |wiki_routes| |
|
| 20 |
wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
|
|
| 21 |
wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i |
|
| 22 |
wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil |
|
| 23 |
wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit' |
|
| 24 |
wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename' |
|
| 25 |
wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history' |
|
| 26 |
wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff' |
|
| 27 |
wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate' |
|
| 28 |
end |
|
| 29 |
|
|
| 30 |
wiki_routes.connect 'projects/:id/wiki/:page/:action', |
|
| 31 |
:action => /edit|rename|destroy|preview|protect/, |
|
| 32 |
:conditions => {:method => :post}
|
|
| 33 |
end |
|
| 34 |
|
|
| 35 |
map.with_options :controller => 'messages' do |messages_routes| |
|
| 36 |
messages_routes.connect 'boards/:board_id/topics/new', :action => 'new', :conditions => {:method => :get}
|
|
| 37 |
messages_routes.connect 'boards/:board_id/topics/new', :action => 'new', :conditions => {:method => :post}
|
|
| 38 |
messages_routes.connect 'boards/:board_id/topics/:id', :action => 'show', :conditions => {:method => :get}
|
|
| 39 |
messages_routes.connect 'boards/:board_id/topics/:id', :action => 'reply', :conditions => {:method => :post}
|
|
| 40 |
messages_routes.connect 'boards/:board_id/topics/:id/edit', :action => 'edit', :conditions => {:method => :get}
|
|
| 41 |
messages_routes.connect 'boards/:board_id/topics/:id/edit', :action => 'edit', :conditions => {:method => :post}
|
|
| 42 |
messages_routes.connect 'boards/:board_id/topics/:id/replies', :action => 'reply', :conditions => {:method => :post}
|
|
| 43 |
messages_routes.connect 'boards/:board_id/topics/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
|
|
| 44 |
end |
|
| 45 |
map.with_options :controller => 'boards' do |board_routes| |
|
| 46 |
board_routes.connect 'projects/:project_id/boards', :action => 'index', :conditions => {:method => :get}
|
|
| 47 |
board_routes.connect 'projects/:project_id/boards/new', :action => 'new', :conditions => {:method => :get}
|
|
| 48 |
board_routes.connect 'projects/:project_id/boards', :action => 'new', :conditions => {:method => :post}
|
|
| 49 |
board_routes.connect 'projects/:project_id/boards/:id', :action => 'show', :conditions => {:method => :get}
|
|
| 50 |
board_routes.connect 'projects/:project_id/boards/:id/edit', :action => 'edit', :conditions => {:method => :get}
|
|
| 51 |
board_routes.connect 'projects/:project_id/boards/:id/edit', :action => 'edit', :conditions => {:method => :post}
|
|
| 52 |
board_routes.connect 'projects/:project_id/boards/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
|
|
| 53 |
end |
|
| 54 |
|
|
| 55 |
map.with_options :controller => 'documents' do |document_routes| |
|
| 56 |
document_routes.connect 'projects/:project_id/documents', :action => 'index', :conditions => {:method => :get}
|
|
| 57 |
document_routes.connect 'projects/:project_id/documents/new', :action => 'new', :conditions => {:method => :get}
|
|
| 58 |
document_routes.connect 'projects/:project_id/documents', :action => 'new', :conditions => {:method => :post}
|
|
| 59 |
|
|
| 60 |
document_routes.connect 'documents/:id', :action => 'show', :conditions => {:method => :get}
|
|
| 61 |
document_routes.connect 'documents/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
|
|
| 62 |
document_routes.connect 'documents/:id/edit', :action => 'edit', :conditions => {:method => :get}
|
|
| 63 |
document_routes.connect 'documents/:id/edit', :action => 'edit', :conditions => {:method => :post}
|
|
| 64 |
end |
|
| 65 |
|
|
| 66 |
map.with_options :controller => 'issues' do |issues_routes| |
|
| 67 |
issues_routes.with_options :conditions => {:method => :get} do |issues_views|
|
|
| 68 |
issues_views.connect 'issues', :action => 'index' |
|
| 69 |
issues_views.connect 'issues.:format', :action => 'index' |
|
| 70 |
issues_views.connect 'projects/:project_id/issues.:format', :action => 'index' |
|
| 71 |
issues_views.connect 'projects/:project_id/issues/new', :action => 'new' |
|
| 72 |
issues_views.connect 'projects/:project_id/issues/:copy_from/copy', :action => 'new' |
|
| 73 |
issues_views.connect 'issues/:id', :action => 'show' |
|
| 74 |
issues_views.connect 'issues/:id.:format', :action => 'show' |
|
| 75 |
issues_views.connect 'issues/:id/edit', :action => 'edit' |
|
| 76 |
issues_views.connect 'issues/:id/quoted', :action => 'reply' |
|
| 77 |
issues_views.connect 'issues/:id/move', :action => 'move' |
|
| 78 |
end |
|
| 79 |
issues_routes.connect 'projects/:project_id/issues', :action => 'new', :conditions => {:method => :post}
|
|
| 80 |
issues_routes.connect 'issues/:id/:action', |
|
| 81 |
:action => /edit|move|destroy/, |
|
| 82 |
:conditions => {:method => :post}
|
|
| 83 |
end |
|
| 84 |
map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
|
|
| 85 |
relations.connect 'issues/:issue_id/relations/:id', :action => 'new' |
|
| 86 |
relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy' |
|
| 87 |
end |
|
| 88 |
map.with_options :controller => 'reports', :action => 'issue_report', :conditions => {:method => :get} do |reports|
|
|
| 89 |
reports.connect 'projects/:id/issues/report' |
|
| 90 |
reports.connect 'projects/:id/issues/report/:detail' |
|
| 91 |
end |
|
| 92 |
|
|
| 93 |
map.with_options :controller => 'news' do |news_routes| |
|
| 94 |
news_routes.with_options :conditions => {:method => :get} do |news_views|
|
|
| 95 |
news_views.connect 'news', :action => 'index' |
|
| 96 |
news_views.connect 'projects/:project_id/news', :action => 'index' |
|
| 97 |
news_views.connect 'projects/:project_id/news.:format', :action => 'index' |
|
| 98 |
news_views.connect 'news.:format', :action => 'index' |
|
| 99 |
news_views.connect 'projects/:project_id/news/new', :action => 'new' |
|
| 100 |
news_views.connect 'news/:id', :action => 'show' |
|
| 101 |
news_views.connect 'news/:id/edit', :action => 'edit' |
|
| 102 |
end |
|
| 103 |
news_routes.with_options do |news_actions| |
|
| 104 |
news_actions.connect 'projects/:project_id/news', :action => 'new' |
|
| 105 |
news_actions.connect 'news/:id/edit', :action => 'edit' |
|
| 106 |
news_actions.connect 'news/:id/destroy', :action => 'destroy' |
|
| 107 |
end |
|
| 108 |
end |
|
| 109 |
|
|
| 110 |
map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new' |
|
| 111 |
map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
|
|
| 112 |
|
|
| 113 |
map.with_options :controller => 'projects' do |projects| |
|
| 114 |
projects.connect 'projects', :action => 'index', :conditions => {:method => :get}
|
|
| 115 |
projects.connect 'projects.:format', :action => 'index', :conditions => {:method => :get}
|
|
| 116 |
projects.connect 'projects/new', :action => 'add', :conditions => {:method => :get}
|
|
| 117 |
projects.connect 'projects', :action => 'add', :conditions => {:method => :post}
|
|
| 118 |
projects.connect 'projects/:id', :action => 'show', :conditions => {:method => :get}
|
|
| 119 |
|
|
| 120 |
projects.connect 'projects/:id/roadmap', :action => 'roadmap', :conditions => {:method => :get}
|
|
| 121 |
projects.connect 'projects/:id/changelog', :action => 'changelog', :conditions => {:method => :get}
|
|
| 122 |
|
|
| 123 |
projects.connect 'projects/:id/files', :action => 'list_files', :conditions => {:method => :get}
|
|
| 124 |
projects.connect 'projects/:id/files/new', :action => 'add_file', :conditions => {:method => :get}
|
|
| 125 |
projects.connect 'projects/:id/files/new', :action => 'add_file', :conditions => {:method => :post}
|
|
| 126 |
|
|
| 127 |
projects.connect 'projects/:id/versions/new', :action => 'add_version', :conditions => {:method => :get}
|
|
| 128 |
projects.connect 'projects/:id/versions/new', :action => 'add_version', :conditions => {:method => :post}
|
|
| 129 | ||
| 130 |
projects.connect 'projects/:id/categories/new', :action => 'add_issue_category', :conditions => {:method => :get}
|
|
| 131 |
projects.connect 'projects/:id/categories/new', :action => 'add_issue_category', :conditions => {:method => :post}
|
|
| 132 |
|
|
| 133 |
projects.connect 'projects/:id/settings', :action => 'settings', :conditions => {:method => :get}
|
|
| 134 |
projects.connect 'projects/:id/settings/:tab', :action => 'settings', :conditions => {:method => :get}
|
|
| 135 |
|
|
| 136 |
projects.with_options :action => 'activity', :conditions => {:method => :get} do |activity|
|
|
| 137 |
activity.connect 'projects/:id/activity' |
|
| 138 |
activity.connect 'projects/:id/activity.:format' |
|
| 139 |
activity.connect 'activity' |
|
| 140 |
activity.connect 'activity.:format' |
|
| 141 |
end |
|
| 142 |
end |
|
| 143 |
|
|
| 144 |
map.with_options :controller => 'repositories' do |repositories| |
|
| 145 |
repositories.connect 'projects/:id/repository', :action => 'show', :conditions => {:method => :get}
|
|
| 146 |
repositories.connect 'projects/:id/repository/edit', :action => 'edit', :conditions => {:method => :post}
|
|
| 147 |
repositories.connect 'projects/:id/repository/edit', :action => 'edit', :conditions => {:method => :get}
|
|
| 148 |
repositories.connect 'projects/:id/repository/statistics', :action => 'stats', :conditions => {:method => :get}
|
|
| 149 |
repositories.connect 'projects/:id/repository/revisions', :action => 'revisions', :conditions => {:method => :get}
|
|
| 150 |
repositories.connect 'projects/:id/repository/revisions.:format', :action => 'revisions', :conditions => {:method => :get}
|
|
| 151 |
repositories.connect 'projects/:id/repository/revisions/:rev', :action => 'revision', :conditions => {:method => :get}
|
|
| 152 |
repositories.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff', :conditions => {:method => :get}
|
|
| 153 |
repositories.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff', :conditions => {:method => :get}
|
|
| 154 | ||
| 155 |
repositories.connect 'projects/:id/repository/:action/*path', :conditions => {:method => :get}
|
|
| 156 |
end |
|
| 157 |
|
|
| 158 |
map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/ |
|
| 159 |
map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ |
|
| 160 |
map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ |
|
| 161 |
|
|
| 162 | ||
| 163 |
#left old routes at the bottom for backwards compat |
|
| 19 | 164 |
map.connect 'projects/:project_id/issues/:action', :controller => 'issues' |
| 20 |
map.connect 'projects/:project_id/news/:action', :controller => 'news' |
|
| 21 | 165 |
map.connect 'projects/:project_id/documents/:action', :controller => 'documents' |
| 22 | 166 |
map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' |
| 23 |
map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/ |
|
| 24 | 167 |
map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' |
| 25 | ||
| 168 |
map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki' |
|
| 169 |
map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations' |
|
| 170 |
map.connect 'projects/:project_id/news/:action', :controller => 'news' |
|
| 171 |
map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/ |
|
| 26 | 172 |
map.with_options :controller => 'repositories' do |omap| |
| 27 | 173 |
omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse' |
| 28 | 174 |
omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes' |
| 29 | 175 |
omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff' |
| 30 | 176 |
omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry' |
| 31 | 177 |
omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate' |
| 32 |
omap.repositories_revision 'repositories/revision/:id/:rev', :action => 'revision'
|
|
| 178 |
omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
|
|
| 33 | 179 |
end |
| 34 |
|
|
| 35 |
map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/ |
|
| 36 |
map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ |
|
| 37 |
map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ |
|
| 38 | 180 |
|
| 39 | 181 |
# Allow downloading Web Service WSDL as a file with an extension |
| 40 | 182 |
# instead of a file named 'wsdl' |
| 41 | 183 |
map.connect ':controller/service.wsdl', :action => 'wsdl' |
| 42 | ||
| 43 | 184 |
|
| 44 | 185 |
# Install the default route as the lowest priority. |
| 45 | 186 |
map.connect ':controller/:action/:id' |
| test/functional/boards_controller_test.rb | ||
|---|---|---|
| 31 | 31 |
User.current = nil |
| 32 | 32 |
end |
| 33 | 33 |
|
| 34 |
def test_index_routing |
|
| 35 |
assert_routing( |
|
| 36 |
{:method => :get, :path => '/projects/world_domination/boards'},
|
|
| 37 |
:controller => 'boards', :action => 'index', :project_id => 'world_domination' |
|
| 38 |
) |
|
| 39 |
end |
|
| 40 |
|
|
| 34 | 41 |
def test_index |
| 35 | 42 |
get :index, :project_id => 1 |
| 36 | 43 |
assert_response :success |
| ... | ... | |
| 39 | 46 |
assert_not_nil assigns(:project) |
| 40 | 47 |
end |
| 41 | 48 |
|
| 49 |
def test_new_routing |
|
| 50 |
assert_routing( |
|
| 51 |
{:method => :get, :path => '/projects/world_domination/boards/new'},
|
|
| 52 |
:controller => 'boards', :action => 'new', :project_id => 'world_domination' |
|
| 53 |
) |
|
| 54 |
assert_recognizes( |
|
| 55 |
{:controller => 'boards', :action => 'new', :project_id => 'world_domination'},
|
|
| 56 |
{:method => :post, :path => '/projects/world_domination/boards'}
|
|
| 57 |
) |
|
| 58 |
end |
|
| 59 |
|
|
| 60 |
def test_show_routing |
|
| 61 |
assert_routing( |
|
| 62 |
{:method => :get, :path => '/projects/world_domination/boards/44'},
|
|
| 63 |
:controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination' |
|
| 64 |
) |
|
| 65 |
end |
|
| 66 |
|
|
| 42 | 67 |
def test_show |
| 43 | 68 |
get :show, :project_id => 1, :id => 1 |
| 44 | 69 |
assert_response :success |
| ... | ... | |
| 47 | 72 |
assert_not_nil assigns(:project) |
| 48 | 73 |
assert_not_nil assigns(:topics) |
| 49 | 74 |
end |
| 75 |
|
|
| 76 |
def test_edit_routing |
|
| 77 |
assert_routing( |
|
| 78 |
{:method => :get, :path => '/projects/world_domination/boards/44/edit'},
|
|
| 79 |
:controller => 'boards', :action => 'edit', :id => '44', :project_id => 'world_domination' |
|
| 80 |
) |
|
| 81 |
assert_recognizes(#TODO: use PUT method to board_path, modify form accordingly |
|
| 82 |
{:controller => 'boards', :action => 'edit', :id => '44', :project_id => 'world_domination'},
|
|
| 83 |
{:method => :post, :path => '/projects/world_domination/boards/44/edit'}
|
|
| 84 |
) |
|
| 85 |
end |
|
| 86 |
|
|
| 87 |
def test_destroy_routing |
|
| 88 |
assert_routing(#TODO: use DELETE method to board_path, modify form accoringly |
|
| 89 |
{:method => :post, :path => '/projects/world_domination/boards/44/destroy'},
|
|
| 90 |
:controller => 'boards', :action => 'destroy', :id => '44', :project_id => 'world_domination' |
|
| 91 |
) |
|
| 92 |
end |
|
| 50 | 93 |
end |
| test/functional/documents_controller_test.rb | ||
|---|---|---|
| 30 | 30 |
@response = ActionController::TestResponse.new |
| 31 | 31 |
User.current = nil |
| 32 | 32 |
end |
| 33 | ||
| 33 |
|
|
| 34 |
def test_index_routing |
|
| 35 |
assert_routing( |
|
| 36 |
{:method => :get, :path => '/projects/567/documents'},
|
|
| 37 |
:controller => 'documents', :action => 'index', :project_id => '567' |
|
| 38 |
) |
|
| 39 |
end |
|
| 40 |
|
|
| 34 | 41 |
def test_index |
| 35 | 42 |
get :index, :project_id => 'ecookbook' |
| 36 | 43 |
assert_response :success |
| ... | ... | |
| 38 | 45 |
assert_not_nil assigns(:grouped) |
| 39 | 46 |
end |
| 40 | 47 |
|
| 48 |
def test_new_routing |
|
| 49 |
assert_routing( |
|
| 50 |
{:method => :get, :path => '/projects/567/documents/new'},
|
|
| 51 |
:controller => 'documents', :action => 'new', :project_id => '567' |
|
| 52 |
) |
|
| 53 |
assert_recognizes( |
|
| 54 |
{:controller => 'documents', :action => 'new', :project_id => '567'},
|
|
| 55 |
{:method => :post, :path => '/projects/567/documents'}
|
|
| 56 |
) |
|
| 57 |
end |
|
| 58 |
|
|
| 41 | 59 |
def test_new_with_one_attachment |
| 42 | 60 |
@request.session[:user_id] = 2 |
| 43 | 61 |
set_tmp_attachments_directory |
| ... | ... | |
| 57 | 75 |
assert_equal 'testfile.txt', document.attachments.first.filename |
| 58 | 76 |
end |
| 59 | 77 |
|
| 78 |
def test_edit_routing |
|
| 79 |
assert_routing( |
|
| 80 |
{:method => :get, :path => '/documents/22/edit'},
|
|
| 81 |
:controller => 'documents', :action => 'edit', :id => '22' |
|
| 82 |
) |
|
| 83 |
assert_recognizes(#TODO: should be using PUT on document URI |
|
| 84 |
{:controller => 'documents', :action => 'edit', :id => '567'},
|
|
| 85 |
{:method => :post, :path => '/documents/567/edit'}
|
|
| 86 |
) |
|
| 87 |
end |
|
| 88 |
|
|
| 89 |
def test_show_routing |
|
| 90 |
assert_routing( |
|
| 91 |
{:method => :get, :path => '/documents/22'},
|
|
| 92 |
:controller => 'documents', :action => 'show', :id => '22' |
|
| 93 |
) |
|
| 94 |
end |
|
| 95 |
|
|
| 96 |
def test_destroy_routing |
|
| 97 |
assert_recognizes(#TODO: should be using DELETE on document URI |
|
| 98 |
{:controller => 'documents', :action => 'destroy', :id => '567'},
|
|
| 99 |
{:method => :post, :path => '/documents/567/destroy'}
|
|
| 100 |
) |
|
| 101 |
end |
|
| 102 |
|
|
| 60 | 103 |
def test_destroy |
| 61 | 104 |
@request.session[:user_id] = 2 |
| 62 | 105 |
post :destroy, :id => 1 |
| test/functional/issue_relations_controller_test.rb | ||
|---|---|---|
| 1 |
require File.dirname(__FILE__) + '/../test_helper' |
|
| 2 |
require 'issue_relations_controller' |
|
| 3 | ||
| 4 |
# Re-raise errors caught by the controller. |
|
| 5 |
class IssueRelationsController; def rescue_action(e) raise e end; end |
|
| 6 | ||
| 7 | ||
| 8 |
class IssueRelationsControllerTest < Test::Unit::TestCase |
|
| 9 |
def test_new_routing |
|
| 10 |
assert_routing( |
|
| 11 |
{:method => :post, :path => '/issues/1/relations'},
|
|
| 12 |
{:controller => 'issue_relations', :action => 'new', :issue_id => '1'}
|
|
| 13 |
) |
|
| 14 |
end |
|
| 15 |
|
|
| 16 |
def test_destroy_routing |
|
| 17 |
assert_recognizes( #TODO: use DELETE on issue URI |
|
| 18 |
{:controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'},
|
|
| 19 |
{:method => :post, :path => '/issues/1/relations/23/destroy'}
|
|
| 20 |
) |
|
| 21 |
end |
|
| 22 |
end |
|
| test/functional/issues_controller_test.rb | ||
|---|---|---|
| 49 | 49 |
@response = ActionController::TestResponse.new |
| 50 | 50 |
User.current = nil |
| 51 | 51 |
end |
| 52 |
|
|
| 53 |
def test_index_routing |
|
| 54 |
assert_routing( |
|
| 55 |
{:method => :get, :path => '/issues'},
|
|
| 56 |
:controller => 'issues', :action => 'index' |
|
| 57 |
) |
|
| 58 |
end |
|
| 52 | 59 | |
| 53 | 60 |
def test_index |
| 54 | 61 |
get :index |
| ... | ... | |
| 62 | 69 |
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/ |
| 63 | 70 |
assert_no_tag :tag => 'a', :content => /Issue on project 2/ |
| 64 | 71 |
end |
| 65 | ||
| 72 |
|
|
| 73 |
def test_index_with_project_routing |
|
| 74 |
assert_routing( |
|
| 75 |
{:method => :get, :path => '/projects/23/issues'},
|
|
| 76 |
:controller => 'issues', :action => 'index', :project_id => '23' |
|
| 77 |
) |
|
| 78 |
end |
|
| 79 |
|
|
| 66 | 80 |
def test_index_with_project |
| 67 | 81 |
Setting.display_subprojects_issues = 0 |
| 68 | 82 |
get :index, :project_id => 1 |
| ... | ... | |
| 96 | 110 |
assert_tag :tag => 'a', :content => /Issue of a private subproject/ |
| 97 | 111 |
end |
| 98 | 112 |
|
| 113 |
def test_index_with_project_routing_formatted |
|
| 114 |
assert_routing( |
|
| 115 |
{:method => :get, :path => 'projects/23/issues.pdf'},
|
|
| 116 |
:controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf' |
|
| 117 |
) |
|
| 118 |
assert_routing( |
|
| 119 |
{:method => :get, :path => 'projects/23/issues.atom'},
|
|
| 120 |
:controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom' |
|
| 121 |
) |
|
| 122 |
end |
|
| 123 |
|
|
| 99 | 124 |
def test_index_with_project_and_filter |
| 100 | 125 |
get :index, :project_id => 1, :set_filter => 1 |
| 101 | 126 |
assert_response :success |
| ... | ... | |
| 115 | 140 |
assert_equal 'text/csv', @response.content_type |
| 116 | 141 |
end |
| 117 | 142 |
|
| 143 |
def test_index_formatted |
|
| 144 |
assert_routing( |
|
| 145 |
{:method => :get, :path => 'issues.pdf'},
|
|
| 146 |
:controller => 'issues', :action => 'index', :format => 'pdf' |
|
| 147 |
) |
|
| 148 |
assert_routing( |
|
| 149 |
{:method => :get, :path => 'issues.atom'},
|
|
| 150 |
:controller => 'issues', :action => 'index', :format => 'atom' |
|
| 151 |
) |
|
| 152 |
end |
|
| 153 |
|
|
| 118 | 154 |
def test_index_pdf |
| 119 | 155 |
get :index, :format => 'pdf' |
| 120 | 156 |
assert_response :success |
| ... | ... | |
| 176 | 212 |
assert_equal 'application/atom+xml', @response.content_type |
| 177 | 213 |
end |
| 178 | 214 |
|
| 215 |
def test_show_routing |
|
| 216 |
assert_routing( |
|
| 217 |
{:method => :get, :path => '/issues/64'},
|
|
| 218 |
:controller => 'issues', :action => 'show', :id => '64' |
|
| 219 |
) |
|
| 220 |
end |
|
| 221 |
|
|
| 222 |
def test_show_routing_formatted |
|
| 223 |
assert_routing( |
|
| 224 |
{:method => :get, :path => '/issues/2332.pdf'},
|
|
| 225 |
:controller => 'issues', :action => 'show', :id => '2332', :format => 'pdf' |
|
| 226 |
) |
|
| 227 |
assert_routing( |
|
| 228 |
{:method => :get, :path => '/issues/23123.atom'},
|
|
| 229 |
:controller => 'issues', :action => 'show', :id => '23123', :format => 'atom' |
|
| 230 |
) |
|
| 231 |
end |
|
| 232 |
|
|
| 179 | 233 |
def test_show_by_anonymous |
| 180 | 234 |
get :show, :id => 1 |
| 181 | 235 |
assert_response :success |
| ... | ... | |
| 206 | 260 |
:child => { :tag => 'legend',
|
| 207 | 261 |
:content => /Notes/ } } |
| 208 | 262 |
end |
| 263 |
|
|
| 264 |
def test_new_routing |
|
| 265 |
assert_routing( |
|
| 266 |
{:method => :get, :path => '/projects/1/issues/new'},
|
|
| 267 |
:controller => 'issues', :action => 'new', :project_id => '1' |
|
| 268 |
) |
|
| 269 |
assert_recognizes( |
|
| 270 |
{:controller => 'issues', :action => 'new', :project_id => '1'},
|
|
| 271 |
{:method => :post, :path => '/projects/1/issues'}
|
|
| 272 |
) |
|
| 273 |
end |
|
| 209 | 274 | |
| 210 | 275 |
def test_get_new |
| 211 | 276 |
@request.session[:user_id] = 2 |
| ... | ... | |
| 248 | 313 |
:priority_id => 5, |
| 249 | 314 |
:estimated_hours => '', |
| 250 | 315 |
:custom_field_values => {'2' => 'Value for field 2'}}
|
| 251 |
assert_redirected_to 'issues/show'
|
|
| 316 |
assert_redirected_to :action => 'show'
|
|
| 252 | 317 |
|
| 253 | 318 |
issue = Issue.find_by_subject('This is the test_new issue')
|
| 254 | 319 |
assert_not_nil issue |
| ... | ... | |
| 267 | 332 |
:subject => 'This is the test_new issue', |
| 268 | 333 |
:description => 'This is the description', |
| 269 | 334 |
:priority_id => 5} |
| 270 |
assert_redirected_to 'issues/show'
|
|
| 335 |
assert_redirected_to :action => 'show'
|
|
| 271 | 336 |
end |
| 272 | 337 |
|
| 273 | 338 |
def test_post_new_with_required_custom_field_and_without_custom_fields_param |
| ... | ... | |
| 314 | 379 |
:value => 'Value for field 2'} |
| 315 | 380 |
end |
| 316 | 381 |
|
| 382 |
def test_copy_routing |
|
| 383 |
assert_routing( |
|
| 384 |
{:method => :get, :path => '/projects/world_domination/issues/567/copy'},
|
|
| 385 |
:controller => 'issues', :action => 'new', :project_id => 'world_domination', :copy_from => '567' |
|
| 386 |
) |
|
| 387 |
end |
|
| 388 |
|
|
| 317 | 389 |
def test_copy_issue |
| 318 | 390 |
@request.session[:user_id] = 2 |
| 319 | 391 |
get :new, :project_id => 1, :copy_from => 1 |
| ... | ... | |
| 323 | 395 |
assert_equal orig.subject, assigns(:issue).subject |
| 324 | 396 |
end |
| 325 | 397 |
|
| 398 |
def test_edit_routing |
|
| 399 |
assert_routing( |
|
| 400 |
{:method => :get, :path => '/issues/1/edit'},
|
|
| 401 |
:controller => 'issues', :action => 'edit', :id => '1' |
|
| 402 |
) |
|
| 403 |
assert_recognizes( #TODO: use a PUT on the issue URI isntead, need to adjust form |
|
| 404 |
{:controller => 'issues', :action => 'edit', :id => '1'},
|
|
| 405 |
{:method => :post, :path => '/issues/1/edit'}
|
|
| 406 |
) |
|
| 407 |
end |
|
| 408 |
|
|
| 326 | 409 |
def test_get_edit |
| 327 | 410 |
@request.session[:user_id] = 2 |
| 328 | 411 |
get :edit, :id => 1 |
| ... | ... | |
| 354 | 437 |
:attributes => { :selected => 'selected' } }
|
| 355 | 438 |
end |
| 356 | 439 |
|
| 440 |
def test_reply_routing |
|
| 441 |
assert_routing( |
|
| 442 |
{:method => :get, :path => '/issues/1/quoted'},
|
|
| 443 |
:controller => 'issues', :action => 'reply', :id => '1' |
|
| 444 |
) |
|
| 445 |
end |
|
| 446 |
|
|
| 357 | 447 |
def test_reply_to_issue |
| 358 | 448 |
@request.session[:user_id] = 2 |
| 359 | 449 |
get :reply, :id => 1 |
| ... | ... | |
| 385 | 475 |
} |
| 386 | 476 |
end |
| 387 | 477 |
end |
| 388 |
assert_redirected_to 'issues/show/1'
|
|
| 478 |
assert_redirected_to :action => 'show', :id => '1'
|
|
| 389 | 479 |
issue.reload |
| 390 | 480 |
assert_equal new_subject, issue.subject |
| 391 | 481 |
# Make sure custom fields were not cleared |
| ... | ... | |
| 411 | 501 |
} |
| 412 | 502 |
end |
| 413 | 503 |
end |
| 414 |
assert_redirected_to 'issues/show/1'
|
|
| 504 |
assert_redirected_to :action => 'show', :id => '1'
|
|
| 415 | 505 |
issue.reload |
| 416 | 506 |
assert_equal 'New custom value', issue.custom_value_for(2).value |
| 417 | 507 |
|
| ... | ... | |
| 431 | 521 |
:notes => 'Assigned to dlopper', |
| 432 | 522 |
:time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
|
| 433 | 523 |
end |
| 434 |
assert_redirected_to 'issues/show/1'
|
|
| 524 |
assert_redirected_to :action => 'show', :id => '1'
|
|
| 435 | 525 |
issue.reload |
| 436 | 526 |
assert_equal 2, issue.status_id |
| 437 | 527 |
j = issue.journals.find(:first, :order => 'id DESC') |
| ... | ... | |
| 448 | 538 |
post :edit, |
| 449 | 539 |
:id => 1, |
| 450 | 540 |
:notes => notes |
| 451 |
assert_redirected_to 'issues/show/1'
|
|
| 541 |
assert_redirected_to :action => 'show', :id => '1'
|
|
| 452 | 542 |
j = Issue.find(1).journals.find(:first, :order => 'id DESC') |
| 453 | 543 |
assert_equal notes, j.notes |
| 454 | 544 |
assert_equal 0, j.details.size |
| ... | ... | |
| 467 | 557 |
:notes => '2.5 hours added', |
| 468 | 558 |
:time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
|
| 469 | 559 |
end |
| 470 |
assert_redirected_to 'issues/show/1'
|
|
| 560 |
assert_redirected_to :action => 'show', :id => '1'
|
|
| 471 | 561 |
|
| 472 | 562 |
issue = Issue.find(1) |
| 473 | 563 |
|
| ... | ... | |
| 489 | 579 |
:id => 1, |
| 490 | 580 |
:notes => '', |
| 491 | 581 |
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
| 492 |
assert_redirected_to 'issues/show/1'
|
|
| 582 |
assert_redirected_to :action => 'show', :id => '1'
|
|
| 493 | 583 |
j = Issue.find(1).journals.find(:first, :order => 'id DESC') |
| 494 | 584 |
assert j.notes.blank? |
| 495 | 585 |
assert_equal 1, j.details.size |
| ... | ... | |
| 508 | 598 |
post :edit, |
| 509 | 599 |
:id => 1, |
| 510 | 600 |
:notes => '' |
| 511 |
assert_redirected_to 'issues/show/1'
|
|
| 601 |
assert_redirected_to :action => 'show', :id => '1'
|
|
| 512 | 602 |
|
| 513 | 603 |
issue.reload |
| 514 | 604 |
assert issue.journals.empty? |
| ... | ... | |
| 536 | 626 |
assert_nil Issue.find(2).assigned_to |
| 537 | 627 |
end |
| 538 | 628 |
|
| 629 |
def test_move_routing |
|
| 630 |
assert_routing( |
|
| 631 |
{:method => :get, :path => '/issues/1/move'},
|
|
| 632 |
:controller => 'issues', :action => 'move', :id => '1' |
|
| 633 |
) |
|
| 634 |
assert_recognizes( |
|
| 635 |
{:controller => 'issues', :action => 'move', :id => '1'},
|
|
| 636 |
{:method => :post, :path => '/issues/1/move'}
|
|
| 637 |
) |
|
| 638 |
end |
|
| 639 |
|
|
| 539 | 640 |
def test_move_one_issue_to_another_project |
| 540 | 641 |
@request.session[:user_id] = 1 |
| 541 | 642 |
post :move, :id => 1, :new_project_id => 2 |
| 542 |
assert_redirected_to 'projects/ecookbook/issues'
|
|
| 643 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
| 543 | 644 |
assert_equal 2, Issue.find(1).project_id |
| 544 | 645 |
end |
| 545 | 646 | |
| 546 | 647 |
def test_bulk_move_to_another_project |
| 547 | 648 |
@request.session[:user_id] = 1 |
| 548 | 649 |
post :move, :ids => [1, 2], :new_project_id => 2 |
| 549 |
assert_redirected_to 'projects/ecookbook/issues'
|
|
| 650 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
| 550 | 651 |
# Issues moved to project 2 |
| 551 | 652 |
assert_equal 2, Issue.find(1).project_id |
| 552 | 653 |
assert_equal 2, Issue.find(2).project_id |
| ... | ... | |
| 558 | 659 |
def test_bulk_move_to_another_tracker |
| 559 | 660 |
@request.session[:user_id] = 1 |
| 560 | 661 |
post :move, :ids => [1, 2], :new_tracker_id => 2 |
| 561 |
assert_redirected_to 'projects/ecookbook/issues'
|
|
| 662 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
| 562 | 663 |
assert_equal 2, Issue.find(1).tracker_id |
| 563 | 664 |
assert_equal 2, Issue.find(2).tracker_id |
| 564 | 665 |
end |
| ... | ... | |
| 569 | 670 |
assert_response :success |
| 570 | 671 |
assert_template 'context_menu' |
| 571 | 672 |
assert_tag :tag => 'a', :content => 'Edit', |
| 572 |
:attributes => { :href => '/issues/edit/1',
|
|
| 673 |
:attributes => { :href => '/issues/1/edit',
|
|
| 573 | 674 |
:class => 'icon-edit' } |
| 574 | 675 |
assert_tag :tag => 'a', :content => 'Closed', |
| 575 |
:attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5',
|
|
| 676 |
:attributes => { :href => '/issues/1/edit?issue%5Bstatus_id%5D=5',
|
|
| 576 | 677 |
:class => '' } |
| 577 | 678 |
assert_tag :tag => 'a', :content => 'Immediate', |
| 578 | 679 |
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&priority_id=8',
|
| ... | ... | |
| 581 | 682 |
:attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&ids%5B%5D=1',
|
| 582 | 683 |
:class => '' } |
| 583 | 684 |
assert_tag :tag => 'a', :content => 'Copy', |
| 584 |
:attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1',
|
|
| 685 |
:attributes => { :href => '/projects/ecookbook/issues/1/copy',
|
|
| 585 | 686 |
:class => 'icon-copy' } |
| 586 | 687 |
assert_tag :tag => 'a', :content => 'Move', |
| 587 | 688 |
:attributes => { :href => '/issues/move?ids%5B%5D=1',
|
| ... | ... | |
| 632 | 733 |
:class => 'icon-del disabled' } |
| 633 | 734 |
end |
| 634 | 735 |
|
| 736 |
def test_destroy_routing |
|
| 737 |
assert_recognizes( #TODO: use DELETE on issue URI (need to change forms) |
|
| 738 |
{:controller => 'issues', :action => 'destroy', :id => '1'},
|
|
| 739 |
{:method => :post, :path => '/issues/1/destroy'}
|
|
| 740 |
) |
|
| 741 |
end |
|
| 742 |
|
|
| 635 | 743 |
def test_destroy_issue_with_no_time_entries |
| 636 | 744 |
assert_nil TimeEntry.find_by_issue_id(2) |
| 637 | 745 |
@request.session[:user_id] = 2 |
| 638 | 746 |
post :destroy, :id => 2 |
| 639 |
assert_redirected_to 'projects/ecookbook/issues'
|
|
| 747 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
| 640 | 748 |
assert_nil Issue.find_by_id(2) |
| 641 | 749 |
end |
| 642 | 750 | |
| ... | ... | |
| 652 | 760 |
def test_destroy_issues_and_destroy_time_entries |
| 653 | 761 |
@request.session[:user_id] = 2 |
| 654 | 762 |
post :destroy, :ids => [1, 3], :todo => 'destroy' |
| 655 |
assert_redirected_to 'projects/ecookbook/issues'
|
|
| 763 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
| 656 | 764 |
assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
| 657 | 765 |
assert_nil TimeEntry.find_by_id([1, 2]) |
| 658 | 766 |
end |
| ... | ... | |
| 660 | 768 |
def test_destroy_issues_and_assign_time_entries_to_project |
| 661 | 769 |
@request.session[:user_id] = 2 |
| 662 | 770 |
post :destroy, :ids => [1, 3], :todo => 'nullify' |
| 663 |
assert_redirected_to 'projects/ecookbook/issues'
|
|
| 771 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
| 664 | 772 |
assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
| 665 | 773 |
assert_nil TimeEntry.find(1).issue_id |
| 666 | 774 |
assert_nil TimeEntry.find(2).issue_id |
| ... | ... | |
| 669 | 777 |
def test_destroy_issues_and_reassign_time_entries_to_another_issue |
| 670 | 778 |
@request.session[:user_id] = 2 |
| 671 | 779 |
post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2 |
| 672 |
assert_redirected_to 'projects/ecookbook/issues'
|
|
| 780 |
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
| 673 | 781 |
assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
| 674 | 782 |
assert_equal 2, TimeEntry.find(1).issue_id |
| 675 | 783 |
assert_equal 2, TimeEntry.find(2).issue_id |
| ... | ... | |
| 680 | 788 |
a = issue.attachments.size |
| 681 | 789 |
@request.session[:user_id] = 2 |
| 682 | 790 |
post :destroy_attachment, :id => 3, :attachment_id => 1 |
| 683 |
assert_redirected_to 'issues/show/3'
|
|
| 791 |
assert_redirected_to :action => 'show', :id => '3'
|
|
| 684 | 792 |
assert_nil Attachment.find_by_id(1) |
| 685 | 793 |
issue.reload |
| 686 | 794 |
assert_equal((a-1), issue.attachments.size) |
| test/functional/members_controller_test.rb | ||
|---|---|---|
| 1 |
require File.dirname(__FILE__) + '/../test_helper' |
|
| 2 |
require 'members_controller' |
|
| 3 | ||
| 4 |
# Re-raise errors caught by the controller. |
|
| 5 |
class MembersController; def rescue_action(e) raise e end; end |
|
| 6 | ||
| 7 | ||
| 8 |
class MembersControllerTest < Test::Unit::TestCase |
|
| 9 |
def test_members_routing |
|
| 10 |
assert_routing( |
|
| 11 |
{:method => :post, :path => 'projects/5234/members/new'},
|
|
| 12 |
:controller => 'members', :action => 'new', :id => '5234' |
|
| 13 |
) |
|
| 14 |
end |
|
| 15 |
end |
|
| test/functional/messages_controller_test.rb | ||
|---|---|---|
| 31 | 31 |
User.current = nil |
| 32 | 32 |
end |
| 33 | 33 |
|
| 34 |
def test_show_routing |
|
| 35 |
assert_routing( |
|
| 36 |
{:method => :get, :path => '/boards/22/topics/2'},
|
|
| 37 |
:controller => 'messages', :action => 'show', :id => '2', :board_id => '22' |
|
| 38 |
) |
|
| 39 |
end |
|
| 40 |
|
|
| 34 | 41 |
def test_show |
| 35 | 42 |
get :show, :board_id => 1, :id => 1 |
| 36 | 43 |
assert_response :success |
| ... | ... | |
| 54 | 61 |
assert_response 404 |
| 55 | 62 |
end |
| 56 | 63 |
|
| 64 |
def test_new_routing |
|
| 65 |
assert_routing( |
|
| 66 |
{:method => :get, :path => '/boards/lala/topics/new'},
|
|
| 67 |
:controller => 'messages', :action => 'new', :board_id => 'lala' |
|
| 68 |
) |
|
| 69 |
assert_recognizes(#TODO: POST to collection, need to adjust form accordingly |
|
| 70 |
{:controller => 'messages', :action => 'new', :board_id => 'lala'},
|
|
| 71 |
{:method => :post, :path => '/boards/lala/topics/new'}
|
|
| 72 |
) |
|
| 73 |
end |
|
| 74 |
|
|
| 57 | 75 |
def test_get_new |
| 58 | 76 |
@request.session[:user_id] = 2 |
| 59 | 77 |
get :new, :board_id => 1 |
| ... | ... | |
| 86 | 104 |
assert mail.bcc.include?('dlopper@somenet.foo')
|
| 87 | 105 |
end |
| 88 | 106 |
|
| 107 |
def test_edit_routing |
|
| 108 |
assert_routing( |
|
| 109 |
{:method => :get, :path => '/boards/lala/topics/22/edit'},
|
|
| 110 |
:controller => 'messages', :action => 'edit', :board_id => 'lala', :id => '22' |
|
| 111 |
) |
|
| 112 |
assert_recognizes( #TODO: use PUT to topic_path, modify form accordingly |
|
| 113 |
{:controller => 'messages', :action => 'edit', :board_id => 'lala', :id => '22'},
|
|
| 114 |
{:method => :post, :path => '/boards/lala/topics/22/edit'}
|
|
| 115 |
) |
|
| 116 |
end |
|
| 117 |
|
|
| 89 | 118 |
def test_get_edit |
| 90 | 119 |
@request.session[:user_id] = 2 |
| 91 | 120 |
get :edit, :board_id => 1, :id => 1 |
| ... | ... | |
| 104 | 133 |
assert_equal 'New body', message.content |
| 105 | 134 |
end |
| 106 | 135 |
|
| 136 |
def test_reply_routing |
|
| 137 |
assert_recognizes( |
|
| 138 |
{:controller => 'messages', :action => 'reply', :board_id => '22', :id => '555'},
|
|
| 139 |
{:method => :post, :path => '/boards/22/topics/555/replies'}
|
|
| 140 |
) |
|
| 141 |
end |
|
| 142 |
|
|
| 107 | 143 |
def test_reply |
| 108 | 144 |
@request.session[:user_id] = 2 |
| 109 | 145 |
post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
|
| ... | ... | |
| 111 | 147 |
assert Message.find_by_subject('Test reply')
|
| 112 | 148 |
end |
| 113 | 149 |
|
| 150 |
def test_destroy_routing |
|
| 151 |
assert_recognizes(#TODO: use DELETE to topic_path, adjust form accordingly |
|
| 152 |
{:controller => 'messages', :action => 'destroy', :board_id => '22', :id => '555'},
|
|
| 153 |
{:method => :post, :path => '/boards/22/topics/555/destroy'}
|
|
| 154 |
) |
|
| 155 |
end |
|
| 156 |
|
|
| 114 | 157 |
def test_destroy_topic |
| 115 | 158 |
@request.session[:user_id] = 2 |
| 116 | 159 |
post :destroy, :board_id => 1, :id => 1 |
| test/functional/news_controller_test.rb | ||
|---|---|---|
| 31 | 31 |
User.current = nil |
| 32 | 32 |
end |
| 33 | 33 |
|
| 34 |
def test_index_routing |
|
| 35 |
assert_routing( |
|
| 36 |
{:method => :get, :path => '/news'},
|
|
| 37 |
:controller => 'news', :action => 'index' |
|
| 38 |
) |
|
| 39 |
end |
|
| 40 |
|
|
| 41 |
def test_index_routing_formatted |
|
| 42 |
assert_routing( |
|
| 43 |
{:method => :get, :path => '/news.atom'},
|
|
| 44 |
:controller => 'news', :action => 'index', :format => 'atom' |
|
| 45 |
) |
|
| 46 |
end |
|
| 47 |
|
|
| 34 | 48 |
def test_index |
| 35 | 49 |
get :index |
| 36 | 50 |
assert_response :success |
| ... | ... | |
| 38 | 52 |
assert_not_nil assigns(:newss) |
| 39 | 53 |
assert_nil assigns(:project) |
| 40 | 54 |
end |
| 55 |
|
|
| 56 |
def test_index_with_project_routing |
|
| 57 |
assert_routing( |
|
| 58 |
{:method => :get, :path => '/projects/567/news'},
|
|
| 59 |
:controller => 'news', :action => 'index', :project_id => '567' |
|
| 60 |
) |
|
| 61 |
end |
|
| 62 |
|
|
| 63 |
def test_index_with_project_routing_formatted |
|
| 64 |
assert_routing( |
|
| 65 |
{:method => :get, :path => '/projects/567/news.atom'},
|
|
| 66 |
:controller => 'news', :action => 'index', :project_id => '567', :format => 'atom' |
|
| 67 |
) |
|
| 68 |
end |
|
| 41 | 69 | |
| 42 | 70 |
def test_index_with_project |
| 43 | 71 |
get :index, :project_id => 1 |
| ... | ... | |
| 46 | 74 |
assert_not_nil assigns(:newss) |
| 47 | 75 |
end |
| 48 | 76 |
|
| 77 |
def test_show_routing |
|
| 78 |
assert_routing( |
|
| 79 |
{:method => :get, :path => '/news/2'},
|
|
| 80 |
:controller => 'news', :action => 'show', :id => '2' |
|
| 81 |
) |
|
| 82 |
end |
|
| 83 |
|
|
| 49 | 84 |
def test_show |
| 50 | 85 |
get :show, :id => 1 |
| 51 | 86 |
assert_response :success |
| ... | ... | |
| 58 | 93 |
assert_response 404 |
| 59 | 94 |
end |
| 60 | 95 |
|
| 96 |
def test_new_routing |
|
| 97 |
assert_routing( |
|
| 98 |
{:method => :get, :path => '/projects/567/news/new'},
|
|
| 99 |
:controller => 'news', :action => 'new', :project_id => '567' |
|
| 100 |
) |
|
| 101 |
assert_recognizes( |
|
| 102 |
{:controller => 'news', :action => 'new', :project_id => '567'},
|
|
| 103 |
{:method => :post, :path => '/projects/567/news'}
|
|
| 104 |
) |
|
| 105 |
end |
|
| 106 |
|
|
| 61 | 107 |
def test_get_new |
| 62 | 108 |
@request.session[:user_id] = 2 |
| 63 | 109 |
get :new, :project_id => 1 |
| ... | ... | |
| 79 | 125 |
assert_equal Project.find(1), news.project |
| 80 | 126 |
end |
| 81 | 127 |
|
| 128 |
def test_edit_routing |
|
| 129 |
assert_routing( |
|
| 130 |
{:method => :get, :path => '/news/234'},
|
|
| 131 |
:controller => 'news', :action => 'show', :id => '234' |
|
| 132 |
) |
|
| 133 |
assert_recognizes(#TODO: PUT to news URI instead, need to modify form |
|
| 134 |
{:controller => 'news', :action => 'edit', :id => '567'},
|
|
| 135 |
{:method => :post, :path => '/news/567/edit'}
|
|
| 136 |
) |
|
| 137 |
end |
|
| 138 |
|
|
| 82 | 139 |
def test_get_edit |
| 83 | 140 |
@request.session[:user_id] = 2 |
| 84 | 141 |
get :edit, :id => 1 |
| ... | ... | |
| 127 | 184 |
assert_equal comments_count - 1, News.find(1).comments.size |
| 128 | 185 |
end |
| 129 | 186 |
|
| 187 |
def test_destroy_routing |
|
| 188 |
assert_recognizes(#TODO: should use DELETE to news URI, need to change form |
|
| 189 |
{:controller => 'news', :action => 'destroy', :id => '567'},
|
|
| 190 |
{:method => :post, :path => '/news/567/destroy'}
|
|
| 191 |
) |
|
| 192 |
end |
|
| 193 |
|
|
| 130 | 194 |
def test_destroy |
| 131 | 195 |
@request.session[:user_id] = 2 |
| 132 | 196 |
post :destroy, :id => 1 |
| test/functional/projects_controller_test.rb | ||
|---|---|---|
| 31 | 31 |
@response = ActionController::TestResponse.new |
| 32 | 32 |
@request.session[:user_id] = nil |
| 33 | 33 |
end |
| 34 | ||
| 34 |
|
|
| 35 |
def test_index_routing |
|
| 36 |
assert_routing( |
|
| 37 |
{:method => :get, :path => '/projects'},
|
|
| 38 |
:controller => 'projects', :action => 'index' |
|
| 39 |
) |
|
| 40 |
end |
|
| 41 |
|
|
| 35 | 42 |
def test_index |
| 36 | 43 |
get :index |
| 37 | 44 |
assert_response :success |
| ... | ... | |
| 41 | 48 |
assert assigns(:project_tree).keys.include?(Project.find(1)) |
| 42 | 49 |
# Subproject in corresponding value |
| 43 | 50 |
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3)) |
| 44 |
end |
|
| 51 |
end |
|
| 52 |
|
|
| 53 |
def test_index_atom_routing |
|
| 54 |
assert_routing( |
|
| 55 |
{:method => :get, :path => '/projects.atom'},
|
|
| 56 |
:controller => 'projects', :action => 'index', :format => 'atom' |
|
| 57 |
) |
|
| 58 |
end |
|
| 45 | 59 |
|
| 46 | 60 |
def test_index_atom |
| 47 | 61 |
get :index, :format => 'atom' |
| ... | ... | |
| 50 | 64 |
assert_select 'feed>title', :text => 'Redmine: Latest projects' |
| 51 | 65 |
assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current)) |
| 52 | 66 |
end |
| 53 |
|
|
| 54 |
def test_show_by_id |
|
| 55 |
get :show, :id => 1 |
|
| 67 |
|
|
| 68 |
def test_add_routing |
|
| 69 |
assert_routing( |
|
| 70 |
{:method => :get, :path => '/projects/new'},
|
|
| 71 |
:controller => 'projects', :action => 'add' |
|
| 72 |
) |
|
| 73 |
assert_recognizes( |
|
| 74 |
{:controller => 'projects', :action => 'add'},
|
|
| 75 |
{:method => :post, :path => '/projects'}
|
|
| 76 |
) |
|
| 77 |
end |
|
| 78 |
|
|
| 79 |
def test_show_routing |
|
| 80 |
assert_routing( |
|
| 81 |
{:method => :get, :path => '/projects/test'},
|
|
| 82 |
:controller => 'projects', :action => 'show', :id => 'test' |
|
| 83 |
) |
|
| 84 |
end |
|
| 85 |
|
|
| 86 |
def test_show_by_id |
|
| 87 |
get :show, :id => 1 |
|
| 56 | 88 |
assert_response :success |
| 57 |
assert_template 'show'
|
|
| 58 |
assert_not_nil assigns(:project)
|
|
| 89 |
assert_template 'show' |
|
| 90 |
assert_not_nil assigns(:project) |
|
| 59 | 91 |
end |
| 60 | 92 | |
| 61 | 93 |
def test_show_by_identifier |
| ... | ... | |
| 81 | 113 |
assert_tag :tag => 'a', :content => /Private child/ |
| 82 | 114 |
end |
| 83 | 115 |
|
| 116 |
def test_settings_routing |
|
| 117 |
assert_routing( |
|
| 118 |
{:method => :get, :path => '/projects/4223/settings'},
|
|
| 119 |
:controller => 'projects', :action => 'settings', :id => '4223' |
|
| 120 |
) |
|
| 121 |
assert_routing( |
|
| 122 |
{:method => :get, :path => '/projects/4223/settings/members'},
|
|
| 123 |
:controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members' |
|
| 124 |
) |
|
| 125 |
end |
|
| 126 |
|
|
| 84 | 127 |
def test_settings |
| 85 | 128 |
@request.session[:user_id] = 2 # manager |
| 86 | 129 |
get :settings, :id => 1 |
| ... | ... | |
| 97 | 140 |
assert_equal 'Test changed name', project.name |
| 98 | 141 |
end |
| 99 | 142 |
|
| 143 |
def test_add_version_routing |
|
| 144 |
assert_routing( |
|
| 145 |
{:method => :get, :path => 'projects/64/versions/new'},
|
|
| 146 |
:controller => 'projects', :action => 'add_version', :id => '64' |
|
| 147 |
) |
|
| 148 |
assert_routing( |
|
| 149 |
#TODO: use PUT |
|
| 150 |
{:method => :post, :path => 'projects/64/versions/new'},
|
|
| 151 |
:controller => 'projects', :action => 'add_version', :id => '64' |
|
| 152 |
) |
|
| 153 |
end |
|
| 154 |
|
|
| 155 |
def test_add_issue_category_routing |
|
| 156 |
assert_routing( |
|
| 157 |
{:method => :get, :path => 'projects/test/categories/new'},
|
|
| 158 |
:controller => 'projects', :action => 'add_issue_category', :id => 'test' |
|
| 159 |
) |
|
| 160 |
assert_routing( |
|
| 161 |
#TODO: use PUT |
|
| 162 |
{:method => :post, :path => 'projects/64/categories/new'},
|
|
| 163 |
:controller => 'projects', :action => 'add_issue_category', :id => '64' |
|
| 164 |
) |
|
| 165 |
end |
|
| 166 |
|
|
| 100 | 167 |
def test_get_destroy |
| 101 | 168 |
@request.session[:user_id] = 1 # admin |
| 102 | 169 |
get :destroy, :id => 1 |
| 103 | 170 |
assert_response :success |
| 104 | 171 |
assert_template 'destroy' |
| 105 | 172 |
assert_not_nil Project.find_by_id(1) |
| 106 |
end
|
|
| 173 |
end |
|
| 107 | 174 | |
| 108 | 175 |
def test_post_destroy |
| 109 | 176 |
@request.session[:user_id] = 1 # admin |
| ... | ... | |
| 111 | 178 |
assert_redirected_to 'admin/projects' |
| 112 | 179 |
assert_nil Project.find_by_id(1) |
| 113 | 180 |
end |
| 114 |
|
|
| 115 |
def test_list_files |
|
| 116 |
get :list_files, :id => 1 |
|
| 117 |
assert_response :success |
|
| 118 |
assert_template 'list_files' |
|
| 119 |
assert_not_nil assigns(:versions) |
|
| 120 |
end |
|
| 121 |
|
|
| 122 |
def test_changelog |
|
| 123 |
get :changelog, :id => 1 |
|
| 124 |
assert_response :success |
|
| 125 |
assert_template 'changelog' |
|
| 126 |
assert_not_nil assigns(:versions) |
|
| 181 |
|
|
| 182 |
def test_list_files_routing |
|
| 183 |
assert_routing( |
|
| 184 |
{:method => :get, :path => '/projects/33/files'},
|
|
| 185 |
:controller => 'projects', :action => 'list_files', :id => '33' |
|
| 186 |
) |
|
| 187 |
end |
|
| 188 |
|
|
| 189 |
def test_add_file_routing |
|
| 190 |
assert_routing( |
|
| 191 |
{:method => :get, :path => '/projects/33/files/new'},
|
|
| 192 |
:controller => 'projects', :action => 'add_file', :id => '33' |
|
| 193 |
) |
|
| 194 |
assert_routing( |
|
| 195 |
{:method => :post, :path => '/projects/33/files/new'},
|
|
| 196 |
:controller => 'projects', :action => 'add_file', :id => '33' |
|
| 197 |
) |
|
| 198 |
end |
|
| 199 |
|
|
| 200 |
def test_list_files |
|
| 201 |
get :list_files, :id => 1 |
|
| 202 |
assert_response :success |
|
| 203 |
assert_template 'list_files' |
|
| 204 |
assert_not_nil assigns(:versions) |
|
| 205 |
end |
|
| 206 |
|
|
| 207 |
def test_changelog_routing |
|
| 208 |
assert_routing( |
|
| 209 |
{:method => :get, :path => '/projects/44/changelog'},
|
|
| 210 |
:controller => 'projects', :action => 'changelog', :id => '44' |
|
| 211 |
) |
|
| 212 |
end |
|
| 213 |
|
|
| 214 |
def test_changelog |
|
| 215 |
get :changelog, :id => 1 |
|
| 216 |
assert_response :success |
|
| 217 |
assert_template 'changelog' |
|
| 218 |
assert_not_nil assigns(:versions) |
|
| 219 |
end |
|
| 220 |
|
|
| 221 |
def test_roadmap_routing |
|
| 222 |
assert_routing( |
|
| 223 |
{:method => :get, :path => 'projects/33/roadmap'},
|
|
| 224 |
:controller => 'projects', :action => 'roadmap', :id => '33' |
|
| 225 |
) |
|
| 127 | 226 |
end |
| 128 | 227 |
|
| 129 | 228 |
def test_roadmap |
| ... | ... | |
| 147 | 246 |
# Completed version appears |
| 148 | 247 |
assert assigns(:versions).include?(Version.find(1)) |
| 149 | 248 |
end |
| 150 | ||
| 249 |
|
|
| 250 |
def test_project_activity_routing |
|
| 251 |
assert_routing( |
|
| 252 |
{:method => :get, :path => '/projects/1/activity'},
|
|
| 253 |
:controller => 'projects', :action => 'activity', :id => '1' |
|
| 254 |
) |
|
| 255 |
end |
|
| 256 |
|
|
| 257 |
def test_project_activity_atom_routing |
|
| 258 |
assert_routing( |
|
| 259 |
{:method => :get, :path => '/projects/1/activity.atom'},
|
|
| 260 |
:controller => 'projects', :action => 'activity', :id => '1', :format => 'atom' |
|
| 261 |
) |
|
| 262 |
end |
|
| 263 |
|
|
| 151 | 264 |
def test_project_activity |
| 152 | 265 |
get :activity, :id => 1, :with_subprojects => 0 |
| 153 | 266 |
assert_response :success |
| ... | ... | |
| 184 | 297 |
} |
| 185 | 298 |
end |
| 186 | 299 |
|
| 300 |
def test_global_activity_routing |
|
| 301 |
assert_routing({:method => :get, :path => '/activity'}, :controller => 'projects', :action => 'activity')
|
|
| 302 |
end |
|
| 303 |
|
|
| 187 | 304 |
def test_global_activity |
| 188 | 305 |
get :activity |
| 189 | 306 |
assert_response :success |
| ... | ... | |
| 202 | 319 |
} |
| 203 | 320 |
end |
| 204 | 321 |
|
| 322 |
def test_global_activity_atom_routing |
|
| 323 |
assert_routing({:method => :get, :path => '/activity.atom'}, :controller => 'projects', :action => 'activity', :format => 'atom')
|
|
| 324 |
end |
|
| 325 |
|
|
| 205 | 326 |
def test_activity_atom_feed |
| 206 | 327 |
get :activity, :format => 'atom' |
| 207 | 328 |
assert_response :success |
| test/functional/reports_controller_test.rb | ||
|---|---|---|
| 1 |
require File.dirname(__FILE__) + '/../test_helper' |
|
| 2 |
require 'reports_controller' |
|
| 3 | ||
| 4 |
# Re-raise errors caught by the controller. |
|
| 5 |
class ReportsController; def rescue_action(e) raise e end; end |
|
| 6 | ||
| 7 | ||
| 8 |
class ReportsControllerTest < Test::Unit::TestCase |
|
| 9 |
def test_issue_report_routing |
|
| 10 |
assert_routing( |
|
| 11 |
{:method => :get, :path => '/projects/567/issues/report'},
|
|
| 12 |
:controller => 'reports', :action => 'issue_report', :id => '567' |
|
| 13 |
) |
|
| 14 |
assert_routing( |
|
| 15 |
{:method => :get, :path => '/projects/567/issues/report/assigned_to'},
|
|
| 16 |
:controller => 'reports', :action => 'issue_report', :id => '567', :detail => 'assigned_to' |
|
| 17 |
) |
|
| 18 |
|
|
| 19 |
end |
|
| 20 |
end |
|
| test/functional/repositories_controller_test.rb | ||
|---|---|---|
| 31 | 31 |
User.current = nil |
| 32 | 32 |
end |
| 33 | 33 |
|
| 34 |
def test_show_routing |
|
| 35 |
assert_routing( |
|
| 36 |
{:method => :get, :path => '/projects/redmine/repository'},
|
|
| 37 |
:controller => 'repositories', :action => 'show', :id => 'redmine' |
|
| 38 |
) |
|
| 39 |
end |
|
| 40 |
|
|
| 41 |
def test_edit_routing |
|
| 42 |
assert_routing( |
|
| 43 |
{:method => :get, :path => '/projects/world_domination/repository/edit'},
|
|
| 44 |
:controller => 'repositories', :action => 'edit', :id => 'world_domination' |
|
| 45 |
) |
|
| 46 |
assert_routing( |
|
| 47 |
{:method => :post, :path => '/projects/world_domination/repository/edit'},
|
|
| 48 |
:controller => 'repositories', :action => 'edit', :id => 'world_domination' |
|
| 49 |
) |
|
| 50 |
end |
|
| 51 |
|
|
| 52 |
def test_revisions_routing |
|
| 53 |
assert_routing( |
|
| 54 |
{:method => :get, :path => '/projects/redmine/repository/revisions'},
|
|
| 55 |
:controller => 'repositories', :action => 'revisions', :id => 'redmine' |
|
| 56 |
) |
|
| 57 |
end |
|
| 58 |
|
|
| 59 |
def test_revisions_atom_routing |
|
| 60 |
assert_routing( |
|
| 61 |
{:method => :get, :path => '/projects/redmine/repository/revisions.atom'},
|
|
| 62 |
:controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom' |
|
| 63 |
) |
|
| 64 |
end |
|
| 65 |
|
|
| 34 | 66 |
def test_revisions |
| 35 | 67 |
get :revisions, :id => 1 |
| 36 | 68 |
assert_response :success |
| 37 | 69 |
assert_template 'revisions' |
| 38 | 70 |
assert_not_nil assigns(:changesets) |
| 39 | 71 |
end |
| 72 | ||
| 73 |
def test_revision_routing |
|
| 74 |
assert_routing( |
|
| 75 |
{:method => :get, :path => '/projects/restmine/repository/revisions/2457'},
|
|
| 76 |
:controller => 'repositories', :action => 'revision', :id => 'restmine', :rev => '2457' |
|
| 77 |
) |
|
| 78 |
end |
|
| 40 | 79 |
|
| 41 | 80 |
def test_revision_with_before_nil_and_afer_normal |
| 42 | 81 |
get :revision, {:id => 1, :rev => 1}
|
| 43 | 82 |
assert_response :success |
| 44 | 83 |
assert_template 'revision' |
| 45 | 84 |
assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
|
| 46 |
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook/0'}
|
|
| 85 |
:child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/0'}
|
|
| 47 | 86 |
} |
| 48 | 87 |
assert_tag :tag => "div", :attributes => { :class => "contextual" },
|
| 49 |
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook/2'}
|
|
| 88 |
:child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/2'}
|
|
| 50 | 89 |
} |
| 51 | 90 |
end |
| 52 | ||
| 91 |
|
|
| 92 |
def test_diff_routing |
|
| 93 |
assert_routing( |
|
| 94 |
{:method => :get, :path => '/projects/restmine/repository/revisions/2457/diff'},
|
|
| 95 |
:controller => 'repositories', :action => 'diff', :id => 'restmine', :rev => '2457' |
|
| 96 |
) |
|
| 97 |
end |
|
| 98 |
|
|
| 99 |
def test_unified_diff_routing |
|
| 100 |
assert_routing( |
|
| 101 |
{:method => :get, :path => '/projects/restmine/repository/revisions/2457/diff.diff'},
|
|
| 102 |
:controller => 'repositories', :action => 'diff', :id => 'restmine', :rev => '2457', :format => 'diff' |
|
| 103 |
) |
|
| 104 |
end |
|
| 105 |
|
|
| 106 |
def test_diff_path_routing |
|
| 107 |
assert_routing( |
|
| 108 |
{:method => :get, :path => '/projects/restmine/repository/diff/path/to/file.c'},
|
|
| 109 |
:controller => 'repositories', :action => 'diff', :id => 'restmine', :path => %w[path to file.c] |
|
| 110 |
) |
|
| 111 |
end |
|
| 112 |
|
|
| 113 |
def test_browse_routing |
|
| 114 |
assert_routing( |
|
| 115 |
{:method => :get, :path => '/projects/restmine/repository/browse/path/to/dir'},
|
|
| 116 |
:controller => 'repositories', :action => 'browse', :id => 'restmine', :path => %w[path to dir] |
|
| 117 |
) |
|
| 118 |
end |
|
| 119 |
|
|
| 120 |
def test_entry_routing |
|
| 121 |
assert_routing( |
|
| 122 |
{:method => :get, :path => '/projects/restmine/repository/entry/path/to/file.c'},
|
|
| 123 |
:controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c] |
|
| 124 |
) |
|
| 125 |
end |
|
| 126 |
|
|
| 127 |
def test_annotate_routing |
|
| 128 |
assert_routing( |
|
| 129 |
{:method => :get, :path => '/projects/restmine/repository/annotate/path/to/file.c'},
|
|
| 130 |
:controller => 'repositories', :action => 'annotate', :id => 'restmine', :path => %w[path to file.c] |
|
| 131 |
) |
|
| 132 |
end |
|
| 133 |
|
|
| 134 |
def test_changesrouting |
|
| 135 |
assert_routing( |
|
| 136 |
{:method => :get, :path => '/projects/restmine/repository/changes/path/to/file.c'},
|
|
| 137 |
:controller => 'repositories', :action => 'changes', :id => 'restmine', :path => %w[path to file.c] |
|
| 138 |
) |
|
| 139 |
end |
|
| 140 |
|
|
| 141 |
def test_statistics_routing |
|
| 142 |
assert_routing( |
|
| 143 |
{:method => :get, :path => '/projects/restmine/repository/statistics'},
|
|
| 144 |
:controller => 'repositories', :action => 'stats', :id => 'restmine' |
|
| 145 |
) |
|
| 146 |
end |
|
| 147 |
|
|
| 53 | 148 |
def test_graph_commits_per_month |
| 54 | 149 |
get :graph, :id => 1, :graph => 'commits_per_month' |
| 55 | 150 |
assert_response :success |
| test/functional/wiki_controller_test.rb | ||
|---|---|---|
| 31 | 31 |
User.current = nil |
| 32 | 32 |
end |
| 33 | 33 |
|
| 34 |
def test_index_routing |
|
| 35 |
assert_routing( |
|
| 36 |
{:method => :get, :path => '/projects/567/wiki'},
|
|
| 37 |
:controller => 'wiki', :action => 'index', :id => '567' |
|
| 38 |
) |
|
| 39 |
assert_routing( |
|
| 40 |
{:method => :get, :path => '/projects/567/wiki/lalala'},
|
|
| 41 |
:controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala' |
|
| 42 |
) |
|
| 43 |
assert_generates( |
|
| 44 |
'/projects/567/wiki', |
|
| 45 |
:controller => 'wiki', :action => 'index', :id => '567', :page => nil |
|
| 46 |
) |
|
| 47 |
end |
|
| 48 |
|
|
| 34 | 49 |
def test_show_start_page |
| 35 | 50 |
get :index, :id => 'ecookbook' |
| 36 | 51 |
assert_response :success |
| ... | ... | |
| 40 | 55 |
# child_pages macro |
| 41 | 56 |
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
| 42 | 57 |
:child => { :tag => 'li',
|
| 43 |
:child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' },
|
|
| 58 |
:child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
|
|
| 44 | 59 |
:content => 'Page with an inline image' } } |
| 45 | 60 |
end |
| 46 | 61 |
|
| ... | ... | |
| 67 | 82 |
assert_template 'edit' |
| 68 | 83 |
end |
| 69 | 84 |
|
| 85 |
def test_edit_routing |
|
| 86 |
assert_routing( |
|
| 87 |
{:method => :get, :path => '/projects/567/wiki/my_page/edit'},
|
|
| 88 |
:controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page' |
|
| 89 |
) |
|
| 90 |
assert_recognizes(#TODO: use PUT to page path, adjust forms accordingly |
|
| 91 |
{:controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'},
|
|
| 92 |
{:method => :post, :path => '/projects/567/wiki/my_page/edit'}
|
|
| 93 |
) |
|
| 94 |
end |
|
| 95 |
|
|
| 70 | 96 |
def test_create_page |
| 71 | 97 |
@request.session[:user_id] = 2 |
| 72 | 98 |
post :edit, :id => 1, |
| ... | ... | |
| 74 | 100 |
:content => {:comments => 'Created the page',
|
| 75 | 101 |
:text => "h1. New page\n\nThis is a new page", |
| 76 | 102 |
:version => 0} |
| 77 |
assert_redirected_to 'wiki/ecookbook/New_page'
|
|
| 103 |
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'New_page'
|
|
| 78 | 104 |
page = Project.find(1).wiki.find_page('New page')
|
| 79 | 105 |
assert !page.new_record? |
| 80 | 106 |
assert_not_nil page.content |
| 81 | 107 |
assert_equal 'Created the page', page.content.comments |
| 82 | 108 |
end |
| 83 | 109 |
|
| 110 |
def test_preview_routing |
|
| 111 |
assert_routing( |
|
| 112 |
{:method => :post, :path => '/projects/567/wiki/CookBook_documentation/preview'},
|
|
| 113 |
:controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation' |
|
| 114 |
) |
|
| 115 |
end |
|
| 116 |
|
|
| 84 | 117 |
def test_preview |
| 85 | 118 |
@request.session[:user_id] = 2 |
| 86 | 119 |
xhr :post, :preview, :id => 1, :page => 'CookBook_documentation', |
| ... | ... | |
| 103 | 136 |
assert_tag :tag => 'h1', :content => /New page/ |
| 104 | 137 |
end |
| 105 | 138 |
|
| 139 |
def test_history_routing |
|
| 140 |
assert_routing( |
|
| 141 |
{:method => :get, :path => '/projects/1/wiki/CookBook_documentation/history'},
|
|
| 142 |
:controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation' |
|
| 143 |
) |
|
| 144 |
end |
|
| 145 |
|
|
| 106 | 146 |
def test_history |
| 107 | 147 |
get :history, :id => 1, :page => 'CookBook_documentation' |
| 108 | 148 |
assert_response :success |
| ... | ... | |
| 120 | 160 |
assert_equal 1, assigns(:versions).size |
| 121 | 161 |
assert_select "input[type=submit][name=commit]", false |
| 122 | 162 |
end |
| 163 |
|
|
| 164 |
def test_diff_routing |
|
| 165 |
assert_routing( |
|
| 166 |
{:method => :get, :path => '/projects/1/wiki/CookBook_documentation/diff/2/vs/1'},
|
|
| 167 |
:controller => 'wiki', :action => 'diff', :id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1' |
|
| 168 |
) |
|
| 169 |
end |
|
| 123 | 170 | |
| 124 | 171 |
def test_diff |
| 125 | 172 |
get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1 |
| ... | ... | |
| 129 | 176 |
:content => /updated/ |
| 130 | 177 |
end |
| 131 | 178 |
|
| 179 |
def test_annotate_routing |
|
| 180 |
assert_routing( |
|
| 181 |
{:method => :get, :path => '/projects/1/wiki/CookBook_documentation/annotate/2'},
|
|
| 182 |
:controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2' |
|
| 183 |
) |
|
| 184 |
end |
|
| 185 |
|
|
| 132 | 186 |
def test_annotate |
| 133 | 187 |
get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2 |
| 134 | 188 |
assert_response :success |
| ... | ... | |
| 143 | 197 |
:child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
|
| 144 | 198 |
end |
| 145 | 199 |
|
| 200 |
def test_rename_routing |
|
| 201 |
assert_routing( |
|
| 202 |
{:method => :get, :path => '/projects/22/wiki/ladida/rename'},
|
|
| 203 |
:controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida' |
|
| 204 |
) |
|
| 205 |
assert_recognizes( |
|
| 206 |
#TODO: should be moved into a update action and use a PUT to the page URI |
|
| 207 |
{:controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'},
|
|
| 208 |
{:method => :post, :path => '/projects/22/wiki/ladida/rename'}
|
|
| 209 |
) |
|
| 210 |
end |
|
| 211 |
|
|
| 146 | 212 |
def test_rename_with_redirect |
| 147 | 213 |
@request.session[:user_id] = 2 |
| 148 | 214 |
post :rename, :id => 1, :page => 'Another_page', |
| 149 | 215 |
:wiki_page => { :title => 'Another renamed page',
|
| 150 | 216 |
:redirect_existing_links => 1 } |
| 151 |
assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
|
|
| 217 |
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_renamed_page'
|
|
| 152 | 218 |
wiki = Project.find(1).wiki |
| 153 | 219 |
# Check redirects |
| 154 | 220 |
assert_not_nil wiki.find_page('Another page')
|
| ... | ... | |
| 160 | 226 |
post :rename, :id => 1, :page => 'Another_page', |
| 161 | 227 |
:wiki_page => { :title => 'Another renamed page',
|
| 162 | 228 |
:redirect_existing_links => "0" } |
| 163 |
assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
|
|
| 229 |
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_renamed_page'
|
|
| 164 | 230 |
wiki = Project.find(1).wiki |
| 165 | 231 |
# Check that there's no redirects |
| 166 | 232 |
assert_nil wiki.find_page('Another page')
|
| 167 | 233 |
end |
| 168 | 234 |
|
| 235 |
def test_destroy_routing |
|
| 236 |
assert_recognizes( |
|
| 237 |
#TODO: should use DELETE on page URI |
|
| 238 |
{:controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida'},
|
|
| 239 |
{:method => :post, :path => 'projects/22/wiki/ladida/destroy'}
|
|
| 240 |
) |
|
| 241 |
end |
|
| 242 |
|
|
| 169 | 243 |
def test_destroy |
| 170 | 244 |
@request.session[:user_id] = 2 |
| 171 | 245 |
post :destroy, :id => 1, :page => 'CookBook_documentation' |
| 172 |
assert_redirected_to 'wiki/ecookbook/Page_index/special' |
|
| 246 |
assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index' |
|