calling tracker method from within acts_as_list scope

pull/6827/head
Jens Ulferts 14 years ago
parent 81c0d3de36
commit 9d87bd473d
  1. 2
      app/models/impediment.rb
  2. 2
      app/models/story.rb
  3. 2
      features/product_owner.feature
  4. 4
      features/step_definitions/_then_steps.rb
  5. 26
      lib/backlogs_list.rb
  6. 5
      spec/models/backlog_spec.rb
  7. 4
      spec/models/tasks_spec.rb

@ -4,7 +4,7 @@ class Impediment < Task
unloadable
include Backlogs::List
acts_as_backlogs_list(Setting.plugin_redmine_backlogs[:task_tracker])
acts_as_backlogs_list(:tracker)
after_save :update_blocks_list

@ -4,7 +4,7 @@ class Story < Issue
unloadable
include Backlogs::List
acts_as_backlogs_list(Setting.plugin_redmine_backlogs[:story_trackers])
acts_as_backlogs_list(:trackers)
def self.condition(project_id, sprint_id, extras=[])
if sprint_id.nil?

@ -56,7 +56,7 @@ Feature: Product Owner
And I set the subject of the story to A Whole New Story
And I create the story
Then the 1st story in the "Product Backlog" should be "A Whole New Story"
And all positions should be unique
And all positions should be unique within versions
Scenario: Update a story
Given I am on the master backlog

@ -90,8 +90,8 @@ Then /^the (\d+)(?:st|nd|rd|th) story in (?:the )"(.+?)" should be "(.+)"$/ do |
story.subject.should == subject
end
Then /^all positions should be unique$/ do
Story.find_by_sql("select project_id, position, count(*) as dups from issues where not position is NULL group by project_id, position having count(*) > 1").length.should == 0
Then /^all positions should be unique within versions$/ do
Story.find_by_sql("select project_id, fixed_version_id, position, count(*) as dups from issues where not position is NULL group by project_id, fixed_version_id, position having count(*) > 1").length.should == 0
end
Then /^the (\d+)(?:st|nd|rd|th) task for (.+) should be (.+)$/ do |position, story_subject, task_subject|

@ -8,10 +8,26 @@ module Backlogs
end
module ClassMethods
def acts_as_backlogs_list(trackers)
self.class_eval do
acts_as_list :scope => :project #TODO: consider changing the scope to project, version and tracker
@trackers = trackers
def acts_as_backlogs_list(tracker_method)
scope_string = 'project_id = #{self.project_id}' +
' AND fixed_version_id = #{self.fixed_version_id}' +
' AND tracker_id in (#{self.class.trackers_in_scope})'
trackers_method = "def self.trackers_method() \"#{tracker_method}\" end"
class_eval <<-EOV
acts_as_list :scope => scope_string
#{ trackers_method }
EOV
end
def trackers_in_scope
trackers = self.send(self.trackers_method().to_sym)
if trackers.is_a?(Array)
trackers.join(', ')
else
trackers
end
end
end
@ -47,7 +63,7 @@ module Backlogs
private
def set_default_prev_positions_silently(prev)
stories = self.class.find(:all, :conditions => {:fixed_version_id => self.fixed_version_id, :tracker_id => @trackers})
stories = self.class.find(:all, :conditions => {:fixed_version_id => self.fixed_version_id, :tracker_id => self.class.trackers_in_scope})
self.class.record_timestamps = false #temporarily turn off column updates

@ -5,6 +5,11 @@ describe Backlog do
before(:each) do
@feature = Factory.create(:tracker_feature)
Setting.plugin_redmine_backlogs = {:points_burn_direction => "down",
:wiki_template => "",
:card_spec => "Sattleford VM-5040",
:story_trackers => [@feature.id.to_s],
:task_tracker => "0"}
@status = Factory.create(:issue_status)
end

@ -23,8 +23,8 @@ describe Task do
Setting.plugin_redmine_backlogs = {"points_burn_direction" => "down",
"wiki_template" => "",
"card_spec" => "Sattleford VM-5040",
"story_trackers" => [tracker_feature.id.to_s],
"task_tracker" => tracker_task.id.to_s }
:story_trackers => [tracker_feature.id.to_s],
:task_tracker => tracker_task.id.to_s }
end
describe "Instance Methods" do

Loading…
Cancel
Save