Merge pull request #47 from finnlabs/feature/rails3_sti

pull/6827/head
Hagen Schink 12 years ago
commit fed4587f2f
  1. 2
      app/controllers/rb_taskboards_controller.rb
  2. 2
      app/models/backlog.rb
  3. 2
      app/models/impediment.rb
  4. 8
      app/models/story.rb
  5. 2
      app/models/task.rb
  6. 2
      app/views/rb_taskboards/show.html.erb
  7. 16
      db/migrate/011_create_stories_tasks_sprints_and_burndown.rb
  8. 8
      db/migrate/017_change_issue_position_column.rb
  9. 7
      db/migrate/20130625094113_add_backlogs_column_to_work_package.rb
  10. 4
      features/common.feature
  11. 4
      features/edit_story.feature
  12. 4
      features/edit_story_tracker_and_status.feature
  13. 4
      features/edit_via_modal.feature
  14. 12
      features/fixed_version_by_issue_hierarchy.feature
  15. 4
      features/issue_hierarchy_restriction_project_boundaries.feature
  16. 4
      features/product_owner.feature
  17. 4
      features/scrum_master.feature
  18. 4
      features/step_definitions/_given_steps.rb
  19. 2
      features/step_definitions/_then_steps.rb
  20. 4
      features/team_member.feature
  21. 8
      lib/open_project/backlogs/burndown/series_raw_data.rb
  22. 17
      lib/open_project/backlogs/mixins/prevent_issue_sti.rb
  23. 1
      lib/open_project/backlogs/patches/issue_patch.rb
  24. 16
      spec/models/burndown_spec.rb

@ -10,7 +10,7 @@ class RbTaskboardsController < RbApplicationController
@story_ids = @sprint.stories(@project).map{|s| s.id}
@last_updated = Task.find(:first,
:conditions => ["parent_id in (?)", @story_ids],
:order => "updated_on DESC")
:order => "updated_at DESC")
end
def default_breadcrumb

@ -30,7 +30,7 @@ class Backlog
end
def updated_on
@stories.max_by(&:updated_on).try(:updated_on)
@stories.max_by(&:updated_at).try(:updated_at)
end
def owner_backlog?

@ -1,6 +1,8 @@
class Impediment < Task
unloadable
extend OpenProject::Backlogs::Mixins::PreventIssueSti
after_save :update_blocks_list
validate :validate_blocks_list

