2929require "spec_helper"
3030
3131RSpec . describe Burndown do
32- def set_attribute_journalized ( story , attribute , value , day )
33- story . reload
34- story . send ( attribute , value )
35- story . save!
36- story . journals [ -2 ] . update_columns ( validity_period : story . journals [ -2 ] . created_at ...day ) if story . journals . count > 1
37- story . journals [ -1 ] . update_columns ( created_at : day , updated_at : day , validity_period : day ..Float ::INFINITY )
32+ def set_attribute_journalized ( work_package , attribute , value , day )
33+ work_package . reload
34+ work_package . send ( attribute , value )
35+ work_package . save!
36+ if work_package . journals . many?
37+ work_package . journals [ -2 ] . update_columns ( validity_period : work_package . journals [ -2 ] . created_at ...day )
38+ end
39+ work_package . journals [ -1 ] . update_columns ( created_at : day , updated_at : day , validity_period : day ..Float ::INFINITY )
3840 end
3941
4042 let ( :project ) { create ( :project ) }
@@ -87,29 +89,30 @@ def set_attribute_journalized(story, attribute, value, day)
8789 sprint . save!
8890 end
8991
90- describe "WITH 1 story assigned to the sprint" do
91- let ( :story ) do
92- build ( :story , subject : "Story 1" ,
93- project :,
94- sprint :,
95- type : type_feature ,
96- status : issue_open ,
97- priority : issue_priority ,
98- created_at : Time . zone . today - 20 . days ,
99- updated_at : Time . zone . today - 20 . days )
92+ describe "WITH 1 work_package assigned to the sprint" do
93+ let ( :work_package ) do
94+ build ( :work_package ,
95+ subject : "WorkPackage 1" ,
96+ project :,
97+ sprint :,
98+ type : type_feature ,
99+ status : issue_open ,
100+ priority : issue_priority ,
101+ created_at : Time . zone . today - 20 . days ,
102+ updated_at : Time . zone . today - 20 . days )
100103 end
101104
102- describe "WITH the story having story_point defined on creation" do
105+ describe "WITH the work_package having story_point defined on creation" do
103106 before do
104- story . story_points = 9
105- story . save!
106- story . last_journal . update_columns ( created_at : story . created_at , updated_at : story . created_at )
107+ work_package . story_points = 9
108+ work_package . save!
109+ work_package . last_journal . update_columns ( created_at : work_package . created_at , updated_at : work_package . created_at )
107110 end
108111
109- describe "WITH the story being closed and opened again within the sprint duration" do
112+ describe "WITH the work_package being closed and opened again within the sprint duration" do
110113 before do
111- set_attribute_journalized story , :status_id= , issue_closed . id , 6 . days . ago
112- set_attribute_journalized story , :status_id= , issue_open . id , 3 . days . ago
114+ set_attribute_journalized work_package , :status_id= , issue_closed . id , 6 . days . ago
115+ set_attribute_journalized work_package , :status_id= , issue_open . id , 3 . days . ago
113116 end
114117
115118 it { expect ( burndown . story_points ) . to eql [ 9.0 , 0.0 , 0.0 , 0.0 , 9.0 , 9.0 ] }
@@ -124,14 +127,13 @@ def set_attribute_journalized(story, attribute, value, day)
124127 it { expect ( burndown . story_points_ideal ) . to eql [ 9.0 , 8.0 , 7.0 , 6.0 , 5.0 , 4.0 , 3.0 , 2.0 , 1.0 , 0.0 ] }
125128 end
126129
127- describe "WITH the story marked as resolved and consequently 'done'" do
130+ describe "WITH the work_package marked as resolved and consequently 'done'" do
128131 before do
129- set_attribute_journalized story , :status_id= , issue_resolved . id , 6 . days . ago
130- set_attribute_journalized story , :status_id= , issue_open . id , 3 . days . ago
132+ set_attribute_journalized work_package , :status_id= , issue_resolved . id , 6 . days . ago
133+ set_attribute_journalized work_package , :status_id= , issue_open . id , 3 . days . ago
131134 project . done_statuses << issue_resolved
132135 end
133136
134- it { expect ( story . done? ) . to be false }
135137 it { expect ( burndown . story_points ) . to eql [ 9.0 , 0.0 , 0.0 , 0.0 , 9.0 , 9.0 ] }
136138 end
137139 end
@@ -142,14 +144,15 @@ def set_attribute_journalized(story, attribute, value, day)
142144 stories = [ ]
143145
144146 10 . times do |i |
145- stories [ i ] = create ( :story , subject : "Story #{ i } " ,
146- project :,
147- sprint :,
148- type : type_feature ,
149- status : issue_open ,
150- priority : issue_priority ,
151- created_at : Time . zone . today - ( 20 - i ) . days ,
152- updated_at : Time . zone . today - ( 20 - i ) . days )
147+ stories [ i ] = create ( :work_package ,
148+ subject : "WorkPackage #{ i } " ,
149+ project :,
150+ sprint :,
151+ type : type_feature ,
152+ status : issue_open ,
153+ priority : issue_priority ,
154+ created_at : Time . zone . today - ( 20 - i ) . days ,
155+ updated_at : Time . zone . today - ( 20 - i ) . days )
153156 stories [ i ] . last_journal . update_columns ( created_at : stories [ i ] . created_at ,
154157 updated_at : stories [ i ] . created_at ,
155158 validity_period : stories [ i ] . created_at ..Float ::INFINITY )
@@ -158,14 +161,14 @@ def set_attribute_journalized(story, attribute, value, day)
158161 stories
159162 end
160163
161- describe "WITH each story having story points defined at start" do
164+ describe "WITH each work_package having story points defined at start" do
162165 before do
163166 stories . each do |s |
164167 set_attribute_journalized s , :story_points= , 10 , sprint . start_date - 3 . days
165168 end
166169 end
167170
168- describe "WITH 5 stories having been reduced to 0 story points, one story per day" do
171+ describe "WITH 5 stories having been reduced to 0 story points, one work_package per day" do
169172 before do
170173 5 . times do |i |
171174 set_attribute_journalized stories [ i ] , :story_points= , nil , sprint . start_date + i . days + 1 . hour
@@ -192,10 +195,10 @@ def set_attribute_journalized(story, attribute, value, day)
192195
193196 context "without dates on the sprint" do
194197 let ( :sprint ) { create ( :sprint , project :, start_date : nil , finish_date : nil ) }
195- let ( :story ) do
196- build ( :story ,
198+ let ( :work_package ) do
199+ build ( :work_package ,
197200 :created_in_past ,
198- subject : "Story 1" ,
201+ subject : "WorkPackage 1" ,
199202 project :,
200203 sprint :,
201204 type : type_feature ,
0 commit comments