@@ -1,123 +1,123 | |||||
1 | <%= render :partial => 'action_menu' %> |
|
1 | <%= render :partial => 'action_menu' %> | |
2 |
|
2 | |||
3 | <%= title l(:label_workflow) %> |
|
3 | <%= title l(:label_workflow) %> | |
4 |
|
4 | |||
5 | <div class="tabs"> |
|
5 | <div class="tabs"> | |
6 | <ul> |
|
6 | <ul> | |
7 | <li><%= link_to l(:label_status_transitions), workflows_edit_path(:role_id => @roles, :tracker_id => @trackers) %></li> |
|
7 | <li><%= link_to l(:label_status_transitions), workflows_edit_path(:role_id => @roles, :tracker_id => @trackers) %></li> | |
8 | <li><%= link_to l(:label_fields_permissions), workflows_permissions_path(:role_id => @roles, :tracker_id => @trackers), :class => 'selected' %></li> |
|
8 | <li><%= link_to l(:label_fields_permissions), workflows_permissions_path(:role_id => @roles, :tracker_id => @trackers), :class => 'selected' %></li> | |
9 | </ul> |
|
9 | </ul> | |
10 | </div> |
|
10 | </div> | |
11 |
|
11 | |||
12 | <p><%=l(:text_workflow_edit)%>:</p> |
|
12 | <p><%=l(:text_workflow_edit)%>:</p> | |
13 |
|
13 | |||
14 | <%= form_tag({}, :method => 'get') do %> |
|
14 | <%= form_tag({}, :method => 'get') do %> | |
15 | <p> |
|
15 | <p> | |
16 | <label><%=l(:label_role)%>: |
|
16 | <label><%=l(:label_role)%>: | |
17 | <%= options_for_workflow_select 'role_id[]', Role.sorted.select(&:consider_workflow?), @roles, :id => 'role_id', :class => 'expandable' %> |
|
17 | <%= options_for_workflow_select 'role_id[]', Role.sorted.select(&:consider_workflow?), @roles, :id => 'role_id', :class => 'expandable' %> | |
18 | </label> |
|
18 | </label> | |
19 | <a href="#" data-expands="#role_id"><%= image_tag 'bullet_toggle_plus.png' %></a> |
|
19 | <a href="#" data-expands="#role_id"><%= image_tag 'bullet_toggle_plus.png' %></a> | |
20 |
|
20 | |||
21 | <label><%=l(:label_tracker)%>: |
|
21 | <label><%=l(:label_tracker)%>: | |
22 | <%= options_for_workflow_select 'tracker_id[]', Tracker.sorted, @trackers, :id => 'tracker_id', :class => 'expandable' %> |
|
22 | <%= options_for_workflow_select 'tracker_id[]', Tracker.sorted, @trackers, :id => 'tracker_id', :class => 'expandable' %> | |
23 | </label> |
|
23 | </label> | |
24 | <a href="#" data-expands="#tracker_id"><%= image_tag 'bullet_toggle_plus.png' %></a> |
|
24 | <a href="#" data-expands="#tracker_id"><%= image_tag 'bullet_toggle_plus.png' %></a> | |
25 |
|
25 | |||
26 | <%= submit_tag l(:button_edit), :name => nil %> |
|
26 | <%= submit_tag l(:button_edit), :name => nil %> | |
27 |
|
27 | |||
28 | <%= hidden_field_tag 'used_statuses_only', '0', :id => nil %> |
|
28 | <%= hidden_field_tag 'used_statuses_only', '0', :id => nil %> | |
29 | <label><%= check_box_tag 'used_statuses_only', '1', @used_statuses_only %> <%= l(:label_display_used_statuses_only) %></label> |
|
29 | <label><%= check_box_tag 'used_statuses_only', '1', @used_statuses_only %> <%= l(:label_display_used_statuses_only) %></label> | |
30 | </p> |
|
30 | </p> | |
31 | <% end %> |
|
31 | <% end %> | |
32 |
|
32 | |||
33 | <% if @trackers && @roles && @statuses.any? %> |
|
33 | <% if @trackers && @roles && @statuses.any? %> | |
34 | <%= form_tag({}, :id => 'workflow_form' ) do %> |
|
34 | <%= form_tag({}, :id => 'workflow_form' ) do %> | |
35 | <%= @trackers.map {|tracker| hidden_field_tag 'tracker_id[]', tracker.id, :id => nil}.join.html_safe %> |
|
35 | <%= @trackers.map {|tracker| hidden_field_tag 'tracker_id[]', tracker.id, :id => nil}.join.html_safe %> | |
36 | <%= @roles.map {|role| hidden_field_tag 'role_id[]', role.id, :id => nil}.join.html_safe %> |
|
36 | <%= @roles.map {|role| hidden_field_tag 'role_id[]', role.id, :id => nil}.join.html_safe %> | |
37 | <%= hidden_field_tag 'used_statuses_only', params[:used_statuses_only], :id => nil %> |
|
37 | <%= hidden_field_tag 'used_statuses_only', params[:used_statuses_only], :id => nil %> | |
38 | <div class="autoscroll"> |
|
38 | <div class="autoscroll"> | |
39 | <table class="list workflows fields_permissions"> |
|
39 | <table class="list workflows fields_permissions"> | |
40 | <thead> |
|
40 | <thead> | |
41 | <tr> |
|
41 | <tr> | |
42 | <th> |
|
42 | <th> | |
43 | </th> |
|
43 | </th> | |
44 | <th colspan="<%= @statuses.length %>"><%=l(:label_issue_status)%></th> |
|
44 | <th colspan="<%= @statuses.length %>"><%=l(:label_issue_status)%></th> | |
45 | </tr> |
|
45 | </tr> | |
46 | <tr> |
|
46 | <tr> | |
47 | <td></td> |
|
47 | <td></td> | |
48 | <% for status in @statuses %> |
|
48 | <% for status in @statuses %> | |
49 | <td style="width:<%= 75 / @statuses.size %>%;"> |
|
49 | <td style="width:<%= 75 / @statuses.size %>%;"> | |
50 | <%=h status.name %> |
|
50 | <%=h status.name %> | |
51 | </td> |
|
51 | </td> | |
52 | <% end %> |
|
52 | <% end %> | |
53 | </tr> |
|
53 | </tr> | |
54 | </thead> |
|
54 | </thead> | |
55 | <tbody> |
|
55 | <tbody> | |
56 | <tr class="group open"> |
|
56 | <tr class="group open"> | |
57 | <td colspan="<%= @statuses.size + 1 %>"> |
|
57 | <td colspan="<%= @statuses.size + 1 %>"> | |
58 | <span class="expander" onclick="toggleRowGroup(this);"> </span> |
|
58 | <span class="expander" onclick="toggleRowGroup(this);"> </span> | |
59 | <%= l(:field_core_fields) %> |
|
59 | <%= l(:field_core_fields) %> | |
60 | </td> |
|
60 | </td> | |
61 | </tr> |
|
61 | </tr> | |
62 | <% @fields.each do |field, name| %> |
|
62 | <% @fields.each do |field, name| %> | |
63 | <tr class="<%= cycle("odd", "even") %>"> |
|
63 | <tr class="<%= cycle("odd", "even") %>"> | |
64 | <td class="name"> |
|
64 | <td class="name"> | |
65 | <%=h name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %> |
|
65 | <%=h name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %> | |
66 | </td> |
|
66 | </td> | |
67 | <% for status in @statuses -%> |
|
67 | <% for status in @statuses -%> | |
68 | <td class="<%= @permissions[status.id][field] %>"> |
|
68 | <td class="<%= @permissions[status.id][field].try(:join, ' ') %>"> | |
69 | <%= field_permission_tag(@permissions, status, field, @roles) %> |
|
69 | <%= field_permission_tag(@permissions, status, field, @roles) %> | |
70 | <% unless status == @statuses.last %><a href="#" class="repeat-value">»</a><% end %> |
|
70 | <% unless status == @statuses.last %><a href="#" class="repeat-value">»</a><% end %> | |
71 | </td> |
|
71 | </td> | |
72 | <% end -%> |
|
72 | <% end -%> | |
73 | </tr> |
|
73 | </tr> | |
74 | <% end %> |
|
74 | <% end %> | |
75 | <% if @custom_fields.any? %> |
|
75 | <% if @custom_fields.any? %> | |
76 | <tr class="group open"> |
|
76 | <tr class="group open"> | |
77 | <td colspan="<%= @statuses.size + 1 %>"> |
|
77 | <td colspan="<%= @statuses.size + 1 %>"> | |
78 | <span class="expander" onclick="toggleRowGroup(this);"> </span> |
|
78 | <span class="expander" onclick="toggleRowGroup(this);"> </span> | |
79 | <%= l(:label_custom_field_plural) %> |
|
79 | <%= l(:label_custom_field_plural) %> | |
80 | </td> |
|
80 | </td> | |
81 | </tr> |
|
81 | </tr> | |
82 | <% @custom_fields.each do |field| %> |
|
82 | <% @custom_fields.each do |field| %> | |
83 | <tr class="<%= cycle("odd", "even") %>"> |
|
83 | <tr class="<%= cycle("odd", "even") %>"> | |
84 | <td class="name"> |
|
84 | <td class="name"> | |
85 | <%=h field.name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %> |
|
85 | <%=h field.name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %> | |
86 | </td> |
|
86 | </td> | |
87 | <% for status in @statuses -%> |
|
87 | <% for status in @statuses -%> | |
88 | <td class="<%= @permissions[status.id][field.id.to_s] %>"> |
|
88 | <td class="<%= @permissions[status.id][field.id.to_s] %>"> | |
89 | <%= field_permission_tag(@permissions, status, field, @roles) %> |
|
89 | <%= field_permission_tag(@permissions, status, field, @roles) %> | |
90 | <% unless status == @statuses.last %><a href="#" class="repeat-value">»</a><% end %> |
|
90 | <% unless status == @statuses.last %><a href="#" class="repeat-value">»</a><% end %> | |
91 | </td> |
|
91 | </td> | |
92 | <% end -%> |
|
92 | <% end -%> | |
93 | </tr> |
|
93 | </tr> | |
94 | <% end %> |
|
94 | <% end %> | |
95 | <% end %> |
|
95 | <% end %> | |
96 | </tbody> |
|
96 | </tbody> | |
97 | </table> |
|
97 | </table> | |
98 | </div> |
|
98 | </div> | |
99 | <%= submit_tag l(:button_save) %> |
|
99 | <%= submit_tag l(:button_save) %> | |
100 | <% end %> |
|
100 | <% end %> | |
101 | <% end %> |
|
101 | <% end %> | |
102 |
|
102 | |||
103 | <%= javascript_tag do %> |
|
103 | <%= javascript_tag do %> | |
104 | $("a.repeat-value").click(function(e){ |
|
104 | $("a.repeat-value").click(function(e){ | |
105 | e.preventDefault(); |
|
105 | e.preventDefault(); | |
106 | var td = $(this).closest('td'); |
|
106 | var td = $(this).closest('td'); | |
107 | var selected = td.find("select").find(":selected").val(); |
|
107 | var selected = td.find("select").find(":selected").val(); | |
108 | td.nextAll('td').find("select").val(selected); |
|
108 | td.nextAll('td').find("select").val(selected); | |
109 | }); |
|
109 | }); | |
110 |
|
110 | |||
111 | $("a[data-expands]").click(function(e){ |
|
111 | $("a[data-expands]").click(function(e){ | |
112 | e.preventDefault(); |
|
112 | e.preventDefault(); | |
113 | var target = $($(this).attr("data-expands")); |
|
113 | var target = $($(this).attr("data-expands")); | |
114 | if (target.attr("multiple")) { |
|
114 | if (target.attr("multiple")) { | |
115 | target.attr("multiple", false); |
|
115 | target.attr("multiple", false); | |
116 | target.find("option[value=all]").show(); |
|
116 | target.find("option[value=all]").show(); | |
117 | } else { |
|
117 | } else { | |
118 | target.attr("multiple", true); |
|
118 | target.attr("multiple", true); | |
119 | target.find("option[value=all]").attr("selected", false).hide(); |
|
119 | target.find("option[value=all]").attr("selected", false).hide(); | |
120 | } |
|
120 | } | |
121 | }); |
|
121 | }); | |
122 |
|
122 | |||
123 | <% end %> |
|
123 | <% end %> |
@@ -1,360 +1,369 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2015 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2015 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 WorkflowsControllerTest < ActionController::TestCase |
|
20 | class WorkflowsControllerTest < ActionController::TestCase | |
21 | fixtures :roles, :trackers, :workflows, :users, :issue_statuses |
|
21 | fixtures :roles, :trackers, :workflows, :users, :issue_statuses | |
22 |
|
22 | |||
23 | def setup |
|
23 | def setup | |
24 | User.current = nil |
|
24 | User.current = nil | |
25 | @request.session[:user_id] = 1 # admin |
|
25 | @request.session[:user_id] = 1 # admin | |
26 | end |
|
26 | end | |
27 |
|
27 | |||
28 | def test_index |
|
28 | def test_index | |
29 | get :index |
|
29 | get :index | |
30 | assert_response :success |
|
30 | assert_response :success | |
31 | assert_template 'index' |
|
31 | assert_template 'index' | |
32 |
|
32 | |||
33 | count = WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count |
|
33 | count = WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count | |
34 | assert_select 'a[href=?]', '/workflows/edit?role_id=1&tracker_id=2', :content => count.to_s |
|
34 | assert_select 'a[href=?]', '/workflows/edit?role_id=1&tracker_id=2', :content => count.to_s | |
35 | end |
|
35 | end | |
36 |
|
36 | |||
37 | def test_get_edit |
|
37 | def test_get_edit | |
38 | get :edit |
|
38 | get :edit | |
39 | assert_response :success |
|
39 | assert_response :success | |
40 | assert_template 'edit' |
|
40 | assert_template 'edit' | |
41 | end |
|
41 | end | |
42 |
|
42 | |||
43 | def test_get_edit_with_role_and_tracker |
|
43 | def test_get_edit_with_role_and_tracker | |
44 | WorkflowTransition.delete_all |
|
44 | WorkflowTransition.delete_all | |
45 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3) |
|
45 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3) | |
46 | WorkflowTransition.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5) |
|
46 | WorkflowTransition.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5) | |
47 |
|
47 | |||
48 | get :edit, :role_id => 2, :tracker_id => 1 |
|
48 | get :edit, :role_id => 2, :tracker_id => 1 | |
49 | assert_response :success |
|
49 | assert_response :success | |
50 | assert_template 'edit' |
|
50 | assert_template 'edit' | |
51 |
|
51 | |||
52 | # used status only |
|
52 | # used status only | |
53 | assert_not_nil assigns(:statuses) |
|
53 | assert_not_nil assigns(:statuses) | |
54 | assert_equal [2, 3, 5], assigns(:statuses).collect(&:id) |
|
54 | assert_equal [2, 3, 5], assigns(:statuses).collect(&:id) | |
55 |
|
55 | |||
56 | # allowed transitions |
|
56 | # allowed transitions | |
57 | assert_select 'input[type=checkbox][name=?][value="1"][checked=checked]', 'transitions[3][5][always]' |
|
57 | assert_select 'input[type=checkbox][name=?][value="1"][checked=checked]', 'transitions[3][5][always]' | |
58 | # not allowed |
|
58 | # not allowed | |
59 | assert_select 'input[type=checkbox][name=?][value="1"]:not([checked=checked])', 'transitions[3][2][always]' |
|
59 | assert_select 'input[type=checkbox][name=?][value="1"]:not([checked=checked])', 'transitions[3][2][always]' | |
60 | # unused |
|
60 | # unused | |
61 | assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]', 0 |
|
61 | assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]', 0 | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | def test_get_edit_with_all_roles_and_all_trackers |
|
64 | def test_get_edit_with_all_roles_and_all_trackers | |
65 | get :edit, :role_id => 'all', :tracker_id => 'all' |
|
65 | get :edit, :role_id => 'all', :tracker_id => 'all' | |
66 | assert_response :success |
|
66 | assert_response :success | |
67 | assert_equal Role.sorted.to_a, assigns(:roles) |
|
67 | assert_equal Role.sorted.to_a, assigns(:roles) | |
68 | assert_equal Tracker.sorted.to_a, assigns(:trackers) |
|
68 | assert_equal Tracker.sorted.to_a, assigns(:trackers) | |
69 | end |
|
69 | end | |
70 |
|
70 | |||
71 | def test_get_edit_with_role_and_tracker_and_all_statuses |
|
71 | def test_get_edit_with_role_and_tracker_and_all_statuses | |
72 | WorkflowTransition.delete_all |
|
72 | WorkflowTransition.delete_all | |
73 |
|
73 | |||
74 | get :edit, :role_id => 2, :tracker_id => 1, :used_statuses_only => '0' |
|
74 | get :edit, :role_id => 2, :tracker_id => 1, :used_statuses_only => '0' | |
75 | assert_response :success |
|
75 | assert_response :success | |
76 | assert_template 'edit' |
|
76 | assert_template 'edit' | |
77 |
|
77 | |||
78 | assert_not_nil assigns(:statuses) |
|
78 | assert_not_nil assigns(:statuses) | |
79 | assert_equal IssueStatus.count, assigns(:statuses).size |
|
79 | assert_equal IssueStatus.count, assigns(:statuses).size | |
80 |
|
80 | |||
81 | assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]' |
|
81 | assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]' | |
82 | end |
|
82 | end | |
83 |
|
83 | |||
84 | def test_post_edit |
|
84 | def test_post_edit | |
85 | WorkflowTransition.delete_all |
|
85 | WorkflowTransition.delete_all | |
86 |
|
86 | |||
87 | post :edit, :role_id => 2, :tracker_id => 1, |
|
87 | post :edit, :role_id => 2, :tracker_id => 1, | |
88 | :transitions => { |
|
88 | :transitions => { | |
89 | '4' => {'5' => {'always' => '1'}}, |
|
89 | '4' => {'5' => {'always' => '1'}}, | |
90 | '3' => {'1' => {'always' => '1'}, '2' => {'always' => '1'}} |
|
90 | '3' => {'1' => {'always' => '1'}, '2' => {'always' => '1'}} | |
91 | } |
|
91 | } | |
92 | assert_response 302 |
|
92 | assert_response 302 | |
93 |
|
93 | |||
94 | assert_equal 3, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count |
|
94 | assert_equal 3, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count | |
95 | assert_not_nil WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2).first |
|
95 | assert_not_nil WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2).first | |
96 | assert_nil WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4).first |
|
96 | assert_nil WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4).first | |
97 | end |
|
97 | end | |
98 |
|
98 | |||
99 | def test_post_edit_with_additional_transitions |
|
99 | def test_post_edit_with_additional_transitions | |
100 | WorkflowTransition.delete_all |
|
100 | WorkflowTransition.delete_all | |
101 |
|
101 | |||
102 | post :edit, :role_id => 2, :tracker_id => 1, |
|
102 | post :edit, :role_id => 2, :tracker_id => 1, | |
103 | :transitions => { |
|
103 | :transitions => { | |
104 | '4' => {'5' => {'always' => '1', 'author' => '0', 'assignee' => '0'}}, |
|
104 | '4' => {'5' => {'always' => '1', 'author' => '0', 'assignee' => '0'}}, | |
105 | '3' => {'1' => {'always' => '0', 'author' => '1', 'assignee' => '0'}, |
|
105 | '3' => {'1' => {'always' => '0', 'author' => '1', 'assignee' => '0'}, | |
106 | '2' => {'always' => '0', 'author' => '0', 'assignee' => '1'}, |
|
106 | '2' => {'always' => '0', 'author' => '0', 'assignee' => '1'}, | |
107 | '4' => {'always' => '0', 'author' => '1', 'assignee' => '1'}} |
|
107 | '4' => {'always' => '0', 'author' => '1', 'assignee' => '1'}} | |
108 | } |
|
108 | } | |
109 | assert_response 302 |
|
109 | assert_response 302 | |
110 |
|
110 | |||
111 | assert_equal 4, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count |
|
111 | assert_equal 4, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count | |
112 |
|
112 | |||
113 | w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 4, :new_status_id => 5).first |
|
113 | w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 4, :new_status_id => 5).first | |
114 | assert ! w.author |
|
114 | assert ! w.author | |
115 | assert ! w.assignee |
|
115 | assert ! w.assignee | |
116 | w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 1).first |
|
116 | w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 1).first | |
117 | assert w.author |
|
117 | assert w.author | |
118 | assert ! w.assignee |
|
118 | assert ! w.assignee | |
119 | w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2).first |
|
119 | w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2).first | |
120 | assert ! w.author |
|
120 | assert ! w.author | |
121 | assert w.assignee |
|
121 | assert w.assignee | |
122 | w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 4).first |
|
122 | w = WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 4).first | |
123 | assert w.author |
|
123 | assert w.author | |
124 | assert w.assignee |
|
124 | assert w.assignee | |
125 | end |
|
125 | end | |
126 |
|
126 | |||
127 | def test_get_permissions |
|
127 | def test_get_permissions | |
128 | get :permissions |
|
128 | get :permissions | |
129 |
|
129 | |||
130 | assert_response :success |
|
130 | assert_response :success | |
131 | assert_template 'permissions' |
|
131 | assert_template 'permissions' | |
132 | end |
|
132 | end | |
133 |
|
133 | |||
134 | def test_get_permissions_with_role_and_tracker |
|
134 | def test_get_permissions_with_role_and_tracker | |
135 | WorkflowPermission.delete_all |
|
135 | WorkflowPermission.delete_all | |
136 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :field_name => 'assigned_to_id', :rule => 'required') |
|
136 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :field_name => 'assigned_to_id', :rule => 'required') | |
137 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :field_name => 'fixed_version_id', :rule => 'required') |
|
137 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :field_name => 'fixed_version_id', :rule => 'required') | |
138 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 3, :field_name => 'fixed_version_id', :rule => 'readonly') |
|
138 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 3, :field_name => 'fixed_version_id', :rule => 'readonly') | |
139 |
|
139 | |||
140 | get :permissions, :role_id => 1, :tracker_id => 2 |
|
140 | get :permissions, :role_id => 1, :tracker_id => 2 | |
141 | assert_response :success |
|
141 | assert_response :success | |
142 | assert_template 'permissions' |
|
142 | assert_template 'permissions' | |
143 |
|
143 | |||
144 | assert_select 'input[name=?][value="1"]', 'role_id[]' |
|
144 | assert_select 'input[name=?][value="1"]', 'role_id[]' | |
145 | assert_select 'input[name=?][value="2"]', 'tracker_id[]' |
|
145 | assert_select 'input[name=?][value="2"]', 'tracker_id[]' | |
146 |
|
146 | |||
147 | # Required field |
|
147 | # Required field | |
148 | assert_select 'select[name=?]', 'permissions[2][assigned_to_id]' do |
|
148 | assert_select 'select[name=?]', 'permissions[2][assigned_to_id]' do | |
149 | assert_select 'option[value=""]' |
|
149 | assert_select 'option[value=""]' | |
150 | assert_select 'option[value=""][selected=selected]', 0 |
|
150 | assert_select 'option[value=""][selected=selected]', 0 | |
151 | assert_select 'option[value=readonly]', :text => 'Read-only' |
|
151 | assert_select 'option[value=readonly]', :text => 'Read-only' | |
152 | assert_select 'option[value=readonly][selected=selected]', 0 |
|
152 | assert_select 'option[value=readonly][selected=selected]', 0 | |
153 | assert_select 'option[value=required]', :text => 'Required' |
|
153 | assert_select 'option[value=required]', :text => 'Required' | |
154 | assert_select 'option[value=required][selected=selected]' |
|
154 | assert_select 'option[value=required][selected=selected]' | |
155 | end |
|
155 | end | |
156 |
|
156 | |||
157 | # Read-only field |
|
157 | # Read-only field | |
158 | assert_select 'select[name=?]', 'permissions[3][fixed_version_id]' do |
|
158 | assert_select 'select[name=?]', 'permissions[3][fixed_version_id]' do | |
159 | assert_select 'option[value=""]' |
|
159 | assert_select 'option[value=""]' | |
160 | assert_select 'option[value=""][selected=selected]', 0 |
|
160 | assert_select 'option[value=""][selected=selected]', 0 | |
161 | assert_select 'option[value=readonly]', :text => 'Read-only' |
|
161 | assert_select 'option[value=readonly]', :text => 'Read-only' | |
162 | assert_select 'option[value=readonly][selected=selected]' |
|
162 | assert_select 'option[value=readonly][selected=selected]' | |
163 | assert_select 'option[value=required]', :text => 'Required' |
|
163 | assert_select 'option[value=required]', :text => 'Required' | |
164 | assert_select 'option[value=required][selected=selected]', 0 |
|
164 | assert_select 'option[value=required][selected=selected]', 0 | |
165 | end |
|
165 | end | |
166 |
|
166 | |||
167 | # Other field |
|
167 | # Other field | |
168 | assert_select 'select[name=?]', 'permissions[3][due_date]' do |
|
168 | assert_select 'select[name=?]', 'permissions[3][due_date]' do | |
169 | assert_select 'option[value=""]' |
|
169 | assert_select 'option[value=""]' | |
170 | assert_select 'option[value=""][selected=selected]', 0 |
|
170 | assert_select 'option[value=""][selected=selected]', 0 | |
171 | assert_select 'option[value=readonly]', :text => 'Read-only' |
|
171 | assert_select 'option[value=readonly]', :text => 'Read-only' | |
172 | assert_select 'option[value=readonly][selected=selected]', 0 |
|
172 | assert_select 'option[value=readonly][selected=selected]', 0 | |
173 | assert_select 'option[value=required]', :text => 'Required' |
|
173 | assert_select 'option[value=required]', :text => 'Required' | |
174 | assert_select 'option[value=required][selected=selected]', 0 |
|
174 | assert_select 'option[value=required][selected=selected]', 0 | |
175 | end |
|
175 | end | |
176 | end |
|
176 | end | |
177 |
|
177 | |||
178 | def test_get_permissions_with_required_custom_field_should_not_show_required_option |
|
178 | def test_get_permissions_with_required_custom_field_should_not_show_required_option | |
179 | cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :tracker_ids => [1], :is_required => true) |
|
179 | cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :tracker_ids => [1], :is_required => true) | |
180 |
|
180 | |||
181 | get :permissions, :role_id => 1, :tracker_id => 1 |
|
181 | get :permissions, :role_id => 1, :tracker_id => 1 | |
182 | assert_response :success |
|
182 | assert_response :success | |
183 | assert_template 'permissions' |
|
183 | assert_template 'permissions' | |
184 |
|
184 | |||
185 | # Custom field that is always required |
|
185 | # Custom field that is always required | |
186 | # The default option is "(Required)" |
|
186 | # The default option is "(Required)" | |
187 | assert_select 'select[name=?]', "permissions[3][#{cf.id}]" do |
|
187 | assert_select 'select[name=?]', "permissions[3][#{cf.id}]" do | |
188 | assert_select 'option[value=""]' |
|
188 | assert_select 'option[value=""]' | |
189 | assert_select 'option[value=readonly]', :text => 'Read-only' |
|
189 | assert_select 'option[value=readonly]', :text => 'Read-only' | |
190 | assert_select 'option[value=required]', 0 |
|
190 | assert_select 'option[value=required]', 0 | |
191 | end |
|
191 | end | |
192 | end |
|
192 | end | |
193 |
|
193 | |||
194 | def test_get_permissions_should_disable_hidden_custom_fields |
|
194 | def test_get_permissions_should_disable_hidden_custom_fields | |
195 | cf1 = IssueCustomField.generate!(:tracker_ids => [1], :visible => true) |
|
195 | cf1 = IssueCustomField.generate!(:tracker_ids => [1], :visible => true) | |
196 | cf2 = IssueCustomField.generate!(:tracker_ids => [1], :visible => false, :role_ids => [1]) |
|
196 | cf2 = IssueCustomField.generate!(:tracker_ids => [1], :visible => false, :role_ids => [1]) | |
197 | cf3 = IssueCustomField.generate!(:tracker_ids => [1], :visible => false, :role_ids => [1, 2]) |
|
197 | cf3 = IssueCustomField.generate!(:tracker_ids => [1], :visible => false, :role_ids => [1, 2]) | |
198 |
|
198 | |||
199 | get :permissions, :role_id => 2, :tracker_id => 1 |
|
199 | get :permissions, :role_id => 2, :tracker_id => 1 | |
200 | assert_response :success |
|
200 | assert_response :success | |
201 | assert_template 'permissions' |
|
201 | assert_template 'permissions' | |
202 |
|
202 | |||
203 | assert_select 'select[name=?]:not(.disabled)', "permissions[1][#{cf1.id}]" |
|
203 | assert_select 'select[name=?]:not(.disabled)', "permissions[1][#{cf1.id}]" | |
204 | assert_select 'select[name=?]:not(.disabled)', "permissions[1][#{cf3.id}]" |
|
204 | assert_select 'select[name=?]:not(.disabled)', "permissions[1][#{cf3.id}]" | |
205 |
|
205 | |||
206 | assert_select 'select[name=?][disabled=disabled]', "permissions[1][#{cf2.id}]" do |
|
206 | assert_select 'select[name=?][disabled=disabled]', "permissions[1][#{cf2.id}]" do | |
207 | assert_select 'option[value=""][selected=selected]', :text => 'Hidden' |
|
207 | assert_select 'option[value=""][selected=selected]', :text => 'Hidden' | |
208 | end |
|
208 | end | |
209 | end |
|
209 | end | |
210 |
|
210 | |||
211 | def test_get_permissions_with_missing_permissions_for_roles_should_default_to_no_change |
|
211 | def test_get_permissions_with_missing_permissions_for_roles_should_default_to_no_change | |
212 | WorkflowPermission.delete_all |
|
212 | WorkflowPermission.delete_all | |
213 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') |
|
213 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') | |
214 |
|
214 | |||
215 | get :permissions, :role_id => [1, 2], :tracker_id => 2 |
|
215 | get :permissions, :role_id => [1, 2], :tracker_id => 2 | |
216 | assert_response :success |
|
216 | assert_response :success | |
217 |
|
217 | |||
218 | assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do |
|
218 | assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do | |
219 | assert_select 'option[selected]', 1 |
|
219 | assert_select 'option[selected]', 1 | |
220 | assert_select 'option[selected][value=no_change]' |
|
220 | assert_select 'option[selected][value=no_change]' | |
221 | end |
|
221 | end | |
222 | end |
|
222 | end | |
223 |
|
223 | |||
224 | def test_get_permissions_with_different_permissions_for_roles_should_default_to_no_change |
|
224 | def test_get_permissions_with_different_permissions_for_roles_should_default_to_no_change | |
225 | WorkflowPermission.delete_all |
|
225 | WorkflowPermission.delete_all | |
226 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') |
|
226 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') | |
227 | WorkflowPermission.create!(:role_id => 2, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'readonly') |
|
227 | WorkflowPermission.create!(:role_id => 2, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'readonly') | |
228 |
|
228 | |||
229 | get :permissions, :role_id => [1, 2], :tracker_id => 2 |
|
229 | get :permissions, :role_id => [1, 2], :tracker_id => 2 | |
230 | assert_response :success |
|
230 | assert_response :success | |
231 |
|
231 | |||
232 | assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do |
|
232 | assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do | |
233 | assert_select 'option[selected]', 1 |
|
233 | assert_select 'option[selected]', 1 | |
234 | assert_select 'option[selected][value=no_change]' |
|
234 | assert_select 'option[selected][value=no_change]' | |
235 | end |
|
235 | end | |
236 | end |
|
236 | end | |
237 |
|
237 | |||
238 | def test_get_permissions_with_same_permissions_for_roles_should_default_to_permission |
|
238 | def test_get_permissions_with_same_permissions_for_roles_should_default_to_permission | |
239 | WorkflowPermission.delete_all |
|
239 | WorkflowPermission.delete_all | |
240 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') |
|
240 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') | |
241 | WorkflowPermission.create!(:role_id => 2, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') |
|
241 | WorkflowPermission.create!(:role_id => 2, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') | |
242 |
|
242 | |||
243 | get :permissions, :role_id => [1, 2], :tracker_id => 2 |
|
243 | get :permissions, :role_id => [1, 2], :tracker_id => 2 | |
244 | assert_response :success |
|
244 | assert_response :success | |
245 |
|
245 | |||
246 | assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do |
|
246 | assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do | |
247 | assert_select 'option[selected]', 1 |
|
247 | assert_select 'option[selected]', 1 | |
248 | assert_select 'option[selected][value=required]' |
|
248 | assert_select 'option[selected][value=required]' | |
249 | end |
|
249 | end | |
250 | end |
|
250 | end | |
251 |
|
251 | |||
252 | def test_get_permissions_with_role_and_tracker_and_all_statuses_should_show_all_statuses |
|
252 | def test_get_permissions_with_role_and_tracker_and_all_statuses_should_show_all_statuses | |
253 | WorkflowTransition.delete_all |
|
253 | WorkflowTransition.delete_all | |
254 |
|
254 | |||
255 | get :permissions, :role_id => 1, :tracker_id => 2, :used_statuses_only => '0' |
|
255 | get :permissions, :role_id => 1, :tracker_id => 2, :used_statuses_only => '0' | |
256 | assert_response :success |
|
256 | assert_response :success | |
257 | assert_equal IssueStatus.sorted.to_a, assigns(:statuses) |
|
257 | assert_equal IssueStatus.sorted.to_a, assigns(:statuses) | |
258 | end |
|
258 | end | |
259 |
|
259 | |||
|
260 | def test_get_permissions_should_set_css_class | |||
|
261 | WorkflowPermission.delete_all | |||
|
262 | WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') | |||
|
263 | ||||
|
264 | get :permissions, :role_id => 1, :tracker_id => 2 | |||
|
265 | assert_response :success | |||
|
266 | assert_select 'td.required > select[name=?]', 'permissions[1][assigned_to_id]' | |||
|
267 | end | |||
|
268 | ||||
260 | def test_post_permissions |
|
269 | def test_post_permissions | |
261 | WorkflowPermission.delete_all |
|
270 | WorkflowPermission.delete_all | |
262 |
|
271 | |||
263 | post :permissions, :role_id => 1, :tracker_id => 2, :permissions => { |
|
272 | post :permissions, :role_id => 1, :tracker_id => 2, :permissions => { | |
264 | '1' => {'assigned_to_id' => '', 'fixed_version_id' => 'required', 'due_date' => ''}, |
|
273 | '1' => {'assigned_to_id' => '', 'fixed_version_id' => 'required', 'due_date' => ''}, | |
265 | '2' => {'assigned_to_id' => 'readonly', 'fixed_version_id' => 'readonly', 'due_date' => ''}, |
|
274 | '2' => {'assigned_to_id' => 'readonly', 'fixed_version_id' => 'readonly', 'due_date' => ''}, | |
266 | '3' => {'assigned_to_id' => '', 'fixed_version_id' => '', 'due_date' => ''} |
|
275 | '3' => {'assigned_to_id' => '', 'fixed_version_id' => '', 'due_date' => ''} | |
267 | } |
|
276 | } | |
268 | assert_response 302 |
|
277 | assert_response 302 | |
269 |
|
278 | |||
270 | workflows = WorkflowPermission.all |
|
279 | workflows = WorkflowPermission.all | |
271 | assert_equal 3, workflows.size |
|
280 | assert_equal 3, workflows.size | |
272 | workflows.each do |workflow| |
|
281 | workflows.each do |workflow| | |
273 | assert_equal 1, workflow.role_id |
|
282 | assert_equal 1, workflow.role_id | |
274 | assert_equal 2, workflow.tracker_id |
|
283 | assert_equal 2, workflow.tracker_id | |
275 | end |
|
284 | end | |
276 | assert workflows.detect {|wf| wf.old_status_id == 2 && wf.field_name == 'assigned_to_id' && wf.rule == 'readonly'} |
|
285 | assert workflows.detect {|wf| wf.old_status_id == 2 && wf.field_name == 'assigned_to_id' && wf.rule == 'readonly'} | |
277 | assert workflows.detect {|wf| wf.old_status_id == 1 && wf.field_name == 'fixed_version_id' && wf.rule == 'required'} |
|
286 | assert workflows.detect {|wf| wf.old_status_id == 1 && wf.field_name == 'fixed_version_id' && wf.rule == 'required'} | |
278 | assert workflows.detect {|wf| wf.old_status_id == 2 && wf.field_name == 'fixed_version_id' && wf.rule == 'readonly'} |
|
287 | assert workflows.detect {|wf| wf.old_status_id == 2 && wf.field_name == 'fixed_version_id' && wf.rule == 'readonly'} | |
279 | end |
|
288 | end | |
280 |
|
289 | |||
281 | def test_get_copy |
|
290 | def test_get_copy | |
282 | get :copy |
|
291 | get :copy | |
283 | assert_response :success |
|
292 | assert_response :success | |
284 | assert_template 'copy' |
|
293 | assert_template 'copy' | |
285 | assert_select 'select[name=source_tracker_id]' do |
|
294 | assert_select 'select[name=source_tracker_id]' do | |
286 | assert_select 'option[value="1"]', :text => 'Bug' |
|
295 | assert_select 'option[value="1"]', :text => 'Bug' | |
287 | end |
|
296 | end | |
288 | assert_select 'select[name=source_role_id]' do |
|
297 | assert_select 'select[name=source_role_id]' do | |
289 | assert_select 'option[value="2"]', :text => 'Developer' |
|
298 | assert_select 'option[value="2"]', :text => 'Developer' | |
290 | end |
|
299 | end | |
291 | assert_select 'select[name=?]', 'target_tracker_ids[]' do |
|
300 | assert_select 'select[name=?]', 'target_tracker_ids[]' do | |
292 | assert_select 'option[value="3"]', :text => 'Support request' |
|
301 | assert_select 'option[value="3"]', :text => 'Support request' | |
293 | end |
|
302 | end | |
294 | assert_select 'select[name=?]', 'target_role_ids[]' do |
|
303 | assert_select 'select[name=?]', 'target_role_ids[]' do | |
295 | assert_select 'option[value="1"]', :text => 'Manager' |
|
304 | assert_select 'option[value="1"]', :text => 'Manager' | |
296 | end |
|
305 | end | |
297 | end |
|
306 | end | |
298 |
|
307 | |||
299 | def test_post_copy_one_to_one |
|
308 | def test_post_copy_one_to_one | |
300 | source_transitions = status_transitions(:tracker_id => 1, :role_id => 2) |
|
309 | source_transitions = status_transitions(:tracker_id => 1, :role_id => 2) | |
301 |
|
310 | |||
302 | post :copy, :source_tracker_id => '1', :source_role_id => '2', |
|
311 | post :copy, :source_tracker_id => '1', :source_role_id => '2', | |
303 | :target_tracker_ids => ['3'], :target_role_ids => ['1'] |
|
312 | :target_tracker_ids => ['3'], :target_role_ids => ['1'] | |
304 | assert_response 302 |
|
313 | assert_response 302 | |
305 | assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) |
|
314 | assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) | |
306 | end |
|
315 | end | |
307 |
|
316 | |||
308 | def test_post_copy_one_to_many |
|
317 | def test_post_copy_one_to_many | |
309 | source_transitions = status_transitions(:tracker_id => 1, :role_id => 2) |
|
318 | source_transitions = status_transitions(:tracker_id => 1, :role_id => 2) | |
310 |
|
319 | |||
311 | post :copy, :source_tracker_id => '1', :source_role_id => '2', |
|
320 | post :copy, :source_tracker_id => '1', :source_role_id => '2', | |
312 | :target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] |
|
321 | :target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |
313 | assert_response 302 |
|
322 | assert_response 302 | |
314 | assert_equal source_transitions, status_transitions(:tracker_id => 2, :role_id => 1) |
|
323 | assert_equal source_transitions, status_transitions(:tracker_id => 2, :role_id => 1) | |
315 | assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) |
|
324 | assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) | |
316 | assert_equal source_transitions, status_transitions(:tracker_id => 2, :role_id => 3) |
|
325 | assert_equal source_transitions, status_transitions(:tracker_id => 2, :role_id => 3) | |
317 | assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 3) |
|
326 | assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 3) | |
318 | end |
|
327 | end | |
319 |
|
328 | |||
320 | def test_post_copy_many_to_many |
|
329 | def test_post_copy_many_to_many | |
321 | source_t2 = status_transitions(:tracker_id => 2, :role_id => 2) |
|
330 | source_t2 = status_transitions(:tracker_id => 2, :role_id => 2) | |
322 | source_t3 = status_transitions(:tracker_id => 3, :role_id => 2) |
|
331 | source_t3 = status_transitions(:tracker_id => 3, :role_id => 2) | |
323 |
|
332 | |||
324 | post :copy, :source_tracker_id => 'any', :source_role_id => '2', |
|
333 | post :copy, :source_tracker_id => 'any', :source_role_id => '2', | |
325 | :target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] |
|
334 | :target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |
326 | assert_response 302 |
|
335 | assert_response 302 | |
327 | assert_equal source_t2, status_transitions(:tracker_id => 2, :role_id => 1) |
|
336 | assert_equal source_t2, status_transitions(:tracker_id => 2, :role_id => 1) | |
328 | assert_equal source_t3, status_transitions(:tracker_id => 3, :role_id => 1) |
|
337 | assert_equal source_t3, status_transitions(:tracker_id => 3, :role_id => 1) | |
329 | assert_equal source_t2, status_transitions(:tracker_id => 2, :role_id => 3) |
|
338 | assert_equal source_t2, status_transitions(:tracker_id => 2, :role_id => 3) | |
330 | assert_equal source_t3, status_transitions(:tracker_id => 3, :role_id => 3) |
|
339 | assert_equal source_t3, status_transitions(:tracker_id => 3, :role_id => 3) | |
331 | end |
|
340 | end | |
332 |
|
341 | |||
333 | def test_post_copy_with_incomplete_source_specification_should_fail |
|
342 | def test_post_copy_with_incomplete_source_specification_should_fail | |
334 | assert_no_difference 'WorkflowRule.count' do |
|
343 | assert_no_difference 'WorkflowRule.count' do | |
335 | post :copy, |
|
344 | post :copy, | |
336 | :source_tracker_id => '', :source_role_id => '2', |
|
345 | :source_tracker_id => '', :source_role_id => '2', | |
337 | :target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] |
|
346 | :target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |
338 | assert_response 200 |
|
347 | assert_response 200 | |
339 | assert_select 'div.flash.error', :text => 'Please select a source tracker or role' |
|
348 | assert_select 'div.flash.error', :text => 'Please select a source tracker or role' | |
340 | end |
|
349 | end | |
341 | end |
|
350 | end | |
342 |
|
351 | |||
343 | def test_post_copy_with_incomplete_target_specification_should_fail |
|
352 | def test_post_copy_with_incomplete_target_specification_should_fail | |
344 | assert_no_difference 'WorkflowRule.count' do |
|
353 | assert_no_difference 'WorkflowRule.count' do | |
345 | post :copy, |
|
354 | post :copy, | |
346 | :source_tracker_id => '1', :source_role_id => '2', |
|
355 | :source_tracker_id => '1', :source_role_id => '2', | |
347 | :target_tracker_ids => ['2', '3'] |
|
356 | :target_tracker_ids => ['2', '3'] | |
348 | assert_response 200 |
|
357 | assert_response 200 | |
349 | assert_select 'div.flash.error', :text => 'Please select target tracker(s) and role(s)' |
|
358 | assert_select 'div.flash.error', :text => 'Please select target tracker(s) and role(s)' | |
350 | end |
|
359 | end | |
351 | end |
|
360 | end | |
352 |
|
361 | |||
353 | # Returns an array of status transitions that can be compared |
|
362 | # Returns an array of status transitions that can be compared | |
354 | def status_transitions(conditions) |
|
363 | def status_transitions(conditions) | |
355 | WorkflowTransition. |
|
364 | WorkflowTransition. | |
356 | where(conditions). |
|
365 | where(conditions). | |
357 | order('tracker_id, role_id, old_status_id, new_status_id'). |
|
366 | order('tracker_id, role_id, old_status_id, new_status_id'). | |
358 | collect {|w| [w.old_status, w.new_status_id]} |
|
367 | collect {|w| [w.old_status, w.new_status_id]} | |
359 | end |
|
368 | end | |
360 | end |
|
369 | end |
General Comments 0
You need to be logged in to leave comments.
Login now