##// END OF EJS Templates
Adds a link to spent time on version details (#13558)....
Jean-Philippe Lang -
r15266:abf3fe9c83d8
parent child
Show More
@@ -1,55 +1,56
1 1 <div class="contextual">
2 2 <%= link_to(l(:button_edit), edit_version_path(@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 4 <%= delete_link version_path(@version, :back_url => url_for(:controller => 'versions', :action => 'index', :project_id => @version.project)) if User.current.allowed_to?(:manage_versions, @version.project) %>
5 5 <%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %>
6 6 </div>
7 7
8 8 <h2><%= @version.name %></h2>
9 9
10 10 <div id="roadmap" class="<%= @version.css_classes %>">
11 11 <%= render :partial => 'versions/overview', :locals => {:version => @version} %>
12 12 <%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %>
13 13
14 14 <div id="version-summary">
15 15 <% if @version.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %>
16 16 <fieldset class="time-tracking"><legend><%= l(:label_time_tracking) %></legend>
17 17 <table>
18 18 <tr>
19 19 <th><%= l(:field_estimated_hours) %></th>
20 20 <td class="total-hours"><%= html_hours(l_hours(@version.estimated_hours)) %></td>
21 21 </tr>
22 22 <% if User.current.allowed_to_view_all_time_entries?(@project) %>
23 23 <tr>
24 24 <th><%= l(:label_spent_time) %></th>
25 <td class="total-hours"><%= html_hours(l_hours(@version.spent_hours)) %></td>
25 <td class="total-hours"><%= link_to html_hours(l_hours(@version.spent_hours)),
26 project_time_entries_path(@version.project, :set_filter => 1, :"issue.fixed_version_id" => @version.id) %></td>
26 27 </tr>
27 28 <% end %>
28 29 </table>
29 30 </fieldset>
30 31 <% end %>
31 32
32 33 <div id="status_by">
33 34 <%= render_issue_status_by(@version, params[:status_by]) if @version.fixed_issues.count > 0 %>
34 35 </div>
35 36 </div>
36 37
37 38 <% if @issues.present? %>
38 39 <%= form_tag({}) do -%>
39 40 <table class="list related-issues">
40 41 <caption><%= l(:label_related_issues) %></caption>
41 42 <%- @issues.each do |issue| -%>
42 43 <tr class="issue hascontextmenu">
43 44 <td class="checkbox"><%= check_box_tag 'ids[]', issue.id, false, :id => nil %></td>
44 45 <td class="subject"><%= link_to_issue(issue, :project => (@project != issue.project)) %></td>
45 46 </tr>
46 47 <% end %>
47 48 </table>
48 49 <% end %>
49 50 <%= context_menu issues_context_menu_path %>
50 51 <% end %>
51 52 </div>
52 53
53 54 <%= call_hook :view_versions_show_bottom, :version => @version %>
54 55
55 56 <% html_title @version.name %>
@@ -1,238 +1,250
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2016 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 VersionsControllerTest < ActionController::TestCase
21 21 fixtures :projects, :versions, :issues, :users, :roles, :members,
22 22 :member_roles, :enabled_modules, :issue_statuses,
23 :issue_categories
23 :issue_categories, :enumerations
24 24
25 25 def setup
26 26 User.current = nil
27 27 end
28 28
29 29 def test_index
30 30 get :index, :project_id => 1
31 31 assert_response :success
32 32 assert_template 'index'
33 33 assert_not_nil assigns(:versions)
34 34 # Version with no date set appears
35 35 assert assigns(:versions).include?(Version.find(3))
36 36 # Completed version doesn't appear
37 37 assert !assigns(:versions).include?(Version.find(1))
38 38 # Context menu on issues
39 39 assert_select "script", :text => Regexp.new(Regexp.escape("contextMenuInit('/issues/context_menu')"))
40 40 assert_select "div#sidebar" do
41 41 # Links to versions anchors
42 42 assert_select 'a[href=?]', '#2.0'
43 43 # Links to completed versions in the sidebar
44 44 assert_select 'a[href=?]', '/versions/1'
45 45 end
46 46 end
47 47
48 48 def test_index_with_completed_versions
49 49 get :index, :project_id => 1, :completed => 1
50 50 assert_response :success
51 51 assert_template 'index'
52 52 assert_not_nil assigns(:versions)
53 53 # Version with no date set appears
54 54 assert assigns(:versions).include?(Version.find(3))
55 55 # Completed version appears
56 56 assert assigns(:versions).include?(Version.find(1))
57 57 end
58 58
59 59 def test_index_with_tracker_ids
60 60 get :index, :project_id => 1, :tracker_ids => [1, 3]
61 61 assert_response :success
62 62 assert_template 'index'
63 63 assert_not_nil assigns(:issues_by_version)
64 64 assert_nil assigns(:issues_by_version).values.flatten.detect {|issue| issue.tracker_id == 2}
65 65 end
66 66
67 67 def test_index_showing_subprojects_versions
68 68 @subproject_version = Version.create!(:project => Project.find(3), :name => "Subproject version")
69 69 get :index, :project_id => 1, :with_subprojects => 1
70 70 assert_response :success
71 71 assert_template 'index'
72 72 assert_not_nil assigns(:versions)
73 73
74 74 assert assigns(:versions).include?(Version.find(4)), "Shared version not found"
75 75 assert assigns(:versions).include?(@subproject_version), "Subproject version not found"
76 76 end
77 77
78 78 def test_index_should_prepend_shared_versions
79 79 get :index, :project_id => 1
80 80 assert_response :success
81 81
82 82 assert_select '#sidebar' do
83 83 assert_select 'a[href=?]', '#2.0', :text => '2.0'
84 84 assert_select 'a[href=?]', '#subproject1-2.0', :text => 'eCookbook Subproject 1 - 2.0'
85 85 end
86 86 assert_select '#content' do
87 87 assert_select 'a[name=?]', '2.0', :text => '2.0'
88 88 assert_select 'a[name=?]', 'subproject1-2.0', :text => 'eCookbook Subproject 1 - 2.0'
89 89 end
90 90 end
91 91
92 92 def test_show
93 93 get :show, :id => 2
94 94 assert_response :success
95 95 assert_template 'show'
96 96 assert_not_nil assigns(:version)
97 97
98 98 assert_select 'h2', :text => /1.0/
99 99 end
100 100
101 def test_show_should_link_to_spent_time_on_version
102 version = Version.generate!
103 issue = Issue.generate(:fixed_version => version)
104 TimeEntry.generate!(:issue => issue, :hours => 7.2)
105
106 get :show, :id => version.id
107 assert_response :success
108
109 assert_select '.total-hours', :text => '7.20 hours'
110 assert_select '.total-hours a[href=?]', "/projects/ecookbook/time_entries?issue.fixed_version_id=#{version.id}&set_filter=1"
111 end
112
101 113 def test_show_should_display_nil_counts
102 114 with_settings :default_language => 'en' do
103 115 get :show, :id => 2, :status_by => 'category'
104 116 assert_response :success
105 117 assert_select 'div#status_by' do
106 118 assert_select 'select[name=status_by]' do
107 119 assert_select 'option[value=category][selected=selected]'
108 120 end
109 121 assert_select 'a', :text => 'none'
110 122 end
111 123 end
112 124 end
113 125
114 126 def test_new
115 127 @request.session[:user_id] = 2
116 128 get :new, :project_id => '1'
117 129 assert_response :success
118 130 assert_template 'new'
119 131 end
120 132
121 133 def test_new_from_issue_form
122 134 @request.session[:user_id] = 2
123 135 xhr :get, :new, :project_id => '1'
124 136 assert_response :success
125 137 assert_template 'new'
126 138 assert_equal 'text/javascript', response.content_type
127 139 end
128 140
129 141 def test_create
130 142 @request.session[:user_id] = 2 # manager
131 143 assert_difference 'Version.count' do
132 144 post :create, :project_id => '1', :version => {:name => 'test_add_version'}
133 145 end
134 146 assert_redirected_to '/projects/ecookbook/settings/versions'
135 147 version = Version.find_by_name('test_add_version')
136 148 assert_not_nil version
137 149 assert_equal 1, version.project_id
138 150 end
139 151
140 152 def test_create_from_issue_form
141 153 @request.session[:user_id] = 2
142 154 assert_difference 'Version.count' do
143 155 xhr :post, :create, :project_id => '1', :version => {:name => 'test_add_version_from_issue_form'}
144 156 end
145 157 version = Version.find_by_name('test_add_version_from_issue_form')
146 158 assert_not_nil version
147 159 assert_equal 1, version.project_id
148 160
149 161 assert_response :success
150 162 assert_template 'create'
151 163 assert_equal 'text/javascript', response.content_type
152 164 assert_include 'test_add_version_from_issue_form', response.body
153 165 end
154 166
155 167 def test_create_from_issue_form_with_failure
156 168 @request.session[:user_id] = 2
157 169 assert_no_difference 'Version.count' do
158 170 xhr :post, :create, :project_id => '1', :version => {:name => ''}
159 171 end
160 172 assert_response :success
161 173 assert_template 'new'
162 174 assert_equal 'text/javascript', response.content_type
163 175 end
164 176
165 177 def test_get_edit
166 178 @request.session[:user_id] = 2
167 179 get :edit, :id => 2
168 180 assert_response :success
169 181 assert_template 'edit'
170 182 end
171 183
172 184 def test_close_completed
173 185 Version.update_all("status = 'open'")
174 186 @request.session[:user_id] = 2
175 187 put :close_completed, :project_id => 'ecookbook'
176 188 assert_redirected_to :controller => 'projects', :action => 'settings',
177 189 :tab => 'versions', :id => 'ecookbook'
178 190 assert_not_nil Version.find_by_status('closed')
179 191 end
180 192
181 193 def test_post_update
182 194 @request.session[:user_id] = 2
183 195 put :update, :id => 2,
184 196 :version => {:name => 'New version name',
185 197 :effective_date => Date.today.strftime("%Y-%m-%d")}
186 198 assert_redirected_to :controller => 'projects', :action => 'settings',
187 199 :tab => 'versions', :id => 'ecookbook'
188 200 version = Version.find(2)
189 201 assert_equal 'New version name', version.name
190 202 assert_equal Date.today, version.effective_date
191 203 end
192 204
193 205 def test_post_update_with_validation_failure
194 206 @request.session[:user_id] = 2
195 207 put :update, :id => 2,
196 208 :version => { :name => '',
197 209 :effective_date => Date.today.strftime("%Y-%m-%d")}
198 210 assert_response :success
199 211 assert_template 'edit'
200 212 end
201 213
202 214 def test_destroy
203 215 @request.session[:user_id] = 2
204 216 assert_difference 'Version.count', -1 do
205 217 delete :destroy, :id => 3
206 218 end
207 219 assert_redirected_to :controller => 'projects', :action => 'settings',
208 220 :tab => 'versions', :id => 'ecookbook'
209 221 assert_nil Version.find_by_id(3)
210 222 end
211 223
212 224 def test_destroy_version_in_use_should_fail
213 225 @request.session[:user_id] = 2
214 226 assert_no_difference 'Version.count' do
215 227 delete :destroy, :id => 2
216 228 end
217 229 assert_redirected_to :controller => 'projects', :action => 'settings',
218 230 :tab => 'versions', :id => 'ecookbook'
219 231 assert flash[:error].match(/Unable to delete version/)
220 232 assert Version.find_by_id(2)
221 233 end
222 234
223 235 def test_issue_status_by
224 236 xhr :get, :status_by, :id => 2
225 237 assert_response :success
226 238 assert_template 'status_by'
227 239 assert_template '_issue_counts'
228 240 end
229 241
230 242 def test_issue_status_by_status
231 243 xhr :get, :status_by, :id => 2, :status_by => 'status'
232 244 assert_response :success
233 245 assert_template 'status_by'
234 246 assert_template '_issue_counts'
235 247 assert_include 'Assigned', response.body
236 248 assert_include 'Closed', response.body
237 249 end
238 250 end
General Comments 0
You need to be logged in to leave comments. Login now