Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[#3772] Added a Manual Sync button.

This will update the Kanban board from the issues in Redmine. This is
used when some issues were updated in Redmine but they aren't reflected
in the Kanban board yet (e.g. pre-Kanban issues).
  • Loading branch information...
commit c93b4976f9dee4f91c715c770257aa1641cb8c0e 1 parent 9e02a9c
@edavis10 authored
View
14 app/controllers/kanbans_controller.rb
@@ -47,6 +47,20 @@ def update
end
end
+ def sync
+ # Brute force update :)
+ Issue.all.each do |issue|
+ KanbanIssue.update_from_issue(issue)
+ end
+
+ respond_to do |format|
+ format.html {
+ flash[:notice] = l(:kanban_text_notice_sync)
+ redirect_to kanban_path
+ }
+ end
+ end
+
private
# Override the default authorize and add in the global option. This will allow
# the user in if they have any roles with the correct permission
View
6 app/views/kanbans/show.html.erb
@@ -2,6 +2,12 @@
<h2><%= l(:kanban_title) %></h2>
+<div class="contextual">
+ <% if User.current.allowed_to?(:edit_kanban, nil, :global => true) %>
+ <%= link_to(l(:kanban_text_sync), sync_kanban_url, :method => :put, :class => 'icon icon-reload') %>
+ <% end %>
+</div>
+
<p class="general-help"><%= l(:kanban_text_general_help) %></p>
<div id="kanban">
View
2  config/locales/en.yml
@@ -14,6 +14,7 @@ en:
kanban_text_pane_settings: Pane Settings
kanban_text_pane_settings_description: "Select the Issue status you would like to associate with each pane. The issues will be updated to these statuses when they are dragged and dropped."
kanban_text_general_help: "Each list is a Pane of issues. The issues can be dragged and dropped onto other panes based on Roles and Permissions settings."
+ kanban_text_sync: "Sync"
kanban_label_incoming_pane: Incoming
kanban_label_backlog_pane: Backlog
kanban_label_selected-requests_pane: Selected Requests
@@ -29,6 +30,7 @@ en:
kanban_label_staff_role: Role to use for Staffed Requests
kanban_label_incoming_project: Project to use for the Incoming pane
kanban_text_error_saving: Error saving lists. Please refresh the page and try again.
+ kanban_text_notice_sync: Kanban lists synced.
kanban_text_saved: Updated lists.
field_state: "State"
kanban_text_nothing: "(No issues)"
View
2  config/routes.rb
@@ -1,3 +1,3 @@
ActionController::Routing::Routes.draw do |map|
- map.resource :kanban
+ map.resource :kanban, :member => {:sync => :put}
end
View
2  init.rb
@@ -24,7 +24,7 @@
requires_redmine :version_or_higher => '0.8.0'
permission(:view_kanban, {:kanbans => [:show]})
- permission(:edit_kanban, {:kanbans => [:update]})
+ permission(:edit_kanban, {:kanbans => [:update, :sync]})
permission(:manage_kanban, {})
settings(:partial => 'settings/kanban_settings',
View
2  routes.rb
@@ -1 +1 @@
-resource :kanban
+resource :kanban, :member => {:sync => :put}
View
110 test/functional/kanbans_controller_test.rb
@@ -189,5 +189,115 @@ def shared_setup
end
+ context "on PUT to :sync" do
+ setup do
+ shared_setup
+ setup_kanban_issues
+ setup_all_issues
+ end
+
+ context "" do
+ setup do
+ put :sync
+ end
+
+ should_respond_with :redirect
+ should_set_the_flash_to /sync/i
+ should_redirect_to("main page") { kanban_path }
+ end
+
+ should "update outdated selected records" do
+ selected_status = IssueStatus.find_by_name('Selected')
+ unstaffed_status = IssueStatus.find_by_name('Unstaffed')
+ issue_moved_from_selected = Issue.first(:conditions => {:status_id => selected_status.id})
+ issue_moved_from_selected.update_attributes(:status_id => IssueStatus.find_by_name('Active').id,
+ :assigned_to => @user)
+
+ issue_moved_into_selected = Issue.first(:conditions => {:status_id => unstaffed_status.id})
+ issue_moved_into_selected.update_attributes(:status_id => selected_status.id)
+
+ assert KanbanIssue.find_by_issue_id(issue_moved_from_selected.id).destroy
+ assert KanbanIssue.find_by_issue_id(issue_moved_into_selected.id).destroy
+
+ put :sync
+
+ issue_moved_from_selected.reload
+ assert_equal IssueStatus.find_by_name('Active'), issue_moved_from_selected.status
+ kanban_issue_moved_from = KanbanIssue.find_by_issue_id(issue_moved_from_selected.id)
+ assert_equal 'active', kanban_issue_moved_from.state
+ assert_equal @user, kanban_issue_moved_from.user
+ assert_equal 1, kanban_issue_moved_from.position # First for user
+
+ issue_moved_into_selected.reload
+ assert_equal IssueStatus.find_by_name('Selected'), issue_moved_into_selected.status
+ kanban_issue_moved_into = KanbanIssue.find_by_issue_id(issue_moved_into_selected.id)
+ assert_equal 'selected', kanban_issue_moved_into.state
+ assert_equal 11, kanban_issue_moved_into.position
+ end
+
+ should "update outdated active records xxx" do
+ selected_status = IssueStatus.find_by_name('Selected')
+ unstaffed_status = IssueStatus.find_by_name('Unstaffed')
+ active_status = IssueStatus.find_by_name('Active')
+ issue_moved_from_active = Issue.first(:conditions => {:status_id => active_status.id})
+ issue_moved_from_active.update_attributes(:status_id => selected_status.id)
+
+ issue_moved_into_active = Issue.first(:conditions => {:status_id => unstaffed_status.id})
+ issue_moved_into_active.update_attributes(:status_id => active_status.id, :assigned_to => @user)
+
+ assert KanbanIssue.find_by_issue_id(issue_moved_from_active.id).destroy
+ assert KanbanIssue.find_by_issue_id(issue_moved_into_active.id).destroy
+
+ put :sync
+
+ issue_moved_from_active.reload
+ assert_equal selected_status, issue_moved_from_active.status
+ kanban_issue_moved_from = KanbanIssue.find_by_issue_id(issue_moved_from_active.id)
+ assert_equal 'selected', kanban_issue_moved_from.state
+ assert_equal nil, kanban_issue_moved_from.user
+ assert_equal 11, kanban_issue_moved_from.position
+
+ issue_moved_into_active.reload
+ assert_equal active_status, issue_moved_into_active.status
+ kanban_issue_moved_into = KanbanIssue.find_by_issue_id(issue_moved_into_active.id)
+ assert_equal 'active', kanban_issue_moved_into.state
+ assert_equal @user, kanban_issue_moved_into.user
+ assert_equal 1, kanban_issue_moved_into.position # First for user
+
+ end
+
+ should "update outdated testing records xxx" do
+ selected_status = IssueStatus.find_by_name('Selected')
+ unstaffed_status = IssueStatus.find_by_name('Unstaffed')
+ active_status = IssueStatus.find_by_name('Active')
+ testing_status = IssueStatus.find_by_name('Test-N-Doc')
+
+ issue_moved_from_testing = Issue.first(:conditions => {:status_id => testing_status.id})
+ issue_moved_from_testing.update_attributes(:status_id => selected_status.id)
+
+ issue_moved_into_testing = Issue.first(:conditions => {:status_id => unstaffed_status.id})
+ issue_moved_into_testing.update_attributes(:status_id => testing_status.id, :assigned_to => @user)
+
+ assert KanbanIssue.find_by_issue_id(issue_moved_from_testing.id).destroy
+ assert KanbanIssue.find_by_issue_id(issue_moved_into_testing.id).destroy
+
+ put :sync
+
+ issue_moved_from_testing.reload
+ assert_equal selected_status, issue_moved_from_testing.status
+ kanban_issue_moved_from = KanbanIssue.find_by_issue_id(issue_moved_from_testing.id)
+ assert_equal 'selected', kanban_issue_moved_from.state
+ assert_equal nil, kanban_issue_moved_from.user
+ assert_equal 11, kanban_issue_moved_from.position
+
+ issue_moved_into_testing.reload
+ assert_equal testing_status, issue_moved_into_testing.status
+ kanban_issue_moved_into = KanbanIssue.find_by_issue_id(issue_moved_into_testing.id)
+ assert_equal 'testing', kanban_issue_moved_into.state
+ assert_equal @user, kanban_issue_moved_into.user
+ assert_equal 1, kanban_issue_moved_into.position # First for user
+
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.