thinreports 0.10.3 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +39 -0
  3. data/CHANGELOG.md +20 -0
  4. data/Dockerfile +12 -0
  5. data/Gemfile +5 -0
  6. data/README.md +37 -13
  7. data/Rakefile +1 -0
  8. data/lib/thinreports/core/shape/image_block.rb +1 -1
  9. data/lib/thinreports/core/shape/list.rb +1 -1
  10. data/lib/thinreports/core/shape/page_number.rb +1 -1
  11. data/lib/thinreports/core/shape/text.rb +1 -1
  12. data/lib/thinreports/core/shape/text_block.rb +1 -1
  13. data/lib/thinreports/core/shape/text_block/formatter/number.rb +6 -1
  14. data/lib/thinreports/core/shape/text_block/internal.rb +0 -2
  15. data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +6 -0
  16. data/lib/thinreports/layout/base.rb +1 -1
  17. data/lib/thinreports/layout/version.rb +1 -1
  18. data/lib/thinreports/report/internal.rb +2 -0
  19. data/lib/thinreports/version.rb +1 -1
  20. data/thinreports.gemspec +5 -9
  21. metadata +6 -204
  22. data/.travis.yml +0 -32
  23. data/test/data/font.ttf +0 -0
  24. data/test/data/image_normal.jpg +0 -0
  25. data/test/data/image_normal.png +0 -0
  26. data/test/data/image_normal_jpg_noext +0 -0
  27. data/test/data/image_normal_png_noext +0 -0
  28. data/test/data/image_pallete_based.png +0 -0
  29. data/test/data/legacy_layout/all-items.tlf +0 -1
  30. data/test/features/dynamic_style/expect.pdf +0 -3714
  31. data/test/features/dynamic_style/image.png +0 -0
  32. data/test/features/dynamic_style/templates/styles.tlf +0 -1835
  33. data/test/features/dynamic_style/templates/styles_in_list.tlf +0 -344
  34. data/test/features/dynamic_style/test_dynamic_style.rb +0 -152
  35. data/test/features/eudc/eudc.ttf +0 -0
  36. data/test/features/eudc/expect.pdf +0 -0
  37. data/test/features/eudc/template.tlf +0 -180
  38. data/test/features/eudc/test_eudc.rb +0 -27
  39. data/test/features/feature_test.rb +0 -58
  40. data/test/features/graphics/expect.pdf +0 -475
  41. data/test/features/graphics/template.tlf +0 -309
  42. data/test/features/graphics/test_graphics.rb +0 -12
  43. data/test/features/hidden_item/expect.pdf +0 -0
  44. data/test/features/hidden_item/template.tlf +0 -449
  45. data/test/features/hidden_item/test_hidden_item.rb +0 -12
  46. data/test/features/image_block/expect.pdf +0 -0
  47. data/test/features/image_block/img200x100.png +0 -0
  48. data/test/features/image_block/img50x50.png +0 -0
  49. data/test/features/image_block/template.tlf +0 -661
  50. data/test/features/image_block/test_image_block.rb +0 -35
  51. data/test/features/list_events/expect.pdf +0 -659
  52. data/test/features/list_events/template.tlf +0 -361
  53. data/test/features/list_events/test_list_events.rb +0 -36
  54. data/test/features/list_manually/expect.pdf +0 -599
  55. data/test/features/list_manually/template.tlf +0 -132
  56. data/test/features/list_manually/test_list_manually.rb +0 -25
  57. data/test/features/page_number/expect.pdf +0 -400
  58. data/test/features/page_number/template.tlf +0 -215
  59. data/test/features/page_number/test_page_number.rb +0 -24
  60. data/test/features/page_number_with_list/expect.pdf +0 -721
  61. data/test/features/page_number_with_list/template.tlf +0 -254
  62. data/test/features/page_number_with_list/test_page_number_with_list.rb +0 -21
  63. data/test/features/palleted_png/expect.pdf +0 -0
  64. data/test/features/palleted_png/palleted_png.png +0 -0
  65. data/test/features/palleted_png/template.tlf +0 -47
  66. data/test/features/palleted_png/test_palleted_png.rb +0 -14
  67. data/test/features/report_callbacks/expect.pdf +0 -169
  68. data/test/features/report_callbacks/template.tlf +0 -147
  69. data/test/features/report_callbacks/test_report_callbacks.rb +0 -18
  70. data/test/features/text_align/expect.pdf +0 -0
  71. data/test/features/text_align/template.tlf +0 -241
  72. data/test/features/text_align/test_text_align.rb +0 -12
  73. data/test/features/text_block_overflow/expect.pdf +0 -0
  74. data/test/features/text_block_overflow/template.tlf +0 -538
  75. data/test/features/text_block_overflow/test_text_block_overflow.rb +0 -25
  76. data/test/features/text_block_singleline/expect.pdf +0 -0
  77. data/test/features/text_block_singleline/template.tlf +0 -170
  78. data/test/features/text_block_singleline/test_text_block_singleline.rb +0 -15
  79. data/test/features/text_block_style/expect.pdf +0 -1391
  80. data/test/features/text_block_style/templates/basic_styles.tlf +0 -889
  81. data/test/features/text_block_style/templates/font_size.tlf +0 -383
  82. data/test/features/text_block_style/test_text_block_style.rb +0 -47
  83. data/test/features/text_character_spacing/expect.pdf +0 -0
  84. data/test/features/text_character_spacing/template.tlf +0 -293
  85. data/test/features/text_character_spacing/test_text_character_spacing.rb +0 -12
  86. data/test/features/text_word_wrap/expect.pdf +0 -0
  87. data/test/features/text_word_wrap/template.tlf +0 -297
  88. data/test/features/text_word_wrap/test_text_word_wrap.rb +0 -30
  89. data/test/schema_helper.rb +0 -122
  90. data/test/test_helper.rb +0 -39
  91. data/test/units/core/format/test_base.rb +0 -152
  92. data/test/units/core/shape/base/test_internal.rb +0 -87
  93. data/test/units/core/shape/basic/test_block_format.rb +0 -23
  94. data/test/units/core/shape/basic/test_block_interface.rb +0 -29
  95. data/test/units/core/shape/basic/test_block_internal.rb +0 -55
  96. data/test/units/core/shape/basic/test_format.rb +0 -37
  97. data/test/units/core/shape/basic/test_interface.rb +0 -108
  98. data/test/units/core/shape/basic/test_internal.rb +0 -55
  99. data/test/units/core/shape/image_block/test_interface.rb +0 -24
  100. data/test/units/core/shape/image_block/test_internal.rb +0 -31
  101. data/test/units/core/shape/list/test_format.rb +0 -111
  102. data/test/units/core/shape/list/test_manager.rb +0 -67
  103. data/test/units/core/shape/list/test_page.rb +0 -156
  104. data/test/units/core/shape/list/test_page_state.rb +0 -31
  105. data/test/units/core/shape/list/test_section_format.rb +0 -36
  106. data/test/units/core/shape/list/test_section_interface.rb +0 -75
  107. data/test/units/core/shape/list/test_section_internal.rb +0 -50
  108. data/test/units/core/shape/manager/test_format.rb +0 -38
  109. data/test/units/core/shape/manager/test_internal.rb +0 -132
  110. data/test/units/core/shape/manager/test_target.rb +0 -140
  111. data/test/units/core/shape/page_number/test_format.rb +0 -55
  112. data/test/units/core/shape/page_number/test_interface.rb +0 -33
  113. data/test/units/core/shape/page_number/test_internal.rb +0 -81
  114. data/test/units/core/shape/styles/test_base.rb +0 -191
  115. data/test/units/core/shape/styles/test_basic.rb +0 -24
  116. data/test/units/core/shape/styles/test_graphic.rb +0 -50
  117. data/test/units/core/shape/styles/test_text.rb +0 -97
  118. data/test/units/core/shape/text/test_format.rb +0 -44
  119. data/test/units/core/shape/text/test_internal.rb +0 -20
  120. data/test/units/core/shape/text_block/formatter/test_basic.rb +0 -24
  121. data/test/units/core/shape/text_block/formatter/test_datetime.rb +0 -49
  122. data/test/units/core/shape/text_block/formatter/test_number.rb +0 -76
  123. data/test/units/core/shape/text_block/formatter/test_padding.rb +0 -77
  124. data/test/units/core/shape/text_block/test_format.rb +0 -169
  125. data/test/units/core/shape/text_block/test_formatter.rb +0 -28
  126. data/test/units/core/shape/text_block/test_interface.rb +0 -63
  127. data/test/units/core/shape/text_block/test_internal.rb +0 -128
  128. data/test/units/core/test_shape.rb +0 -52
  129. data/test/units/core/test_utils.rb +0 -68
  130. data/test/units/generator/pdf/document/graphics/test_attributes.rb +0 -135
  131. data/test/units/generator/pdf/document/graphics/test_basic.rb +0 -46
  132. data/test/units/generator/pdf/document/graphics/test_image.rb +0 -46
  133. data/test/units/generator/pdf/document/graphics/test_text.rb +0 -171
  134. data/test/units/generator/pdf/document/test_font.rb +0 -110
  135. data/test/units/generator/pdf/document/test_graphics.rb +0 -42
  136. data/test/units/generator/pdf/document/test_page.rb +0 -122
  137. data/test/units/generator/pdf/document/test_parse_color.rb +0 -30
  138. data/test/units/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +0 -41
  139. data/test/units/generator/pdf/prawn_ext/test_width_of.rb +0 -22
  140. data/test/units/generator/pdf/test_document.rb +0 -22
  141. data/test/units/generator/test_pdf.rb +0 -26
  142. data/test/units/layout/test_base.rb +0 -41
  143. data/test/units/layout/test_format.rb +0 -100
  144. data/test/units/layout/test_legacy_schema.rb +0 -576
  145. data/test/units/layout/test_version.rb +0 -26
  146. data/test/units/report/test_base.rb +0 -248
  147. data/test/units/report/test_internal.rb +0 -206
  148. data/test/units/test_config.rb +0 -36
  149. data/test/units/test_layout.rb +0 -12
  150. data/test/units/test_report.rb +0 -18
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class Thinreports::Layout::TestVersion < Minitest::Test
6
- include Thinreports::TestHelper
7
-
8
- # Alias
9
- Version = Thinreports::Layout::Version
10
-
11
- def test_compatible?
12
- Version.stubs(:compatible_rules).returns(['>= 0.8.0', '< 1.0.0'])
13
-
14
- assert Version.new('0.8.0').compatible?
15
- assert Version.new('0.9.9').compatible?
16
- assert Version.new('0.10.0').compatible?
17
-
18
- refute Version.new('0.7.9').compatible?
19
- refute Version.new('1.0.0').compatible?
20
- end
21
-
22
- def test_legacy?
23
- assert Version.new('0.8.9').legacy?
24
- refute Version.new('0.9.0').legacy?
25
- end
26
- end
@@ -1,248 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class Thinreports::Report::TestBase < Minitest::Test
6
- include Thinreports::TestHelper
7
-
8
- Report = Thinreports::Report
9
-
10
- def setup
11
- @report = Report::Base.new
12
- @layout_file = layout_file
13
- end
14
-
15
- def test_on_page_create_callback
16
- report = Report::Base.new layout: @layout_file.path
17
-
18
- counter = 0
19
- callback = -> page {
20
- assert_instance_of Report::Page, page
21
- counter += 1
22
- }
23
-
24
- report.on_page_create(&callback)
25
-
26
- 2.times { report.start_new_page }
27
- assert_equal counter, 2
28
- end
29
-
30
- def test_initialize_should_register_layout_as_default_when_layout_is_specified_as_the_option
31
- report = Report::Base.new layout: @layout_file.path
32
- assert_equal report.default_layout.filename, @layout_file.path
33
- end
34
-
35
- def test_initialize_should_initialize_new_Report_without_default_layout
36
- assert_nil @report.default_layout
37
- end
38
-
39
- def test_use_layout_should_register_default_layout_when_default_property_is_omitted
40
- @report.use_layout(@layout_file.path)
41
-
42
- assert_equal @report.default_layout.filename, @layout_file.path
43
- end
44
-
45
- def test_use_layout_should_register_default_layout_when_default_property_is_true
46
- @report.use_layout(@layout_file.path, default: true)
47
-
48
- assert_equal @report.default_layout.filename, @layout_file.path
49
- end
50
-
51
- def test_start_new_page_should_properly_create_a_new_Page_and_return
52
- @report.use_layout(@layout_file.path)
53
-
54
- assert_instance_of Thinreports::Report::Page, @report.start_new_page
55
- end
56
-
57
- def test_start_new_page_should_raise_when_the_layout_has_not_been_registered_yet
58
- assert_raises Thinreports::Errors::NoRegisteredLayoutFound do
59
- @report.start_new_page(layout: :unknown)
60
- end
61
- end
62
-
63
- def test_start_new_page_should_create_a_new_page_using_a_default_layout
64
- @report.use_layout(@layout_file.path, default: true)
65
-
66
- assert_equal @report.start_new_page.layout.filename, @layout_file.path
67
- end
68
-
69
- def test_start_new_page_should_create_a_new_page_using_a_layout_with_specified_id
70
- @report.use_layout(@layout_file.path, id: :foo)
71
-
72
- assert_equal @report.start_new_page(layout: :foo).layout.filename,
73
- @layout_file.path
74
- end
75
-
76
- def test_start_new_page_should_create_a_new_page_using_a_specified_layoutfile
77
- new_page = @report.start_new_page(layout: @layout_file.path)
78
- assert_equal new_page.layout.filename, @layout_file.path
79
- end
80
-
81
- def test_start_new_page_with_count_option
82
- @report.use_layout @layout_file.path, default: true
83
-
84
- new_page = @report.start_new_page count: false
85
- assert_nil new_page.no
86
- assert_equal @report.page_count, 0
87
-
88
- new_page = @report.start_new_page count: true
89
- assert_equal new_page.no, 1
90
- assert_equal @report.page_count, 1
91
-
92
- new_page = @report.start_new_page
93
- assert_equal new_page.no, 2
94
- assert_equal @report.page_count, 2
95
- end
96
-
97
- def test_add_blank_page_should_properly_create_a_new_blank_page
98
- @report.use_layout(@layout_file.path)
99
-
100
- assert_instance_of Thinreports::Report::BlankPage, @report.add_blank_page
101
- end
102
-
103
- def test_layout_should_return_the_default_layout_with_no_arguments
104
- @report.use_layout(@layout_file.path, default: true)
105
-
106
- assert_equal @report.layout.filename, @layout_file.path
107
- end
108
-
109
- def test_layout_should_raise_when_the_specified_layout_is_not_found
110
- assert_raises Thinreports::Errors::UnknownLayoutId do
111
- @report.layout(:unknown_layout_id)
112
- end
113
- end
114
-
115
- def test_layout_should_return_the_layout_with_specified_id
116
- @report.use_layout(@layout_file.path, id: :foo)
117
-
118
- assert_equal @report.layout(:foo).filename, @layout_file.path
119
- end
120
-
121
- def test_generate
122
- report = Report::Base.new(layout: @layout_file.path)
123
-
124
- generator = mock('generator')
125
- generator.expects(:generate).with('result.pdf')
126
-
127
- Thinreports::Generator::PDF.expects(:new)
128
- .with(report, { security: { owner_password: 'pass' }})
129
- .returns(generator)
130
-
131
- report.generate(
132
- filename: 'result.pdf',
133
- security: { owner_password: 'pass' }
134
- )
135
- end
136
-
137
- def test_page_should_return_the_current_page
138
- @report.use_layout(@layout_file.path)
139
- @report.start_new_page
140
-
141
- assert_instance_of Thinreports::Report::Page, @report.page
142
- end
143
-
144
- def test_page_count_should_return_total_page_count
145
- @report.use_layout(@layout_file.path)
146
- 2.times { @report.start_new_page }
147
-
148
- assert_equal @report.page_count, 2
149
- end
150
-
151
- def test_finalize_should_finalize_report
152
- @report.finalize
153
- assert_equal @report.finalized?, true
154
- end
155
-
156
- def test_finalized_asker_should_return_false_when_report_has_not_been_finalized_yet
157
- assert_equal @report.finalized?, false
158
- end
159
-
160
- def test_finalized_asker_should_return_true_when_report_is_already_finalized
161
- @report.finalize
162
- assert_equal @report.finalized?, true
163
- end
164
-
165
- def test_list_should_create_new_page_when_page_is_not_created
166
- @report.use_layout(@layout_file.path)
167
- @report.list
168
-
169
- refute_nil @report.page
170
- end
171
-
172
- def test_list_should_create_new_page_when_page_is_finalized
173
- @report.tap do |r|
174
- r.use_layout(@layout_file.path)
175
- r.start_new_page
176
- r.page.finalize
177
- end
178
- @report.list
179
-
180
- assert_equal @report.page.finalized?, false
181
- end
182
-
183
- def test_list_should_properly_return_shape_with_the_specified_id
184
- @report.use_layout(@layout_file.path)
185
-
186
- assert_equal @report.list.id, 'default'
187
- end
188
-
189
- def test_start_page_number
190
- assert_equal @report.start_page_number, 1
191
- @report.start_page_number_from 10
192
- assert_equal @report.start_page_number, 10
193
- end
194
-
195
- def test_Base_create_should_finalize_report
196
- report = Report::Base.create do |r|
197
- assert_instance_of Report::Base, r
198
- end
199
- assert_equal report.finalized?, true
200
- end
201
-
202
- def test_Base_create_should_raise_when_no_block_given
203
- assert_raises ArgumentError do
204
- Report::Base.create
205
- end
206
- end
207
-
208
- def test_Base_generate_should_raise_when_no_block_given
209
- assert_raises ArgumentError do
210
- Report::Base.generate(:pdf)
211
- end
212
- end
213
-
214
- def test_Base_generate_with_deprecated_arguments
215
- Report::Base.expects(:create).with(layout: '/path/to/layout.tlf').returns(@report)
216
- @report.expects(:generate).with(
217
- filename: 'result.pdf',
218
- security: { owner_password: 'pass' }
219
- )
220
-
221
- Report::Base.generate(
222
- report: { layout: '/path/to/layout.tlf' },
223
- generator: {
224
- filename: 'result.pdf',
225
- security: { owner_password: 'pass' }
226
- }
227
- ) { |_| }
228
- end
229
-
230
- def test_Base_generate_argument_priority
231
- Report::Base.expects(:create).with(layout: '/path/to/layout.tlf').returns(@report)
232
- @report.expects(:generate).with(
233
- filename: 'result.pdf',
234
- security: { owner_password: 'pass' }
235
- )
236
-
237
- Report::Base.generate(
238
- layout: '/path/to/layout.tlf',
239
- filename: 'result.pdf',
240
- security: { owner_password: 'pass' },
241
- report: { layout: '/path/to/deprecated.tlf' },
242
- generator: {
243
- filename: 'deprecated.pdf',
244
- security: { owner_password: 'deprecated' }
245
- }
246
- ) { |_| }
247
- end
248
- end
@@ -1,206 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class Thinreports::Report::TestInternal < Minitest::Test
6
- include Thinreports::TestHelper
7
-
8
- Report = Thinreports::Report
9
-
10
- def setup
11
- @layout_file = layout_file
12
- end
13
-
14
- def report
15
- Report::Base.new
16
- end
17
-
18
- def test_layout_specified_in_new_method_should_be_defined_as_default_layout
19
- internal = Report::Internal.new(report, layout: @layout_file.path)
20
- assert_equal internal.default_layout.filename, @layout_file.path
21
- end
22
-
23
- def test_register_layout_should_be_set_as_default_layout_when_options_are_omitted
24
- internal = Report::Internal.new(report, {})
25
- internal.register_layout(@layout_file.path)
26
-
27
- assert_equal internal.default_layout.filename, @layout_file.path
28
- end
29
-
30
- def test_register_layout_should_be_set_as_default_layout_when_default_option_is_true
31
- internal = Report::Internal.new(report, {})
32
- internal.register_layout(@layout_file.path, default: true)
33
-
34
- assert_equal internal.default_layout.filename, @layout_file.path
35
- end
36
-
37
- def test_register_layout_should_be_able_to_change_the_default_layout
38
- internal = Report::Internal.new(report, layout: @layout_file.path)
39
- internal.register_layout(@layout_file.path, default: true)
40
-
41
- assert_equal internal.default_layout.filename, @layout_file.path
42
- end
43
-
44
- def test_register_layout_should_be_set_as_with_id_when_id_option_is_set
45
- internal = Report::Internal.new(report, {})
46
- internal.register_layout(@layout_file.path, id: :foo)
47
-
48
- assert_equal internal.layout_registry[:foo].filename, @layout_file.path
49
- end
50
-
51
- def test_register_layout_should_raise_an_error_when_id_is_already_registered
52
- internal = Report::Internal.new(report, {})
53
- internal.register_layout(@layout_file.path, id: :foo)
54
-
55
- assert_raises ArgumentError do
56
- internal.register_layout(@layout_file.path, id: :foo)
57
- end
58
- end
59
-
60
- def test_add_page_should_finalize_the_current_page
61
- layout = Thinreports::Layout.new(@layout_file.path)
62
-
63
- internal = Report::Internal.new(report, layout: @layout_file.path)
64
- page = internal.add_page(Thinreports::Report::Page.new(report, layout))
65
- internal.add_page(Thinreports::Report::Page.new(report, layout))
66
-
67
- assert_equal page.finalized?, true
68
- end
69
-
70
- def test_add_page_should_return_the_current_page
71
- layout = Thinreports::Layout.new(@layout_file.path)
72
- new_page = Thinreports::Report::Page.new(report, layout)
73
-
74
- internal = Report::Internal.new(report, layout: @layout_file.path)
75
-
76
- assert_same new_page, internal.add_page(new_page)
77
- end
78
-
79
- def test_add_page_should_add_the_initialized_page
80
- layout = Thinreports::Layout.new(@layout_file.path)
81
- new_page = Thinreports::Report::Page.new(report, layout)
82
-
83
- internal = Report::Internal.new(report, layout: @layout_file.path)
84
- internal.add_page(new_page)
85
-
86
- assert_same new_page, internal.pages.last
87
- end
88
-
89
- def test_add_page_should_count_up_the_total_page_count
90
- layout = Thinreports::Layout.new(@layout_file.path)
91
-
92
- internal = Report::Internal.new(report, layout: @layout_file.path)
93
- internal.add_page(Thinreports::Report::Page.new(report, layout))
94
-
95
- assert_equal internal.page_count, 1
96
- end
97
-
98
- def test_add_page_should_switch_to_a_reference_to_the_current_page
99
- layout = Thinreports::Layout.new(@layout_file.path)
100
- new_pages = (1..2).inject([]) do |pages|
101
- pages << Thinreports::Report::Page.new(report, layout)
102
- end
103
-
104
- internal = Report::Internal.new(report, layout: @layout_file.path)
105
- internal.add_page(new_pages[0])
106
-
107
- assert_same internal.page, new_pages[0]
108
-
109
- internal.add_page(new_pages[1])
110
-
111
- assert_same internal.page, new_pages[1]
112
- end
113
-
114
- def test_add_blank_page_should_not_count_up_the_total_page_count_when_count_is_disabled
115
- internal = Report::Internal.new(report, layout: @layout_file.path)
116
- internal.add_page(Thinreports::Report::BlankPage.new(false))
117
-
118
- assert_equal internal.page_count, 0
119
- end
120
-
121
- def test_add_blank_page_should_count_up_the_total_page_count_when_count_is_enabled
122
- internal = Report::Internal.new(report, layout: @layout_file.path)
123
- internal.add_page(Thinreports::Report::BlankPage.new)
124
-
125
- assert_equal internal.page_count, 1
126
- end
127
-
128
- def test_finalize_should_finalize_the_report
129
- internal = Report::Internal.new(report, layout: @layout_file.path)
130
- internal.finalize
131
-
132
- assert internal.finalized?
133
- end
134
-
135
- def test_finalize_should_not_work_when_report_is_already_finalized
136
- internal = Report::Internal.new(report, layout: @layout_file.path)
137
- internal.finalize
138
-
139
- # #finalize_current_page must never be called
140
- internal.expects(:finalize_current_page).never
141
- internal.finalize
142
- end
143
-
144
- def test_finalized_should_return_true_when_report_is_already_finalized
145
- internal = Report::Internal.new(report, layout: @layout_file.path)
146
- internal.finalize
147
-
148
- assert internal.finalized?
149
- end
150
-
151
- def test_load_layout_with_String
152
- internal = Report::Internal.new(report, layout: @layout_file.path)
153
-
154
- assert_equal internal.load_layout(@layout_file.path).filename,
155
- @layout_file.path
156
- end
157
-
158
- def test_load_layout_with_id
159
- internal = Report::Internal.new(report, {})
160
- internal.register_layout(@layout_file.path, id: :sample)
161
-
162
- assert_equal internal.load_layout(:sample).filename,
163
- @layout_file.path
164
- end
165
-
166
- def test_load_layout_with_unknown_id
167
- internal = Report::Internal.new(report, {})
168
- assert_nil internal.load_layout(:unknown)
169
- end
170
-
171
- def test_load_layout_should_set_default_layout_when_default_layout_is_nil
172
- internal = Report::Internal.new(report, {})
173
- internal.load_layout(@layout_file.path)
174
-
175
- assert_equal internal.default_layout.filename,
176
- @layout_file.path
177
- end
178
-
179
- def test_load_layout_should_raise_error_when_invalid_value_set
180
- internal = Report::Internal.new(report, {})
181
-
182
- assert_raises Thinreports::Errors::LayoutFileNotFound do
183
- internal.load_layout('/path/to/unkown.tlf')
184
- end
185
- end
186
-
187
- def test_copy_page_should_finalize_current_page
188
- layout = Thinreports::Layout.new(@layout_file.path)
189
-
190
- internal = Report::Internal.new(report, layout: @layout_file.path)
191
- internal.add_page(page = Thinreports::Report::Page.new(report, layout))
192
- internal.copy_page
193
-
194
- assert page.finalized?
195
- end
196
-
197
- def test_copy_page_should_add_the_copied_page
198
- layout = Thinreports::Layout.new(@layout_file.path)
199
-
200
- internal = Report::Internal.new(report, layout: @layout_file.path)
201
- internal.add_page(Thinreports::Report::Page.new(report, layout))
202
- internal.copy_page
203
-
204
- assert_equal internal.page_count, 2
205
- end
206
- end