##// END OF EJS Templates
Resourcified custom fields....
Jean-Philippe Lang -
r8024:b127f9157d45
parent child
Show More
@@ -1,64 +1,78
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class CustomFieldsController < ApplicationController
18 class CustomFieldsController < ApplicationController
19 layout 'admin'
19 layout 'admin'
20
20
21 before_filter :require_admin
21 before_filter :require_admin
22 before_filter :build_new_custom_field, :only => [:new, :create]
23 before_filter :find_custom_field, :only => [:edit, :update, :destroy]
22
24
23 def index
25 def index
24 @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name }
26 @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name }
25 @tab = params[:tab] || 'IssueCustomField'
27 @tab = params[:tab] || 'IssueCustomField'
26 end
28 end
27
29
28 def new
30 def new
29 @custom_field = begin
31 end
30 if params[:type].to_s.match(/.+CustomField$/)
31 params[:type].to_s.constantize.new(params[:custom_field])
32 end
33 rescue
34 end
35 (redirect_to(:action => 'index'); return) unless @custom_field.is_a?(CustomField)
36
32
33 def create
37 if request.post? and @custom_field.save
34 if request.post? and @custom_field.save
38 flash[:notice] = l(:notice_successful_create)
35 flash[:notice] = l(:notice_successful_create)
39 call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field)
36 call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field)
40 redirect_to :action => 'index', :tab => @custom_field.class.name
37 redirect_to :action => 'index', :tab => @custom_field.class.name
41 else
38 else
42 @trackers = Tracker.find(:all, :order => 'position')
39 render :action => 'new'
43 end
40 end
44 end
41 end
45
42
46 def edit
43 def edit
47 @custom_field = CustomField.find(params[:id])
44 end
48 if request.post? and @custom_field.update_attributes(params[:custom_field])
45
46 def update
47 if request.put? and @custom_field.update_attributes(params[:custom_field])
49 flash[:notice] = l(:notice_successful_update)
48 flash[:notice] = l(:notice_successful_update)
50 call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field)
49 call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field)
51 redirect_to :action => 'index', :tab => @custom_field.class.name
50 redirect_to :action => 'index', :tab => @custom_field.class.name
52 else
51 else
53 @trackers = Tracker.find(:all, :order => 'position')
52 render :action => 'edit'
54 end
53 end
55 end
54 end
56
55
57 def destroy
56 def destroy
58 @custom_field = CustomField.find(params[:id]).destroy
57 @custom_field.destroy
59 redirect_to :action => 'index', :tab => @custom_field.class.name
58 redirect_to :action => 'index', :tab => @custom_field.class.name
60 rescue
59 rescue
61 flash[:error] = l(:error_can_not_delete_custom_field)
60 flash[:error] = l(:error_can_not_delete_custom_field)
62 redirect_to :action => 'index'
61 redirect_to :action => 'index'
63 end
62 end
63
64 private
65
66 def build_new_custom_field
67 @custom_field = CustomField.new_subclass_instance(params[:type], params[:custom_field])
68 if @custom_field.nil?
69 render_404
70 end
71 end
72
73 def find_custom_field
74 @custom_field = CustomField.find(params[:id])
75 rescue ActiveRecord::RecordNotFound
76 render_404
77 end
64 end
78 end
@@ -1,161 +1,177
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class CustomField < ActiveRecord::Base
18 class CustomField < ActiveRecord::Base
19 has_many :custom_values, :dependent => :delete_all
19 has_many :custom_values, :dependent => :delete_all
20 acts_as_list :scope => 'type = \'#{self.class}\''
20 acts_as_list :scope => 'type = \'#{self.class}\''
21 serialize :possible_values
21 serialize :possible_values
22
22
23 validates_presence_of :name, :field_format
23 validates_presence_of :name, :field_format
24 validates_uniqueness_of :name, :scope => :type
24 validates_uniqueness_of :name, :scope => :type
25 validates_length_of :name, :maximum => 30
25 validates_length_of :name, :maximum => 30
26 validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
26 validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
27
27
28 validate :validate_values
28 validate :validate_values
29
29
30 def initialize(attributes = nil)
30 def initialize(attributes = nil)
31 super
31 super
32 self.possible_values ||= []
32 self.possible_values ||= []
33 end
33 end
34
34
35 def before_validation
35 def before_validation
36 # make sure these fields are not searchable
36 # make sure these fields are not searchable
37 self.searchable = false if %w(int float date bool).include?(field_format)
37 self.searchable = false if %w(int float date bool).include?(field_format)
38 true
38 true
39 end
39 end
40
40
41 def validate_values
41 def validate_values
42 if self.field_format == "list"
42 if self.field_format == "list"
43 errors.add(:possible_values, :blank) if self.possible_values.nil? || self.possible_values.empty?
43 errors.add(:possible_values, :blank) if self.possible_values.nil? || self.possible_values.empty?
44 errors.add(:possible_values, :invalid) unless self.possible_values.is_a? Array
44 errors.add(:possible_values, :invalid) unless self.possible_values.is_a? Array
45 end
45 end
46
46
47 if regexp.present?
47 if regexp.present?
48 begin
48 begin
49 Regexp.new(regexp)
49 Regexp.new(regexp)
50 rescue
50 rescue
51 errors.add(:regexp, :invalid)
51 errors.add(:regexp, :invalid)
52 end
52 end
53 end
53 end
54
54
55 # validate default value
55 # validate default value
56 v = CustomValue.new(:custom_field => self.clone, :value => default_value, :customized => nil)
56 v = CustomValue.new(:custom_field => self.clone, :value => default_value, :customized => nil)
57 v.custom_field.is_required = false
57 v.custom_field.is_required = false
58 errors.add(:default_value, :invalid) unless v.valid?
58 errors.add(:default_value, :invalid) unless v.valid?
59 end
59 end
60
60
61 def possible_values_options(obj=nil)
61 def possible_values_options(obj=nil)
62 case field_format
62 case field_format
63 when 'user', 'version'
63 when 'user', 'version'
64 if obj.respond_to?(:project) && obj.project
64 if obj.respond_to?(:project) && obj.project
65 case field_format
65 case field_format
66 when 'user'
66 when 'user'
67 obj.project.users.sort.collect {|u| [u.to_s, u.id.to_s]}
67 obj.project.users.sort.collect {|u| [u.to_s, u.id.to_s]}
68 when 'version'
68 when 'version'
69 obj.project.shared_versions.sort.collect {|u| [u.to_s, u.id.to_s]}
69 obj.project.shared_versions.sort.collect {|u| [u.to_s, u.id.to_s]}
70 end
70 end
71 elsif obj.is_a?(Array)
71 elsif obj.is_a?(Array)
72 obj.collect {|o| possible_values_options(o)}.inject {|memo, v| memo & v}
72 obj.collect {|o| possible_values_options(o)}.inject {|memo, v| memo & v}
73 else
73 else
74 []
74 []
75 end
75 end
76 else
76 else
77 read_attribute :possible_values
77 read_attribute :possible_values
78 end
78 end
79 end
79 end
80
80
81 def possible_values(obj=nil)
81 def possible_values(obj=nil)
82 case field_format
82 case field_format
83 when 'user', 'version'
83 when 'user', 'version'
84 possible_values_options(obj).collect(&:last)
84 possible_values_options(obj).collect(&:last)
85 else
85 else
86 read_attribute :possible_values
86 read_attribute :possible_values
87 end
87 end
88 end
88 end
89
89
90 # Makes possible_values accept a multiline string
90 # Makes possible_values accept a multiline string
91 def possible_values=(arg)
91 def possible_values=(arg)
92 if arg.is_a?(Array)
92 if arg.is_a?(Array)
93 write_attribute(:possible_values, arg.compact.collect(&:strip).select {|v| !v.blank?})
93 write_attribute(:possible_values, arg.compact.collect(&:strip).select {|v| !v.blank?})
94 else
94 else
95 self.possible_values = arg.to_s.split(/[\n\r]+/)
95 self.possible_values = arg.to_s.split(/[\n\r]+/)
96 end
96 end
97 end
97 end
98
98
99 def cast_value(value)
99 def cast_value(value)
100 casted = nil
100 casted = nil
101 unless value.blank?
101 unless value.blank?
102 case field_format
102 case field_format
103 when 'string', 'text', 'list'
103 when 'string', 'text', 'list'
104 casted = value
104 casted = value
105 when 'date'
105 when 'date'
106 casted = begin; value.to_date; rescue; nil end
106 casted = begin; value.to_date; rescue; nil end
107 when 'bool'
107 when 'bool'
108 casted = (value == '1' ? true : false)
108 casted = (value == '1' ? true : false)
109 when 'int'
109 when 'int'
110 casted = value.to_i
110 casted = value.to_i
111 when 'float'
111 when 'float'
112 casted = value.to_f
112 casted = value.to_f
113 when 'user', 'version'
113 when 'user', 'version'
114 casted = (value.blank? ? nil : field_format.classify.constantize.find_by_id(value.to_i))
114 casted = (value.blank? ? nil : field_format.classify.constantize.find_by_id(value.to_i))
115 end
115 end
116 end
116 end
117 casted
117 casted
118 end
118 end
119
119
120 # Returns a ORDER BY clause that can used to sort customized
120 # Returns a ORDER BY clause that can used to sort customized
121 # objects by their value of the custom field.
121 # objects by their value of the custom field.
122 # Returns false, if the custom field can not be used for sorting.
122 # Returns false, if the custom field can not be used for sorting.
123 def order_statement
123 def order_statement
124 case field_format
124 case field_format
125 when 'string', 'text', 'list', 'date', 'bool'
125 when 'string', 'text', 'list', 'date', 'bool'
126 # COALESCE is here to make sure that blank and NULL values are sorted equally
126 # COALESCE is here to make sure that blank and NULL values are sorted equally
127 "COALESCE((SELECT cv_sort.value FROM #{CustomValue.table_name} cv_sort" +
127 "COALESCE((SELECT cv_sort.value FROM #{CustomValue.table_name} cv_sort" +
128 " WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
128 " WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
129 " AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
129 " AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
130 " AND cv_sort.custom_field_id=#{id} LIMIT 1), '')"
130 " AND cv_sort.custom_field_id=#{id} LIMIT 1), '')"
131 when 'int', 'float'
131 when 'int', 'float'
132 # Make the database cast values into numeric
132 # Make the database cast values into numeric
133 # Postgresql will raise an error if a value can not be casted!
133 # Postgresql will raise an error if a value can not be casted!
134 # CustomValue validations should ensure that it doesn't occur
134 # CustomValue validations should ensure that it doesn't occur
135 "(SELECT CAST(cv_sort.value AS decimal(60,3)) FROM #{CustomValue.table_name} cv_sort" +
135 "(SELECT CAST(cv_sort.value AS decimal(60,3)) FROM #{CustomValue.table_name} cv_sort" +
136 " WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
136 " WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
137 " AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
137 " AND cv_sort.customized_id=#{self.class.customized_class.table_name}.id" +
138 " AND cv_sort.custom_field_id=#{id} AND cv_sort.value <> '' AND cv_sort.value IS NOT NULL LIMIT 1)"
138 " AND cv_sort.custom_field_id=#{id} AND cv_sort.value <> '' AND cv_sort.value IS NOT NULL LIMIT 1)"
139 else
139 else
140 nil
140 nil
141 end
141 end
142 end
142 end
143
143
144 def <=>(field)
144 def <=>(field)
145 position <=> field.position
145 position <=> field.position
146 end
146 end
147
147
148 def self.customized_class
148 def self.customized_class
149 self.name =~ /^(.+)CustomField$/
149 self.name =~ /^(.+)CustomField$/
150 begin; $1.constantize; rescue nil; end
150 begin; $1.constantize; rescue nil; end
151 end
151 end
152
152
153 # to move in project_custom_field
153 # to move in project_custom_field
154 def self.for_all
154 def self.for_all
155 find(:all, :conditions => ["is_for_all=?", true], :order => 'position')
155 find(:all, :conditions => ["is_for_all=?", true], :order => 'position')
156 end
156 end
157
157
158 # Returns an instance of the given subclass name
159 def self.new_subclass_instance(class_name, *args)
160 klass = nil
161 begin
162 klass = class_name.to_s.classify.constantize
163 rescue
164 # invalid class name
165 end
166 unless subclasses.include? klass
167 klass = nil
168 end
169 if klass
170 klass.new(*args)
171 end
172 end
173
158 def type_name
174 def type_name
159 nil
175 nil
160 end
176 end
161 end
177 end
@@ -1,120 +1,120
1 <%= error_messages_for 'custom_field' %>
1 <%= error_messages_for 'custom_field' %>
2
2
3 <script type="text/javascript">
3 <script type="text/javascript">
4 //<![CDATA[
4 //<![CDATA[
5 function toggle_custom_field_format() {
5 function toggle_custom_field_format() {
6 format = $("custom_field_field_format");
6 format = $("custom_field_field_format");
7 p_length = $("custom_field_min_length");
7 p_length = $("custom_field_min_length");
8 p_regexp = $("custom_field_regexp");
8 p_regexp = $("custom_field_regexp");
9 p_values = $("custom_field_possible_values");
9 p_values = $("custom_field_possible_values");
10 p_searchable = $("custom_field_searchable");
10 p_searchable = $("custom_field_searchable");
11 p_default = $("custom_field_default_value");
11 p_default = $("custom_field_default_value");
12
12
13 p_default.setAttribute('type','text');
13 p_default.setAttribute('type','text');
14 Element.show(p_default.parentNode);
14 Element.show(p_default.parentNode);
15
15
16 switch (format.value) {
16 switch (format.value) {
17 case "list":
17 case "list":
18 Element.hide(p_length.parentNode);
18 Element.hide(p_length.parentNode);
19 Element.hide(p_regexp.parentNode);
19 Element.hide(p_regexp.parentNode);
20 if (p_searchable) Element.show(p_searchable.parentNode);
20 if (p_searchable) Element.show(p_searchable.parentNode);
21 Element.show(p_values.parentNode);
21 Element.show(p_values.parentNode);
22 break;
22 break;
23 case "bool":
23 case "bool":
24 p_default.setAttribute('type','checkbox');
24 p_default.setAttribute('type','checkbox');
25 Element.hide(p_length.parentNode);
25 Element.hide(p_length.parentNode);
26 Element.hide(p_regexp.parentNode);
26 Element.hide(p_regexp.parentNode);
27 if (p_searchable) Element.hide(p_searchable.parentNode);
27 if (p_searchable) Element.hide(p_searchable.parentNode);
28 Element.hide(p_values.parentNode);
28 Element.hide(p_values.parentNode);
29 break;
29 break;
30 case "date":
30 case "date":
31 Element.hide(p_length.parentNode);
31 Element.hide(p_length.parentNode);
32 Element.hide(p_regexp.parentNode);
32 Element.hide(p_regexp.parentNode);
33 if (p_searchable) Element.hide(p_searchable.parentNode);
33 if (p_searchable) Element.hide(p_searchable.parentNode);
34 Element.hide(p_values.parentNode);
34 Element.hide(p_values.parentNode);
35 break;
35 break;
36 case "float":
36 case "float":
37 case "int":
37 case "int":
38 Element.show(p_length.parentNode);
38 Element.show(p_length.parentNode);
39 Element.show(p_regexp.parentNode);
39 Element.show(p_regexp.parentNode);
40 if (p_searchable) Element.hide(p_searchable.parentNode);
40 if (p_searchable) Element.hide(p_searchable.parentNode);
41 Element.hide(p_values.parentNode);
41 Element.hide(p_values.parentNode);
42 break;
42 break;
43 case "user":
43 case "user":
44 case "version":
44 case "version":
45 Element.hide(p_length.parentNode);
45 Element.hide(p_length.parentNode);
46 Element.hide(p_regexp.parentNode);
46 Element.hide(p_regexp.parentNode);
47 if (p_searchable) Element.hide(p_searchable.parentNode);
47 if (p_searchable) Element.hide(p_searchable.parentNode);
48 Element.hide(p_values.parentNode);
48 Element.hide(p_values.parentNode);
49 Element.hide(p_default.parentNode);
49 Element.hide(p_default.parentNode);
50 break;
50 break;
51 default:
51 default:
52 Element.show(p_length.parentNode);
52 Element.show(p_length.parentNode);
53 Element.show(p_regexp.parentNode);
53 Element.show(p_regexp.parentNode);
54 if (p_searchable) Element.show(p_searchable.parentNode);
54 if (p_searchable) Element.show(p_searchable.parentNode);
55 Element.hide(p_values.parentNode);
55 Element.hide(p_values.parentNode);
56 break;
56 break;
57 }
57 }
58 }
58 }
59
59
60 //]]>
60 //]]>
61 </script>
61 </script>
62
62
63 <div class="box tabular">
63 <div class="box tabular">
64 <p><%= f.text_field :name, :required => true %></p>
64 <p><%= f.text_field :name, :required => true %></p>
65 <p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :onchange => "toggle_custom_field_format();",
65 <p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :onchange => "toggle_custom_field_format();",
66 :disabled => !@custom_field.new_record? %></p>
66 :disabled => !@custom_field.new_record? %></p>
67 <p><label for="custom_field_min_length"><%=l(:label_min_max_length)%></label>
67 <p><label for="custom_field_min_length"><%=l(:label_min_max_length)%></label>
68 <%= f.text_field :min_length, :size => 5, :no_label => true %> -
68 <%= f.text_field :min_length, :size => 5, :no_label => true %> -
69 <%= f.text_field :max_length, :size => 5, :no_label => true %><br />(<%=l(:text_min_max_length_info)%>)</p>
69 <%= f.text_field :max_length, :size => 5, :no_label => true %><br />(<%=l(:text_min_max_length_info)%>)</p>
70 <p><%= f.text_field :regexp, :size => 50 %><br />(<%=l(:text_regexp_info)%>)</p>
70 <p><%= f.text_field :regexp, :size => 50 %><br />(<%=l(:text_regexp_info)%>)</p>
71 <p>
71 <p>
72 <%= f.text_area :possible_values, :value => @custom_field.possible_values.to_a.join("\n"), :rows => 15 %>
72 <%= f.text_area :possible_values, :value => @custom_field.possible_values.to_a.join("\n"), :rows => 15 %>
73 <br /><em><%= l(:text_custom_field_possible_values_info) %></em>
73 <br /><em><%= l(:text_custom_field_possible_values_info) %></em>
74 </p>
74 </p>
75 <p><%= @custom_field.field_format == 'bool' ? f.check_box(:default_value) : f.text_field(:default_value) %></p>
75 <p><%= @custom_field.field_format == 'bool' ? f.check_box(:default_value) : f.text_field(:default_value) %></p>
76 <%= call_hook(:view_custom_fields_form_upper_box, :custom_field => @custom_field, :form => f) %>
76 <%= call_hook(:view_custom_fields_form_upper_box, :custom_field => @custom_field, :form => f) %>
77 </div>
77 </div>
78
78
79 <div class="box tabular">
79 <div class="box tabular">
80 <% case @custom_field.class.name
80 <% case @custom_field.class.name
81 when "IssueCustomField" %>
81 when "IssueCustomField" %>
82
82
83 <fieldset><legend><%=l(:label_tracker_plural)%></legend>
83 <fieldset><legend><%=l(:label_tracker_plural)%></legend>
84 <% for tracker in @trackers %>
84 <% Tracker.all.each do |tracker| %>
85 <%= check_box_tag "custom_field[tracker_ids][]",
85 <%= check_box_tag "custom_field[tracker_ids][]",
86 tracker.id,
86 tracker.id,
87 (@custom_field.trackers.include? tracker),
87 (@custom_field.trackers.include? tracker),
88 :id => "custom_field_tracker_ids_#{tracker.id}" %>
88 :id => "custom_field_tracker_ids_#{tracker.id}" %>
89 <label class="no-css" for="custom_field_tracker_ids_<%=tracker.id%>">
89 <label class="no-css" for="custom_field_tracker_ids_<%=tracker.id%>">
90 <%= h(tracker.name) %>
90 <%= h(tracker.name) %>
91 </label>
91 </label>
92 <% end %>
92 <% end %>
93 <%= hidden_field_tag "custom_field[tracker_ids][]", '' %>
93 <%= hidden_field_tag "custom_field[tracker_ids][]", '' %>
94 </fieldset>
94 </fieldset>
95 &nbsp;
95 &nbsp;
96 <p><%= f.check_box :is_required %></p>
96 <p><%= f.check_box :is_required %></p>
97 <p><%= f.check_box :is_for_all %></p>
97 <p><%= f.check_box :is_for_all %></p>
98 <p><%= f.check_box :is_filter %></p>
98 <p><%= f.check_box :is_filter %></p>
99 <p><%= f.check_box :searchable %></p>
99 <p><%= f.check_box :searchable %></p>
100
100
101 <% when "UserCustomField" %>
101 <% when "UserCustomField" %>
102 <p><%= f.check_box :is_required %></p>
102 <p><%= f.check_box :is_required %></p>
103 <p><%= f.check_box :visible %></p>
103 <p><%= f.check_box :visible %></p>
104 <p><%= f.check_box :editable %></p>
104 <p><%= f.check_box :editable %></p>
105
105
106 <% when "ProjectCustomField" %>
106 <% when "ProjectCustomField" %>
107 <p><%= f.check_box :is_required %></p>
107 <p><%= f.check_box :is_required %></p>
108 <p><%= f.check_box :visible %></p>
108 <p><%= f.check_box :visible %></p>
109 <p><%= f.check_box :searchable %></p>
109 <p><%= f.check_box :searchable %></p>
110
110
111 <% when "TimeEntryCustomField" %>
111 <% when "TimeEntryCustomField" %>
112 <p><%= f.check_box :is_required %></p>
112 <p><%= f.check_box :is_required %></p>
113
113
114 <% else %>
114 <% else %>
115 <p><%= f.check_box :is_required %></p>
115 <p><%= f.check_box :is_required %></p>
116
116
117 <% end %>
117 <% end %>
118 <%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
118 <%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
119 </div>
119 </div>
120 <%= javascript_tag "toggle_custom_field_format();" %>
120 <%= javascript_tag "toggle_custom_field_format();" %>
@@ -1,35 +1,35
1 <table class="list">
1 <table class="list">
2 <thead><tr>
2 <thead><tr>
3 <th width="30%"><%=l(:field_name)%></th>
3 <th width="30%"><%=l(:field_name)%></th>
4 <th><%=l(:field_field_format)%></th>
4 <th><%=l(:field_field_format)%></th>
5 <th><%=l(:field_is_required)%></th>
5 <th><%=l(:field_is_required)%></th>
6 <% if tab[:name] == 'IssueCustomField' %>
6 <% if tab[:name] == 'IssueCustomField' %>
7 <th><%=l(:field_is_for_all)%></th>
7 <th><%=l(:field_is_for_all)%></th>
8 <th><%=l(:label_used_by)%></th>
8 <th><%=l(:label_used_by)%></th>
9 <% end %>
9 <% end %>
10 <th><%=l(:button_sort)%></th>
10 <th><%=l(:button_sort)%></th>
11 <th width="10%"></th>
11 <th width="10%"></th>
12 </tr></thead>
12 </tr></thead>
13 <tbody>
13 <tbody>
14 <% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%>
14 <% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%>
15 <tr class="<%= cycle("odd", "even") %>">
15 <tr class="<%= cycle("odd", "even") %>">
16 <td><%= link_to h(custom_field.name), :action => 'edit', :id => custom_field %></td>
16 <td><%= link_to h(custom_field.name), edit_custom_field_path(custom_field) %></td>
17 <td align="center"><%= l(Redmine::CustomFieldFormat.label_for(custom_field.field_format)) %></td>
17 <td align="center"><%= l(Redmine::CustomFieldFormat.label_for(custom_field.field_format)) %></td>
18 <td align="center"><%= checked_image custom_field.is_required? %></td>
18 <td align="center"><%= checked_image custom_field.is_required? %></td>
19 <% if tab[:name] == 'IssueCustomField' %>
19 <% if tab[:name] == 'IssueCustomField' %>
20 <td align="center"><%= checked_image custom_field.is_for_all? %></td>
20 <td align="center"><%= checked_image custom_field.is_for_all? %></td>
21 <td align="center"><%= l(:label_x_projects, :count => custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
21 <td align="center"><%= l(:label_x_projects, :count => custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
22 <% end %>
22 <% end %>
23 <td align="center" style="width:15%;"><%= reorder_links('custom_field', {:action => 'edit', :id => custom_field}) %></td>
23 <td align="center" style="width:15%;"><%= reorder_links('custom_field', {:action => 'edit', :id => custom_field}) %></td>
24 <td class="buttons">
24 <td class="buttons">
25 <%= link_to(l(:button_delete), { :action => 'destroy', :id => custom_field },
25 <%= link_to(l(:button_delete), custom_field_path(custom_field),
26 :method => :post,
26 :method => :delete,
27 :confirm => l(:text_are_you_sure),
27 :confirm => l(:text_are_you_sure),
28 :class => 'icon icon-del') %>
28 :class => 'icon icon-del') %>
29 </td>
29 </td>
30 </tr>
30 </tr>
31 <% end; reset_cycle %>
31 <% end; reset_cycle %>
32 </tbody>
32 </tbody>
33 </table>
33 </table>
34
34
35 <p><%= link_to l(:label_custom_field_new), {:action => 'new', :type => tab[:name]}, :class => 'icon icon-add' %></p>
35 <p><%= link_to l(:label_custom_field_new), new_custom_field_path(:type => tab[:name]), :class => 'icon icon-add' %></p>
@@ -1,8 +1,8
1 <h2><%= link_to l(:label_custom_field_plural), :controller => 'custom_fields', :action => 'index' %>
1 <h2><%= link_to l(:label_custom_field_plural), :controller => 'custom_fields', :action => 'index' %>
2 &#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.class.name %>
2 &#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.class.name %>
3 &#187; <%=h @custom_field.name %></h2>
3 &#187; <%=h @custom_field.name %></h2>
4
4
5 <% labelled_form_for :custom_field, @custom_field, :url => { :action => "edit", :id => @custom_field } do |f| %>
5 <% labelled_form_for :custom_field, @custom_field, :url => custom_field_path(@custom_field), :html => {:method => :put} do |f| %>
6 <%= render :partial => 'form', :locals => { :f => f } %>
6 <%= render :partial => 'form', :locals => { :f => f } %>
7 <%= submit_tag l(:button_save) %>
7 <%= submit_tag l(:button_save) %>
8 <% end %>
8 <% end %>
@@ -1,9 +1,9
1 <h2><%= link_to l(:label_custom_field_plural), :controller => 'custom_fields', :action => 'index' %>
1 <h2><%= link_to l(:label_custom_field_plural), :controller => 'custom_fields', :action => 'index' %>
2 &#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.class.name %>
2 &#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.class.name %>
3 &#187; <%= l(:label_custom_field_new) %></h2>
3 &#187; <%= l(:label_custom_field_new) %></h2>
4
4
5 <% labelled_form_for :custom_field, @custom_field, :url => { :action => "new" } do |f| %>
5 <% labelled_form_for :custom_field, @custom_field, :url => custom_fields_path do |f| %>
6 <%= render :partial => 'form', :locals => { :f => f } %>
6 <%= render :partial => 'form', :locals => { :f => f } %>
7 <%= hidden_field_tag 'type', @custom_field.type %>
7 <%= hidden_field_tag 'type', @custom_field.type %>
8 <%= submit_tag l(:button_save) %>
8 <%= submit_tag l(:button_save) %>
9 <% end %>
9 <% end %>
@@ -1,211 +1,212
1 ActionController::Routing::Routes.draw do |map|
1 ActionController::Routing::Routes.draw do |map|
2 # Add your own custom routes here.
2 # Add your own custom routes here.
3 # The priority is based upon order of creation: first created -> highest priority.
3 # The priority is based upon order of creation: first created -> highest priority.
4
4
5 # Here's a sample route:
5 # Here's a sample route:
6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
7 # Keep in mind you can assign values other than :controller and :action
7 # Keep in mind you can assign values other than :controller and :action
8
8
9 map.home '', :controller => 'welcome'
9 map.home '', :controller => 'welcome'
10
10
11 map.signin 'login', :controller => 'account', :action => 'login'
11 map.signin 'login', :controller => 'account', :action => 'login'
12 map.signout 'logout', :controller => 'account', :action => 'logout'
12 map.signout 'logout', :controller => 'account', :action => 'logout'
13
13
14 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
14 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
15 map.connect 'help/:ctrl/:page', :controller => 'help'
15 map.connect 'help/:ctrl/:page', :controller => 'help'
16
16
17 map.time_entries_context_menu '/time_entries/context_menu',
17 map.time_entries_context_menu '/time_entries/context_menu',
18 :controller => 'context_menus', :action => 'time_entries'
18 :controller => 'context_menus', :action => 'time_entries'
19
19
20 map.resources :time_entries, :controller => 'timelog', :collection => {:report => :get, :bulk_edit => :get, :bulk_update => :post}
20 map.resources :time_entries, :controller => 'timelog', :collection => {:report => :get, :bulk_edit => :get, :bulk_update => :post}
21
21
22 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
22 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
23 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
23 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
24 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
24 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
25
25
26 map.with_options :controller => 'messages' do |messages_routes|
26 map.with_options :controller => 'messages' do |messages_routes|
27 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
27 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
28 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
28 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
29 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
29 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
30 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
30 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
31 end
31 end
32 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
32 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
33 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
33 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
34 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
34 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
35 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
35 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
36 end
36 end
37 end
37 end
38
38
39 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
39 map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
40 map.resources :queries, :except => [:show]
40 map.resources :queries, :except => [:show]
41
41
42 # Misc issue routes. TODO: move into resources
42 # Misc issue routes. TODO: move into resources
43 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues', :conditions => { :method => :get }
43 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues', :conditions => { :method => :get }
44 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview
44 map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview
45 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
45 map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
46 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
46 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
47 map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get }
47 map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get }
48 map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post }
48 map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post }
49 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
49 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
50 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
50 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
51
51
52 map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
52 map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
53 gantts_routes.connect '/projects/:project_id/issues/gantt'
53 gantts_routes.connect '/projects/:project_id/issues/gantt'
54 gantts_routes.connect '/projects/:project_id/issues/gantt.:format'
54 gantts_routes.connect '/projects/:project_id/issues/gantt.:format'
55 gantts_routes.connect '/issues/gantt.:format'
55 gantts_routes.connect '/issues/gantt.:format'
56 end
56 end
57
57
58 map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes|
58 map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes|
59 calendars_routes.connect '/projects/:project_id/issues/calendar'
59 calendars_routes.connect '/projects/:project_id/issues/calendar'
60 calendars_routes.connect '/issues/calendar'
60 calendars_routes.connect '/issues/calendar'
61 end
61 end
62
62
63 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
63 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
64 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
64 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
65 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
65 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
66 end
66 end
67
67
68 map.resources :issues do |issues|
68 map.resources :issues do |issues|
69 issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get}
69 issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get}
70 issues.resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
70 issues.resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
71 end
71 end
72
72
73 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
73 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
74
74
75 map.with_options :controller => 'users' do |users|
75 map.with_options :controller => 'users' do |users|
76 users.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil, :conditions => {:method => :get}
76 users.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil, :conditions => {:method => :get}
77
77
78 users.with_options :conditions => {:method => :post} do |user_actions|
78 users.with_options :conditions => {:method => :post} do |user_actions|
79 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
79 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
80 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
80 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
81 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
81 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
82 end
82 end
83 end
83 end
84
84
85 map.resources :users, :member => {
85 map.resources :users, :member => {
86 :edit_membership => :post,
86 :edit_membership => :post,
87 :destroy_membership => :post
87 :destroy_membership => :post
88 }
88 }
89
89
90 # For nice "roadmap" in the url for the index action
90 # For nice "roadmap" in the url for the index action
91 map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
91 map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
92
92
93 map.all_news 'news', :controller => 'news', :action => 'index'
93 map.all_news 'news', :controller => 'news', :action => 'index'
94 map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index'
94 map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index'
95 map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
95 map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
96 map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post}
96 map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post}
97 map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete}
97 map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete}
98
98
99 map.resources :projects, :member => {
99 map.resources :projects, :member => {
100 :copy => [:get, :post],
100 :copy => [:get, :post],
101 :settings => :get,
101 :settings => :get,
102 :modules => :post,
102 :modules => :post,
103 :archive => :post,
103 :archive => :post,
104 :unarchive => :post
104 :unarchive => :post
105 } do |project|
105 } do |project|
106 project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy]
106 project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy]
107 project.resources :issues, :only => [:index, :new, :create] do |issues|
107 project.resources :issues, :only => [:index, :new, :create] do |issues|
108 issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get}
108 issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get}
109 end
109 end
110 project.resources :files, :only => [:index, :new, :create]
110 project.resources :files, :only => [:index, :new, :create]
111 project.resources :versions, :shallow => true, :collection => {:close_completed => :put}, :member => {:status_by => :post}
111 project.resources :versions, :shallow => true, :collection => {:close_completed => :put}, :member => {:status_by => :post}
112 project.resources :news, :shallow => true
112 project.resources :news, :shallow => true
113 project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id', :collection => {:report => :get}
113 project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id', :collection => {:report => :get}
114 project.resources :queries, :only => [:new, :create]
114 project.resources :queries, :only => [:new, :create]
115 project.resources :issue_categories, :shallow => true
115 project.resources :issue_categories, :shallow => true
116 project.resources :documents, :shallow => true, :member => {:add_attachment => :post}
116 project.resources :documents, :shallow => true, :member => {:add_attachment => :post}
117 project.resources :boards
117 project.resources :boards
118
118
119 project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
119 project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
120 project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
120 project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
121 project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
121 project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
122 project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
122 project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
123 project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
123 project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
124 project.resources :wiki, :except => [:new, :create], :member => {
124 project.resources :wiki, :except => [:new, :create], :member => {
125 :rename => [:get, :post],
125 :rename => [:get, :post],
126 :history => :get,
126 :history => :get,
127 :preview => :any,
127 :preview => :any,
128 :protect => :post,
128 :protect => :post,
129 :add_attachment => :post
129 :add_attachment => :post
130 }, :collection => {
130 }, :collection => {
131 :export => :get,
131 :export => :get,
132 :date_index => :get
132 :date_index => :get
133 }
133 }
134
134
135 end
135 end
136
136
137 # Destroy uses a get request to prompt the user before the actual DELETE request
137 # Destroy uses a get request to prompt the user before the actual DELETE request
138 map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get}
138 map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get}
139
139
140 # TODO: port to be part of the resources route(s)
140 # TODO: port to be part of the resources route(s)
141 map.with_options :controller => 'projects' do |project_mapper|
141 map.with_options :controller => 'projects' do |project_mapper|
142 project_mapper.with_options :conditions => {:method => :get} do |project_views|
142 project_mapper.with_options :conditions => {:method => :get} do |project_views|
143 project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings'
143 project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings'
144 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
144 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
145 end
145 end
146 end
146 end
147
147
148 map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
148 map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
149 activity.connect 'projects/:id/activity'
149 activity.connect 'projects/:id/activity'
150 activity.connect 'projects/:id/activity.:format'
150 activity.connect 'projects/:id/activity.:format'
151 activity.connect 'activity', :id => nil
151 activity.connect 'activity', :id => nil
152 activity.connect 'activity.:format', :id => nil
152 activity.connect 'activity.:format', :id => nil
153 end
153 end
154
154
155 map.with_options :controller => 'repositories' do |repositories|
155 map.with_options :controller => 'repositories' do |repositories|
156 repositories.with_options :conditions => {:method => :get} do |repository_views|
156 repositories.with_options :conditions => {:method => :get} do |repository_views|
157 repository_views.connect 'projects/:id/repository', :action => 'show'
157 repository_views.connect 'projects/:id/repository', :action => 'show'
158 repository_views.connect 'projects/:id/repository/edit', :action => 'edit'
158 repository_views.connect 'projects/:id/repository/edit', :action => 'edit'
159 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats'
159 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats'
160 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions'
160 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions'
161 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
161 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
162 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
162 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
163 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
163 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
164 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
164 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
165 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
165 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
166 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
166 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
167 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw'
167 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw'
168 # TODO: why the following route is required?
168 # TODO: why the following route is required?
169 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry'
169 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry'
170 repository_views.connect 'projects/:id/repository/:action/*path'
170 repository_views.connect 'projects/:id/repository/:action/*path'
171 end
171 end
172
172
173 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
173 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
174 end
174 end
175
175
176 map.resources :attachments, :only => [:show, :destroy]
176 map.resources :attachments, :only => [:show, :destroy]
177 # additional routes for having the file name at the end of url
177 # additional routes for having the file name at the end of url
178 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
178 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
179 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
179 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
180
180
181 map.resources :groups, :member => {:autocomplete_for_user => :get}
181 map.resources :groups, :member => {:autocomplete_for_user => :get}
182 map.group_users 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :conditions => {:method => :post}
182 map.group_users 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :conditions => {:method => :post}
183 map.group_user 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :conditions => {:method => :delete}
183 map.group_user 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :conditions => {:method => :delete}
184
184
185 map.resources :trackers, :except => :show
185 map.resources :trackers, :except => :show
186 map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post}
186 map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post}
187 map.resources :custom_fields, :except => :show
187
188
188 #left old routes at the bottom for backwards compat
189 #left old routes at the bottom for backwards compat
189 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
190 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
190 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
191 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
191 map.connect 'projects/:project_id/news/:action', :controller => 'news'
192 map.connect 'projects/:project_id/news/:action', :controller => 'news'
192 map.with_options :controller => 'repositories' do |omap|
193 map.with_options :controller => 'repositories' do |omap|
193 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
194 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
194 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
195 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
195 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
196 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
196 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
197 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
197 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
198 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
198 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
199 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
199 end
200 end
200
201
201 map.with_options :controller => 'sys' do |sys|
202 map.with_options :controller => 'sys' do |sys|
202 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
203 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
203 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
204 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
204 end
205 end
205
206
206 # Install the default route as the lowest priority.
207 # Install the default route as the lowest priority.
207 map.connect ':controller/:action/:id'
208 map.connect ':controller/:action/:id'
208 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
209 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
209 # Used for OpenID
210 # Used for OpenID
210 map.root :controller => 'account', :action => 'login'
211 map.root :controller => 'account', :action => 'login'
211 end
212 end
@@ -1,117 +1,138
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19 require 'custom_fields_controller'
19 require 'custom_fields_controller'
20
20
21 # Re-raise errors caught by the controller.
21 # Re-raise errors caught by the controller.
22 class CustomFieldsController; def rescue_action(e) raise e end; end
22 class CustomFieldsController; def rescue_action(e) raise e end; end
23
23
24 class CustomFieldsControllerTest < ActionController::TestCase
24 class CustomFieldsControllerTest < ActionController::TestCase
25 fixtures :custom_fields, :custom_values, :trackers, :users
25 fixtures :custom_fields, :custom_values, :trackers, :users
26
26
27 def setup
27 def setup
28 @controller = CustomFieldsController.new
28 @controller = CustomFieldsController.new
29 @request = ActionController::TestRequest.new
29 @request = ActionController::TestRequest.new
30 @response = ActionController::TestResponse.new
30 @response = ActionController::TestResponse.new
31 @request.session[:user_id] = 1
31 @request.session[:user_id] = 1
32 end
32 end
33
33
34 def test_index
34 def test_index
35 get :index
35 get :index
36 assert_response :success
36 assert_response :success
37 assert_template 'index'
37 assert_template 'index'
38 end
38 end
39
39
40 def test_get_new_issue_custom_field
40 def test_new_issue_custom_field
41 get :new, :type => 'IssueCustomField'
41 get :new, :type => 'IssueCustomField'
42 assert_response :success
42 assert_response :success
43 assert_template 'new'
43 assert_template 'new'
44 assert_tag :input, :attributes => {:name => 'custom_field[name]'}
44 assert_tag :select,
45 assert_tag :select,
45 :attributes => {:name => 'custom_field[field_format]'},
46 :attributes => {:name => 'custom_field[field_format]'},
46 :child => {
47 :child => {
47 :tag => 'option',
48 :tag => 'option',
48 :attributes => {:value => 'user'},
49 :attributes => {:value => 'user'},
49 :content => 'User'
50 :content => 'User'
50 }
51 }
51 assert_tag :select,
52 assert_tag :select,
52 :attributes => {:name => 'custom_field[field_format]'},
53 :attributes => {:name => 'custom_field[field_format]'},
53 :child => {
54 :child => {
54 :tag => 'option',
55 :tag => 'option',
55 :attributes => {:value => 'version'},
56 :attributes => {:value => 'version'},
56 :content => 'Version'
57 :content => 'Version'
57 }
58 }
59 assert_tag :input, :attributes => {:name => 'type', :value => 'IssueCustomField'}
58 end
60 end
59
61
60 def test_get_new_with_invalid_custom_field_class_should_redirect_to_list
62 def test_new_with_invalid_custom_field_class_should_render_404
61 get :new, :type => 'UnknownCustomField'
63 get :new, :type => 'UnknownCustomField'
62 assert_redirected_to '/custom_fields'
64 assert_response 404
63 end
65 end
64
66
65 def test_post_new_list_custom_field
67 def test_create_list_custom_field
66 assert_difference 'CustomField.count' do
68 assert_difference 'CustomField.count' do
67 post :new, :type => "IssueCustomField",
69 post :create, :type => "IssueCustomField",
68 :custom_field => {:name => "test_post_new_list",
70 :custom_field => {:name => "test_post_new_list",
69 :default_value => "",
71 :default_value => "",
70 :min_length => "0",
72 :min_length => "0",
71 :searchable => "0",
73 :searchable => "0",
72 :regexp => "",
74 :regexp => "",
73 :is_for_all => "1",
75 :is_for_all => "1",
74 :possible_values => "0.1\n0.2\n",
76 :possible_values => "0.1\n0.2\n",
75 :max_length => "0",
77 :max_length => "0",
76 :is_filter => "0",
78 :is_filter => "0",
77 :is_required =>"0",
79 :is_required =>"0",
78 :field_format => "list",
80 :field_format => "list",
79 :tracker_ids => ["1", ""]}
81 :tracker_ids => ["1", ""]}
80 end
82 end
81 assert_redirected_to '/custom_fields?tab=IssueCustomField'
83 assert_redirected_to '/custom_fields?tab=IssueCustomField'
82 field = IssueCustomField.find_by_name('test_post_new_list')
84 field = IssueCustomField.find_by_name('test_post_new_list')
83 assert_not_nil field
85 assert_not_nil field
84 assert_equal ["0.1", "0.2"], field.possible_values
86 assert_equal ["0.1", "0.2"], field.possible_values
85 assert_equal 1, field.trackers.size
87 assert_equal 1, field.trackers.size
86 end
88 end
87
89
88 def test_get_edit
90 def test_create_with_failure
91 assert_no_difference 'CustomField.count' do
92 post :create, :type => "IssueCustomField", :custom_field => {:name => ''}
93 end
94 assert_response :success
95 assert_template 'new'
96 end
97
98 def test_edit
89 get :edit, :id => 1
99 get :edit, :id => 1
90 assert_response :success
100 assert_response :success
91 assert_template 'edit'
101 assert_template 'edit'
92 assert_tag 'input', :attributes => {:name => 'custom_field[name]', :value => 'Database'}
102 assert_tag 'input', :attributes => {:name => 'custom_field[name]', :value => 'Database'}
93 end
103 end
94
104
95 def test_post_edit
105 def test_edit_invalid_custom_field_should_render_404
96 post :edit, :id => 1, :custom_field => {:name => 'New name'}
106 get :edit, :id => 99
107 assert_response 404
108 end
109
110 def test_update
111 put :update, :id => 1, :custom_field => {:name => 'New name'}
97 assert_redirected_to '/custom_fields?tab=IssueCustomField'
112 assert_redirected_to '/custom_fields?tab=IssueCustomField'
98
113
99 field = CustomField.find(1)
114 field = CustomField.find(1)
100 assert_equal 'New name', field.name
115 assert_equal 'New name', field.name
101 end
116 end
102
117
118 def test_update_with_failure
119 put :update, :id => 1, :custom_field => {:name => ''}
120 assert_response :success
121 assert_template 'edit'
122 end
123
103 def test_destroy
124 def test_destroy
104 custom_values_count = CustomValue.count(:conditions => {:custom_field_id => 1})
125 custom_values_count = CustomValue.count(:conditions => {:custom_field_id => 1})
105 assert custom_values_count > 0
126 assert custom_values_count > 0
106
127
107 assert_difference 'CustomField.count', -1 do
128 assert_difference 'CustomField.count', -1 do
108 assert_difference 'CustomValue.count', - custom_values_count do
129 assert_difference 'CustomValue.count', - custom_values_count do
109 post :destroy, :id => 1
130 delete :destroy, :id => 1
110 end
131 end
111 end
132 end
112
133
113 assert_redirected_to '/custom_fields?tab=IssueCustomField'
134 assert_redirected_to '/custom_fields?tab=IssueCustomField'
114 assert_nil CustomField.find_by_id(1)
135 assert_nil CustomField.find_by_id(1)
115 assert_nil CustomValue.find_by_custom_field_id(1)
136 assert_nil CustomValue.find_by_custom_field_id(1)
116 end
137 end
117 end
138 end
@@ -1,425 +1,434
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class RoutingTest < ActionController::IntegrationTest
20 class RoutingTest < ActionController::IntegrationTest
21 context "activities" do
21 context "activities" do
22 should_route :get, "/activity", :controller => 'activities', :action => 'index', :id => nil
22 should_route :get, "/activity", :controller => 'activities', :action => 'index', :id => nil
23 should_route :get, "/activity.atom", :controller => 'activities', :action => 'index', :id => nil, :format => 'atom'
23 should_route :get, "/activity.atom", :controller => 'activities', :action => 'index', :id => nil, :format => 'atom'
24 end
24 end
25
25
26 context "attachments" do
26 context "attachments" do
27 should_route :get, "/attachments/1", :controller => 'attachments', :action => 'show', :id => '1'
27 should_route :get, "/attachments/1", :controller => 'attachments', :action => 'show', :id => '1'
28 should_route :get, "/attachments/1.xml", :controller => 'attachments', :action => 'show', :id => '1', :format => 'xml'
28 should_route :get, "/attachments/1.xml", :controller => 'attachments', :action => 'show', :id => '1', :format => 'xml'
29 should_route :get, "/attachments/1.json", :controller => 'attachments', :action => 'show', :id => '1', :format => 'json'
29 should_route :get, "/attachments/1.json", :controller => 'attachments', :action => 'show', :id => '1', :format => 'json'
30 should_route :get, "/attachments/1/filename.ext", :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext'
30 should_route :get, "/attachments/1/filename.ext", :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext'
31 should_route :get, "/attachments/download/1", :controller => 'attachments', :action => 'download', :id => '1'
31 should_route :get, "/attachments/download/1", :controller => 'attachments', :action => 'download', :id => '1'
32 should_route :get, "/attachments/download/1/filename.ext", :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext'
32 should_route :get, "/attachments/download/1/filename.ext", :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext'
33 end
33 end
34
34
35 context "boards" do
35 context "boards" do
36 should_route :get, "/projects/world_domination/boards", :controller => 'boards', :action => 'index', :project_id => 'world_domination'
36 should_route :get, "/projects/world_domination/boards", :controller => 'boards', :action => 'index', :project_id => 'world_domination'
37 should_route :get, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
37 should_route :get, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
38 should_route :get, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44'
38 should_route :get, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44'
39 should_route :get, "/projects/world_domination/boards/44.atom", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44', :format => 'atom'
39 should_route :get, "/projects/world_domination/boards/44.atom", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44', :format => 'atom'
40 should_route :get, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
40 should_route :get, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
41
41
42 should_route :post, "/projects/world_domination/boards", :controller => 'boards', :action => 'create', :project_id => 'world_domination'
42 should_route :post, "/projects/world_domination/boards", :controller => 'boards', :action => 'create', :project_id => 'world_domination'
43 should_route :put, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'update', :project_id => 'world_domination', :id => '44'
43 should_route :put, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'update', :project_id => 'world_domination', :id => '44'
44 should_route :delete, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'destroy', :project_id => 'world_domination', :id => '44'
44 should_route :delete, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'destroy', :project_id => 'world_domination', :id => '44'
45
45
46 end
46 end
47
47
48 context "custom_fields" do
49 should_route :get, "/custom_fields", :controller => 'custom_fields', :action => 'index'
50 should_route :get, "/custom_fields/new", :controller => 'custom_fields', :action => 'new'
51 should_route :post, "/custom_fields", :controller => 'custom_fields', :action => 'create'
52 should_route :get, "/custom_fields/2/edit", :controller => 'custom_fields', :action => 'edit', :id => 2
53 should_route :put, "/custom_fields/2", :controller => 'custom_fields', :action => 'update', :id => 2
54 should_route :delete, "/custom_fields/2", :controller => 'custom_fields', :action => 'destroy', :id => 2
55 end
56
48 context "documents" do
57 context "documents" do
49 should_route :get, "/projects/567/documents", :controller => 'documents', :action => 'index', :project_id => '567'
58 should_route :get, "/projects/567/documents", :controller => 'documents', :action => 'index', :project_id => '567'
50 should_route :get, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
59 should_route :get, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
51 should_route :get, "/documents/22", :controller => 'documents', :action => 'show', :id => '22'
60 should_route :get, "/documents/22", :controller => 'documents', :action => 'show', :id => '22'
52 should_route :get, "/documents/22/edit", :controller => 'documents', :action => 'edit', :id => '22'
61 should_route :get, "/documents/22/edit", :controller => 'documents', :action => 'edit', :id => '22'
53
62
54 should_route :post, "/projects/567/documents", :controller => 'documents', :action => 'create', :project_id => '567'
63 should_route :post, "/projects/567/documents", :controller => 'documents', :action => 'create', :project_id => '567'
55 should_route :put, "/documents/22", :controller => 'documents', :action => 'update', :id => '22'
64 should_route :put, "/documents/22", :controller => 'documents', :action => 'update', :id => '22'
56 should_route :delete, "/documents/22", :controller => 'documents', :action => 'destroy', :id => '22'
65 should_route :delete, "/documents/22", :controller => 'documents', :action => 'destroy', :id => '22'
57
66
58 should_route :post, "/documents/22/add_attachment", :controller => 'documents', :action => 'add_attachment', :id => '22'
67 should_route :post, "/documents/22/add_attachment", :controller => 'documents', :action => 'add_attachment', :id => '22'
59 end
68 end
60
69
61 context "groups" do
70 context "groups" do
62 should_route :post, "/groups/567/users", :controller => 'groups', :action => 'add_users', :id => '567'
71 should_route :post, "/groups/567/users", :controller => 'groups', :action => 'add_users', :id => '567'
63 should_route :delete, "/groups/567/users/12", :controller => 'groups', :action => 'remove_user', :id => '567', :user_id => '12'
72 should_route :delete, "/groups/567/users/12", :controller => 'groups', :action => 'remove_user', :id => '567', :user_id => '12'
64 end
73 end
65
74
66 context "issues" do
75 context "issues" do
67 # REST actions
76 # REST actions
68 should_route :get, "/issues", :controller => 'issues', :action => 'index'
77 should_route :get, "/issues", :controller => 'issues', :action => 'index'
69 should_route :get, "/issues.pdf", :controller => 'issues', :action => 'index', :format => 'pdf'
78 should_route :get, "/issues.pdf", :controller => 'issues', :action => 'index', :format => 'pdf'
70 should_route :get, "/issues.atom", :controller => 'issues', :action => 'index', :format => 'atom'
79 should_route :get, "/issues.atom", :controller => 'issues', :action => 'index', :format => 'atom'
71 should_route :get, "/issues.xml", :controller => 'issues', :action => 'index', :format => 'xml'
80 should_route :get, "/issues.xml", :controller => 'issues', :action => 'index', :format => 'xml'
72 should_route :get, "/projects/23/issues", :controller => 'issues', :action => 'index', :project_id => '23'
81 should_route :get, "/projects/23/issues", :controller => 'issues', :action => 'index', :project_id => '23'
73 should_route :get, "/projects/23/issues.pdf", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf'
82 should_route :get, "/projects/23/issues.pdf", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf'
74 should_route :get, "/projects/23/issues.atom", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom'
83 should_route :get, "/projects/23/issues.atom", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom'
75 should_route :get, "/projects/23/issues.xml", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'xml'
84 should_route :get, "/projects/23/issues.xml", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'xml'
76 should_route :get, "/issues/64", :controller => 'issues', :action => 'show', :id => '64'
85 should_route :get, "/issues/64", :controller => 'issues', :action => 'show', :id => '64'
77 should_route :get, "/issues/64.pdf", :controller => 'issues', :action => 'show', :id => '64', :format => 'pdf'
86 should_route :get, "/issues/64.pdf", :controller => 'issues', :action => 'show', :id => '64', :format => 'pdf'
78 should_route :get, "/issues/64.atom", :controller => 'issues', :action => 'show', :id => '64', :format => 'atom'
87 should_route :get, "/issues/64.atom", :controller => 'issues', :action => 'show', :id => '64', :format => 'atom'
79 should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml'
88 should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml'
80
89
81 should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23'
90 should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23'
82 should_route :post, "/projects/23/issues", :controller => 'issues', :action => 'create', :project_id => '23'
91 should_route :post, "/projects/23/issues", :controller => 'issues', :action => 'create', :project_id => '23'
83 should_route :post, "/issues.xml", :controller => 'issues', :action => 'create', :format => 'xml'
92 should_route :post, "/issues.xml", :controller => 'issues', :action => 'create', :format => 'xml'
84
93
85 should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
94 should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
86 should_route :put, "/issues/1.xml", :controller => 'issues', :action => 'update', :id => '1', :format => 'xml'
95 should_route :put, "/issues/1.xml", :controller => 'issues', :action => 'update', :id => '1', :format => 'xml'
87
96
88 # TODO: Should use DELETE
97 # TODO: Should use DELETE
89 should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64'
98 should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64'
90 should_route :delete, "/issues/1.xml", :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml'
99 should_route :delete, "/issues/1.xml", :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml'
91
100
92 # Extra actions
101 # Extra actions
93 should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64'
102 should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64'
94
103
95 should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new'
104 should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new'
96 should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create'
105 should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create'
97
106
98 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
107 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
99
108
100 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
109 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
101 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
110 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
102
111
103 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
112 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
104 should_route :get, "/issues/gantt.pdf", :controller => 'gantts', :action => 'show', :format => 'pdf'
113 should_route :get, "/issues/gantt.pdf", :controller => 'gantts', :action => 'show', :format => 'pdf'
105 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
114 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
106 should_route :get, "/projects/project-name/issues/gantt.pdf", :controller => 'gantts', :action => 'show', :project_id => 'project-name', :format => 'pdf'
115 should_route :get, "/projects/project-name/issues/gantt.pdf", :controller => 'gantts', :action => 'show', :project_id => 'project-name', :format => 'pdf'
107
116
108 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
117 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
109
118
110 should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
119 should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
111 should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
120 should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
112 should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
121 should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
113 should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
122 should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
114
123
115 should_route :get, "/issues/changes", :controller => 'journals', :action => 'index'
124 should_route :get, "/issues/changes", :controller => 'journals', :action => 'index'
116
125
117 should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit'
126 should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit'
118 should_route :post, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_update'
127 should_route :post, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_update'
119 end
128 end
120
129
121 context "issue categories" do
130 context "issue categories" do
122 should_route :get, "/projects/foo/issue_categories", :controller => 'issue_categories', :action => 'index', :project_id => 'foo'
131 should_route :get, "/projects/foo/issue_categories", :controller => 'issue_categories', :action => 'index', :project_id => 'foo'
123 should_route :get, "/projects/foo/issue_categories.xml", :controller => 'issue_categories', :action => 'index', :project_id => 'foo', :format => 'xml'
132 should_route :get, "/projects/foo/issue_categories.xml", :controller => 'issue_categories', :action => 'index', :project_id => 'foo', :format => 'xml'
124 should_route :get, "/projects/foo/issue_categories.json", :controller => 'issue_categories', :action => 'index', :project_id => 'foo', :format => 'json'
133 should_route :get, "/projects/foo/issue_categories.json", :controller => 'issue_categories', :action => 'index', :project_id => 'foo', :format => 'json'
125
134
126 should_route :get, "/projects/foo/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'foo'
135 should_route :get, "/projects/foo/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'foo'
127
136
128 should_route :post, "/projects/foo/issue_categories", :controller => 'issue_categories', :action => 'create', :project_id => 'foo'
137 should_route :post, "/projects/foo/issue_categories", :controller => 'issue_categories', :action => 'create', :project_id => 'foo'
129 should_route :post, "/projects/foo/issue_categories.xml", :controller => 'issue_categories', :action => 'create', :project_id => 'foo', :format => 'xml'
138 should_route :post, "/projects/foo/issue_categories.xml", :controller => 'issue_categories', :action => 'create', :project_id => 'foo', :format => 'xml'
130 should_route :post, "/projects/foo/issue_categories.json", :controller => 'issue_categories', :action => 'create', :project_id => 'foo', :format => 'json'
139 should_route :post, "/projects/foo/issue_categories.json", :controller => 'issue_categories', :action => 'create', :project_id => 'foo', :format => 'json'
131
140
132 should_route :get, "/issue_categories/1", :controller => 'issue_categories', :action => 'show', :id => '1'
141 should_route :get, "/issue_categories/1", :controller => 'issue_categories', :action => 'show', :id => '1'
133 should_route :get, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'show', :id => '1', :format => 'xml'
142 should_route :get, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'show', :id => '1', :format => 'xml'
134 should_route :get, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'show', :id => '1', :format => 'json'
143 should_route :get, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'show', :id => '1', :format => 'json'
135
144
136 should_route :get, "/issue_categories/1/edit", :controller => 'issue_categories', :action => 'edit', :id => '1'
145 should_route :get, "/issue_categories/1/edit", :controller => 'issue_categories', :action => 'edit', :id => '1'
137
146
138 should_route :put, "/issue_categories/1", :controller => 'issue_categories', :action => 'update', :id => '1'
147 should_route :put, "/issue_categories/1", :controller => 'issue_categories', :action => 'update', :id => '1'
139 should_route :put, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'update', :id => '1', :format => 'xml'
148 should_route :put, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'update', :id => '1', :format => 'xml'
140 should_route :put, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'update', :id => '1', :format => 'json'
149 should_route :put, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'update', :id => '1', :format => 'json'
141
150
142 should_route :delete, "/issue_categories/1", :controller => 'issue_categories', :action => 'destroy', :id => '1'
151 should_route :delete, "/issue_categories/1", :controller => 'issue_categories', :action => 'destroy', :id => '1'
143 should_route :delete, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'destroy', :id => '1', :format => 'xml'
152 should_route :delete, "/issue_categories/1.xml", :controller => 'issue_categories', :action => 'destroy', :id => '1', :format => 'xml'
144 should_route :delete, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'destroy', :id => '1', :format => 'json'
153 should_route :delete, "/issue_categories/1.json", :controller => 'issue_categories', :action => 'destroy', :id => '1', :format => 'json'
145 end
154 end
146
155
147 context "issue relations" do
156 context "issue relations" do
148 should_route :get, "/issues/1/relations", :controller => 'issue_relations', :action => 'index', :issue_id => '1'
157 should_route :get, "/issues/1/relations", :controller => 'issue_relations', :action => 'index', :issue_id => '1'
149 should_route :get, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'xml'
158 should_route :get, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'xml'
150 should_route :get, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'json'
159 should_route :get, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'json'
151
160
152 should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'create', :issue_id => '1'
161 should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'create', :issue_id => '1'
153 should_route :post, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'xml'
162 should_route :post, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'xml'
154 should_route :post, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'json'
163 should_route :post, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'json'
155
164
156 should_route :get, "/relations/23", :controller => 'issue_relations', :action => 'show', :id => '23'
165 should_route :get, "/relations/23", :controller => 'issue_relations', :action => 'show', :id => '23'
157 should_route :get, "/relations/23.xml", :controller => 'issue_relations', :action => 'show', :id => '23', :format => 'xml'
166 should_route :get, "/relations/23.xml", :controller => 'issue_relations', :action => 'show', :id => '23', :format => 'xml'
158 should_route :get, "/relations/23.json", :controller => 'issue_relations', :action => 'show', :id => '23', :format => 'json'
167 should_route :get, "/relations/23.json", :controller => 'issue_relations', :action => 'show', :id => '23', :format => 'json'
159
168
160 should_route :delete, "/relations/23", :controller => 'issue_relations', :action => 'destroy', :id => '23'
169 should_route :delete, "/relations/23", :controller => 'issue_relations', :action => 'destroy', :id => '23'
161 should_route :delete, "/relations/23.xml", :controller => 'issue_relations', :action => 'destroy', :id => '23', :format => 'xml'
170 should_route :delete, "/relations/23.xml", :controller => 'issue_relations', :action => 'destroy', :id => '23', :format => 'xml'
162 should_route :delete, "/relations/23.json", :controller => 'issue_relations', :action => 'destroy', :id => '23', :format => 'json'
171 should_route :delete, "/relations/23.json", :controller => 'issue_relations', :action => 'destroy', :id => '23', :format => 'json'
163 end
172 end
164
173
165 context "issue reports" do
174 context "issue reports" do
166 should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567'
175 should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567'
167 should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to'
176 should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to'
168 end
177 end
169
178
170 context "members" do
179 context "members" do
171 should_route :post, "/projects/5234/members/new", :controller => 'members', :action => 'new', :id => '5234'
180 should_route :post, "/projects/5234/members/new", :controller => 'members', :action => 'new', :id => '5234'
172 end
181 end
173
182
174 context "messages" do
183 context "messages" do
175 should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
184 should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
176 should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
185 should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
177 should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
186 should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
178
187
179 should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
188 should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
180 should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
189 should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
181 should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22'
190 should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22'
182 should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22'
191 should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22'
183 end
192 end
184
193
185 context "news" do
194 context "news" do
186 should_route :get, "/news", :controller => 'news', :action => 'index'
195 should_route :get, "/news", :controller => 'news', :action => 'index'
187 should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom'
196 should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom'
188 should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml'
197 should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml'
189 should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json'
198 should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json'
190 should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567'
199 should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567'
191 should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567'
200 should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567'
192 should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567'
201 should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567'
193 should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567'
202 should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567'
194 should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2'
203 should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2'
195 should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
204 should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
196 should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234'
205 should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234'
197 should_route :get, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567'
206 should_route :get, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567'
198 should_route :get, "/news/preview", :controller => 'previews', :action => 'news'
207 should_route :get, "/news/preview", :controller => 'previews', :action => 'news'
199
208
200 should_route :post, "/projects/567/news", :controller => 'news', :action => 'create', :project_id => '567'
209 should_route :post, "/projects/567/news", :controller => 'news', :action => 'create', :project_id => '567'
201 should_route :post, "/news/567/comments", :controller => 'comments', :action => 'create', :id => '567'
210 should_route :post, "/news/567/comments", :controller => 'comments', :action => 'create', :id => '567'
202
211
203 should_route :put, "/news/567", :controller => 'news', :action => 'update', :id => '567'
212 should_route :put, "/news/567", :controller => 'news', :action => 'update', :id => '567'
204
213
205 should_route :delete, "/news/567", :controller => 'news', :action => 'destroy', :id => '567'
214 should_route :delete, "/news/567", :controller => 'news', :action => 'destroy', :id => '567'
206 should_route :delete, "/news/567/comments/15", :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15'
215 should_route :delete, "/news/567/comments/15", :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15'
207 end
216 end
208
217
209 context "projects" do
218 context "projects" do
210 should_route :get, "/projects", :controller => 'projects', :action => 'index'
219 should_route :get, "/projects", :controller => 'projects', :action => 'index'
211 should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
220 should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
212 should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
221 should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
213 should_route :get, "/projects/new", :controller => 'projects', :action => 'new'
222 should_route :get, "/projects/new", :controller => 'projects', :action => 'new'
214 should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test'
223 should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test'
215 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
224 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
216 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
225 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
217 should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
226 should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
218 should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :project_id => '33'
227 should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :project_id => '33'
219 should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :project_id => '33'
228 should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :project_id => '33'
220 should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
229 should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
221 should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
230 should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
222 should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
231 should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
223
232
224 should_route :post, "/projects", :controller => 'projects', :action => 'create'
233 should_route :post, "/projects", :controller => 'projects', :action => 'create'
225 should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml'
234 should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml'
226 should_route :post, "/projects/33/files", :controller => 'files', :action => 'create', :project_id => '33'
235 should_route :post, "/projects/33/files", :controller => 'files', :action => 'create', :project_id => '33'
227 should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64'
236 should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64'
228 should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64'
237 should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64'
229
238
230 should_route :put, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'update', :project_id => '64'
239 should_route :put, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'update', :project_id => '64'
231 should_route :put, "/projects/4223", :controller => 'projects', :action => 'update', :id => '4223'
240 should_route :put, "/projects/4223", :controller => 'projects', :action => 'update', :id => '4223'
232 should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml'
241 should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml'
233
242
234 should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64'
243 should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64'
235 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
244 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
236 should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64'
245 should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64'
237 end
246 end
238
247
239 context "queries" do
248 context "queries" do
240 should_route :get, "/queries.xml", :controller => 'queries', :action => 'index', :format => 'xml'
249 should_route :get, "/queries.xml", :controller => 'queries', :action => 'index', :format => 'xml'
241 should_route :get, "/queries.json", :controller => 'queries', :action => 'index', :format => 'json'
250 should_route :get, "/queries.json", :controller => 'queries', :action => 'index', :format => 'json'
242
251
243 should_route :get, "/queries/new", :controller => 'queries', :action => 'new'
252 should_route :get, "/queries/new", :controller => 'queries', :action => 'new'
244 should_route :get, "/projects/redmine/queries/new", :controller => 'queries', :action => 'new', :project_id => 'redmine'
253 should_route :get, "/projects/redmine/queries/new", :controller => 'queries', :action => 'new', :project_id => 'redmine'
245
254
246 should_route :post, "/queries", :controller => 'queries', :action => 'create'
255 should_route :post, "/queries", :controller => 'queries', :action => 'create'
247 should_route :post, "/projects/redmine/queries", :controller => 'queries', :action => 'create', :project_id => 'redmine'
256 should_route :post, "/projects/redmine/queries", :controller => 'queries', :action => 'create', :project_id => 'redmine'
248
257
249 should_route :get, "/queries/1/edit", :controller => 'queries', :action => 'edit', :id => '1'
258 should_route :get, "/queries/1/edit", :controller => 'queries', :action => 'edit', :id => '1'
250
259
251 should_route :put, "/queries/1", :controller => 'queries', :action => 'update', :id => '1'
260 should_route :put, "/queries/1", :controller => 'queries', :action => 'update', :id => '1'
252
261
253 should_route :delete, "/queries/1", :controller => 'queries', :action => 'destroy', :id => '1'
262 should_route :delete, "/queries/1", :controller => 'queries', :action => 'destroy', :id => '1'
254 end
263 end
255
264
256 context "repositories" do
265 context "repositories" do
257 should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'
266 should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'
258 should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
267 should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
259 should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine'
268 should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine'
260 should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
269 should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
261 should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457'
270 should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457'
262 should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457'
271 should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457'
263 should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff'
272 should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff'
264 should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c]
273 should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c]
265 should_route :get, "/projects/redmine/repository/revisions/2/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c], :rev => '2'
274 should_route :get, "/projects/redmine/repository/revisions/2/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c], :rev => '2'
266 should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c]
275 should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c]
267 should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c]
276 should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c]
268 should_route :get, "/projects/redmine/repository/revisions/2/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2'
277 should_route :get, "/projects/redmine/repository/revisions/2/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2'
269 should_route :get, "/projects/redmine/repository/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :format => 'raw'
278 should_route :get, "/projects/redmine/repository/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :format => 'raw'
270 should_route :get, "/projects/redmine/repository/revisions/2/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2', :format => 'raw'
279 should_route :get, "/projects/redmine/repository/revisions/2/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2', :format => 'raw'
271 should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c]
280 should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c]
272 should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c]
281 should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c]
273 should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine'
282 should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine'
274
283
275 should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
284 should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
276 end
285 end
277
286
278 context "timelogs (global)" do
287 context "timelogs (global)" do
279 should_route :get, "/time_entries", :controller => 'timelog', :action => 'index'
288 should_route :get, "/time_entries", :controller => 'timelog', :action => 'index'
280 should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'index', :format => 'csv'
289 should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'index', :format => 'csv'
281 should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'index', :format => 'atom'
290 should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'index', :format => 'atom'
282 should_route :get, "/time_entries/new", :controller => 'timelog', :action => 'new'
291 should_route :get, "/time_entries/new", :controller => 'timelog', :action => 'new'
283 should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22'
292 should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22'
284
293
285 should_route :post, "/time_entries", :controller => 'timelog', :action => 'create'
294 should_route :post, "/time_entries", :controller => 'timelog', :action => 'create'
286
295
287 should_route :put, "/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22'
296 should_route :put, "/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22'
288
297
289 should_route :delete, "/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55'
298 should_route :delete, "/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55'
290 end
299 end
291
300
292 context "timelogs (scoped under project)" do
301 context "timelogs (scoped under project)" do
293 should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567'
302 should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567'
294 should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv'
303 should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv'
295 should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom'
304 should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom'
296 should_route :get, "/projects/567/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => '567'
305 should_route :get, "/projects/567/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => '567'
297 should_route :get, "/projects/567/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :project_id => '567'
306 should_route :get, "/projects/567/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :project_id => '567'
298
307
299 should_route :post, "/projects/567/time_entries", :controller => 'timelog', :action => 'create', :project_id => '567'
308 should_route :post, "/projects/567/time_entries", :controller => 'timelog', :action => 'create', :project_id => '567'
300
309
301 should_route :put, "/projects/567/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :project_id => '567'
310 should_route :put, "/projects/567/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :project_id => '567'
302
311
303 should_route :delete, "/projects/567/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :project_id => '567'
312 should_route :delete, "/projects/567/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :project_id => '567'
304 end
313 end
305
314
306 context "timelogs (scoped under issues)" do
315 context "timelogs (scoped under issues)" do
307 should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234'
316 should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234'
308 should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv'
317 should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv'
309 should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom'
318 should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom'
310 should_route :get, "/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234'
319 should_route :get, "/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234'
311 should_route :get, "/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234'
320 should_route :get, "/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234'
312
321
313 should_route :post, "/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234'
322 should_route :post, "/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234'
314
323
315 should_route :put, "/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234'
324 should_route :put, "/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234'
316
325
317 should_route :delete, "/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234'
326 should_route :delete, "/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234'
318 end
327 end
319
328
320 context "timelogs (scoped under project and issues)" do
329 context "timelogs (scoped under project and issues)" do
321 should_route :get, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook'
330 should_route :get, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook'
322 should_route :get, "/projects/ecookbook/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'csv'
331 should_route :get, "/projects/ecookbook/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'csv'
323 should_route :get, "/projects/ecookbook/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'atom'
332 should_route :get, "/projects/ecookbook/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'atom'
324 should_route :get, "/projects/ecookbook/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234', :project_id => 'ecookbook'
333 should_route :get, "/projects/ecookbook/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234', :project_id => 'ecookbook'
325 should_route :get, "/projects/ecookbook/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
334 should_route :get, "/projects/ecookbook/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
326
335
327 should_route :post, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234', :project_id => 'ecookbook'
336 should_route :post, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234', :project_id => 'ecookbook'
328
337
329 should_route :put, "/projects/ecookbook/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
338 should_route :put, "/projects/ecookbook/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234', :project_id => 'ecookbook'
330
339
331 should_route :delete, "/projects/ecookbook/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234', :project_id => 'ecookbook'
340 should_route :delete, "/projects/ecookbook/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234', :project_id => 'ecookbook'
332
341
333 should_route :get, "/time_entries/report", :controller => 'timelog', :action => 'report'
342 should_route :get, "/time_entries/report", :controller => 'timelog', :action => 'report'
334 should_route :get, "/projects/567/time_entries/report", :controller => 'timelog', :action => 'report', :project_id => '567'
343 should_route :get, "/projects/567/time_entries/report", :controller => 'timelog', :action => 'report', :project_id => '567'
335 should_route :get, "/projects/567/time_entries/report.csv", :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv'
344 should_route :get, "/projects/567/time_entries/report.csv", :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv'
336 end
345 end
337
346
338 context "users" do
347 context "users" do
339 should_route :get, "/users", :controller => 'users', :action => 'index'
348 should_route :get, "/users", :controller => 'users', :action => 'index'
340 should_route :get, "/users.xml", :controller => 'users', :action => 'index', :format => 'xml'
349 should_route :get, "/users.xml", :controller => 'users', :action => 'index', :format => 'xml'
341 should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
350 should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
342 should_route :get, "/users/44.xml", :controller => 'users', :action => 'show', :id => '44', :format => 'xml'
351 should_route :get, "/users/44.xml", :controller => 'users', :action => 'show', :id => '44', :format => 'xml'
343 should_route :get, "/users/current", :controller => 'users', :action => 'show', :id => 'current'
352 should_route :get, "/users/current", :controller => 'users', :action => 'show', :id => 'current'
344 should_route :get, "/users/current.xml", :controller => 'users', :action => 'show', :id => 'current', :format => 'xml'
353 should_route :get, "/users/current.xml", :controller => 'users', :action => 'show', :id => 'current', :format => 'xml'
345 should_route :get, "/users/new", :controller => 'users', :action => 'new'
354 should_route :get, "/users/new", :controller => 'users', :action => 'new'
346 should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
355 should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
347 should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
356 should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
348
357
349 should_route :post, "/users", :controller => 'users', :action => 'create'
358 should_route :post, "/users", :controller => 'users', :action => 'create'
350 should_route :post, "/users.xml", :controller => 'users', :action => 'create', :format => 'xml'
359 should_route :post, "/users.xml", :controller => 'users', :action => 'create', :format => 'xml'
351 should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123'
360 should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123'
352 should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
361 should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
353 should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
362 should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
354
363
355 should_route :put, "/users/444", :controller => 'users', :action => 'update', :id => '444'
364 should_route :put, "/users/444", :controller => 'users', :action => 'update', :id => '444'
356 should_route :put, "/users/444.xml", :controller => 'users', :action => 'update', :id => '444', :format => 'xml'
365 should_route :put, "/users/444.xml", :controller => 'users', :action => 'update', :id => '444', :format => 'xml'
357
366
358 should_route :delete, "/users/44", :controller => 'users', :action => 'destroy', :id => '44'
367 should_route :delete, "/users/44", :controller => 'users', :action => 'destroy', :id => '44'
359 should_route :delete, "/users/44.xml", :controller => 'users', :action => 'destroy', :id => '44', :format => 'xml'
368 should_route :delete, "/users/44.xml", :controller => 'users', :action => 'destroy', :id => '44', :format => 'xml'
360 end
369 end
361
370
362 context "versions" do
371 context "versions" do
363 # /projects/foo/versions is /projects/foo/roadmap
372 # /projects/foo/versions is /projects/foo/roadmap
364 should_route :get, "/projects/foo/versions.xml", :controller => 'versions', :action => 'index', :project_id => 'foo', :format => 'xml'
373 should_route :get, "/projects/foo/versions.xml", :controller => 'versions', :action => 'index', :project_id => 'foo', :format => 'xml'
365 should_route :get, "/projects/foo/versions.json", :controller => 'versions', :action => 'index', :project_id => 'foo', :format => 'json'
374 should_route :get, "/projects/foo/versions.json", :controller => 'versions', :action => 'index', :project_id => 'foo', :format => 'json'
366
375
367 should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
376 should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
368
377
369 should_route :post, "/projects/foo/versions", :controller => 'versions', :action => 'create', :project_id => 'foo'
378 should_route :post, "/projects/foo/versions", :controller => 'versions', :action => 'create', :project_id => 'foo'
370 should_route :post, "/projects/foo/versions.xml", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'xml'
379 should_route :post, "/projects/foo/versions.xml", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'xml'
371 should_route :post, "/projects/foo/versions.json", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'json'
380 should_route :post, "/projects/foo/versions.json", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'json'
372
381
373 should_route :get, "/versions/1", :controller => 'versions', :action => 'show', :id => '1'
382 should_route :get, "/versions/1", :controller => 'versions', :action => 'show', :id => '1'
374 should_route :get, "/versions/1.xml", :controller => 'versions', :action => 'show', :id => '1', :format => 'xml'
383 should_route :get, "/versions/1.xml", :controller => 'versions', :action => 'show', :id => '1', :format => 'xml'
375 should_route :get, "/versions/1.json", :controller => 'versions', :action => 'show', :id => '1', :format => 'json'
384 should_route :get, "/versions/1.json", :controller => 'versions', :action => 'show', :id => '1', :format => 'json'
376
385
377 should_route :get, "/versions/1/edit", :controller => 'versions', :action => 'edit', :id => '1'
386 should_route :get, "/versions/1/edit", :controller => 'versions', :action => 'edit', :id => '1'
378
387
379 should_route :put, "/versions/1", :controller => 'versions', :action => 'update', :id => '1'
388 should_route :put, "/versions/1", :controller => 'versions', :action => 'update', :id => '1'
380 should_route :put, "/versions/1.xml", :controller => 'versions', :action => 'update', :id => '1', :format => 'xml'
389 should_route :put, "/versions/1.xml", :controller => 'versions', :action => 'update', :id => '1', :format => 'xml'
381 should_route :put, "/versions/1.json", :controller => 'versions', :action => 'update', :id => '1', :format => 'json'
390 should_route :put, "/versions/1.json", :controller => 'versions', :action => 'update', :id => '1', :format => 'json'
382
391
383 should_route :delete, "/versions/1", :controller => 'versions', :action => 'destroy', :id => '1'
392 should_route :delete, "/versions/1", :controller => 'versions', :action => 'destroy', :id => '1'
384 should_route :delete, "/versions/1.xml", :controller => 'versions', :action => 'destroy', :id => '1', :format => 'xml'
393 should_route :delete, "/versions/1.xml", :controller => 'versions', :action => 'destroy', :id => '1', :format => 'xml'
385 should_route :delete, "/versions/1.json", :controller => 'versions', :action => 'destroy', :id => '1', :format => 'json'
394 should_route :delete, "/versions/1.json", :controller => 'versions', :action => 'destroy', :id => '1', :format => 'json'
386
395
387 should_route :put, "/projects/foo/versions/close_completed", :controller => 'versions', :action => 'close_completed', :project_id => 'foo'
396 should_route :put, "/projects/foo/versions/close_completed", :controller => 'versions', :action => 'close_completed', :project_id => 'foo'
388 should_route :post, "/versions/1/status_by", :controller => 'versions', :action => 'status_by', :id => '1'
397 should_route :post, "/versions/1/status_by", :controller => 'versions', :action => 'status_by', :id => '1'
389 end
398 end
390
399
391 context "wiki (singular, project's pages)" do
400 context "wiki (singular, project's pages)" do
392 should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'show', :project_id => '567'
401 should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'show', :project_id => '567'
393 should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'show', :project_id => '567', :id => 'lalala'
402 should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'show', :project_id => '567', :id => 'lalala'
394 should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :project_id => '567', :id => 'my_page'
403 should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :project_id => '567', :id => 'my_page'
395 should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :project_id => '1', :id => 'CookBook_documentation'
404 should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :project_id => '1', :id => 'CookBook_documentation'
396 should_route :get, "/projects/1/wiki/CookBook_documentation/diff", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation'
405 should_route :get, "/projects/1/wiki/CookBook_documentation/diff", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation'
397 should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation', :version => '2'
406 should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation', :version => '2'
398 should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation', :version => '2', :version_from => '1'
407 should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation', :version => '2', :version_from => '1'
399 should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :project_id => '1', :id => 'CookBook_documentation', :version => '2'
408 should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :project_id => '1', :id => 'CookBook_documentation', :version => '2'
400 should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida'
409 should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida'
401 should_route :get, "/projects/567/wiki/index", :controller => 'wiki', :action => 'index', :project_id => '567'
410 should_route :get, "/projects/567/wiki/index", :controller => 'wiki', :action => 'index', :project_id => '567'
402 should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'date_index', :project_id => '567'
411 should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'date_index', :project_id => '567'
403 should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :project_id => '567'
412 should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :project_id => '567'
404
413
405 should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :project_id => '567', :id => 'CookBook_documentation'
414 should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :project_id => '567', :id => 'CookBook_documentation'
406 should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida'
415 should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida'
407 should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :project_id => '22', :id => 'ladida'
416 should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :project_id => '22', :id => 'ladida'
408 should_route :post, "/projects/22/wiki/ladida/add_attachment", :controller => 'wiki', :action => 'add_attachment', :project_id => '22', :id => 'ladida'
417 should_route :post, "/projects/22/wiki/ladida/add_attachment", :controller => 'wiki', :action => 'add_attachment', :project_id => '22', :id => 'ladida'
409
418
410 should_route :put, "/projects/567/wiki/my_page", :controller => 'wiki', :action => 'update', :project_id => '567', :id => 'my_page'
419 should_route :put, "/projects/567/wiki/my_page", :controller => 'wiki', :action => 'update', :project_id => '567', :id => 'my_page'
411
420
412 should_route :delete, "/projects/22/wiki/ladida", :controller => 'wiki', :action => 'destroy', :project_id => '22', :id => 'ladida'
421 should_route :delete, "/projects/22/wiki/ladida", :controller => 'wiki', :action => 'destroy', :project_id => '22', :id => 'ladida'
413 end
422 end
414
423
415 context "wikis (plural, admin setup)" do
424 context "wikis (plural, admin setup)" do
416 should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
425 should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
417
426
418 should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida'
427 should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida'
419 should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
428 should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
420 end
429 end
421
430
422 context "administration panel" do
431 context "administration panel" do
423 should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects'
432 should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects'
424 end
433 end
425 end
434 end
@@ -1,59 +1,78
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class CustomFieldTest < ActiveSupport::TestCase
20 class CustomFieldTest < ActiveSupport::TestCase
21 fixtures :custom_fields
21 fixtures :custom_fields
22
22
23 def test_create
23 def test_create
24 field = UserCustomField.new(:name => 'Money money money', :field_format => 'float')
24 field = UserCustomField.new(:name => 'Money money money', :field_format => 'float')
25 assert field.save
25 assert field.save
26 end
26 end
27
27
28 def test_regexp_validation
28 def test_regexp_validation
29 field = IssueCustomField.new(:name => 'regexp', :field_format => 'text', :regexp => '[a-z0-9')
29 field = IssueCustomField.new(:name => 'regexp', :field_format => 'text', :regexp => '[a-z0-9')
30 assert !field.save
30 assert !field.save
31 assert_equal I18n.t('activerecord.errors.messages.invalid'),
31 assert_equal I18n.t('activerecord.errors.messages.invalid'),
32 field.errors[:regexp].to_s
32 field.errors[:regexp].to_s
33 field.regexp = '[a-z0-9]'
33 field.regexp = '[a-z0-9]'
34 assert field.save
34 assert field.save
35 end
35 end
36
36
37 def test_possible_values_should_accept_an_array
37 def test_possible_values_should_accept_an_array
38 field = CustomField.new
38 field = CustomField.new
39 field.possible_values = ["One value", ""]
39 field.possible_values = ["One value", ""]
40 assert_equal ["One value"], field.possible_values
40 assert_equal ["One value"], field.possible_values
41 end
41 end
42
42
43 def test_possible_values_should_accept_a_string
43 def test_possible_values_should_accept_a_string
44 field = CustomField.new
44 field = CustomField.new
45 field.possible_values = "One value"
45 field.possible_values = "One value"
46 assert_equal ["One value"], field.possible_values
46 assert_equal ["One value"], field.possible_values
47 end
47 end
48
48
49 def test_possible_values_should_accept_a_multiline_string
49 def test_possible_values_should_accept_a_multiline_string
50 field = CustomField.new
50 field = CustomField.new
51 field.possible_values = "One value\nAnd another one \r\n \n"
51 field.possible_values = "One value\nAnd another one \r\n \n"
52 assert_equal ["One value", "And another one"], field.possible_values
52 assert_equal ["One value", "And another one"], field.possible_values
53 end
53 end
54
54
55 def test_destroy
55 def test_destroy
56 field = CustomField.find(1)
56 field = CustomField.find(1)
57 assert field.destroy
57 assert field.destroy
58 end
58 end
59
60 def test_new_subclass_instance_should_return_an_instance
61 f = CustomField.new_subclass_instance('IssueCustomField')
62 assert_kind_of IssueCustomField, f
63 end
64
65 def test_new_subclass_instance_should_set_attributes
66 f = CustomField.new_subclass_instance('IssueCustomField', :name => 'Test')
67 assert_kind_of IssueCustomField, f
68 assert_equal 'Test', f.name
69 end
70
71 def test_new_subclass_instance_with_invalid_class_name_should_return_nil
72 assert_nil CustomField.new_subclass_instance('WrongClassName')
73 end
74
75 def test_new_subclass_instance_with_non_subclass_name_should_return_nil
76 assert_nil CustomField.new_subclass_instance('Project')
77 end
59 end
78 end
General Comments 0
You need to be logged in to leave comments. Login now