Skip to content
Browse files

[#2766] When an issue is destroyed, any KanbanIssues related to it wi…

…ll also be.
  • Loading branch information...
1 parent eec8992 commit f0aa958ab6fb605655df5bfd2a3ee00149e69731 @edavis10 committed Jul 17, 2009
Showing with 25 additions and 1 deletion.
  1. +3 −1 app/views/kanbans/_issue.html.erb
  2. +5 −0 lib/redmine_kanban/issue_patch.rb
  3. +17 −0 test/unit/issue_test.rb
View
4 app/views/kanbans/_issue.html.erb
@@ -1,6 +1,8 @@
+<% if issue %>
<li id="issue_<%= issue.id %>" class="kanban-issue issue <%= over_pane_limit?(limit, issue_counter) if defined?(limit) -%>">
<div class="issue-details">
<%= link_to(image_tag('ticket.png'), :controller => 'issues', :action => 'show', :id => issue) %>
#<%= h(issue.id) %> - <%= h(issue.project.name) %> - <%= h(issue.subject) %>
</div>
-</li>
+</li>
+<% end %>
View
5 lib/redmine_kanban/issue_patch.rb
@@ -11,6 +11,7 @@ def self.included(base) # :nodoc:
unloadable # Send unloadable so it will not be unloaded in development
after_save :update_kanban_from_issue
+ after_destroy :remove_kanban_issues
# Add visible to Redmine 0.8.x
unless respond_to?(:visible)
@@ -31,6 +32,10 @@ def update_kanban_from_issue
KanbanIssue.update_from_issue(self)
return true
end
+
+ def remove_kanban_issues
+ KanbanIssue.destroy_all(['issue_id = (?)', self.id]) if self.id
+ end
end
end
end
View
17 test/unit/issue_test.rb
@@ -5,4 +5,21 @@ def shared_setup
configure_plugin
end
+ context 'after_destroy' do
+ should 'destroy any associated KanbanIssues' do
+ shared_setup
+ project = make_project_with_trackers
+ issue = Issue.make(:project => project,
+ :tracker => project.trackers.first,
+ :status => IssueStatus.find_by_name('Active')
+ )
+
+ assert KanbanIssue.find_by_issue_id(issue.id)
+ assert_difference('KanbanIssue.count',-1) do
+ issue.destroy
+ end
+ assert_nil KanbanIssue.find_by_issue_id(issue.id)
+ end
+ end
+
end

0 comments on commit f0aa958

Please sign in to comment.
Something went wrong with that request. Please try again.