Skip to content

Commit 0ef2cf6

Browse files
committed
add domain tests for OrderBoard and modified function signatures (flag to specify if we only want the hours for the active period, or for any time)
1 parent 33cb8a5 commit 0ef2cf6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/domain/plannings/order_board_test.rb

+22
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,18 @@ class OrderBoardTest < ActiveSupport::TestCase
117117
assert_equal 16, board.total_row_planned_hours(employees(:lucien).id, work_items(:hitobito_demo_app).id)
118118
end
119119

120+
test '#total_row_planned_hours includes plannings from only the active period if the respective flag is set' do
121+
create_plannings
122+
Planning.create!(work_item_id: work_items(:hitobito_demo_app).id,
123+
employee_id: employees(:lucien).id,
124+
date: date - 28.days,
125+
percent: 100)
126+
127+
board = Plannings::OrderBoard.new(order, period)
128+
129+
assert_equal 8, board.total_row_planned_hours(employees(:lucien).id, work_items(:hitobito_demo_app).id, true)
130+
end
131+
120132
test '#total_post_planned_hours includes plannings for all employees, even if only some are included' do
121133
create_plannings
122134
board = Plannings::OrderBoard.new(order, period)
@@ -144,6 +156,16 @@ class OrderBoardTest < ActiveSupport::TestCase
144156
assert_equal 24, board.total_planned_hours
145157
end
146158

159+
test '#total_planned_hours are calculated for entire timespan or only the active period, depending on the passed flag' do
160+
create_plannings
161+
162+
board = Plannings::OrderBoard.new(order, period)
163+
board.for_rows([[employees(:lucien).id, work_items(:hitobito_demo_app).id]])
164+
165+
assert_equal 24, board.total_planned_hours(false)
166+
assert_equal 20, board.total_planned_hours(true)
167+
end
168+
147169
private
148170

149171
def period

0 commit comments

Comments
 (0)