Skip to content

Commit

Permalink
[#2766] When an issue is destroyed, any KanbanIssues related to it wi…
Browse files Browse the repository at this point in the history
…ll also be.
  • Loading branch information
edavis10 committed Jul 17, 2009
1 parent eec8992 commit f0aa958
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion 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) -%>"> <li id="issue_<%= issue.id %>" class="kanban-issue issue <%= over_pane_limit?(limit, issue_counter) if defined?(limit) -%>">
<div class="issue-details"> <div class="issue-details">
<%= link_to(image_tag('ticket.png'), :controller => 'issues', :action => 'show', :id => issue) %> <%= link_to(image_tag('ticket.png'), :controller => 'issues', :action => 'show', :id => issue) %>
#<%= h(issue.id) %> - <%= h(issue.project.name) %> - <%= h(issue.subject) %> #<%= h(issue.id) %> - <%= h(issue.project.name) %> - <%= h(issue.subject) %>
</div> </div>
</li> </li>
<% end %>
5 changes: 5 additions & 0 deletions lib/redmine_kanban/issue_patch.rb
Expand Up @@ -11,6 +11,7 @@ def self.included(base) # :nodoc:
unloadable # Send unloadable so it will not be unloaded in development unloadable # Send unloadable so it will not be unloaded in development


after_save :update_kanban_from_issue after_save :update_kanban_from_issue
after_destroy :remove_kanban_issues


# Add visible to Redmine 0.8.x # Add visible to Redmine 0.8.x
unless respond_to?(:visible) unless respond_to?(:visible)
Expand All @@ -31,6 +32,10 @@ def update_kanban_from_issue
KanbanIssue.update_from_issue(self) KanbanIssue.update_from_issue(self)
return true return true
end end

def remove_kanban_issues
KanbanIssue.destroy_all(['issue_id = (?)', self.id]) if self.id
end
end end
end end
end end
17 changes: 17 additions & 0 deletions test/unit/issue_test.rb
Expand Up @@ -5,4 +5,21 @@ def shared_setup
configure_plugin configure_plugin
end 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 end

0 comments on commit f0aa958

Please sign in to comment.