diff --git a/app/models/impediment.rb b/app/models/impediment.rb index 5d2e296348..1a6f040233 100644 --- a/app/models/impediment.rb +++ b/app/models/impediment.rb @@ -49,16 +49,14 @@ class Impediment < Task end def blocks_ids - @blocks_ids_list ||= relations_from.select{ |rel| rel.relation_type == IssueRelation::TYPE_BLOCKS } + @blocks_ids_list ||= relations_from.select{ |rel| rel.relation_type == IssueRelation::TYPE_BLOCKS }.collect(&:issue_to_id) end def update_with_relationships(params) - attribs = params.clone.delete_if { |k, v| !safe_attribute_names.include?(k) } + attribs = params.reject { |k, v| !safe_attribute_names.include?(k.to_s) } attribs[:remaining_hours] = 0 if IssueStatus.find(params[:status_id]).is_closed? - attribs[:blocks_ids] = params[:blocks] if params[:blocks] #if blocks param was not sent, that means the impediment was just dragged - result = journalized_update_attributes(attribs) move_after params[:prev] if result diff --git a/spec/models/impediment_spec.rb b/spec/models/impediment_spec.rb index d31fb28793..902281dc6c 100644 --- a/spec/models/impediment_spec.rb +++ b/spec/models/impediment_spec.rb @@ -250,6 +250,21 @@ describe Impediment do impediment.blocks_ids.should eql [1,2,3] end end + + describe "WITH only prior blockers defined" do + before(:each) do + feature.fixed_version = version + feature.save + task.fixed_version = version + task.save + + impediment.relations_from = [IssueRelation.new(:issue_from => impediment, :issue_to => feature, :relation_type => IssueRelation::TYPE_BLOCKS), + IssueRelation.new(:issue_from => impediment, :issue_to => task, :relation_type => IssueRelation::TYPE_BLOCKS)] + true + end + + it { impediment.blocks_ids.should eql [feature.id, task.id] } + end end end end \ No newline at end of file