@@ -1,68 +1,68 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= link_to l(:label_version_new), new_project_version_path(@project), :class => 'icon icon-add' if User.current.allowed_to?(:manage_versions, @project) %> |
|
2 | <%= link_to l(:label_version_new), new_project_version_path(@project), :class => 'icon icon-add' if User.current.allowed_to?(:manage_versions, @project) %> | |
3 | </div> |
|
3 | </div> | |
4 |
|
4 | |||
5 | <h2><%=l(:label_roadmap)%></h2> |
|
5 | <h2><%=l(:label_roadmap)%></h2> | |
6 |
|
6 | |||
7 | <% if @versions.empty? %> |
|
7 | <% if @versions.empty? %> | |
8 | <p class="nodata"><%= l(:label_no_data) %></p> |
|
8 | <p class="nodata"><%= l(:label_no_data) %></p> | |
9 | <% else %> |
|
9 | <% else %> | |
10 | <div id="roadmap"> |
|
10 | <div id="roadmap"> | |
11 | <% @versions.each do |version| %> |
|
11 | <% @versions.each do |version| %> | |
12 | <h3 class="version"><%= tag 'a', :name => anchor(version.name) %><%= link_to_version version %></h3> |
|
12 | <h3 class="version"><%= tag 'a', :name => anchor(version.name) %><%= link_to_version version %></h3> | |
13 | <%= render :partial => 'versions/overview', :locals => {:version => version} %> |
|
13 | <%= render :partial => 'versions/overview', :locals => {:version => version} %> | |
14 | <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %> |
|
14 | <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %> | |
15 |
|
15 | |||
16 | <% if (issues = @issues_by_version[version]) && issues.size > 0 %> |
|
16 | <% if (issues = @issues_by_version[version]) && issues.size > 0 %> | |
17 | <% form_tag({}) do -%> |
|
17 | <% form_tag({}) do -%> | |
18 | <table class="list related-issues"> |
|
18 | <table class="list related-issues"> | |
19 | <caption><%= l(:label_related_issues) %></caption> |
|
19 | <caption><%= l(:label_related_issues) %></caption> | |
20 | <% issues.each do |issue| -%> |
|
20 | <% issues.each do |issue| -%> | |
21 | <tr class="hascontextmenu"> |
|
21 | <tr class="hascontextmenu"> | |
22 | <td class="checkbox"><%= check_box_tag 'ids[]', issue.id, false, :id => nil %></td> |
|
22 | <td class="checkbox"><%= check_box_tag 'ids[]', issue.id, false, :id => nil %></td> | |
23 | <td><%= link_to_issue(issue, :project => (@project != issue.project)) %></td> |
|
23 | <td><%= link_to_issue(issue, :project => (@project != issue.project)) %></td> | |
24 | </tr> |
|
24 | </tr> | |
25 | <% end -%> |
|
25 | <% end -%> | |
26 | </table> |
|
26 | </table> | |
27 | <% end %> |
|
27 | <% end %> | |
28 | <% end %> |
|
28 | <% end %> | |
29 | <%= call_hook :view_projects_roadmap_version_bottom, :version => version %> |
|
29 | <%= call_hook :view_projects_roadmap_version_bottom, :version => version %> | |
30 | <% end %> |
|
30 | <% end %> | |
31 | </div> |
|
31 | </div> | |
32 | <% end %> |
|
32 | <% end %> | |
33 |
|
33 | |||
34 | <% content_for :sidebar do %> |
|
34 | <% content_for :sidebar do %> | |
35 | <% form_tag({}, :method => :get) do %> |
|
35 | <% form_tag({}, :method => :get) do %> | |
36 | <h3><%= l(:label_roadmap) %></h3> |
|
36 | <h3><%= l(:label_roadmap) %></h3> | |
37 | <% @trackers.each do |tracker| %> |
|
37 | <% @trackers.each do |tracker| %> | |
38 | <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s), :id => nil %> |
|
38 | <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s), :id => nil %> | |
39 | <%=h tracker.name %></label><br /> |
|
39 | <%=h tracker.name %></label><br /> | |
40 | <% end %> |
|
40 | <% end %> | |
41 | <br /> |
|
41 | <br /> | |
42 | <label for="completed"><%= check_box_tag "completed", 1, params[:completed] %> <%= l(:label_show_completed_versions) %></label> |
|
42 | <label for="completed"><%= check_box_tag "completed", 1, params[:completed] %> <%= l(:label_show_completed_versions) %></label> | |
43 | <% if @project.descendants.active.any? %> |
|
43 | <% if @project.descendants.active.any? %> | |
44 | <%= hidden_field_tag 'with_subprojects', 0 %> |
|
44 | <%= hidden_field_tag 'with_subprojects', 0 %> | |
45 | <br /><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label> |
|
45 | <br /><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label> | |
46 | <% end %> |
|
46 | <% end %> | |
47 | <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p> |
|
47 | <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p> | |
48 | <% end %> |
|
48 | <% end %> | |
49 |
|
49 | |||
50 | <h3><%= l(:label_version_plural) %></h3> |
|
50 | <h3><%= l(:label_version_plural) %></h3> | |
51 | <% @versions.each do |version| %> |
|
51 | <% @versions.each do |version| %> | |
52 |
<%= link_to format_version_name(version), |
|
52 | <%= link_to format_version_name(version), "##{anchor(version.name)}" %><br /> | |
53 | <% end %> |
|
53 | <% end %> | |
54 | <% if @completed_versions.present? %> |
|
54 | <% if @completed_versions.present? %> | |
55 | <p> |
|
55 | <p> | |
56 | <%= link_to_function l(:label_completed_versions), |
|
56 | <%= link_to_function l(:label_completed_versions), | |
57 | 'Element.toggleClassName("toggle-completed-versions", "collapsed"); Element.toggle("completed-versions")', |
|
57 | 'Element.toggleClassName("toggle-completed-versions", "collapsed"); Element.toggle("completed-versions")', | |
58 | :id => 'toggle-completed-versions', :class => 'collapsible collapsed' %><br /> |
|
58 | :id => 'toggle-completed-versions', :class => 'collapsible collapsed' %><br /> | |
59 | <span id="completed-versions" style="display:none;"> |
|
59 | <span id="completed-versions" style="display:none;"> | |
60 | <%= @completed_versions.map {|version| link_to format_version_name(version), version_path(version)}.join("<br />\n".html_safe) %> |
|
60 | <%= @completed_versions.map {|version| link_to format_version_name(version), version_path(version)}.join("<br />\n".html_safe) %> | |
61 | </span> |
|
61 | </span> | |
62 | </p> |
|
62 | </p> | |
63 | <% end %> |
|
63 | <% end %> | |
64 | <% end %> |
|
64 | <% end %> | |
65 |
|
65 | |||
66 | <% html_title(l(:label_roadmap)) %> |
|
66 | <% html_title(l(:label_roadmap)) %> | |
67 |
|
67 | |||
68 | <%= context_menu issues_context_menu_path %> |
|
68 | <%= context_menu issues_context_menu_path %> |
@@ -1,184 +1,187 | |||||
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 'versions_controller' |
|
19 | require 'versions_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class VersionsController; def rescue_action(e) raise e end; end |
|
22 | class VersionsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class VersionsControllerTest < ActionController::TestCase |
|
24 | class VersionsControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :versions, :issues, :users, :roles, :members, :member_roles, :enabled_modules, :issue_statuses |
|
25 | fixtures :projects, :versions, :issues, :users, :roles, :members, :member_roles, :enabled_modules, :issue_statuses | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = VersionsController.new |
|
28 | @controller = VersionsController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | User.current = nil |
|
31 | User.current = nil | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_index |
|
34 | def test_index | |
35 | get :index, :project_id => 1 |
|
35 | get :index, :project_id => 1 | |
36 | assert_response :success |
|
36 | assert_response :success | |
37 | assert_template 'index' |
|
37 | assert_template 'index' | |
38 | assert_not_nil assigns(:versions) |
|
38 | assert_not_nil assigns(:versions) | |
39 | # Version with no date set appears |
|
39 | # Version with no date set appears | |
40 | assert assigns(:versions).include?(Version.find(3)) |
|
40 | assert assigns(:versions).include?(Version.find(3)) | |
41 | # Completed version doesn't appear |
|
41 | # Completed version doesn't appear | |
42 | assert !assigns(:versions).include?(Version.find(1)) |
|
42 | assert !assigns(:versions).include?(Version.find(1)) | |
43 | # Context menu on issues |
|
43 | # Context menu on issues | |
44 | assert_select "script", :text => Regexp.new(Regexp.escape("new ContextMenu('/issues/context_menu')")) |
|
44 | assert_select "script", :text => Regexp.new(Regexp.escape("new ContextMenu('/issues/context_menu')")) | |
|
45 | # Links to versions anchors | |||
|
46 | assert_tag 'a', :attributes => {:href => '#2.0'}, | |||
|
47 | :ancestor => {:tag => 'div', :attributes => {:id => 'sidebar'}} | |||
45 | # Links to completed versions in the sidebar |
|
48 | # Links to completed versions in the sidebar | |
46 | assert_tag 'a', :attributes => {:href => '/versions/1'}, |
|
49 | assert_tag 'a', :attributes => {:href => '/versions/1'}, | |
47 | :ancestor => {:tag => 'div', :attributes => {:id => 'sidebar'}} |
|
50 | :ancestor => {:tag => 'div', :attributes => {:id => 'sidebar'}} | |
48 | end |
|
51 | end | |
49 |
|
52 | |||
50 | def test_index_with_completed_versions |
|
53 | def test_index_with_completed_versions | |
51 | get :index, :project_id => 1, :completed => 1 |
|
54 | get :index, :project_id => 1, :completed => 1 | |
52 | assert_response :success |
|
55 | assert_response :success | |
53 | assert_template 'index' |
|
56 | assert_template 'index' | |
54 | assert_not_nil assigns(:versions) |
|
57 | assert_not_nil assigns(:versions) | |
55 | # Version with no date set appears |
|
58 | # Version with no date set appears | |
56 | assert assigns(:versions).include?(Version.find(3)) |
|
59 | assert assigns(:versions).include?(Version.find(3)) | |
57 | # Completed version appears |
|
60 | # Completed version appears | |
58 | assert assigns(:versions).include?(Version.find(1)) |
|
61 | assert assigns(:versions).include?(Version.find(1)) | |
59 | end |
|
62 | end | |
60 |
|
63 | |||
61 | def test_index_with_tracker_ids |
|
64 | def test_index_with_tracker_ids | |
62 | get :index, :project_id => 1, :tracker_ids => [1, 3] |
|
65 | get :index, :project_id => 1, :tracker_ids => [1, 3] | |
63 | assert_response :success |
|
66 | assert_response :success | |
64 | assert_template 'index' |
|
67 | assert_template 'index' | |
65 | assert_not_nil assigns(:issues_by_version) |
|
68 | assert_not_nil assigns(:issues_by_version) | |
66 | assert_nil assigns(:issues_by_version).values.flatten.detect {|issue| issue.tracker_id == 2} |
|
69 | assert_nil assigns(:issues_by_version).values.flatten.detect {|issue| issue.tracker_id == 2} | |
67 | end |
|
70 | end | |
68 |
|
71 | |||
69 | def test_index_showing_subprojects_versions |
|
72 | def test_index_showing_subprojects_versions | |
70 | @subproject_version = Version.generate!(:project => Project.find(3)) |
|
73 | @subproject_version = Version.generate!(:project => Project.find(3)) | |
71 | get :index, :project_id => 1, :with_subprojects => 1 |
|
74 | get :index, :project_id => 1, :with_subprojects => 1 | |
72 | assert_response :success |
|
75 | assert_response :success | |
73 | assert_template 'index' |
|
76 | assert_template 'index' | |
74 | assert_not_nil assigns(:versions) |
|
77 | assert_not_nil assigns(:versions) | |
75 |
|
78 | |||
76 | assert assigns(:versions).include?(Version.find(4)), "Shared version not found" |
|
79 | assert assigns(:versions).include?(Version.find(4)), "Shared version not found" | |
77 | assert assigns(:versions).include?(@subproject_version), "Subproject version not found" |
|
80 | assert assigns(:versions).include?(@subproject_version), "Subproject version not found" | |
78 | end |
|
81 | end | |
79 |
|
82 | |||
80 | def test_show |
|
83 | def test_show | |
81 | get :show, :id => 2 |
|
84 | get :show, :id => 2 | |
82 | assert_response :success |
|
85 | assert_response :success | |
83 | assert_template 'show' |
|
86 | assert_template 'show' | |
84 | assert_not_nil assigns(:version) |
|
87 | assert_not_nil assigns(:version) | |
85 |
|
88 | |||
86 | assert_tag :tag => 'h2', :content => /1.0/ |
|
89 | assert_tag :tag => 'h2', :content => /1.0/ | |
87 | end |
|
90 | end | |
88 |
|
91 | |||
89 | def test_new |
|
92 | def test_new | |
90 | @request.session[:user_id] = 2 |
|
93 | @request.session[:user_id] = 2 | |
91 | get :new, :project_id => '1' |
|
94 | get :new, :project_id => '1' | |
92 | assert_response :success |
|
95 | assert_response :success | |
93 | assert_template 'new' |
|
96 | assert_template 'new' | |
94 | end |
|
97 | end | |
95 |
|
98 | |||
96 | def test_create |
|
99 | def test_create | |
97 | @request.session[:user_id] = 2 # manager |
|
100 | @request.session[:user_id] = 2 # manager | |
98 | assert_difference 'Version.count' do |
|
101 | assert_difference 'Version.count' do | |
99 | post :create, :project_id => '1', :version => {:name => 'test_add_version'} |
|
102 | post :create, :project_id => '1', :version => {:name => 'test_add_version'} | |
100 | end |
|
103 | end | |
101 | assert_redirected_to '/projects/ecookbook/settings/versions' |
|
104 | assert_redirected_to '/projects/ecookbook/settings/versions' | |
102 | version = Version.find_by_name('test_add_version') |
|
105 | version = Version.find_by_name('test_add_version') | |
103 | assert_not_nil version |
|
106 | assert_not_nil version | |
104 | assert_equal 1, version.project_id |
|
107 | assert_equal 1, version.project_id | |
105 | end |
|
108 | end | |
106 |
|
109 | |||
107 | def test_create_from_issue_form |
|
110 | def test_create_from_issue_form | |
108 | @request.session[:user_id] = 2 # manager |
|
111 | @request.session[:user_id] = 2 # manager | |
109 | assert_difference 'Version.count' do |
|
112 | assert_difference 'Version.count' do | |
110 | xhr :post, :create, :project_id => '1', :version => {:name => 'test_add_version_from_issue_form'} |
|
113 | xhr :post, :create, :project_id => '1', :version => {:name => 'test_add_version_from_issue_form'} | |
111 | end |
|
114 | end | |
112 | assert_response :success |
|
115 | assert_response :success | |
113 | assert_select_rjs :replace, 'issue_fixed_version_id' |
|
116 | assert_select_rjs :replace, 'issue_fixed_version_id' | |
114 | version = Version.find_by_name('test_add_version_from_issue_form') |
|
117 | version = Version.find_by_name('test_add_version_from_issue_form') | |
115 | assert_not_nil version |
|
118 | assert_not_nil version | |
116 | assert_equal 1, version.project_id |
|
119 | assert_equal 1, version.project_id | |
117 | end |
|
120 | end | |
118 |
|
121 | |||
119 | def test_get_edit |
|
122 | def test_get_edit | |
120 | @request.session[:user_id] = 2 |
|
123 | @request.session[:user_id] = 2 | |
121 | get :edit, :id => 2 |
|
124 | get :edit, :id => 2 | |
122 | assert_response :success |
|
125 | assert_response :success | |
123 | assert_template 'edit' |
|
126 | assert_template 'edit' | |
124 | end |
|
127 | end | |
125 |
|
128 | |||
126 | def test_close_completed |
|
129 | def test_close_completed | |
127 | Version.update_all("status = 'open'") |
|
130 | Version.update_all("status = 'open'") | |
128 | @request.session[:user_id] = 2 |
|
131 | @request.session[:user_id] = 2 | |
129 | put :close_completed, :project_id => 'ecookbook' |
|
132 | put :close_completed, :project_id => 'ecookbook' | |
130 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' |
|
133 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' | |
131 | assert_not_nil Version.find_by_status('closed') |
|
134 | assert_not_nil Version.find_by_status('closed') | |
132 | end |
|
135 | end | |
133 |
|
136 | |||
134 | def test_post_update |
|
137 | def test_post_update | |
135 | @request.session[:user_id] = 2 |
|
138 | @request.session[:user_id] = 2 | |
136 | put :update, :id => 2, |
|
139 | put :update, :id => 2, | |
137 | :version => { :name => 'New version name', |
|
140 | :version => { :name => 'New version name', | |
138 | :effective_date => Date.today.strftime("%Y-%m-%d")} |
|
141 | :effective_date => Date.today.strftime("%Y-%m-%d")} | |
139 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' |
|
142 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' | |
140 | version = Version.find(2) |
|
143 | version = Version.find(2) | |
141 | assert_equal 'New version name', version.name |
|
144 | assert_equal 'New version name', version.name | |
142 | assert_equal Date.today, version.effective_date |
|
145 | assert_equal Date.today, version.effective_date | |
143 | end |
|
146 | end | |
144 |
|
147 | |||
145 | def test_post_update_with_validation_failure |
|
148 | def test_post_update_with_validation_failure | |
146 | @request.session[:user_id] = 2 |
|
149 | @request.session[:user_id] = 2 | |
147 | put :update, :id => 2, |
|
150 | put :update, :id => 2, | |
148 | :version => { :name => '', |
|
151 | :version => { :name => '', | |
149 | :effective_date => Date.today.strftime("%Y-%m-%d")} |
|
152 | :effective_date => Date.today.strftime("%Y-%m-%d")} | |
150 | assert_response :success |
|
153 | assert_response :success | |
151 | assert_template 'edit' |
|
154 | assert_template 'edit' | |
152 | end |
|
155 | end | |
153 |
|
156 | |||
154 | def test_destroy |
|
157 | def test_destroy | |
155 | @request.session[:user_id] = 2 |
|
158 | @request.session[:user_id] = 2 | |
156 | assert_difference 'Version.count', -1 do |
|
159 | assert_difference 'Version.count', -1 do | |
157 | delete :destroy, :id => 3 |
|
160 | delete :destroy, :id => 3 | |
158 | end |
|
161 | end | |
159 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' |
|
162 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' | |
160 | assert_nil Version.find_by_id(3) |
|
163 | assert_nil Version.find_by_id(3) | |
161 | end |
|
164 | end | |
162 |
|
165 | |||
163 | def test_destroy_version_in_use_should_fail |
|
166 | def test_destroy_version_in_use_should_fail | |
164 | @request.session[:user_id] = 2 |
|
167 | @request.session[:user_id] = 2 | |
165 | assert_no_difference 'Version.count' do |
|
168 | assert_no_difference 'Version.count' do | |
166 | delete :destroy, :id => 2 |
|
169 | delete :destroy, :id => 2 | |
167 | end |
|
170 | end | |
168 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' |
|
171 | assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook' | |
169 | assert flash[:error].match(/Unable to delete version/) |
|
172 | assert flash[:error].match(/Unable to delete version/) | |
170 | assert Version.find_by_id(2) |
|
173 | assert Version.find_by_id(2) | |
171 | end |
|
174 | end | |
172 |
|
175 | |||
173 | def test_issue_status_by |
|
176 | def test_issue_status_by | |
174 | xhr :get, :status_by, :id => 2 |
|
177 | xhr :get, :status_by, :id => 2 | |
175 | assert_response :success |
|
178 | assert_response :success | |
176 | assert_template '_issue_counts' |
|
179 | assert_template '_issue_counts' | |
177 | end |
|
180 | end | |
178 |
|
181 | |||
179 | def test_issue_status_by_status |
|
182 | def test_issue_status_by_status | |
180 | xhr :get, :status_by, :id => 2, :status_by => 'status' |
|
183 | xhr :get, :status_by, :id => 2, :status_by => 'status' | |
181 | assert_response :success |
|
184 | assert_response :success | |
182 | assert_template '_issue_counts' |
|
185 | assert_template '_issue_counts' | |
183 | end |
|
186 | end | |
184 | end |
|
187 | end |
General Comments 0
You need to be logged in to leave comments.
Login now