@@ -262,6 +262,46 @@ def pdf_strings_without_footers(nr_of_pages)
262262 expect ( strings ) . to eq ( expected_pdf_strings . join ( " " ) )
263263 end
264264 end
265+
266+ context "when grouped by target versions" , with_settings : { work_package_multiple_versions : true } do
267+ let! ( :version_two ) { create ( :version , project :, name : "2.0" ) }
268+ let! ( :version_one ) { create ( :version , project :, name : "1.0" ) }
269+ let ( :query_attributes ) { { group_by : "target_versions" } }
270+
271+ before do
272+ [ work_package_parent , work_package_child ] . each do |work_package |
273+ create ( :work_package_version , work_package :, version : version_two )
274+ create ( :work_package_version , work_package :, version : version_one )
275+ end
276+ end
277+
278+ it "writes work packages sharing the same target versions into a single group" do
279+ strings = pdf_strings_without_footers ( 1 )
280+ expect ( strings ) . to eq [
281+ query . name ,
282+ "2.0, 1.0" ,
283+ *column_titles ,
284+ *work_package_columns ( work_package_parent ) ,
285+ *work_package_columns ( work_package_child )
286+ ] . join ( " " )
287+ end
288+
289+ context "with sums" do
290+ let ( :query_attributes ) { { group_by : "target_versions" , display_sums : true } }
291+
292+ it "writes the group sums although the versions are ordered by name in the sums" do
293+ strings = pdf_strings_without_footers ( 1 )
294+ expect ( strings ) . to eq [
295+ query . name ,
296+ "2.0, 1.0" ,
297+ *column_titles ,
298+ *work_package_columns ( work_package_parent ) ,
299+ *work_package_columns ( work_package_child ) ,
300+ I18n . t ( "js.label_sum" ) , work_packages_sum . to_s , "38%"
301+ ] . join ( " " )
302+ end
303+ end
304+ end
265305 end
266306
267307 describe "grouped with sums" do
0 commit comments