@@ -0,0 +1,18 | |||
|
1 | api.array :versions, api_meta(:total_count => @versions.size) do | |
|
2 | @versions.each do |version| | |
|
3 | api.version do | |
|
4 | api.id version.id | |
|
5 | api.project(:id => version.project_id, :name => version.project.name) unless version.project.nil? | |
|
6 | ||
|
7 | api.name version.name | |
|
8 | api.description version.description | |
|
9 | api.status version.status | |
|
10 | api.due_date version.effective_date | |
|
11 | ||
|
12 | render_api_custom_values version.custom_field_values, api | |
|
13 | ||
|
14 | api.created_on version.created_on | |
|
15 | api.updated_on version.updated_on | |
|
16 | end | |
|
17 | end | |
|
18 | end |
@@ -0,0 +1,14 | |||
|
1 | api.version do | |
|
2 | api.id @version.id | |
|
3 | api.project(:id => @version.project_id, :name => @version.project.name) unless @version.project.nil? | |
|
4 | ||
|
5 | api.name @version.name | |
|
6 | api.description @version.description | |
|
7 | api.status @version.status | |
|
8 | api.due_date @version.effective_date | |
|
9 | ||
|
10 | render_api_custom_values @version.custom_field_values, api | |
|
11 | ||
|
12 | api.created_on @version.created_on | |
|
13 | api.updated_on @version.updated_on | |
|
14 | end |
@@ -0,0 +1,120 | |||
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
3 | # | |
|
4 | # This program is free software; you can redistribute it and/or | |
|
5 | # modify it under the terms of the GNU General Public License | |
|
6 | # as published by the Free Software Foundation; either version 2 | |
|
7 | # of the License, or (at your option) any later version. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
14 | # You should have received a copy of the GNU General Public License | |
|
15 | # along with this program; if not, write to the Free Software | |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
|
17 | ||
|
18 | require File.expand_path('../../../test_helper', __FILE__) | |
|
19 | ||
|
20 | class ApiTest::VersionsTest < ActionController::IntegrationTest | |
|
21 | fixtures :all | |
|
22 | ||
|
23 | def setup | |
|
24 | Setting.rest_api_enabled = '1' | |
|
25 | end | |
|
26 | ||
|
27 | context "/projects/:project_id/versions" do | |
|
28 | context "GET" do | |
|
29 | should "return project versions" do | |
|
30 | get '/projects/1/versions.xml' | |
|
31 | ||
|
32 | assert_response :success | |
|
33 | assert_equal 'application/xml', @response.content_type | |
|
34 | assert_tag :tag => 'versions', | |
|
35 | :attributes => {:type => 'array'}, | |
|
36 | :child => { | |
|
37 | :tag => 'version', | |
|
38 | :child => { | |
|
39 | :tag => 'id', | |
|
40 | :content => '2', | |
|
41 | :sibling => { | |
|
42 | :tag => 'name', | |
|
43 | :content => '1.0' | |
|
44 | } | |
|
45 | } | |
|
46 | } | |
|
47 | end | |
|
48 | end | |
|
49 | ||
|
50 | context "POST" do | |
|
51 | should "create the version" do | |
|
52 | assert_difference 'Version.count' do | |
|
53 | post '/projects/1/versions.xml', {:version => {:name => 'API test'}}, :authorization => credentials('jsmith') | |
|
54 | end | |
|
55 | ||
|
56 | version = Version.first(:order => 'id DESC') | |
|
57 | assert_equal 'API test', version.name | |
|
58 | ||
|
59 | assert_response :created | |
|
60 | assert_equal 'application/xml', @response.content_type | |
|
61 | assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s} | |
|
62 | end | |
|
63 | ||
|
64 | context "with failure" do | |
|
65 | should "return the errors" do | |
|
66 | assert_no_difference('Version.count') do | |
|
67 | post '/projects/1/versions.xml', {:version => {:name => ''}}, :authorization => credentials('jsmith') | |
|
68 | end | |
|
69 | ||
|
70 | assert_response :unprocessable_entity | |
|
71 | assert_tag :errors, :child => {:tag => 'error', :content => "Name can't be blank"} | |
|
72 | end | |
|
73 | end | |
|
74 | end | |
|
75 | end | |
|
76 | ||
|
77 | context "/projects/:project_id/versions/:id" do | |
|
78 | context "GET" do | |
|
79 | should "return the version" do | |
|
80 | get '/projects/1/versions/2.xml' | |
|
81 | ||
|
82 | assert_response :success | |
|
83 | assert_equal 'application/xml', @response.content_type | |
|
84 | assert_tag 'version', | |
|
85 | :child => { | |
|
86 | :tag => 'id', | |
|
87 | :content => '2', | |
|
88 | :sibling => { | |
|
89 | :tag => 'name', | |
|
90 | :content => '1.0' | |
|
91 | } | |
|
92 | } | |
|
93 | end | |
|
94 | end | |
|
95 | ||
|
96 | context "PUT" do | |
|
97 | should "update the version" do | |
|
98 | put '/projects/1/versions/2.xml', {:version => {:name => 'API update'}}, :authorization => credentials('jsmith') | |
|
99 | ||
|
100 | assert_response :ok | |
|
101 | assert_equal 'API update', Version.find(2).name | |
|
102 | end | |
|
103 | end | |
|
104 | ||
|
105 | context "DELETE" do | |
|
106 | should "destroy the version" do | |
|
107 | assert_difference 'Version.count', -1 do | |
|
108 | delete '/projects/1/versions/3.xml', {}, :authorization => credentials('jsmith') | |
|
109 | end | |
|
110 | ||
|
111 | assert_response :ok | |
|
112 | assert_nil Version.find_by_id(3) | |
|
113 | end | |
|
114 | end | |
|
115 | end | |
|
116 | ||
|
117 | def credentials(user, password=nil) | |
|
118 | ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user) | |
|
119 | end | |
|
120 | end |
@@ -1,159 +1,192 | |||
|
1 |
# |
|
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class VersionsController < ApplicationController |
|
19 | 19 | menu_item :roadmap |
|
20 | 20 | model_object Version |
|
21 | 21 | before_filter :find_model_object, :except => [:index, :new, :create, :close_completed] |
|
22 | 22 | before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed] |
|
23 | 23 | before_filter :find_project, :only => [:index, :new, :create, :close_completed] |
|
24 | 24 | before_filter :authorize |
|
25 | 25 | |
|
26 | accept_key_auth :index, :create, :update, :destroy | |
|
27 | ||
|
26 | 28 | helper :custom_fields |
|
27 | 29 | helper :projects |
|
28 | 30 | |
|
29 | 31 | def index |
|
30 | @trackers = @project.trackers.find(:all, :order => 'position') | |
|
31 | retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?}) | |
|
32 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') | |
|
33 | project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id] | |
|
34 | ||
|
35 | @versions = @project.shared_versions || [] | |
|
36 | @versions += @project.rolled_up_versions.visible if @with_subprojects | |
|
37 | @versions = @versions.uniq.sort | |
|
38 | @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed] | |
|
39 | ||
|
40 | @issues_by_version = {} | |
|
41 | unless @selected_tracker_ids.empty? | |
|
42 | @versions.each do |version| | |
|
43 | issues = version.fixed_issues.visible.find(:all, | |
|
44 | :include => [:project, :status, :tracker, :priority], | |
|
45 | :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids}, | |
|
46 |
|
|
|
47 | @issues_by_version[version] = issues | |
|
48 | end | |
|
32 | respond_to do |format| | |
|
33 | format.html { | |
|
34 | @trackers = @project.trackers.find(:all, :order => 'position') | |
|
35 | retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?}) | |
|
36 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') | |
|
37 | project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id] | |
|
38 | ||
|
39 | @versions = @project.shared_versions || [] | |
|
40 | @versions += @project.rolled_up_versions.visible if @with_subprojects | |
|
41 | @versions = @versions.uniq.sort | |
|
42 | @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed] | |
|
43 | ||
|
44 | @issues_by_version = {} | |
|
45 | unless @selected_tracker_ids.empty? | |
|
46 | @versions.each do |version| | |
|
47 | issues = version.fixed_issues.visible.find(:all, | |
|
48 | :include => [:project, :status, :tracker, :priority], | |
|
49 | :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids}, | |
|
50 | :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id") | |
|
51 | @issues_by_version[version] = issues | |
|
52 | end | |
|
53 | end | |
|
54 | @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?} | |
|
55 | } | |
|
56 | format.api { | |
|
57 | @versions = @project.shared_versions.all | |
|
58 | } | |
|
49 | 59 | end |
|
50 | @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?} | |
|
51 | 60 | end |
|
52 | 61 | |
|
53 | 62 | def show |
|
54 | @issues = @version.fixed_issues.visible.find(:all, | |
|
55 | :include => [:status, :tracker, :priority], | |
|
56 | :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") | |
|
63 | respond_to do |format| | |
|
64 | format.html { | |
|
65 | @issues = @version.fixed_issues.visible.find(:all, | |
|
66 | :include => [:status, :tracker, :priority], | |
|
67 | :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") | |
|
68 | } | |
|
69 | format.api | |
|
70 | end | |
|
57 | 71 | end |
|
58 | 72 | |
|
59 | 73 | def new |
|
60 | 74 | @version = @project.versions.build |
|
61 | 75 | if params[:version] |
|
62 | 76 | attributes = params[:version].dup |
|
63 | 77 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
|
64 | 78 | @version.attributes = attributes |
|
65 | 79 | end |
|
66 | 80 | end |
|
67 | 81 | |
|
68 | 82 | def create |
|
69 | 83 | # TODO: refactor with code above in #new |
|
70 | 84 | @version = @project.versions.build |
|
71 | 85 | if params[:version] |
|
72 | 86 | attributes = params[:version].dup |
|
73 | 87 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
|
74 | 88 | @version.attributes = attributes |
|
75 | 89 | end |
|
76 | 90 | |
|
77 | 91 | if request.post? |
|
78 | 92 | if @version.save |
|
79 | 93 | respond_to do |format| |
|
80 | 94 | format.html do |
|
81 | 95 | flash[:notice] = l(:notice_successful_create) |
|
82 | 96 | redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
83 | 97 | end |
|
84 | 98 | format.js do |
|
85 | 99 | # IE doesn't support the replace_html rjs method for select box options |
|
86 | 100 | render(:update) {|page| page.replace "issue_fixed_version_id", |
|
87 | 101 | content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') |
|
88 | 102 | } |
|
89 | 103 | end |
|
104 | format.api do | |
|
105 | render :action => 'show', :status => :created, :location => project_version_url(@project, @version) | |
|
106 | end | |
|
90 | 107 | end |
|
91 | 108 | else |
|
92 | 109 | respond_to do |format| |
|
93 | 110 | format.html { render :action => 'new' } |
|
94 | 111 | format.js do |
|
95 | 112 | render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) } |
|
96 | 113 | end |
|
114 | format.api { render_validation_errors(@version) } | |
|
97 | 115 | end |
|
98 | 116 | end |
|
99 | 117 | end |
|
100 | 118 | end |
|
101 | 119 | |
|
102 | 120 | def edit |
|
103 | 121 | end |
|
104 | 122 | |
|
105 | 123 | def update |
|
106 | 124 | if request.put? && params[:version] |
|
107 | 125 | attributes = params[:version].dup |
|
108 | 126 | attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) |
|
109 | 127 | if @version.update_attributes(attributes) |
|
110 | flash[:notice] = l(:notice_successful_update) | |
|
111 | redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
|
128 | respond_to do |format| | |
|
129 | format.html { | |
|
130 | flash[:notice] = l(:notice_successful_update) | |
|
131 | redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
|
132 | } | |
|
133 | format.api { head :ok } | |
|
134 | end | |
|
112 | 135 | else |
|
113 | 136 | respond_to do |format| |
|
114 | 137 | format.html { render :action => 'edit' } |
|
138 | format.api { render_validation_errors(@version) } | |
|
115 | 139 | end |
|
116 | 140 | end |
|
117 | 141 | end |
|
118 | 142 | end |
|
119 | 143 | |
|
120 | 144 | def close_completed |
|
121 | 145 | if request.put? |
|
122 | 146 | @project.close_completed_versions |
|
123 | 147 | end |
|
124 | 148 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
125 | 149 | end |
|
126 | 150 | |
|
151 | verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed } | |
|
127 | 152 | def destroy |
|
128 | 153 | if @version.fixed_issues.empty? |
|
129 | 154 | @version.destroy |
|
130 | redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
|
155 | respond_to do |format| | |
|
156 | format.html { redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project } | |
|
157 | format.api { head :ok } | |
|
158 | end | |
|
131 | 159 | else |
|
132 | flash[:error] = l(:notice_unable_delete_version) | |
|
133 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
|
160 | respond_to do |format| | |
|
161 | format.html { | |
|
162 | flash[:error] = l(:notice_unable_delete_version) | |
|
163 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | |
|
164 | } | |
|
165 | format.api { head :unprocessable_entity } | |
|
166 | end | |
|
134 | 167 | end |
|
135 | 168 | end |
|
136 | 169 | |
|
137 | 170 | def status_by |
|
138 | 171 | respond_to do |format| |
|
139 | 172 | format.html { render :action => 'show' } |
|
140 | 173 | format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} } |
|
141 | 174 | end |
|
142 | 175 | end |
|
143 | 176 | |
|
144 | 177 | private |
|
145 | 178 | def find_project |
|
146 | 179 | @project = Project.find(params[:project_id]) |
|
147 | 180 | rescue ActiveRecord::RecordNotFound |
|
148 | 181 | render_404 |
|
149 | 182 | end |
|
150 | 183 | |
|
151 | 184 | def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil) |
|
152 | 185 | if ids = params[:tracker_ids] |
|
153 | 186 | @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s } |
|
154 | 187 | else |
|
155 | 188 | @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s } |
|
156 | 189 | end |
|
157 | 190 | end |
|
158 | 191 | |
|
159 | 192 | end |
@@ -1,41 +1,41 | |||
|
1 | 1 | <% if @project.shared_versions.any? %> |
|
2 | 2 | <table class="list versions"> |
|
3 | 3 | <thead><tr> |
|
4 | 4 | <th><%= l(:label_version) %></th> |
|
5 | 5 | <th><%= l(:field_effective_date) %></th> |
|
6 | 6 | <th><%= l(:field_description) %></th> |
|
7 | 7 | <th><%= l(:field_status) %></th> |
|
8 | 8 | <th><%= l(:field_sharing) %></th> |
|
9 | 9 | <th><%= l(:label_wiki_page) %></th> |
|
10 | 10 | <th style="width:15%"></th> |
|
11 | 11 | </tr></thead> |
|
12 | 12 | <tbody> |
|
13 | 13 | <% for version in @project.shared_versions.sort %> |
|
14 | 14 | <tr class="version <%= cycle 'odd', 'even' %> <%=h version.status %> <%= 'shared' if version.project != @project %>"> |
|
15 | 15 | <td class="name"><%= link_to_version version %></td> |
|
16 | 16 | <td class="date"><%= format_date(version.effective_date) %></td> |
|
17 | 17 | <td class="description"><%=h version.description %></td> |
|
18 | 18 | <td class="status"><%= l("version_status_#{version.status}") %></td> |
|
19 | 19 | <td class="sharing"><%=h format_version_sharing(version.sharing) %></td> |
|
20 | 20 | <td><%= link_to_if_authorized(h(version.wiki_page_title), {:controller => 'wiki', :action => 'show', :project_id => version.project, :id => Wiki.titleize(version.wiki_page_title)}) || h(version.wiki_page_title) unless version.wiki_page_title.blank? || version.project.wiki.nil? %></td> |
|
21 | 21 | <td class="buttons"> |
|
22 | <% if version.project == @project %> | |
|
23 |
<%= link_to |
|
|
24 |
<%= link_to |
|
|
22 | <% if version.project == @project && User.current.allowed_to?(:manage_versions, @project) %> | |
|
23 | <%= link_to l(:button_edit), edit_project_version_path(@project, version), :class => 'icon icon-edit' %> | |
|
24 | <%= link_to l(:button_delete), project_version_path(@project, version), :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %> | |
|
25 | 25 | <% end %> |
|
26 | 26 | </td> |
|
27 | 27 | </tr> |
|
28 | 28 | <% end; reset_cycle %> |
|
29 | 29 | </tbody> |
|
30 | 30 | </table> |
|
31 | 31 | <% else %> |
|
32 | 32 | <p class="nodata"><%= l(:label_no_data) %></p> |
|
33 | 33 | <% end %> |
|
34 | 34 | |
|
35 | 35 | <div class="contextual"> |
|
36 | 36 | <% if @project.versions.any? %> |
|
37 | 37 | <%= link_to l(:label_close_versions), close_completed_project_versions_path(@project), :method => :put %> |
|
38 | 38 | <% end %> |
|
39 | 39 | </div> |
|
40 | 40 | |
|
41 | 41 | <p><%= link_to_if_authorized l(:label_version_new), :controller => 'versions', :action => 'new', :project_id => @project %></p> |
@@ -1,56 +1,56 | |||
|
1 | 1 | <div class="contextual"> |
|
2 | <%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => @version}, :class => 'icon icon-edit' %> | |
|
2 | <%= link_to(l(:button_edit), edit_project_version_path(@version.project, @version), :class => 'icon icon-edit') if User.current.allowed_to?(:manage_versions, @version.project) %> | |
|
3 | 3 | <%= link_to_if_authorized(l(:button_edit_associated_wikipage, :page_title => @version.wiki_page_title), {:controller => 'wiki', :action => 'edit', :project_id => @version.project, :id => Wiki.titleize(@version.wiki_page_title)}, :class => 'icon icon-edit') unless @version.wiki_page_title.blank? || @version.project.wiki.nil? %> |
|
4 |
<%= link_to |
|
|
5 | :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %> | |
|
4 | <%= link_to(l(:button_delete), project_version_path(@version.project, @version, :back_url => url_for(:controller => 'versions', :action => 'index', :project_id => @version.project)), | |
|
5 | :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del') if User.current.allowed_to?(:manage_versions, @version.project) %> | |
|
6 | 6 | <%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %> |
|
7 | 7 | </div> |
|
8 | 8 | |
|
9 | 9 | <h2><%= h(@version.name) %></h2> |
|
10 | 10 | |
|
11 | 11 | <div id="roadmap"> |
|
12 | 12 | <%= render :partial => 'versions/overview', :locals => {:version => @version} %> |
|
13 | 13 | <%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %> |
|
14 | 14 | |
|
15 | 15 | <div id="version-summary"> |
|
16 | 16 | <% if @version.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %> |
|
17 | 17 | <fieldset><legend><%= l(:label_time_tracking) %></legend> |
|
18 | 18 | <table> |
|
19 | 19 | <tr> |
|
20 | 20 | <td width="130px" align="right"><%= l(:field_estimated_hours) %></td> |
|
21 | 21 | <td width="240px" class="total-hours"width="130px" align="right"><%= html_hours(l_hours(@version.estimated_hours)) %></td> |
|
22 | 22 | </tr> |
|
23 | 23 | <% if User.current.allowed_to?(:view_time_entries, @project) %> |
|
24 | 24 | <tr> |
|
25 | 25 | <td width="130px" align="right"><%= l(:label_spent_time) %></td> |
|
26 | 26 | <td width="240px" class="total-hours"><%= html_hours(l_hours(@version.spent_hours)) %></td> |
|
27 | 27 | </tr> |
|
28 | 28 | <% end %> |
|
29 | 29 | </table> |
|
30 | 30 | </fieldset> |
|
31 | 31 | <% end %> |
|
32 | 32 | |
|
33 | 33 | <div id="status_by"> |
|
34 | 34 | <%= render_issue_status_by(@version, params[:status_by]) if @version.fixed_issues.count > 0 %> |
|
35 | 35 | </div> |
|
36 | 36 | </div> |
|
37 | 37 | |
|
38 | 38 | <% if @issues.present? %> |
|
39 | 39 | <% form_tag({}) do -%> |
|
40 | 40 | <table class="list related-issues"> |
|
41 | 41 | <caption><%= l(:label_related_issues) %></caption> |
|
42 | 42 | <%- @issues.each do |issue| -%> |
|
43 | 43 | <tr class="hascontextmenu"> |
|
44 | 44 | <td class="checkbox"><%= check_box_tag 'ids[]', issue.id %></td> |
|
45 | 45 | <td><%= link_to_issue(issue, :project => (@project != issue.project)) %></td> |
|
46 | 46 | </tr> |
|
47 | 47 | <% end %> |
|
48 | 48 | </table> |
|
49 | 49 | <% end %> |
|
50 | 50 | <%= context_menu issues_context_menu_path %> |
|
51 | 51 | <% end %> |
|
52 | 52 | </div> |
|
53 | 53 | |
|
54 | 54 | <%= call_hook :view_versions_show_bottom, :version => @version %> |
|
55 | 55 | |
|
56 | 56 | <% html_title @version.name %> |
@@ -1,375 +1,392 | |||
|
1 |
# |
|
|
2 |
# Copyright (C) 2006-201 |
|
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class RoutingTest < ActionController::IntegrationTest |
|
21 | 21 | context "activities" do |
|
22 | 22 | should_route :get, "/activity", :controller => 'activities', :action => 'index', :id => nil |
|
23 | 23 | should_route :get, "/activity.atom", :controller => 'activities', :action => 'index', :id => nil, :format => 'atom' |
|
24 | 24 | end |
|
25 | 25 | |
|
26 | 26 | context "attachments" do |
|
27 | 27 | should_route :get, "/attachments/1", :controller => 'attachments', :action => 'show', :id => '1' |
|
28 | 28 | should_route :get, "/attachments/1/filename.ext", :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext' |
|
29 | 29 | should_route :get, "/attachments/download/1", :controller => 'attachments', :action => 'download', :id => '1' |
|
30 | 30 | should_route :get, "/attachments/download/1/filename.ext", :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext' |
|
31 | 31 | end |
|
32 | 32 | |
|
33 | 33 | context "boards" do |
|
34 | 34 | should_route :get, "/projects/world_domination/boards", :controller => 'boards', :action => 'index', :project_id => 'world_domination' |
|
35 | 35 | should_route :get, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination' |
|
36 | 36 | should_route :get, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44' |
|
37 | 37 | should_route :get, "/projects/world_domination/boards/44.atom", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44', :format => 'atom' |
|
38 | 38 | should_route :get, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44' |
|
39 | 39 | |
|
40 | 40 | should_route :post, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination' |
|
41 | 41 | should_route :post, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44' |
|
42 | 42 | should_route :post, "/projects/world_domination/boards/44/destroy", :controller => 'boards', :action => 'destroy', :project_id => 'world_domination', :id => '44' |
|
43 | 43 | |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | context "documents" do |
|
47 | 47 | should_route :get, "/projects/567/documents", :controller => 'documents', :action => 'index', :project_id => '567' |
|
48 | 48 | should_route :get, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567' |
|
49 | 49 | should_route :get, "/documents/22", :controller => 'documents', :action => 'show', :id => '22' |
|
50 | 50 | should_route :get, "/documents/22/edit", :controller => 'documents', :action => 'edit', :id => '22' |
|
51 | 51 | |
|
52 | 52 | should_route :post, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567' |
|
53 | 53 | should_route :post, "/documents/567/edit", :controller => 'documents', :action => 'edit', :id => '567' |
|
54 | 54 | should_route :post, "/documents/567/destroy", :controller => 'documents', :action => 'destroy', :id => '567' |
|
55 | 55 | end |
|
56 | 56 | |
|
57 | 57 | context "issues" do |
|
58 | 58 | # REST actions |
|
59 | 59 | should_route :get, "/issues", :controller => 'issues', :action => 'index' |
|
60 | 60 | should_route :get, "/issues.pdf", :controller => 'issues', :action => 'index', :format => 'pdf' |
|
61 | 61 | should_route :get, "/issues.atom", :controller => 'issues', :action => 'index', :format => 'atom' |
|
62 | 62 | should_route :get, "/issues.xml", :controller => 'issues', :action => 'index', :format => 'xml' |
|
63 | 63 | should_route :get, "/projects/23/issues", :controller => 'issues', :action => 'index', :project_id => '23' |
|
64 | 64 | should_route :get, "/projects/23/issues.pdf", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf' |
|
65 | 65 | should_route :get, "/projects/23/issues.atom", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom' |
|
66 | 66 | should_route :get, "/projects/23/issues.xml", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'xml' |
|
67 | 67 | should_route :get, "/issues/64", :controller => 'issues', :action => 'show', :id => '64' |
|
68 | 68 | should_route :get, "/issues/64.pdf", :controller => 'issues', :action => 'show', :id => '64', :format => 'pdf' |
|
69 | 69 | should_route :get, "/issues/64.atom", :controller => 'issues', :action => 'show', :id => '64', :format => 'atom' |
|
70 | 70 | should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml' |
|
71 | 71 | |
|
72 | 72 | should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23' |
|
73 | 73 | should_route :post, "/projects/23/issues", :controller => 'issues', :action => 'create', :project_id => '23' |
|
74 | 74 | should_route :post, "/issues.xml", :controller => 'issues', :action => 'create', :format => 'xml' |
|
75 | 75 | |
|
76 | 76 | should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64' |
|
77 | 77 | # TODO: Should use PUT |
|
78 | 78 | should_route :post, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64' |
|
79 | 79 | should_route :put, "/issues/1.xml", :controller => 'issues', :action => 'update', :id => '1', :format => 'xml' |
|
80 | 80 | |
|
81 | 81 | # TODO: Should use DELETE |
|
82 | 82 | should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64' |
|
83 | 83 | should_route :delete, "/issues/1.xml", :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml' |
|
84 | 84 | |
|
85 | 85 | # Extra actions |
|
86 | 86 | should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64' |
|
87 | 87 | |
|
88 | 88 | should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new' |
|
89 | 89 | should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create' |
|
90 | 90 | |
|
91 | 91 | should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1' |
|
92 | 92 | |
|
93 | 93 | should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show' |
|
94 | 94 | should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name' |
|
95 | 95 | |
|
96 | 96 | should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show' |
|
97 | 97 | should_route :get, "/issues/gantt.pdf", :controller => 'gantts', :action => 'show', :format => 'pdf' |
|
98 | 98 | should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name' |
|
99 | 99 | should_route :get, "/projects/project-name/issues/gantt.pdf", :controller => 'gantts', :action => 'show', :project_id => 'project-name', :format => 'pdf' |
|
100 | 100 | |
|
101 | 101 | should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues' |
|
102 | 102 | |
|
103 | 103 | should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123' |
|
104 | 104 | should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123' |
|
105 | 105 | should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues' |
|
106 | 106 | should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues' |
|
107 | 107 | |
|
108 | 108 | should_route :get, "/issues/changes", :controller => 'journals', :action => 'index' |
|
109 | 109 | |
|
110 | 110 | should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit' |
|
111 | 111 | should_route :post, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_update' |
|
112 | 112 | end |
|
113 | 113 | |
|
114 | 114 | context "issue categories" do |
|
115 | 115 | should_route :get, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test' |
|
116 | 116 | |
|
117 | 117 | should_route :post, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test' |
|
118 | 118 | end |
|
119 | 119 | |
|
120 | 120 | context "issue relations" do |
|
121 | 121 | should_route :get, "/issues/1/relations", :controller => 'issue_relations', :action => 'index', :issue_id => '1' |
|
122 | 122 | should_route :get, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'xml' |
|
123 | 123 | should_route :get, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'index', :issue_id => '1', :format => 'json' |
|
124 | 124 | |
|
125 | 125 | should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'create', :issue_id => '1' |
|
126 | 126 | should_route :post, "/issues/1/relations.xml", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'xml' |
|
127 | 127 | should_route :post, "/issues/1/relations.json", :controller => 'issue_relations', :action => 'create', :issue_id => '1', :format => 'json' |
|
128 | 128 | |
|
129 | 129 | should_route :get, "/issues/1/relations/23", :controller => 'issue_relations', :action => 'show', :issue_id => '1', :id => '23' |
|
130 | 130 | should_route :get, "/issues/1/relations/23.xml", :controller => 'issue_relations', :action => 'show', :issue_id => '1', :id => '23', :format => 'xml' |
|
131 | 131 | should_route :get, "/issues/1/relations/23.json", :controller => 'issue_relations', :action => 'show', :issue_id => '1', :id => '23', :format => 'json' |
|
132 | 132 | |
|
133 | 133 | should_route :delete, "/issues/1/relations/23", :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23' |
|
134 | 134 | should_route :delete, "/issues/1/relations/23.xml", :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23', :format => 'xml' |
|
135 | 135 | should_route :delete, "/issues/1/relations/23.json", :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23', :format => 'json' |
|
136 | 136 | end |
|
137 | 137 | |
|
138 | 138 | context "issue reports" do |
|
139 | 139 | should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567' |
|
140 | 140 | should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to' |
|
141 | 141 | end |
|
142 | 142 | |
|
143 | 143 | context "members" do |
|
144 | 144 | should_route :post, "/projects/5234/members/new", :controller => 'members', :action => 'new', :id => '5234' |
|
145 | 145 | end |
|
146 | 146 | |
|
147 | 147 | context "messages" do |
|
148 | 148 | should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22' |
|
149 | 149 | should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala' |
|
150 | 150 | should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala' |
|
151 | 151 | |
|
152 | 152 | should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala' |
|
153 | 153 | should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala' |
|
154 | 154 | should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22' |
|
155 | 155 | should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22' |
|
156 | 156 | end |
|
157 | 157 | |
|
158 | 158 | context "news" do |
|
159 | 159 | should_route :get, "/news", :controller => 'news', :action => 'index' |
|
160 | 160 | should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom' |
|
161 | 161 | should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml' |
|
162 | 162 | should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json' |
|
163 | 163 | should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567' |
|
164 | 164 | should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567' |
|
165 | 165 | should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567' |
|
166 | 166 | should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567' |
|
167 | 167 | should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2' |
|
168 | 168 | should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567' |
|
169 | 169 | should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234' |
|
170 | 170 | should_route :get, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567' |
|
171 | 171 | should_route :get, "/news/preview", :controller => 'previews', :action => 'news' |
|
172 | 172 | |
|
173 | 173 | should_route :post, "/projects/567/news", :controller => 'news', :action => 'create', :project_id => '567' |
|
174 | 174 | should_route :post, "/news/567/comments", :controller => 'comments', :action => 'create', :id => '567' |
|
175 | 175 | |
|
176 | 176 | should_route :put, "/news/567", :controller => 'news', :action => 'update', :id => '567' |
|
177 | 177 | |
|
178 | 178 | should_route :delete, "/news/567", :controller => 'news', :action => 'destroy', :id => '567' |
|
179 | 179 | should_route :delete, "/news/567/comments/15", :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15' |
|
180 | 180 | end |
|
181 | 181 | |
|
182 | 182 | context "projects" do |
|
183 | 183 | should_route :get, "/projects", :controller => 'projects', :action => 'index' |
|
184 | 184 | should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom' |
|
185 | 185 | should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml' |
|
186 | 186 | should_route :get, "/projects/new", :controller => 'projects', :action => 'new' |
|
187 | 187 | should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test' |
|
188 | 188 | should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml' |
|
189 | 189 | should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223' |
|
190 | 190 | should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members' |
|
191 | 191 | should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :project_id => '33' |
|
192 | 192 | should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :project_id => '33' |
|
193 | 193 | should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33' |
|
194 | 194 | should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33' |
|
195 | 195 | should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom' |
|
196 | 196 | |
|
197 | 197 | should_route :post, "/projects", :controller => 'projects', :action => 'create' |
|
198 | 198 | should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml' |
|
199 | 199 | should_route :post, "/projects/33/files", :controller => 'files', :action => 'create', :project_id => '33' |
|
200 | 200 | should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64' |
|
201 | 201 | should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64' |
|
202 | 202 | |
|
203 | 203 | should_route :put, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'update', :project_id => '64' |
|
204 | 204 | should_route :put, "/projects/4223", :controller => 'projects', :action => 'update', :id => '4223' |
|
205 | 205 | should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml' |
|
206 | 206 | |
|
207 | 207 | should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64' |
|
208 | 208 | should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml' |
|
209 | 209 | should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64' |
|
210 | 210 | end |
|
211 | 211 | |
|
212 | 212 | context "queries" do |
|
213 | 213 | should_route :get, "/queries/new", :controller => 'queries', :action => 'new' |
|
214 | 214 | should_route :get, "/projects/redmine/queries/new", :controller => 'queries', :action => 'new', :project_id => 'redmine' |
|
215 | 215 | |
|
216 | 216 | should_route :post, "/queries/new", :controller => 'queries', :action => 'new' |
|
217 | 217 | should_route :post, "/projects/redmine/queries/new", :controller => 'queries', :action => 'new', :project_id => 'redmine' |
|
218 | 218 | end |
|
219 | 219 | |
|
220 | 220 | context "repositories" do |
|
221 | 221 | should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine' |
|
222 | 222 | should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine' |
|
223 | 223 | should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine' |
|
224 | 224 | should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom' |
|
225 | 225 | should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457' |
|
226 | 226 | should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457' |
|
227 | 227 | should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff' |
|
228 | 228 | should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c] |
|
229 | 229 | 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' |
|
230 | 230 | should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c] |
|
231 | 231 | should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c] |
|
232 | 232 | 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' |
|
233 | 233 | 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' |
|
234 | 234 | 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' |
|
235 | 235 | should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c] |
|
236 | 236 | should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c] |
|
237 | 237 | should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine' |
|
238 | 238 | |
|
239 | 239 | |
|
240 | 240 | should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine' |
|
241 | 241 | end |
|
242 | 242 | |
|
243 | 243 | context "timelogs (global)" do |
|
244 | 244 | should_route :get, "/time_entries", :controller => 'timelog', :action => 'index' |
|
245 | 245 | should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'index', :format => 'csv' |
|
246 | 246 | should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'index', :format => 'atom' |
|
247 | 247 | should_route :get, "/time_entries/new", :controller => 'timelog', :action => 'new' |
|
248 | 248 | should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22' |
|
249 | 249 | |
|
250 | 250 | should_route :post, "/time_entries", :controller => 'timelog', :action => 'create' |
|
251 | 251 | |
|
252 | 252 | should_route :put, "/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22' |
|
253 | 253 | |
|
254 | 254 | should_route :delete, "/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55' |
|
255 | 255 | end |
|
256 | 256 | |
|
257 | 257 | context "timelogs (scoped under project)" do |
|
258 | 258 | should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567' |
|
259 | 259 | should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv' |
|
260 | 260 | should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom' |
|
261 | 261 | should_route :get, "/projects/567/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => '567' |
|
262 | 262 | should_route :get, "/projects/567/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :project_id => '567' |
|
263 | 263 | |
|
264 | 264 | should_route :post, "/projects/567/time_entries", :controller => 'timelog', :action => 'create', :project_id => '567' |
|
265 | 265 | |
|
266 | 266 | should_route :put, "/projects/567/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :project_id => '567' |
|
267 | 267 | |
|
268 | 268 | should_route :delete, "/projects/567/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :project_id => '567' |
|
269 | 269 | end |
|
270 | 270 | |
|
271 | 271 | context "timelogs (scoped under issues)" do |
|
272 | 272 | should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234' |
|
273 | 273 | should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv' |
|
274 | 274 | should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom' |
|
275 | 275 | should_route :get, "/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234' |
|
276 | 276 | should_route :get, "/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234' |
|
277 | 277 | |
|
278 | 278 | should_route :post, "/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234' |
|
279 | 279 | |
|
280 | 280 | should_route :put, "/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234' |
|
281 | 281 | |
|
282 | 282 | should_route :delete, "/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234' |
|
283 | 283 | end |
|
284 | 284 | |
|
285 | 285 | context "timelogs (scoped under project and issues)" do |
|
286 | 286 | should_route :get, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook' |
|
287 | 287 | should_route :get, "/projects/ecookbook/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'csv' |
|
288 | 288 | should_route :get, "/projects/ecookbook/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :project_id => 'ecookbook', :format => 'atom' |
|
289 | 289 | should_route :get, "/projects/ecookbook/issues/234/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '234', :project_id => 'ecookbook' |
|
290 | 290 | should_route :get, "/projects/ecookbook/issues/234/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22', :issue_id => '234', :project_id => 'ecookbook' |
|
291 | 291 | |
|
292 | 292 | should_route :post, "/projects/ecookbook/issues/234/time_entries", :controller => 'timelog', :action => 'create', :issue_id => '234', :project_id => 'ecookbook' |
|
293 | 293 | |
|
294 | 294 | should_route :put, "/projects/ecookbook/issues/234/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22', :issue_id => '234', :project_id => 'ecookbook' |
|
295 | 295 | |
|
296 | 296 | should_route :delete, "/projects/ecookbook/issues/234/time_entries/55", :controller => 'timelog', :action => 'destroy', :id => '55', :issue_id => '234', :project_id => 'ecookbook' |
|
297 | 297 | end |
|
298 | 298 | |
|
299 | 299 | context "time_entry_reports" do |
|
300 | 300 | should_route :get, "/time_entries/report", :controller => 'time_entry_reports', :action => 'report' |
|
301 | 301 | should_route :get, "/projects/567/time_entries/report", :controller => 'time_entry_reports', :action => 'report', :project_id => '567' |
|
302 | 302 | should_route :get, "/projects/567/time_entries/report.csv", :controller => 'time_entry_reports', :action => 'report', :project_id => '567', :format => 'csv' |
|
303 | 303 | end |
|
304 | 304 | |
|
305 | 305 | context "users" do |
|
306 | 306 | should_route :get, "/users", :controller => 'users', :action => 'index' |
|
307 | 307 | should_route :get, "/users.xml", :controller => 'users', :action => 'index', :format => 'xml' |
|
308 | 308 | should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44' |
|
309 | 309 | should_route :get, "/users/44.xml", :controller => 'users', :action => 'show', :id => '44', :format => 'xml' |
|
310 | 310 | should_route :get, "/users/current", :controller => 'users', :action => 'show', :id => 'current' |
|
311 | 311 | should_route :get, "/users/current.xml", :controller => 'users', :action => 'show', :id => 'current', :format => 'xml' |
|
312 | 312 | should_route :get, "/users/new", :controller => 'users', :action => 'new' |
|
313 | 313 | should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444' |
|
314 | 314 | should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership' |
|
315 | 315 | |
|
316 | 316 | should_route :post, "/users", :controller => 'users', :action => 'create' |
|
317 | 317 | should_route :post, "/users.xml", :controller => 'users', :action => 'create', :format => 'xml' |
|
318 | 318 | should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123' |
|
319 | 319 | should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55' |
|
320 | 320 | should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12' |
|
321 | 321 | |
|
322 | 322 | should_route :put, "/users/444", :controller => 'users', :action => 'update', :id => '444' |
|
323 | 323 | should_route :put, "/users/444.xml", :controller => 'users', :action => 'update', :id => '444', :format => 'xml' |
|
324 | 324 | |
|
325 | 325 | should_route :delete, "/users/44", :controller => 'users', :action => 'destroy', :id => '44' |
|
326 | 326 | should_route :delete, "/users/44.xml", :controller => 'users', :action => 'destroy', :id => '44', :format => 'xml' |
|
327 | 327 | end |
|
328 | 328 | |
|
329 | # TODO: should they all be scoped under /projects/:project_id ? | |
|
330 | 329 | context "versions" do |
|
330 | # /projects/foo/versions is /projects/foo/roadmap | |
|
331 | should_route :get, "/projects/foo/versions.xml", :controller => 'versions', :action => 'index', :project_id => 'foo', :format => 'xml' | |
|
332 | should_route :get, "/projects/foo/versions.json", :controller => 'versions', :action => 'index', :project_id => 'foo', :format => 'json' | |
|
333 | ||
|
331 | 334 | should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo' |
|
332 | should_route :get, "/versions/show/1", :controller => 'versions', :action => 'show', :id => '1' | |
|
333 | should_route :get, "/versions/edit/1", :controller => 'versions', :action => 'edit', :id => '1' | |
|
334 | ||
|
335 | ||
|
335 | 336 | should_route :post, "/projects/foo/versions", :controller => 'versions', :action => 'create', :project_id => 'foo' |
|
336 |
should_route :post, "/versions |
|
|
337 | ||
|
338 | should_route :delete, "/versions/destroy/1", :controller => 'versions', :action => 'destroy', :id => '1' | |
|
337 | should_route :post, "/projects/foo/versions.xml", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'xml' | |
|
338 | should_route :post, "/projects/foo/versions.json", :controller => 'versions', :action => 'create', :project_id => 'foo', :format => 'json' | |
|
339 | ||
|
340 | should_route :get, "/projects/foo/versions/1", :controller => 'versions', :action => 'show', :project_id => 'foo', :id => '1' | |
|
341 | should_route :get, "/projects/foo/versions/1.xml", :controller => 'versions', :action => 'show', :project_id => 'foo', :id => '1', :format => 'xml' | |
|
342 | should_route :get, "/projects/foo/versions/1.json", :controller => 'versions', :action => 'show', :project_id => 'foo', :id => '1', :format => 'json' | |
|
343 | ||
|
344 | should_route :get, "/projects/foo/versions/1/edit", :controller => 'versions', :action => 'edit', :project_id => 'foo', :id => '1' | |
|
345 | ||
|
346 | should_route :put, "/projects/foo/versions/1", :controller => 'versions', :action => 'update', :project_id => 'foo', :id => '1' | |
|
347 | should_route :put, "/projects/foo/versions/1.xml", :controller => 'versions', :action => 'update', :project_id => 'foo', :id => '1', :format => 'xml' | |
|
348 | should_route :put, "/projects/foo/versions/1.json", :controller => 'versions', :action => 'update', :project_id => 'foo', :id => '1', :format => 'json' | |
|
349 | ||
|
350 | should_route :delete, "/projects/foo/versions/1", :controller => 'versions', :action => 'destroy', :project_id => 'foo', :id => '1' | |
|
351 | should_route :delete, "/projects/foo/versions/1.xml", :controller => 'versions', :action => 'destroy', :project_id => 'foo', :id => '1', :format => 'xml' | |
|
352 | should_route :delete, "/projects/foo/versions/1.json", :controller => 'versions', :action => 'destroy', :project_id => 'foo', :id => '1', :format => 'json' | |
|
353 | ||
|
354 | should_route :put, "/projects/foo/versions/close_completed", :controller => 'versions', :action => 'close_completed', :project_id => 'foo' | |
|
355 | should_route :post, "/projects/foo/versions/1/status_by", :controller => 'versions', :action => 'status_by', :project_id => 'foo', :id => '1' | |
|
339 | 356 | end |
|
340 | 357 | |
|
341 | 358 | context "wiki (singular, project's pages)" do |
|
342 | 359 | should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'show', :project_id => '567' |
|
343 | 360 | should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'show', :project_id => '567', :id => 'lalala' |
|
344 | 361 | should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :project_id => '567', :id => 'my_page' |
|
345 | 362 | should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :project_id => '1', :id => 'CookBook_documentation' |
|
346 | 363 | should_route :get, "/projects/1/wiki/CookBook_documentation/diff", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation' |
|
347 | 364 | should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2", :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation', :version => '2' |
|
348 | 365 | 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' |
|
349 | 366 | should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :project_id => '1', :id => 'CookBook_documentation', :version => '2' |
|
350 | 367 | should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida' |
|
351 | 368 | should_route :get, "/projects/567/wiki/index", :controller => 'wiki', :action => 'index', :project_id => '567' |
|
352 | 369 | should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'date_index', :project_id => '567' |
|
353 | 370 | should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'export', :project_id => '567' |
|
354 | 371 | |
|
355 | 372 | should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :project_id => '567', :id => 'CookBook_documentation' |
|
356 | 373 | should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :project_id => '22', :id => 'ladida' |
|
357 | 374 | should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :project_id => '22', :id => 'ladida' |
|
358 | 375 | should_route :post, "/projects/22/wiki/ladida/add_attachment", :controller => 'wiki', :action => 'add_attachment', :project_id => '22', :id => 'ladida' |
|
359 | 376 | |
|
360 | 377 | should_route :put, "/projects/567/wiki/my_page", :controller => 'wiki', :action => 'update', :project_id => '567', :id => 'my_page' |
|
361 | 378 | |
|
362 | 379 | should_route :delete, "/projects/22/wiki/ladida", :controller => 'wiki', :action => 'destroy', :project_id => '22', :id => 'ladida' |
|
363 | 380 | end |
|
364 | 381 | |
|
365 | 382 | context "wikis (plural, admin setup)" do |
|
366 | 383 | should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida' |
|
367 | 384 | |
|
368 | 385 | should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida' |
|
369 | 386 | should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida' |
|
370 | 387 | end |
|
371 | 388 | |
|
372 | 389 | context "administration panel" do |
|
373 | 390 | should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects' |
|
374 | 391 | end |
|
375 | 392 | end |
@@ -1,234 +1,235 | |||
|
1 | 1 | # Redmine - project management software |
|
2 |
# Copyright (C) 2006-20 |
|
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class VersionTest < ActiveSupport::TestCase |
|
21 | 21 | fixtures :projects, :users, :issues, :issue_statuses, :trackers, :enumerations, :versions |
|
22 | 22 | |
|
23 | 23 | def setup |
|
24 | 24 | end |
|
25 | 25 | |
|
26 | 26 | def test_create |
|
27 | 27 | v = Version.new(:project => Project.find(1), :name => '1.1', :effective_date => '2011-03-25') |
|
28 | 28 | assert v.save |
|
29 | 29 | assert_equal 'open', v.status |
|
30 | assert_equal 'none', v.sharing | |
|
30 | 31 | end |
|
31 | 32 | |
|
32 | 33 | def test_invalid_effective_date_validation |
|
33 | 34 | v = Version.new(:project => Project.find(1), :name => '1.1', :effective_date => '99999-01-01') |
|
34 | 35 | assert !v.save |
|
35 | 36 | assert_equal I18n.translate('activerecord.errors.messages.not_a_date'), v.errors.on(:effective_date) |
|
36 | 37 | end |
|
37 | 38 | |
|
38 | 39 | def test_progress_should_be_0_with_no_assigned_issues |
|
39 | 40 | project = Project.find(1) |
|
40 | 41 | v = Version.create!(:project => project, :name => 'Progress') |
|
41 | 42 | assert_equal 0, v.completed_pourcent |
|
42 | 43 | assert_equal 0, v.closed_pourcent |
|
43 | 44 | end |
|
44 | 45 | |
|
45 | 46 | def test_progress_should_be_0_with_unbegun_assigned_issues |
|
46 | 47 | project = Project.find(1) |
|
47 | 48 | v = Version.create!(:project => project, :name => 'Progress') |
|
48 | 49 | add_issue(v) |
|
49 | 50 | add_issue(v, :done_ratio => 0) |
|
50 | 51 | assert_progress_equal 0, v.completed_pourcent |
|
51 | 52 | assert_progress_equal 0, v.closed_pourcent |
|
52 | 53 | end |
|
53 | 54 | |
|
54 | 55 | def test_progress_should_be_100_with_closed_assigned_issues |
|
55 | 56 | project = Project.find(1) |
|
56 | 57 | status = IssueStatus.find(:first, :conditions => {:is_closed => true}) |
|
57 | 58 | v = Version.create!(:project => project, :name => 'Progress') |
|
58 | 59 | add_issue(v, :status => status) |
|
59 | 60 | add_issue(v, :status => status, :done_ratio => 20) |
|
60 | 61 | add_issue(v, :status => status, :done_ratio => 70, :estimated_hours => 25) |
|
61 | 62 | add_issue(v, :status => status, :estimated_hours => 15) |
|
62 | 63 | assert_progress_equal 100.0, v.completed_pourcent |
|
63 | 64 | assert_progress_equal 100.0, v.closed_pourcent |
|
64 | 65 | end |
|
65 | 66 | |
|
66 | 67 | def test_progress_should_consider_done_ratio_of_open_assigned_issues |
|
67 | 68 | project = Project.find(1) |
|
68 | 69 | v = Version.create!(:project => project, :name => 'Progress') |
|
69 | 70 | add_issue(v) |
|
70 | 71 | add_issue(v, :done_ratio => 20) |
|
71 | 72 | add_issue(v, :done_ratio => 70) |
|
72 | 73 | assert_progress_equal (0.0 + 20.0 + 70.0)/3, v.completed_pourcent |
|
73 | 74 | assert_progress_equal 0, v.closed_pourcent |
|
74 | 75 | end |
|
75 | 76 | |
|
76 | 77 | def test_progress_should_consider_closed_issues_as_completed |
|
77 | 78 | project = Project.find(1) |
|
78 | 79 | v = Version.create!(:project => project, :name => 'Progress') |
|
79 | 80 | add_issue(v) |
|
80 | 81 | add_issue(v, :done_ratio => 20) |
|
81 | 82 | add_issue(v, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})) |
|
82 | 83 | assert_progress_equal (0.0 + 20.0 + 100.0)/3, v.completed_pourcent |
|
83 | 84 | assert_progress_equal (100.0)/3, v.closed_pourcent |
|
84 | 85 | end |
|
85 | 86 | |
|
86 | 87 | def test_progress_should_consider_estimated_hours_to_weigth_issues |
|
87 | 88 | project = Project.find(1) |
|
88 | 89 | v = Version.create!(:project => project, :name => 'Progress') |
|
89 | 90 | add_issue(v, :estimated_hours => 10) |
|
90 | 91 | add_issue(v, :estimated_hours => 20, :done_ratio => 30) |
|
91 | 92 | add_issue(v, :estimated_hours => 40, :done_ratio => 10) |
|
92 | 93 | add_issue(v, :estimated_hours => 25, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})) |
|
93 | 94 | assert_progress_equal (10.0*0 + 20.0*0.3 + 40*0.1 + 25.0*1)/95.0*100, v.completed_pourcent |
|
94 | 95 | assert_progress_equal 25.0/95.0*100, v.closed_pourcent |
|
95 | 96 | end |
|
96 | 97 | |
|
97 | 98 | def test_progress_should_consider_average_estimated_hours_to_weigth_unestimated_issues |
|
98 | 99 | project = Project.find(1) |
|
99 | 100 | v = Version.create!(:project => project, :name => 'Progress') |
|
100 | 101 | add_issue(v, :done_ratio => 20) |
|
101 | 102 | add_issue(v, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})) |
|
102 | 103 | add_issue(v, :estimated_hours => 10, :done_ratio => 30) |
|
103 | 104 | add_issue(v, :estimated_hours => 40, :done_ratio => 10) |
|
104 | 105 | assert_progress_equal (25.0*0.2 + 25.0*1 + 10.0*0.3 + 40.0*0.1)/100.0*100, v.completed_pourcent |
|
105 | 106 | assert_progress_equal 25.0/100.0*100, v.closed_pourcent |
|
106 | 107 | end |
|
107 | 108 | |
|
108 | 109 | context "#behind_schedule?" do |
|
109 | 110 | setup do |
|
110 | 111 | ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests |
|
111 | 112 | @project = Project.generate!(:identifier => 'test0') |
|
112 | 113 | @project.trackers << Tracker.generate! |
|
113 | 114 | |
|
114 | 115 | @version = Version.generate!(:project => @project, :effective_date => nil) |
|
115 | 116 | end |
|
116 | 117 | |
|
117 | 118 | should "be false if there are no issues assigned" do |
|
118 | 119 | @version.update_attribute(:effective_date, Date.yesterday) |
|
119 | 120 | assert_equal false, @version.behind_schedule? |
|
120 | 121 | end |
|
121 | 122 | |
|
122 | 123 | should "be false if there is no effective_date" do |
|
123 | 124 | assert_equal false, @version.behind_schedule? |
|
124 | 125 | end |
|
125 | 126 | |
|
126 | 127 | should "be false if all of the issues are ahead of schedule" do |
|
127 | 128 | @version.update_attribute(:effective_date, 7.days.from_now.to_date) |
|
128 | 129 | @version.fixed_issues = [ |
|
129 | 130 | Issue.generate_for_project!(@project, :start_date => 7.days.ago, :done_ratio => 60), # 14 day span, 60% done, 50% time left |
|
130 | 131 | Issue.generate_for_project!(@project, :start_date => 7.days.ago, :done_ratio => 60) # 14 day span, 60% done, 50% time left |
|
131 | 132 | ] |
|
132 | 133 | assert_equal 60, @version.completed_pourcent |
|
133 | 134 | assert_equal false, @version.behind_schedule? |
|
134 | 135 | end |
|
135 | 136 | |
|
136 | 137 | should "be true if any of the issues are behind schedule" do |
|
137 | 138 | @version.update_attribute(:effective_date, 7.days.from_now.to_date) |
|
138 | 139 | @version.fixed_issues = [ |
|
139 | 140 | Issue.generate_for_project!(@project, :start_date => 7.days.ago, :done_ratio => 60), # 14 day span, 60% done, 50% time left |
|
140 | 141 | Issue.generate_for_project!(@project, :start_date => 7.days.ago, :done_ratio => 20) # 14 day span, 20% done, 50% time left |
|
141 | 142 | ] |
|
142 | 143 | assert_equal 40, @version.completed_pourcent |
|
143 | 144 | assert_equal true, @version.behind_schedule? |
|
144 | 145 | end |
|
145 | 146 | |
|
146 | 147 | should "be false if all of the issues are complete" do |
|
147 | 148 | @version.update_attribute(:effective_date, 7.days.from_now.to_date) |
|
148 | 149 | @version.fixed_issues = [ |
|
149 | 150 | Issue.generate_for_project!(@project, :start_date => 14.days.ago, :done_ratio => 100, :status => IssueStatus.find(5)), # 7 day span |
|
150 | 151 | Issue.generate_for_project!(@project, :start_date => 14.days.ago, :done_ratio => 100, :status => IssueStatus.find(5)) # 7 day span |
|
151 | 152 | ] |
|
152 | 153 | assert_equal 100, @version.completed_pourcent |
|
153 | 154 | assert_equal false, @version.behind_schedule? |
|
154 | 155 | |
|
155 | 156 | end |
|
156 | 157 | end |
|
157 | 158 | |
|
158 | 159 | context "#estimated_hours" do |
|
159 | 160 | setup do |
|
160 | 161 | @version = Version.create!(:project_id => 1, :name => '#estimated_hours') |
|
161 | 162 | end |
|
162 | 163 | |
|
163 | 164 | should "return 0 with no assigned issues" do |
|
164 | 165 | assert_equal 0, @version.estimated_hours |
|
165 | 166 | end |
|
166 | 167 | |
|
167 | 168 | should "return 0 with no estimated hours" do |
|
168 | 169 | add_issue(@version) |
|
169 | 170 | assert_equal 0, @version.estimated_hours |
|
170 | 171 | end |
|
171 | 172 | |
|
172 | 173 | should "return the sum of estimated hours" do |
|
173 | 174 | add_issue(@version, :estimated_hours => 2.5) |
|
174 | 175 | add_issue(@version, :estimated_hours => 5) |
|
175 | 176 | assert_equal 7.5, @version.estimated_hours |
|
176 | 177 | end |
|
177 | 178 | |
|
178 | 179 | should "return the sum of leaves estimated hours" do |
|
179 | 180 | parent = add_issue(@version) |
|
180 | 181 | add_issue(@version, :estimated_hours => 2.5, :parent_issue_id => parent.id) |
|
181 | 182 | add_issue(@version, :estimated_hours => 5, :parent_issue_id => parent.id) |
|
182 | 183 | assert_equal 7.5, @version.estimated_hours |
|
183 | 184 | end |
|
184 | 185 | end |
|
185 | 186 | |
|
186 | 187 | test "should update all issue's fixed_version associations in case the hierarchy changed XXX" do |
|
187 | 188 | User.current = User.find(1) # Need the admin's permissions |
|
188 | 189 | |
|
189 | 190 | @version = Version.find(7) |
|
190 | 191 | # Separate hierarchy |
|
191 | 192 | project_1_issue = Issue.find(1) |
|
192 | 193 | project_1_issue.fixed_version = @version |
|
193 | 194 | assert project_1_issue.save, project_1_issue.errors.full_messages.to_s |
|
194 | 195 | |
|
195 | 196 | project_5_issue = Issue.find(6) |
|
196 | 197 | project_5_issue.fixed_version = @version |
|
197 | 198 | assert project_5_issue.save |
|
198 | 199 | |
|
199 | 200 | # Project |
|
200 | 201 | project_2_issue = Issue.find(4) |
|
201 | 202 | project_2_issue.fixed_version = @version |
|
202 | 203 | assert project_2_issue.save |
|
203 | 204 | |
|
204 | 205 | # Update the sharing |
|
205 | 206 | @version.sharing = 'none' |
|
206 | 207 | assert @version.save |
|
207 | 208 | |
|
208 | 209 | # Project 1 now out of the shared scope |
|
209 | 210 | project_1_issue.reload |
|
210 | 211 | assert_equal nil, project_1_issue.fixed_version, "Fixed version is still set after changing the Version's sharing" |
|
211 | 212 | |
|
212 | 213 | # Project 5 now out of the shared scope |
|
213 | 214 | project_5_issue.reload |
|
214 | 215 | assert_equal nil, project_5_issue.fixed_version, "Fixed version is still set after changing the Version's sharing" |
|
215 | 216 | |
|
216 | 217 | # Project 2 issue remains |
|
217 | 218 | project_2_issue.reload |
|
218 | 219 | assert_equal @version, project_2_issue.fixed_version |
|
219 | 220 | end |
|
220 | 221 | |
|
221 | 222 | private |
|
222 | 223 | |
|
223 | 224 | def add_issue(version, attributes={}) |
|
224 | 225 | Issue.create!({:project => version.project, |
|
225 | 226 | :fixed_version => version, |
|
226 | 227 | :subject => 'Test', |
|
227 | 228 | :author => User.find(:first), |
|
228 | 229 | :tracker => version.project.trackers.find(:first)}.merge(attributes)) |
|
229 | 230 | end |
|
230 | 231 | |
|
231 | 232 | def assert_progress_equal(expected_float, actual_float, message="") |
|
232 | 233 | assert_in_delta(expected_float, actual_float, 0.000001, message="") |
|
233 | 234 | end |
|
234 | 235 | end |
General Comments 0
You need to be logged in to leave comments.
Login now