ACK – Patch seems good.
--
Benjamin LAN-SUN-LUK
Le 07/04/09 03:50, « Darryl L. Pierce » <mcpierce@gmail.com> a écrit :
THIS PATCH REQUIRES A MIGRATION.
Introduces the new Epic class with unit tests.
Signed-off-by: Darryl L. Pierce <mcpierce@gmail.com>
---
app/models/epic.rb | 34 +++++++++
db/migrate/029_create_epics.rb | 35 +++++++++
.../030_user_stories_reference_project_epics.rb | 29 ++++++++
doc/ChangeLog | 2 +
test/fixtures/epics.yml | 4 +
test/unit/epic_test.rb | 74 ++++++++++++++++++++
6 files changed, 178 insertions(+), 0 deletions(-)
create mode 100644 app/models/epic.rb
create mode 100644 db/migrate/029_create_epics.rb
create mode 100644 db/migrate/030_user_stories_reference_project_epics.rb
create mode 100644 test/fixtures/epics.yml
create mode 100644 test/unit/epic_test.rb
diff --git a/app/models/epic.rb b/app/models/epic.rb
new file mode 100644
index 0000000..6763cae
--- /dev/null
+++ b/app/models/epic.rb
@@ -0,0 +1,34 @@
+# epic.rb
+# Copyright (C) 2009, Darryl L. Pierce <mcpierce@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+# An +Epic+ represents a project-level user story, one that is an overarching feature.
+# An epic is a feature that is implemented by many individual user stories or
+# in more than one product.
+class Epic < ActiveRecord::Base
+ belongs_to :project
+ validates_presence_of :project_id,
+ :message => "A project must be specified."
+
+ validates_presence_of :priority,
+ :message => "A priority must be provided."
+ validates_numericality_of :priority,
+ :message => "Priority must be a positive integer value.",
+ :only_integer => true,
+ :greater_than => 0
+
+ validates_presence_of :title
+end
diff --git a/db/migrate/029_create_epics.rb b/db/migrate/029_create_epics.rb
new file mode 100644
index 0000000..1d04545
--- /dev/null
+++ b/db/migrate/029_create_epics.rb
@@ -0,0 +1,35 @@
+# 029_create_epics.rb
+# Copyright (C) 2009, Darryl L. Pierce <mcpierce@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+class CreateEpics < ActiveRecord::Migration
+ def self.up
+ create_table :epics do |t|
+ t.integer :project_id, :null => false
+ t.integer :priority, :null => false
+ t.boolean :closed, :null => false, :default => false
+ t.string :title, :null => false, :limit => 100
+ t.text :description
+ end
+
+ execute 'alter table epics add constraint fk_epic_project
+ foreign key (project_id) references projects(id)'
+ end
+
+ def self.down
+ drop_table :epics
+ end
+end
diff --git a/db/migrate/030_user_stories_reference_project_epics.rb b/db/migrate/030_user_stories_reference_project_epics.rb
new file mode 100644
index 0000000..6aadc55
--- /dev/null
+++ b/db/migrate/030_user_stories_reference_project_epics.rb
@@ -0,0 +1,29 @@
+# 030_user_stories_reference_project_epics.rb
+# Copyright (C) 2009, Darryl L. Pierce <mcpierce@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+class UserStoriesReferenceProjectEpics < ActiveRecord::Migration
+ def self.up
+ add_column :user_stories, :epic_id, :integer, :null => true
+
+ execute 'alter table user_stories add constraint fk_user_story_epic
+ foreign key (epic_id) references epics(id)'
+ end
+
+ def self.down
+ remove_column :user_stories, :epic_id
+ end
+end
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 35af777..4515634 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -3,6 +3,8 @@ Change Log (0.2.0):
* #98 - Admins can approve projects.
* #99 - Sprints can have team leads.
* #100 - Team leads can reopen items.
+ * #103 - Projects can have epic stories.
+ * #104 - User stories can be associated with project epics.
* #105 - Users can select another sprint from the sprint details page.
* #106 - Task descriptions can have wiki markup.
* #107 - User story descriptions can have wiki markup.
diff --git a/test/fixtures/epics.yml b/test/fixtures/epics.yml
new file mode 100644
index 0000000..492bf61
--- /dev/null
+++ b/test/fixtures/epics.yml
@@ -0,0 +1,4 @@
+user_stories:
+ project_id: <%= Fixtures.identify(:projxp) %>
+ priority: 1
+ title: User stories capture individual features.
diff --git a/test/unit/epic_test.rb b/test/unit/epic_test.rb
new file mode 100644
index 0000000..f79edc4
--- /dev/null
+++ b/test/unit/epic_test.rb
@@ -0,0 +1,74 @@
+# user_story_test.rb
+# Copyright (C) 2008, Darryl L. Pierce <mcpierce@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class EpicTest < ActiveSupport::TestCase
+ fixtures :projects
+
+ def setup
+ @project = projects(:projxp)
+ @new_epic = Epic.new(:project => @project, :priority => 1, :title => "This is an epic")
+ end
+
+ # Ensures the project_id field is required.
+ def test_valid_fails_without_project_id
+ @new_epic.project = nil
+ fail "Project must be required for an epic." if @new_epic.valid?
+ end
+
+ # Ensures that a priority is required.
+ def test_valid_fails_without_priority
+ @new_epic.priority = nil
+ fail "Priority must be required for an epic." if @new_epic.valid?
+ end
+
+ # Ensures that priority is a number.
+ def test_valid_fails_with_nonnumeric_priority
+ @new_epic.priority = 'a'
+ fail "Priority must be a number." if @new_epic.valid?
+ end
+
+ # Ensures that a priority must be a positive integer.
+ def test_valid_fails_with_negative_integer_priority
+ @new_epic.priority = -1
+ fail "Priority cannot be negative." if @new_epic.valid?
+ end
+
+ # Ensures that a priority cannot be 0.
+ def test_valid_fails_with_zero_priority
+ @new_epic.priority = 0
+ fail "Priority cannot be zero." if @new_epic.valid?
+ end
+
+ # Ensures that a title is required.
+ def test_valid_fails_without_title
+ @new_epic.title = nil
+ fail "A title must be provided." if @new_epic.valid?
+ end
+
+ # Ensures that a title cannot be an empty string.
+ def test_valid_fails_with_empty_title
+ @new_epic.title = ""
+ fail "A title cannot be 0 bytes long." if @new_epic.valid?
+ end
+
+ # Ensures that a well-formed epic is valid.
+ def test_valid
+ fail "There is a general problect with validation." unless @new_epic.valid?
+ end
+end
--
1.6.0.6
_______________________________________________
projxp-devel mailing list
projxp-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/projxp-devel