end
@roles = Role.find(:all, :order => 'builtin, position')
@trackers = Tracker.find(:all, :order => 'position')
- @statuses = IssueStatus.find(:all, :order => 'position')
+
+ @used_statuses_only = (params[:used_statuses_only] == '0' ? false : true)
+ if @tracker && @used_statuses_only && @tracker.issue_statuses.any?
+ @statuses = @tracker.issue_statuses
+ end
+ @statuses ||= IssueStatus.find(:all, :order => 'position')
end
def copy
find(:all, :order => 'position')
end
+ # Returns an array of IssueStatus that are used
+ # in the tracker's workflows
+ def issue_statuses
+ if @issue_statuses
+ return @issue_statuses
+ elsif new_record?
+ return []
+ end
+
+ ids = Workflow.
+ connection.select_rows("SELECT DISTINCT old_status_id, new_status_id FROM #{Workflow.table_name} WHERE tracker_id = #{id}").
+ flatten.
+ uniq
+
+ @issue_statuses = IssueStatus.find_all_by_id(ids).sort
+ end
+
private
def check_integrity
raise "Can't delete tracker" if Issue.find(:first, :conditions => ["tracker_id=?", self.id])
<label><%=l(:label_tracker)%>:</label>
<%= select_tag 'tracker_id', options_from_collection_for_select(@trackers, "id", "name", @tracker && @tracker.id) %>
-
- <%= submit_tag l(:button_edit), :name => nil %>
+
+ <%= hidden_field_tag 'used_statuses_only', '0' %>
+ <label><%= check_box_tag 'used_statuses_only', '1', @used_statuses_only %> <%= l(:label_display_used_statuses_only) %></label>
+</p>
+<p>
+<%= submit_tag l(:button_edit), :name => nil %>
</p>
<% end %>
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_copy_source: Source
label_copy_target: Target
label_copy_same_as_target: Same as target
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
button_login: Login
button_submit: Submit
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_copy_target: Cible
label_copy_same_as_target: Comme la cible
label_update_issue_done_ratios: Mettre à jour l'avancement des demandes
+ label_display_used_statuses_only: N'afficher que les statuts utilisés dans ce tracker
button_login: Connexion
button_submit: Soumettre
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
error_workflow_copy_source: Please select a source tracker or role
label_update_issue_done_ratios: Update issue done ratios
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
field_watcher: Observador
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
error_workflow_copy_source: Please select a source tracker or role
label_update_issue_done_ratios: Update issue done ratios
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
label_update_issue_done_ratios: Update issue done ratios
setting_start_of_week: Start calendars on
permission_view_issues: View Issues
+ label_display_used_statuses_only: Only display statuses that are used by this tracker
class WorkflowsController; def rescue_action(e) raise e end; end
class WorkflowsControllerTest < ActionController::TestCase
- fixtures :roles, :trackers, :workflows, :users
+ fixtures :roles, :trackers, :workflows, :users, :issue_statuses
def setup
@controller = WorkflowsController.new
end
def test_get_edit_with_role_and_tracker
+ Workflow.delete_all
+ Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
+ Workflow.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
+
get :edit, :role_id => 2, :tracker_id => 1
assert_response :success
assert_template 'edit'
+
+ # used status only
+ assert_not_nil assigns(:statuses)
+ assert_equal [2, 3, 5], assigns(:statuses).collect(&:id)
+
# allowed transitions
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'issue_status[2][]',
- :value => '1',
+ :name => 'issue_status[3][]',
+ :value => '5',
:checked => 'checked' }
# not allowed
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'issue_status[2][]',
- :value => '3',
+ :name => 'issue_status[3][]',
+ :value => '2',
+ :checked => nil }
+ # unused
+ assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
+ :name => 'issue_status[4][]' }
+ end
+
+ def test_get_edit_with_role_and_tracker_and_all_statuses
+ Workflow.delete_all
+
+ get :edit, :role_id => 2, :tracker_id => 1, :used_statuses_only => '0'
+ assert_response :success
+ assert_template 'edit'
+
+ assert_not_nil assigns(:statuses)
+ assert_equal IssueStatus.count, assigns(:statuses).size
+
+ assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
+ :name => 'issue_status[1][]',
+ :value => '1',
:checked => nil }
end
require File.dirname(__FILE__) + '/../test_helper'
class TrackerTest < ActiveSupport::TestCase
- fixtures :trackers, :workflows
+ fixtures :trackers, :workflows, :issue_statuses, :roles
def test_copy_workflows
source = Tracker.find(1)
target.reload
assert_equal 89, target.workflows.size
end
+
+ def test_issue_statuses
+ tracker = Tracker.find(1)
+ Workflow.delete_all
+ Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
+ Workflow.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
+
+ assert_kind_of Array, tracker.issue_statuses
+ assert_kind_of IssueStatus, tracker.issue_statuses.first
+ assert_equal [2, 3, 5], Tracker.find(1).issue_statuses.collect(&:id)
+ end
+
+ def test_issue_statuses_empty
+ Workflow.delete_all("tracker_id = 1")
+ assert_equal [], Tracker.find(1).issue_statuses
+ end
end