Revision 1297:0a574315af3e .svn/pristine/19
| .svn/pristine/19/1905c04f7ae0c6da24070033b03c6ae55e5dcb3e.svn-base | ||
|---|---|---|
| 1 |
<%= render :partial => 'action_menu' %> |
|
| 2 |
|
|
| 3 |
<h2><%=l(:label_workflow)%></h2> |
|
| 4 |
|
|
| 5 |
<div class="tabs"> |
|
| 6 |
<ul> |
|
| 7 |
<li><%= link_to l(:label_status_transitions), {:action => 'edit', :role_id => @role, :tracker_id => @tracker} %></li>
|
|
| 8 |
<li><%= link_to l(:label_fields_permissions), {:action => 'permissions', :role_id => @role, :tracker_id => @tracker}, :class => 'selected' %></li>
|
|
| 9 |
</ul> |
|
| 10 |
</div> |
|
| 11 |
|
|
| 12 |
<p><%=l(:text_workflow_edit)%>:</p> |
|
| 13 |
|
|
| 14 |
<%= form_tag({}, :method => 'get') do %>
|
|
| 15 |
<p> |
|
| 16 |
<label><%=l(:label_role)%>: |
|
| 17 |
<%= select_tag 'role_id', options_from_collection_for_select(@roles, "id", "name", @role && @role.id) %></label> |
|
| 18 |
|
|
| 19 |
<label><%=l(:label_tracker)%>: |
|
| 20 |
<%= select_tag 'tracker_id', options_from_collection_for_select(@trackers, "id", "name", @tracker && @tracker.id) %></label> |
|
| 21 |
|
|
| 22 |
<%= submit_tag l(:button_edit), :name => nil %> |
|
| 23 |
|
|
| 24 |
<%= hidden_field_tag 'used_statuses_only', '0' %> |
|
| 25 |
<label><%= check_box_tag 'used_statuses_only', '1', @used_statuses_only %> <%= l(:label_display_used_statuses_only) %></label> |
|
| 26 |
</p> |
|
| 27 |
<% end %> |
|
| 28 |
|
|
| 29 |
<% if @tracker && @role && @statuses.any? %> |
|
| 30 |
<%= form_tag({}, :id => 'workflow_form' ) do %>
|
|
| 31 |
<%= hidden_field_tag 'tracker_id', @tracker.id %> |
|
| 32 |
<%= hidden_field_tag 'role_id', @role.id %> |
|
| 33 |
<%= hidden_field_tag 'used_statuses_only', params[:used_statuses_only] %> |
|
| 34 |
<div class="autoscroll"> |
|
| 35 |
<table class="list fields_permissions"> |
|
| 36 |
<thead> |
|
| 37 |
<tr> |
|
| 38 |
<th align="left"> |
|
| 39 |
</th> |
|
| 40 |
<th align="center" colspan="<%= @statuses.length %>"><%=l(:label_issue_status)%></th> |
|
| 41 |
</tr> |
|
| 42 |
<tr> |
|
| 43 |
<td></td> |
|
| 44 |
<% for status in @statuses %> |
|
| 45 |
<td width="<%= 75 / @statuses.size %>%" align="center"> |
|
| 46 |
<%=h status.name %> |
|
| 47 |
</td> |
|
| 48 |
<% end %> |
|
| 49 |
</tr> |
|
| 50 |
</thead> |
|
| 51 |
<tbody> |
|
| 52 |
<tr class="group open"> |
|
| 53 |
<td colspan="<%= @statuses.size + 1 %>"> |
|
| 54 |
<span class="expander" onclick="toggleRowGroup(this);"> </span> |
|
| 55 |
<%= l(:field_core_fields) %> |
|
| 56 |
</td> |
|
| 57 |
</tr> |
|
| 58 |
<% @fields.each do |field, name| %> |
|
| 59 |
<tr class="<%= cycle("odd", "even") %>">
|
|
| 60 |
<td> |
|
| 61 |
<%=h name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %>
|
|
| 62 |
</td> |
|
| 63 |
<% for status in @statuses -%> |
|
| 64 |
<td align="center" class="<%= @permissions[status.id][field] %>"> |
|
| 65 |
<%= field_permission_tag(@permissions, status, field) %> |
|
| 66 |
</td> |
|
| 67 |
<% end -%> |
|
| 68 |
</tr> |
|
| 69 |
<% end %> |
|
| 70 |
<% if @custom_fields.any? %> |
|
| 71 |
<tr class="group open"> |
|
| 72 |
<td colspan="<%= @statuses.size + 1 %>"> |
|
| 73 |
<span class="expander" onclick="toggleRowGroup(this);"> </span> |
|
| 74 |
<%= l(:label_custom_field_plural) %> |
|
| 75 |
</td> |
|
| 76 |
</tr> |
|
| 77 |
<% @custom_fields.each do |field| %> |
|
| 78 |
<tr class="<%= cycle("odd", "even") %>">
|
|
| 79 |
<td> |
|
| 80 |
<%=h field.name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %>
|
|
| 81 |
</td> |
|
| 82 |
<% for status in @statuses -%> |
|
| 83 |
<td align="center" class="<%= @permissions[status.id][field.id.to_s] %>"> |
|
| 84 |
<%= field_permission_tag(@permissions, status, field) %> |
|
| 85 |
</td> |
|
| 86 |
<% end -%> |
|
| 87 |
</tr> |
|
| 88 |
<% end %> |
|
| 89 |
<% end %> |
|
| 90 |
</tbody> |
|
| 91 |
</table> |
|
| 92 |
</div> |
|
| 93 |
<%= submit_tag l(:button_save) %> |
|
| 94 |
<% end %> |
|
| 95 |
<% end %> |
|
| .svn/pristine/19/1959b21aed080e49e7eb19db5f9d559c39f78f7a.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 14 |
# You should have received a copy of the GNU General Public License |
|
| 15 |
# along with this program; if not, write to the Free Software |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
require File.expand_path('../../test_helper', __FILE__)
|
|
| 19 |
require 'journals_controller' |
|
| 20 |
|
|
| 21 |
# Re-raise errors caught by the controller. |
|
| 22 |
class JournalsController; def rescue_action(e) raise e end; end |
|
| 23 |
|
|
| 24 |
class JournalsControllerTest < ActionController::TestCase |
|
| 25 |
fixtures :projects, :users, :members, :member_roles, :roles, :issues, :journals, :journal_details, :enabled_modules, |
|
| 26 |
:trackers, :issue_statuses, :enumerations, :custom_fields, :custom_values, :custom_fields_projects |
|
| 27 |
|
|
| 28 |
def setup |
|
| 29 |
@controller = JournalsController.new |
|
| 30 |
@request = ActionController::TestRequest.new |
|
| 31 |
@response = ActionController::TestResponse.new |
|
| 32 |
User.current = nil |
|
| 33 |
end |
|
| 34 |
|
|
| 35 |
def test_index |
|
| 36 |
get :index, :project_id => 1 |
|
| 37 |
assert_response :success |
|
| 38 |
assert_not_nil assigns(:journals) |
|
| 39 |
assert_equal 'application/atom+xml', @response.content_type |
|
| 40 |
end |
|
| 41 |
|
|
| 42 |
def test_index_should_return_privates_notes_with_permission_only |
|
| 43 |
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true, :user_id => 1) |
|
| 44 |
@request.session[:user_id] = 2 |
|
| 45 |
|
|
| 46 |
get :index, :project_id => 1 |
|
| 47 |
assert_response :success |
|
| 48 |
assert_include journal, assigns(:journals) |
|
| 49 |
|
|
| 50 |
Role.find(1).remove_permission! :view_private_notes |
|
| 51 |
get :index, :project_id => 1 |
|
| 52 |
assert_response :success |
|
| 53 |
assert_not_include journal, assigns(:journals) |
|
| 54 |
end |
|
| 55 |
|
|
| 56 |
def test_diff |
|
| 57 |
get :diff, :id => 3, :detail_id => 4 |
|
| 58 |
assert_response :success |
|
| 59 |
assert_template 'diff' |
|
| 60 |
|
|
| 61 |
assert_tag 'span', |
|
| 62 |
:attributes => {:class => 'diff_out'},
|
|
| 63 |
:content => /removed/ |
|
| 64 |
assert_tag 'span', |
|
| 65 |
:attributes => {:class => 'diff_in'},
|
|
| 66 |
:content => /added/ |
|
| 67 |
end |
|
| 68 |
|
|
| 69 |
def test_reply_to_issue |
|
| 70 |
@request.session[:user_id] = 2 |
|
| 71 |
xhr :get, :new, :id => 6 |
|
| 72 |
assert_response :success |
|
| 73 |
assert_template 'new' |
|
| 74 |
assert_equal 'text/javascript', response.content_type |
|
| 75 |
assert_include '> This is an issue', response.body |
|
| 76 |
end |
|
| 77 |
|
|
| 78 |
def test_reply_to_issue_without_permission |
|
| 79 |
@request.session[:user_id] = 7 |
|
| 80 |
xhr :get, :new, :id => 6 |
|
| 81 |
assert_response 403 |
|
| 82 |
end |
|
| 83 |
|
|
| 84 |
def test_reply_to_note |
|
| 85 |
@request.session[:user_id] = 2 |
|
| 86 |
xhr :get, :new, :id => 6, :journal_id => 4 |
|
| 87 |
assert_response :success |
|
| 88 |
assert_template 'new' |
|
| 89 |
assert_equal 'text/javascript', response.content_type |
|
| 90 |
assert_include '> A comment with a private version', response.body |
|
| 91 |
end |
|
| 92 |
|
|
| 93 |
def test_reply_to_private_note_should_fail_without_permission |
|
| 94 |
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true) |
|
| 95 |
@request.session[:user_id] = 2 |
|
| 96 |
|
|
| 97 |
xhr :get, :new, :id => 2, :journal_id => journal.id |
|
| 98 |
assert_response :success |
|
| 99 |
assert_template 'new' |
|
| 100 |
assert_equal 'text/javascript', response.content_type |
|
| 101 |
assert_include '> Privates notes', response.body |
|
| 102 |
|
|
| 103 |
Role.find(1).remove_permission! :view_private_notes |
|
| 104 |
xhr :get, :new, :id => 2, :journal_id => journal.id |
|
| 105 |
assert_response 404 |
|
| 106 |
end |
|
| 107 |
|
|
| 108 |
def test_edit_xhr |
|
| 109 |
@request.session[:user_id] = 1 |
|
| 110 |
xhr :get, :edit, :id => 2 |
|
| 111 |
assert_response :success |
|
| 112 |
assert_template 'edit' |
|
| 113 |
assert_equal 'text/javascript', response.content_type |
|
| 114 |
assert_include 'textarea', response.body |
|
| 115 |
end |
|
| 116 |
|
|
| 117 |
def test_edit_private_note_should_fail_without_permission |
|
| 118 |
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true) |
|
| 119 |
@request.session[:user_id] = 2 |
|
| 120 |
Role.find(1).add_permission! :edit_issue_notes |
|
| 121 |
|
|
| 122 |
xhr :get, :edit, :id => journal.id |
|
| 123 |
assert_response :success |
|
| 124 |
assert_template 'edit' |
|
| 125 |
assert_equal 'text/javascript', response.content_type |
|
| 126 |
assert_include 'textarea', response.body |
|
| 127 |
|
|
| 128 |
Role.find(1).remove_permission! :view_private_notes |
|
| 129 |
xhr :get, :edit, :id => journal.id |
|
| 130 |
assert_response 404 |
|
| 131 |
end |
|
| 132 |
|
|
| 133 |
def test_update_xhr |
|
| 134 |
@request.session[:user_id] = 1 |
|
| 135 |
xhr :post, :edit, :id => 2, :notes => 'Updated notes' |
|
| 136 |
assert_response :success |
|
| 137 |
assert_template 'update' |
|
| 138 |
assert_equal 'text/javascript', response.content_type |
|
| 139 |
assert_equal 'Updated notes', Journal.find(2).notes |
|
| 140 |
assert_include 'journal-2-notes', response.body |
|
| 141 |
end |
|
| 142 |
|
|
| 143 |
def test_update_xhr_with_empty_notes_should_delete_the_journal |
|
| 144 |
@request.session[:user_id] = 1 |
|
| 145 |
assert_difference 'Journal.count', -1 do |
|
| 146 |
xhr :post, :edit, :id => 2, :notes => '' |
|
| 147 |
assert_response :success |
|
| 148 |
assert_template 'update' |
|
| 149 |
assert_equal 'text/javascript', response.content_type |
|
| 150 |
end |
|
| 151 |
assert_nil Journal.find_by_id(2) |
|
| 152 |
assert_include 'change-2', response.body |
|
| 153 |
end |
|
| 154 |
end |
|
| .svn/pristine/19/196c7c4e4ef7e50cda7944736d264f90424a0cab.svn-base | ||
|---|---|---|
| 1 |
#!/usr/bin/env ruby |
|
| 2 |
|
|
| 3 |
require 'net/http' |
|
| 4 |
require 'net/https' |
|
| 5 |
require 'uri' |
|
| 6 |
require 'optparse' |
|
| 7 |
|
|
| 8 |
module Net |
|
| 9 |
class HTTPS < HTTP |
|
| 10 |
def self.post_form(url, params, headers, options={})
|
|
| 11 |
request = Post.new(url.path) |
|
| 12 |
request.form_data = params |
|
| 13 |
request.initialize_http_header(headers) |
|
| 14 |
request.basic_auth url.user, url.password if url.user |
|
| 15 |
http = new(url.host, url.port) |
|
| 16 |
http.use_ssl = (url.scheme == 'https') |
|
| 17 |
if options[:no_check_certificate] |
|
| 18 |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE |
|
| 19 |
end |
|
| 20 |
http.start {|h| h.request(request) }
|
|
| 21 |
end |
|
| 22 |
end |
|
| 23 |
end |
|
| 24 |
|
|
| 25 |
class RedmineMailHandler |
|
| 26 |
VERSION = '0.2.1' |
|
| 27 |
|
|
| 28 |
attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :url, :key, :no_check_certificate |
|
| 29 |
|
|
| 30 |
def initialize |
|
| 31 |
self.issue_attributes = {}
|
|
| 32 |
|
|
| 33 |
optparse = OptionParser.new do |opts| |
|
| 34 |
opts.banner = "Usage: rdm-mailhandler.rb [options] --url=<Redmine URL> --key=<API key>" |
|
| 35 |
opts.separator("")
|
|
| 36 |
opts.separator("Reads an email from standard input and forward it to a Redmine server through a HTTP request.")
|
|
| 37 |
opts.separator("")
|
|
| 38 |
opts.separator("Required arguments:")
|
|
| 39 |
opts.on("-u", "--url URL", "URL of the Redmine server") {|v| self.url = v}
|
|
| 40 |
opts.on("-k", "--key KEY", "Redmine API key") {|v| self.key = v}
|
|
| 41 |
opts.separator("")
|
|
| 42 |
opts.separator("General options:")
|
|
| 43 |
opts.on("--unknown-user ACTION", "how to handle emails from an unknown user",
|
|
| 44 |
"ACTION can be one of the following values:", |
|
| 45 |
"* ignore: email is ignored (default)", |
|
| 46 |
"* accept: accept as anonymous user", |
|
| 47 |
"* create: create a user account") {|v| self.unknown_user = v}
|
|
| 48 |
opts.on("--no-permission-check", "disable permission checking when receiving",
|
|
| 49 |
"the email") {self.no_permission_check = '1'}
|
|
| 50 |
opts.on("--key-file FILE", "path to a file that contains the Redmine",
|
|
| 51 |
"API key (use this option instead of --key", |
|
| 52 |
"if you don't the key to appear in the", |
|
| 53 |
"command line)") {|v| read_key_from_file(v)}
|
|
| 54 |
opts.on("--no-check-certificate", "do not check server certificate") {self.no_check_certificate = true}
|
|
| 55 |
opts.on("-h", "--help", "show this help") {puts opts; exit 1}
|
|
| 56 |
opts.on("-v", "--verbose", "show extra information") {self.verbose = true}
|
|
| 57 |
opts.on("-V", "--version", "show version information and exit") {puts VERSION; exit}
|
|
| 58 |
opts.separator("")
|
|
| 59 |
opts.separator("Issue attributes control options:")
|
|
| 60 |
opts.on("-p", "--project PROJECT", "identifier of the target project") {|v| self.issue_attributes['project'] = v}
|
|
| 61 |
opts.on("-s", "--status STATUS", "name of the target status") {|v| self.issue_attributes['status'] = v}
|
|
| 62 |
opts.on("-t", "--tracker TRACKER", "name of the target tracker") {|v| self.issue_attributes['tracker'] = v}
|
|
| 63 |
opts.on( "--category CATEGORY", "name of the target category") {|v| self.issue_attributes['category'] = v}
|
|
| 64 |
opts.on( "--priority PRIORITY", "name of the target priority") {|v| self.issue_attributes['priority'] = v}
|
|
| 65 |
opts.on("-o", "--allow-override ATTRS", "allow email content to override attributes",
|
|
| 66 |
"specified by previous options", |
|
| 67 |
"ATTRS is a comma separated list of attributes") {|v| self.allow_override = v}
|
|
| 68 |
opts.separator("")
|
|
| 69 |
opts.separator("Examples:")
|
|
| 70 |
opts.separator("No project specified. Emails MUST contain the 'Project' keyword:")
|
|
| 71 |
opts.separator(" rdm-mailhandler.rb --url http://redmine.domain.foo --key secret")
|
|
| 72 |
opts.separator("")
|
|
| 73 |
opts.separator("Fixed project and default tracker specified, but emails can override")
|
|
| 74 |
opts.separator("both tracker and priority attributes using keywords:")
|
|
| 75 |
opts.separator(" rdm-mailhandler.rb --url https://domain.foo/redmine --key secret \\")
|
|
| 76 |
opts.separator(" --project foo \\")
|
|
| 77 |
opts.separator(" --tracker bug \\")
|
|
| 78 |
opts.separator(" --allow-override tracker,priority")
|
|
| 79 |
|
|
| 80 |
opts.summary_width = 27 |
|
| 81 |
end |
|
| 82 |
optparse.parse! |
|
| 83 |
|
|
| 84 |
unless url && key |
|
| 85 |
puts "Some arguments are missing. Use `rdm-mailhandler.rb --help` for getting help." |
|
| 86 |
exit 1 |
|
| 87 |
end |
|
| 88 |
end |
|
| 89 |
|
|
| 90 |
def submit(email) |
|
| 91 |
uri = url.gsub(%r{/*$}, '') + '/mail_handler'
|
|
| 92 |
|
|
| 93 |
headers = { 'User-Agent' => "Redmine mail handler/#{VERSION}" }
|
|
| 94 |
|
|
| 95 |
data = { 'key' => key, 'email' => email,
|
|
| 96 |
'allow_override' => allow_override, |
|
| 97 |
'unknown_user' => unknown_user, |
|
| 98 |
'no_permission_check' => no_permission_check} |
|
| 99 |
issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value }
|
|
| 100 |
|
|
| 101 |
debug "Posting to #{uri}..."
|
|
| 102 |
response = Net::HTTPS.post_form(URI.parse(uri), data, headers, :no_check_certificate => no_check_certificate) |
|
| 103 |
debug "Response received: #{response.code}"
|
|
| 104 |
|
|
| 105 |
case response.code.to_i |
|
| 106 |
when 403 |
|
| 107 |
warn "Request was denied by your Redmine server. " + |
|
| 108 |
"Make sure that 'WS for incoming emails' is enabled in application settings and that you provided the correct API key." |
|
| 109 |
return 77 |
|
| 110 |
when 422 |
|
| 111 |
warn "Request was denied by your Redmine server. " + |
|
| 112 |
"Possible reasons: email is sent from an invalid email address or is missing some information." |
|
| 113 |
return 77 |
|
| 114 |
when 400..499 |
|
| 115 |
warn "Request was denied by your Redmine server (#{response.code})."
|
|
| 116 |
return 77 |
|
| 117 |
when 500..599 |
|
| 118 |
warn "Failed to contact your Redmine server (#{response.code})."
|
|
| 119 |
return 75 |
|
| 120 |
when 201 |
|
| 121 |
debug "Proccessed successfully" |
|
| 122 |
return 0 |
|
| 123 |
else |
|
| 124 |
return 1 |
|
| 125 |
end |
|
| 126 |
end |
|
| 127 |
|
|
| 128 |
private |
|
| 129 |
|
|
| 130 |
def debug(msg) |
|
| 131 |
puts msg if verbose |
|
| 132 |
end |
|
| 133 |
|
|
| 134 |
def read_key_from_file(filename) |
|
| 135 |
begin |
|
| 136 |
self.key = File.read(filename).strip |
|
| 137 |
rescue Exception => e |
|
| 138 |
$stderr.puts "Unable to read the key from #{filename}:\n#{e.message}"
|
|
| 139 |
exit 1 |
|
| 140 |
end |
|
| 141 |
end |
|
| 142 |
end |
|
| 143 |
|
|
| 144 |
handler = RedmineMailHandler.new |
|
| 145 |
exit(handler.submit(STDIN.read)) |
|
| .svn/pristine/19/19c2933293d5536cb86e9ab59b2a501d3507d1a0.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 14 |
# You should have received a copy of the GNU General Public License |
|
| 15 |
# along with this program; if not, write to the Free Software |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
require File.expand_path('../../../test_helper', __FILE__)
|
|
| 19 |
|
|
| 20 |
class RoutingWikiTest < ActionController::IntegrationTest |
|
| 21 |
def test_wiki_matching |
|
| 22 |
assert_routing( |
|
| 23 |
{ :method => 'get', :path => "/projects/567/wiki" },
|
|
| 24 |
{ :controller => 'wiki', :action => 'show', :project_id => '567' }
|
|
| 25 |
) |
|
| 26 |
assert_routing( |
|
| 27 |
{ :method => 'get', :path => "/projects/567/wiki/lalala" },
|
|
| 28 |
{ :controller => 'wiki', :action => 'show', :project_id => '567',
|
|
| 29 |
:id => 'lalala' } |
|
| 30 |
) |
|
| 31 |
assert_routing( |
|
| 32 |
{ :method => 'get', :path => "/projects/567/wiki/lalala.pdf" },
|
|
| 33 |
{ :controller => 'wiki', :action => 'show', :project_id => '567',
|
|
| 34 |
:id => 'lalala', :format => 'pdf' } |
|
| 35 |
) |
|
| 36 |
assert_routing( |
|
| 37 |
{ :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff" },
|
|
| 38 |
{ :controller => 'wiki', :action => 'diff', :project_id => '1',
|
|
| 39 |
:id => 'CookBook_documentation' } |
|
| 40 |
) |
|
| 41 |
assert_routing( |
|
| 42 |
{ :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2" },
|
|
| 43 |
{ :controller => 'wiki', :action => 'show', :project_id => '1',
|
|
| 44 |
:id => 'CookBook_documentation', :version => '2' } |
|
| 45 |
) |
|
| 46 |
assert_routing( |
|
| 47 |
{ :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2/diff" },
|
|
| 48 |
{ :controller => 'wiki', :action => 'diff', :project_id => '1',
|
|
| 49 |
:id => 'CookBook_documentation', :version => '2' } |
|
| 50 |
) |
|
| 51 |
assert_routing( |
|
| 52 |
{ :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2/annotate" },
|
|
| 53 |
{ :controller => 'wiki', :action => 'annotate', :project_id => '1',
|
|
| 54 |
:id => 'CookBook_documentation', :version => '2' } |
|
| 55 |
) |
|
| 56 |
end |
|
| 57 |
|
|
| 58 |
def test_wiki_misc |
|
| 59 |
assert_routing( |
|
| 60 |
{ :method => 'get', :path => "/projects/567/wiki/date_index" },
|
|
| 61 |
{ :controller => 'wiki', :action => 'date_index', :project_id => '567' }
|
|
| 62 |
) |
|
| 63 |
assert_routing( |
|
| 64 |
{ :method => 'get', :path => "/projects/567/wiki/export" },
|
|
| 65 |
{ :controller => 'wiki', :action => 'export', :project_id => '567' }
|
|
| 66 |
) |
|
| 67 |
assert_routing( |
|
| 68 |
{ :method => 'get', :path => "/projects/567/wiki/export.pdf" },
|
|
| 69 |
{ :controller => 'wiki', :action => 'export', :project_id => '567', :format => 'pdf' }
|
|
| 70 |
) |
|
| 71 |
assert_routing( |
|
| 72 |
{ :method => 'get', :path => "/projects/567/wiki/index" },
|
|
| 73 |
{ :controller => 'wiki', :action => 'index', :project_id => '567' }
|
|
| 74 |
) |
|
| 75 |
end |
|
| 76 |
|
|
| 77 |
def test_wiki_resources |
|
| 78 |
assert_routing( |
|
| 79 |
{ :method => 'get', :path => "/projects/567/wiki/my_page/edit" },
|
|
| 80 |
{ :controller => 'wiki', :action => 'edit', :project_id => '567',
|
|
| 81 |
:id => 'my_page' } |
|
| 82 |
) |
|
| 83 |
assert_routing( |
|
| 84 |
{ :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/history" },
|
|
| 85 |
{ :controller => 'wiki', :action => 'history', :project_id => '1',
|
|
| 86 |
:id => 'CookBook_documentation' } |
|
| 87 |
) |
|
| 88 |
assert_routing( |
|
| 89 |
{ :method => 'get', :path => "/projects/22/wiki/ladida/rename" },
|
|
| 90 |
{ :controller => 'wiki', :action => 'rename', :project_id => '22',
|
|
| 91 |
:id => 'ladida' } |
|
| 92 |
) |
|
| 93 |
["post", "put"].each do |method| |
|
| 94 |
assert_routing( |
|
| 95 |
{ :method => method, :path => "/projects/567/wiki/CookBook_documentation/preview" },
|
|
| 96 |
{ :controller => 'wiki', :action => 'preview', :project_id => '567',
|
|
| 97 |
:id => 'CookBook_documentation' } |
|
| 98 |
) |
|
| 99 |
end |
|
| 100 |
assert_routing( |
|
| 101 |
{ :method => 'post', :path => "/projects/22/wiki/ladida/rename" },
|
|
| 102 |
{ :controller => 'wiki', :action => 'rename', :project_id => '22',
|
|
| 103 |
:id => 'ladida' } |
|
| 104 |
) |
|
| 105 |
assert_routing( |
|
| 106 |
{ :method => 'post', :path => "/projects/22/wiki/ladida/protect" },
|
|
| 107 |
{ :controller => 'wiki', :action => 'protect', :project_id => '22',
|
|
| 108 |
:id => 'ladida' } |
|
| 109 |
) |
|
| 110 |
assert_routing( |
|
| 111 |
{ :method => 'post', :path => "/projects/22/wiki/ladida/add_attachment" },
|
|
| 112 |
{ :controller => 'wiki', :action => 'add_attachment', :project_id => '22',
|
|
| 113 |
:id => 'ladida' } |
|
| 114 |
) |
|
| 115 |
assert_routing( |
|
| 116 |
{ :method => 'put', :path => "/projects/567/wiki/my_page" },
|
|
| 117 |
{ :controller => 'wiki', :action => 'update', :project_id => '567',
|
|
| 118 |
:id => 'my_page' } |
|
| 119 |
) |
|
| 120 |
assert_routing( |
|
| 121 |
{ :method => 'delete', :path => "/projects/22/wiki/ladida" },
|
|
| 122 |
{ :controller => 'wiki', :action => 'destroy', :project_id => '22',
|
|
| 123 |
:id => 'ladida' } |
|
| 124 |
) |
|
| 125 |
assert_routing( |
|
| 126 |
{ :method => 'delete', :path => "/projects/22/wiki/ladida/3" },
|
|
| 127 |
{ :controller => 'wiki', :action => 'destroy_version', :project_id => '22',
|
|
| 128 |
:id => 'ladida', :version => '3' } |
|
| 129 |
) |
|
| 130 |
end |
|
| 131 |
|
|
| 132 |
def test_api |
|
| 133 |
assert_routing( |
|
| 134 |
{ :method => 'get', :path => "/projects/567/wiki/my_page.xml" },
|
|
| 135 |
{ :controller => 'wiki', :action => 'show', :project_id => '567',
|
|
| 136 |
:id => 'my_page', :format => 'xml' } |
|
| 137 |
) |
|
| 138 |
assert_routing( |
|
| 139 |
{ :method => 'get', :path => "/projects/567/wiki/my_page.json" },
|
|
| 140 |
{ :controller => 'wiki', :action => 'show', :project_id => '567',
|
|
| 141 |
:id => 'my_page', :format => 'json' } |
|
| 142 |
) |
|
| 143 |
assert_routing( |
|
| 144 |
{ :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.xml" },
|
|
| 145 |
{ :controller => 'wiki', :action => 'show', :project_id => '1',
|
|
| 146 |
:id => 'CookBook_documentation', :version => '2', :format => 'xml' } |
|
| 147 |
) |
|
| 148 |
assert_routing( |
|
| 149 |
{ :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.json" },
|
|
| 150 |
{ :controller => 'wiki', :action => 'show', :project_id => '1',
|
|
| 151 |
:id => 'CookBook_documentation', :version => '2', :format => 'json' } |
|
| 152 |
) |
|
| 153 |
assert_routing( |
|
| 154 |
{ :method => 'get', :path => "/projects/567/wiki/index.xml" },
|
|
| 155 |
{ :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'xml' }
|
|
| 156 |
) |
|
| 157 |
assert_routing( |
|
| 158 |
{ :method => 'get', :path => "/projects/567/wiki/index.json" },
|
|
| 159 |
{ :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'json' }
|
|
| 160 |
) |
|
| 161 |
assert_routing( |
|
| 162 |
{ :method => 'put', :path => "/projects/567/wiki/my_page.xml" },
|
|
| 163 |
{ :controller => 'wiki', :action => 'update', :project_id => '567',
|
|
| 164 |
:id => 'my_page', :format => 'xml' } |
|
| 165 |
) |
|
| 166 |
assert_routing( |
|
| 167 |
{ :method => 'put', :path => "/projects/567/wiki/my_page.json" },
|
|
| 168 |
{ :controller => 'wiki', :action => 'update', :project_id => '567',
|
|
| 169 |
:id => 'my_page', :format => 'json' } |
|
| 170 |
) |
|
| 171 |
assert_routing( |
|
| 172 |
{ :method => 'delete', :path => "/projects/567/wiki/my_page.xml" },
|
|
| 173 |
{ :controller => 'wiki', :action => 'destroy', :project_id => '567',
|
|
| 174 |
:id => 'my_page', :format => 'xml' } |
|
| 175 |
) |
|
| 176 |
assert_routing( |
|
| 177 |
{ :method => 'delete', :path => "/projects/567/wiki/my_page.json" },
|
|
| 178 |
{ :controller => 'wiki', :action => 'destroy', :project_id => '567',
|
|
| 179 |
:id => 'my_page', :format => 'json' } |
|
| 180 |
) |
|
| 181 |
end |
|
| 182 |
end |
|
Also available in: Unified diff