@ -1,6 +1,8 @@
class Story < Issue
unloadable
extend OpenProject::Backlogs::Mixins::PreventIssueSti
def self.backlogs(project_id, sprint_ids, options = {})
options.reverse_merge!({ :order => Story::ORDER,
@ -128,9 +130,9 @@ class Story < Issue
def rank
if self.position.blank?
extras = ['and ((issues.position is NULL and issues.id <= ?) or not issues.position is NULL)', self.id]
extras = ["and ((#{Issue.table_name}.position is NULL and #{Issue.table_name}.id <= ?) or not #{Issue.table_name}.position is NULL)", self.id]
else
extras = ['and not issues.position is NULL and issues.position <= ?', self.position]
extras = ["and not #{Issue.table_name}.position is NULL and #{Issue.table_name}.position <= ?", self.position]
end
@rank ||= Issue.count(:conditions => Story.condition(self.project.id, self.fixed_version_id, extras), :joins => :status)
@ -153,5 +155,5 @@ class Story < Issue
end
# This forces NULLS-LAST ordering
ORDER = 'CASE WHEN issues.position IS NULL THEN 1 ELSE 0 END ASC, CASE WHEN issues.position IS NULL THEN issues.id ELSE issues.position END ASC'
ORDER = "CASE WHEN #{Issue.table_name}.position IS NULL THEN 1 ELSE 0 END ASC, CASE WHEN #{Issue.table_name}.position IS NULL THEN #{Issue.table_name}.id ELSE #{Issue.table_name}.position END ASC"
end

@ -3,6 +3,8 @@ require 'date'
class Task < Issue
unloadable
extend OpenProject::Backlogs::Mixins::PreventIssueSti
def self.tracker
task_tracker = Setting.plugin_openproject_backlogs["task_tracker"]
task_tracker.blank? ? nil : task_tracker.to_i

@ -108,7 +108,7 @@
</div>
<div id="issue_editor"> </div>
<div class="meta" id="last_updated"><%= date_string_with_milliseconds( (@last_updated.blank? ? Time.now : @last_updated.updated_on) ) %></div>
<div class="meta" id="last_updated"><%= date_string_with_milliseconds( (@last_updated.blank? ? Time.now : @last_updated.updated_at) ) %></div>
<div id="charts"> </div>
<div id="preloader">
<div id="spinner"> </div>

@ -1,8 +1,10 @@
class CreateStoriesTasksSprintsAndBurndown < ActiveRecord::Migration
def self.up
add_column :issues, :position, :integer
add_column :issues, :story_points, :integer
add_column :issues, :remaining_hours, :float
if ActiveRecord::Base.connection.table_exists? 'issues'
add_column :issues, :position, :integer
add_column :issues, :story_points, :integer
add_column :issues, :remaining_hours, :float
end
add_column :versions, :sprint_start_date, :date, :null => true
@ -20,9 +22,11 @@ class CreateStoriesTasksSprintsAndBurndown < ActiveRecord::Migration
end
def self.down
remove_column :issues, :position
remove_column :issues, :story_points
remove_column :issues, :remaining_hours
if ActiveRecord::Base.connection.table_exists? 'issues'
remove_column :issues, :position
remove_column :issues, :story_points
remove_column :issues, :remaining_hours
end
remove_column :versions, :sprint_start_date

@ -1,9 +1,13 @@
class ChangeIssuePositionColumn < ActiveRecord::Migration
def self.up
change_column :issues, :position, :integer, :null => true, :default => nil
if ActiveRecord::Base.connection.table_exists? 'issues'
change_column :issues, :position, :integer, :null => true, :default => nil
end
end
def self.down
change_column :issues, :position, :integer, :null => false
if ActiveRecord::Base.connection.table_exists? 'issues'
change_column :issues, :position, :integer, :null => false
end
end
end

@ -0,0 +1,7 @@
class AddBacklogsColumnToWorkPackage < ActiveRecord::Migration
def change
add_column :work_packages, :position, :integer
add_column :work_packages, :story_points, :integer
add_column :work_packages, :remaining_hours, :float
end
end

@ -18,8 +18,8 @@ Feature: Common
| view_taskboards |
| create_tasks |
| update_tasks |
| view_issues |
| edit_issues |
| view_work_packages |
| edit_work_packages |
| manage_subtasks |
And there are the following issue status:
| name | is_closed | is_default |

@ -25,8 +25,8 @@ Feature: Edit story on backlogs view
| view_master_backlog |
| create_stories |
| update_stories |
| view_issues |
| edit_issues |
| view_work_packages |
| edit_work_packages |
| manage_subtasks |
And the user "mathias" is a "team member"
And the project has the following sprints:

@ -27,8 +27,8 @@ Feature: Edit story tracker and status
| view_master_backlog |
| create_stories |
| update_stories |
| view_issues |
| edit_issues |
| view_work_packages |
| edit_work_packages |
| manage_subtasks |
And the project has the following sprints:
| name | start_date | effective_date |

@ -17,8 +17,8 @@ Feature: Edit issue via modal box
| update_tasks |
| view_wiki_pages |
| edit_wiki_pages |
| view_issues |
| edit_issues |
| view_work_packages |
| edit_work_packages |
| manage_subtasks |
And the backlogs module is initialized
And the following trackers are configured to track stories:

@ -20,8 +20,8 @@ Feature: The issue hierarchy defines the allowed versions for each issue depende
| update_tasks |
| view_wiki_pages |
| edit_wiki_pages |
| view_issues |
| edit_issues |
| view_work_packages |
| edit_work_packages |
| manage_subtasks |
| create_tasks |
| add_issues |
@ -109,7 +109,6 @@ Feature: The issue hierarchy defines the allowed versions for each issue depende
And I click on the first button matching "Create"
Then I should see "Sprint 001" within "td.fixed-version"
@javascript
Scenario: Creating a task, via new issue, as a subtask to a story set´s the new task´s fixed version to the parent´s fixed version
When I go to the issues/new page of the project called "ecookbook"
And I follow "New issue" within "#main-menu"
@ -119,7 +118,6 @@ Feature: The issue hierarchy defines the allowed versions for each issue depende
And I click on the first button matching "Create"
Then I should see "Sprint 001" within "td.fixed-version"
@javascript
Scenario: Creating a task, via new issue, as a subtask to a story and setting a fixed version is overriden by the parent´s fixed version (bug 8904)
When I go to the issues/new page of the project called "ecookbook"
And I follow "New issue" within "#main-menu"
@ -130,19 +128,15 @@ Feature: The issue hierarchy defines the allowed versions for each issue depende
And I click on the first button matching "Create"
Then I should see "Sprint 001" within "td.fixed-version"
@javascript
Scenario: Moving a task between stories via issue/edit (bug 9324)
Given the project has the following tasks:
| subject | parent |
| Task 1 | Story 1 |
When I go to the edit page of the issue "Task 1"
And I follow "More" within "#issue-form"
And I fill in the id of the issue "Story C" as the parent issue
And I press "Submit"
Then I should see "Sprint 002" within "td.fixed-version"
@javascript
Scenario: Changing the fixed_version of a task with a non backlogs parent issue (bug 8354)
Given the project has the following issues:
| subject | sprint | tracker |
@ -155,7 +149,6 @@ Feature: The issue hierarchy defines the allowed versions for each issue depende
And I press "Submit"
Then I should see "Successful update." within "div.flash"
@javascript
Scenario: Changing the fixed_version of an epic should not change the target version of the child (bug 8903)
Given the project has the following issues:
| subject | sprint | tracker | parent |
@ -167,7 +160,6 @@ Feature: The issue hierarchy defines the allowed versions for each issue depende
Then I should see "Successful update." within "div.flash"
And the task "Task 1" should have "Sprint 002" as its target version
@javascript
Scenario: Modification of a backlogs story with tasks is still possible (bug 9711)
Given the project has the following tasks:
| subject | parent |

@ -20,8 +20,8 @@ Feature: The issue hierarchy between backlogs stories and backlogs tasks can not
| update_tasks |
| view_wiki_pages |
| edit_wiki_pages |
| view_issues |
| edit_issues |
| view_work_packages |
| edit_work_packages |
| manage_subtasks |
| create_tasks |
| add_issues |

@ -18,8 +18,8 @@ Feature: Product Owner
| view_master_backlog |
| create_stories |
| update_stories |
| view_issues |
| edit_issues |
| view_work_packages |
| edit_work_packages |
| manage_subtasks |
And the tracker "Story" has the default workflow for the role "product owner"

@ -20,8 +20,8 @@ Feature: Scrum Master
| update_tasks |
| view_wiki_pages |
| edit_wiki_pages |
| view_issues |
| edit_issues |
| view_work_packages |
| edit_work_packages |
| manage_subtasks |
And the backlogs module is initialized
And the following trackers are configured to track stories:

@ -128,7 +128,7 @@ end
Given /^the [pP]roject(?: "([^\"]*)")? has the following stories in the following sprints:$/ do |project_name, table|
project = get_project(project_name)
project.issues.delete_all
project.work_packages.delete_all
prev_id = ''
table.hashes.each do |story|
@ -259,7 +259,7 @@ Given /^I have made (.+) the template page for sprint notes/ do |title|
end
Given /^there are no stories in the [pP]roject$/ do
@project.issues.delete_all
@project.work_packages.delete_all
end
Given /^the tracker "(.+?)" is configured to track tasks$/ do |tracker_name|

@ -114,7 +114,7 @@ Then /^the (\d+)(?:st|nd|rd|th) story in (?:the )?"(.+?)" should have the ID of
end
Then /^all positions should be unique for each version$/ 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
Story.find_by_sql("select project_id, fixed_version_id, position, count(*) as dups from #{Issue.table_name} 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|

@ -28,8 +28,8 @@ Feature: Team Member
| view_taskboards |
| create_tasks |
| update_tasks |
| view_issues |
| edit_issues |
| view_work_packages |
| edit_work_packages |
| manage_subtasks |
And the user "paul" is a "team member"
And the project has the following sprints:

@ -89,11 +89,11 @@ module OpenProject::Backlogs::Burndown
end
def find_interesting_stories
fixed_version_query = "(issues.fixed_version_id = ? OR journals.changed_data LIKE '%fixed_version_id: - ? - [0-9]+%' OR journals.changed_data LIKE '%fixed_version_id: - [0-9]+ - ?%')"
project_id_query = "(issues.project_id = ? OR journals.changed_data LIKE '%project_id: - ? - [0-9]+%' OR journals.changed_data LIKE '%project_id: - [0-9]+ - ?%')"
fixed_version_query = "(#{Issue.table_name}.fixed_version_id = ? OR journals.changed_data LIKE '%fixed_version_id: - ? - [0-9]+%' OR journals.changed_data LIKE '%fixed_version_id: - [0-9]+ - ?%')"
project_id_query = "(#{Issue.table_name}.project_id = ? OR journals.changed_data LIKE '%project_id: - ? - [0-9]+%' OR journals.changed_data LIKE '%project_id: - [0-9]+ - ?%')"
trackers_string = "(#{collected_trackers.map{|i| "(#{i})"}.join("|")})"
tracker_id_query = "(issues.tracker_id in (?) OR journals.changed_data LIKE '%tracker_id: - #{trackers_string} - [0-9]+%' OR journals.changed_data LIKE '%tracker_id: - [0-9]+ - #{trackers_string}%')"
tracker_id_query = "(#{Issue.table_name}.tracker_id in (?) OR journals.changed_data LIKE '%tracker_id: - #{trackers_string} - [0-9]+%' OR journals.changed_data LIKE '%tracker_id: - [0-9]+ - #{trackers_string}%')"
stories = Issue.all(:include => :journals,
:conditions => ["#{ fixed_version_query }" +
@ -145,7 +145,7 @@ module OpenProject::Backlogs::Burndown
((key == "story_points") && story_is_done?(story, date, details_by_prop, current_prop_index)) ||
out_names.include?(key) ||
collected_from_children?(key, story) ||
story.created_on.to_date > date
story.created_at.to_date > date
end
def not_in_project?(story, date, details_by_prop, current_prop_index)

@ -0,0 +1,17 @@
module OpenProject::Backlogs::Mixins
module PreventIssueSti
# overriding ActiveRecord::Inheritance::ClassMethods#sti_name
# so that stories are stored and found with type-attribute = "Issue"
def sti_name
"Issue"
end
# overriding ActiveRecord::Inheritance::ClassMethods#find_sti_classes
# so that stories are instantiated correctly despite sti_name beeing "Issue"
def find_sti_class(type_name)
type_name = self.to_s if type_name == "Issue"
super(type_name)
end
end
end

@ -1,3 +1,4 @@
require_dependency 'work_package'
require_dependency 'issue'
module OpenProject::Backlogs::Patches::IssuePatch

@ -6,7 +6,7 @@ describe Burndown do
story.instance_variable_set(:@current_journal, nil)
story.init_journal(user)
story.send(attribute, value)
story.current_journal.created_on = day
story.current_journal.created_at = day
story.save!
# with aaj created_on is called created_at and current_journal changed - so
@ -74,8 +74,8 @@ describe Burndown do
:tracker => tracker_feature,
:status => issue_open,
:priority => issue_priority,
:created_on => Date.today - 20.days,
:updated_on => Date.today - 20.days)
:created_at => Date.today - 20.days,
:updated_at => Date.today - 20.days)
end
describe "WITH the story having a time_remaining defined on creation" do
@ -166,13 +166,13 @@ describe Burndown do
:remaining_hours => 18,
:parent_issue_id => @story.id,
:priority => issue_priority,
:created_on => Date.today - 20.days,
:updated_on => Date.today - 20.days)
:created_at => Date.today - 20.days,
:updated_at => Date.today - 20.days)
end
describe "WITH the subticket being created within the sprint" do
before(:each) do
@task.created_on = Time.now - 4.days
@task.created_at = Time.now - 4.days
@task.save!
@burndown = Burndown.new(sprint, project)
@ -243,8 +243,8 @@ describe Burndown do
:tracker => tracker_feature,
:status => issue_open,
:priority => issue_priority,
:created_on => Date.today - (20 - i).days,
:updated_on => Date.today - (20 - i).days)
:created_at => Date.today - (20 - i).days,
:updated_at => Date.today - (20 - i).days)
end
end

Loading…
Cancel
Save