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