more renaming IssueRelation 2 Relation

pull/6827/head
Christian Ratz 11 years ago
parent 399cd58e18
commit a142db861f
  1. 10
      app/models/impediment.rb
  2. 8
      lib/open_project/backlogs/hooks.rb
  3. 4
      lib/open_project/backlogs/patches/query_patch.rb
  4. 6
      spec/models/impediment_spec.rb

@ -35,7 +35,7 @@ class Impediment < Task
end
def blocks_ids
@blocks_ids_list ||= relations_from.select{ |rel| rel.relation_type == IssueRelation::TYPE_BLOCKS }.collect(&:work_package_to_id)
@blocks_ids_list ||= relations_from.select{ |rel| rel.relation_type == Relation::TYPE_BLOCKS }.collect(&:to_id)
end
private
@ -47,15 +47,15 @@ class Impediment < Task
end
def remove_from_blocks_list
self.relations_from.delete(self.relations_from.select{|rel| rel.relation_type == IssueRelation::TYPE_BLOCKS && !blocks_ids.include?(rel.work_package_to_id) })
self.relations_from.delete(self.relations_from.select{|rel| rel.relation_type == Relation::TYPE_BLOCKS && !blocks_ids.include?(rel.to_id) })
end
def add_to_blocks_list
currently_blocking = relations_from.select{|rel| rel.relation_type == IssueRelation::TYPE_BLOCKS}.collect(&:work_package_to_id)
currently_blocking = relations_from.select{|rel| rel.relation_type == Relation::TYPE_BLOCKS}.collect(&:to_id)
(self.blocks_ids - currently_blocking).each{ |id|
rel = IssueRelation.new(:relation_type => IssueRelation::TYPE_BLOCKS, :work_package_from => self)
rel.work_package_to_id = id #attr_protected
rel = Relation.new(:relation_type => Relation::TYPE_BLOCKS, :from => self)
rel.to_id = id #attr_protected
self.relations_from << rel
}
end

@ -154,11 +154,11 @@ module OpenProject::Backlogs::Hooks
if work_package.is_story?
if params[:link_to_original]
rel = IssueRelation.new
rel = Relation.new
rel.work_package_from_id = Integer(params[:link_to_original])
rel.work_package_to_id = work_package.id
rel.relation_type = IssueRelation::TYPE_RELATES
rel.from_id = Integer(params[:link_to_original])
rel.to_id = work_package.id
rel.relation_type = Relation::TYPE_RELATES
rel.save
end

@ -57,11 +57,11 @@ module OpenProject::Backlogs::Patches::QueryPatch
sql << "(#{db_table}.type_id = #{Task.type} AND NOT #{db_table}.parent_id IS NULL)"
when "impediment"
sql << "(#{db_table}.id IN (
select work_package_from_id
select from_id
FROM issue_relations ir
JOIN work_packages blocked
ON
blocked.id = ir.issue_to_id
blocked.id = ir.to_id
AND blocked.type_id IN (#{all_types})
WHERE ir.relation_type = 'blocks'
) AND #{db_table}.parent_id IS NULL)"

@ -80,7 +80,7 @@ describe Impediment do
shared_examples_for "impediment creation with 1 blocking relationship" do
it_should_behave_like "impediment creation"
it { @impediment.should have(1).relations_from }
it { @impediment.relations_from[0].issue_to.should eql feature }
it { @impediment.relations_from[0].to.should eql feature }
it { @impediment.relations_from[0].relation_type.should eql Relation::TYPE_BLOCKS }
end
@ -186,7 +186,7 @@ describe Impediment do
it_should_behave_like "impediment update"
it { @impediment.should have(1).relations_from }
it { @impediment.relations_from[0].should_not be_new_record }
it { @impediment.relations_from[0].issue_to.should eql @story }
it { @impediment.relations_from[0].to.should eql @story }
it { @impediment.relations_from[0].relation_type.should eql Relation::TYPE_BLOCKS }
end
@ -194,7 +194,7 @@ describe Impediment do
it_should_behave_like "impediment update"
it { @impediment.should have(1).relations_from }
it { @impediment.relations_from[0].should_not be_changed }
it { @impediment.relations_from[0].issue_to.should eql feature }
it { @impediment.relations_from[0].to.should eql feature }
it { @impediment.relations_from[0].relation_type.should eql Relation::TYPE_BLOCKS }
end

Loading…
Cancel
Save