From e619bfb20b7e741cc1c77c214ac7b38f5b115ac4 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Wed, 30 Mar 2011 09:14:54 +0200 Subject: [PATCH] #3178: using blocks_ids instead of blocks in impediment management, hence removing overhead --- app/helpers/rb_common_helper.rb | 4 ++-- app/models/impediment.rb | 6 +----- app/views/rb_impediments/_impediment.html.erb | 2 +- app/views/rb_taskboards/show.html.erb | 2 +- spec/models/impediment_spec.rb | 12 ++++++------ 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/helpers/rb_common_helper.rb b/app/helpers/rb_common_helper.rb index 7c110b7240..f9d125a92f 100644 --- a/app/helpers/rb_common_helper.rb +++ b/app/helpers/rb_common_helper.rb @@ -9,8 +9,8 @@ module RbCommonHelper story.blank? || story.assigned_to.blank? ? "" : "#{story.assigned_to.firstname} #{story.assigned_to.lastname}" end - def blocked_ids(blocked) - blocked.map{|b| b.id }.join(',') + def blocks_ids(ids) + ids.sort.join(',') end def build_inline_style(task) diff --git a/app/models/impediment.rb b/app/models/impediment.rb index 1a6565f221..2cac71f7d3 100644 --- a/app/models/impediment.rb +++ b/app/models/impediment.rb @@ -5,7 +5,7 @@ class Impediment < Task after_save :update_blocks_list - safe_attributes "blocks", #change to blocks_ids once ui can be manipulated + safe_attributes "blocks_ids", :if => lambda {|impediment, user| (impediment.new_record? && user.allowed_to?(:create_impediments, impediment.project)) || user.allowed_to?(:update_impediments, impediment.project) @@ -30,10 +30,6 @@ class Impediment < Task super(since, project_id, true) end - def blocks=(ids) - self.blocks_ids = ids - end - def blocks_ids=(ids) @blocks_ids_list = [ids] if ids.is_a?(Integer) @blocks_ids_list = ids.split(/\D+/).map{|id| id.to_i} if ids.is_a?(String) diff --git a/app/views/rb_impediments/_impediment.html.erb b/app/views/rb_impediments/_impediment.html.erb index 440b262d72..7cad6ff927 100644 --- a/app/views/rb_impediments/_impediment.html.erb +++ b/app/views/rb_impediments/_impediment.html.erb @@ -4,7 +4,7 @@
<%= id_or_empty(impediment) %>
<%= impediment.subject %>
-
<%= blocked_ids(impediment.blocks) %>
+
<%= blocks_ids(impediment.blocks_ids) %>
<%= assignee_name_or_empty(impediment) %>
<%= assignee_id_or_empty(impediment) %>
diff --git a/app/views/rb_taskboards/show.html.erb b/app/views/rb_taskboards/show.html.erb index d460d065c8..dc0b1c8497 100644 --- a/app/views/rb_taskboards/show.html.erb +++ b/app/views/rb_taskboards/show.html.erb @@ -98,7 +98,7 @@ <%= render :partial => "rb_tasks/task", :object => Task.new %>
- <%= render :partial => "rb_impediments/impediment", :object => Task.new %> + <%= render :partial => "rb_impediments/impediment", :object => Impediment.new %>
diff --git a/spec/models/impediment_spec.rb b/spec/models/impediment_spec.rb index e2b5c9c480..6fdc7d29ce 100644 --- a/spec/models/impediment_spec.rb +++ b/spec/models/impediment_spec.rb @@ -94,7 +94,7 @@ describe Impediment do feature.save @impediment = Impediment.create_with_relationships({:subject => @impediment_subject, :assigned_to_id => user.id, - :blocks => feature.id.to_s, + :blocks_ids => feature.id.to_s, :status_id => issue_status1.id, :fixed_version_id => version.id}, project.id) @@ -112,7 +112,7 @@ describe Impediment do feature.save @impediment = Impediment.create_with_relationships({:subject => @impediment_subject, :assigned_to_id => user.id, - :blocks => feature.id.to_s, + :blocks_ids => feature.id.to_s, :status_id => issue_status1.id, :fixed_version_id => version.id}, project.id) @@ -128,7 +128,7 @@ describe Impediment do before(:each) do @impediment = Impediment.create_with_relationships({:subject => @impediment_subject, :assigned_to_id => user.id, - :blocks => "", + :blocks_ids => "", :status_id => issue_status1.id, :fixed_version_id => version.id}, project.id) @@ -196,7 +196,7 @@ describe Impediment do @story.fixed_version = version @story.save @blocks = @story.id.to_s - @impediment.update_with_relationships({:blocks => @blocks, + @impediment.update_with_relationships({:blocks_ids => @blocks, :status_id => issue_status1.id.to_s}) end @@ -209,7 +209,7 @@ describe Impediment do @story.fixed_version = Factory.create(:version, :project => project, :name => "another version") @story.save @blocks = @story.id.to_s - @impediment.update_with_relationships({:blocks => @blocks, + @impediment.update_with_relationships({:blocks_ids => @blocks, :status_id => issue_status1.id.to_s}) end @@ -222,7 +222,7 @@ describe Impediment do describe "WITHOUT a blocking relationship defined" do before(:each) do @blocks = "" - @impediment.update_with_relationships({:blocks => @blocks, + @impediment.update_with_relationships({:blocks_ids => @blocks, :status_id => issue_status1.id.to_s}) end