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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +39 -0
- data/CHANGELOG.md +20 -0
- data/Dockerfile +12 -0
- data/Gemfile +5 -0
- data/README.md +37 -13
- data/Rakefile +1 -0
- data/lib/thinreports/core/shape/image_block.rb +1 -1
- data/lib/thinreports/core/shape/list.rb +1 -1
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/text.rb +1 -1
- data/lib/thinreports/core/shape/text_block.rb +1 -1
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +6 -1
- data/lib/thinreports/core/shape/text_block/internal.rb +0 -2
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +6 -0
- data/lib/thinreports/layout/base.rb +1 -1
- data/lib/thinreports/layout/version.rb +1 -1
- data/lib/thinreports/report/internal.rb +2 -0
- data/lib/thinreports/version.rb +1 -1
- data/thinreports.gemspec +5 -9
- metadata +6 -204
- data/.travis.yml +0 -32
- data/test/data/font.ttf +0 -0
- data/test/data/image_normal.jpg +0 -0
- data/test/data/image_normal.png +0 -0
- data/test/data/image_normal_jpg_noext +0 -0
- data/test/data/image_normal_png_noext +0 -0
- data/test/data/image_pallete_based.png +0 -0
- data/test/data/legacy_layout/all-items.tlf +0 -1
- data/test/features/dynamic_style/expect.pdf +0 -3714
- data/test/features/dynamic_style/image.png +0 -0
- data/test/features/dynamic_style/templates/styles.tlf +0 -1835
- data/test/features/dynamic_style/templates/styles_in_list.tlf +0 -344
- data/test/features/dynamic_style/test_dynamic_style.rb +0 -152
- data/test/features/eudc/eudc.ttf +0 -0
- data/test/features/eudc/expect.pdf +0 -0
- data/test/features/eudc/template.tlf +0 -180
- data/test/features/eudc/test_eudc.rb +0 -27
- data/test/features/feature_test.rb +0 -58
- data/test/features/graphics/expect.pdf +0 -475
- data/test/features/graphics/template.tlf +0 -309
- data/test/features/graphics/test_graphics.rb +0 -12
- data/test/features/hidden_item/expect.pdf +0 -0
- data/test/features/hidden_item/template.tlf +0 -449
- data/test/features/hidden_item/test_hidden_item.rb +0 -12
- data/test/features/image_block/expect.pdf +0 -0
- data/test/features/image_block/img200x100.png +0 -0
- data/test/features/image_block/img50x50.png +0 -0
- data/test/features/image_block/template.tlf +0 -661
- data/test/features/image_block/test_image_block.rb +0 -35
- data/test/features/list_events/expect.pdf +0 -659
- data/test/features/list_events/template.tlf +0 -361
- data/test/features/list_events/test_list_events.rb +0 -36
- data/test/features/list_manually/expect.pdf +0 -599
- data/test/features/list_manually/template.tlf +0 -132
- data/test/features/list_manually/test_list_manually.rb +0 -25
- data/test/features/page_number/expect.pdf +0 -400
- data/test/features/page_number/template.tlf +0 -215
- data/test/features/page_number/test_page_number.rb +0 -24
- data/test/features/page_number_with_list/expect.pdf +0 -721
- data/test/features/page_number_with_list/template.tlf +0 -254
- data/test/features/page_number_with_list/test_page_number_with_list.rb +0 -21
- data/test/features/palleted_png/expect.pdf +0 -0
- data/test/features/palleted_png/palleted_png.png +0 -0
- data/test/features/palleted_png/template.tlf +0 -47
- data/test/features/palleted_png/test_palleted_png.rb +0 -14
- data/test/features/report_callbacks/expect.pdf +0 -169
- data/test/features/report_callbacks/template.tlf +0 -147
- data/test/features/report_callbacks/test_report_callbacks.rb +0 -18
- data/test/features/text_align/expect.pdf +0 -0
- data/test/features/text_align/template.tlf +0 -241
- data/test/features/text_align/test_text_align.rb +0 -12
- data/test/features/text_block_overflow/expect.pdf +0 -0
- data/test/features/text_block_overflow/template.tlf +0 -538
- data/test/features/text_block_overflow/test_text_block_overflow.rb +0 -25
- data/test/features/text_block_singleline/expect.pdf +0 -0
- data/test/features/text_block_singleline/template.tlf +0 -170
- data/test/features/text_block_singleline/test_text_block_singleline.rb +0 -15
- data/test/features/text_block_style/expect.pdf +0 -1391
- data/test/features/text_block_style/templates/basic_styles.tlf +0 -889
- data/test/features/text_block_style/templates/font_size.tlf +0 -383
- data/test/features/text_block_style/test_text_block_style.rb +0 -47
- data/test/features/text_character_spacing/expect.pdf +0 -0
- data/test/features/text_character_spacing/template.tlf +0 -293
- data/test/features/text_character_spacing/test_text_character_spacing.rb +0 -12
- data/test/features/text_word_wrap/expect.pdf +0 -0
- data/test/features/text_word_wrap/template.tlf +0 -297
- data/test/features/text_word_wrap/test_text_word_wrap.rb +0 -30
- data/test/schema_helper.rb +0 -122
- data/test/test_helper.rb +0 -39
- data/test/units/core/format/test_base.rb +0 -152
- data/test/units/core/shape/base/test_internal.rb +0 -87
- data/test/units/core/shape/basic/test_block_format.rb +0 -23
- data/test/units/core/shape/basic/test_block_interface.rb +0 -29
- data/test/units/core/shape/basic/test_block_internal.rb +0 -55
- data/test/units/core/shape/basic/test_format.rb +0 -37
- data/test/units/core/shape/basic/test_interface.rb +0 -108
- data/test/units/core/shape/basic/test_internal.rb +0 -55
- data/test/units/core/shape/image_block/test_interface.rb +0 -24
- data/test/units/core/shape/image_block/test_internal.rb +0 -31
- data/test/units/core/shape/list/test_format.rb +0 -111
- data/test/units/core/shape/list/test_manager.rb +0 -67
- data/test/units/core/shape/list/test_page.rb +0 -156
- data/test/units/core/shape/list/test_page_state.rb +0 -31
- data/test/units/core/shape/list/test_section_format.rb +0 -36
- data/test/units/core/shape/list/test_section_interface.rb +0 -75
- data/test/units/core/shape/list/test_section_internal.rb +0 -50
- data/test/units/core/shape/manager/test_format.rb +0 -38
- data/test/units/core/shape/manager/test_internal.rb +0 -132
- data/test/units/core/shape/manager/test_target.rb +0 -140
- data/test/units/core/shape/page_number/test_format.rb +0 -55
- data/test/units/core/shape/page_number/test_interface.rb +0 -33
- data/test/units/core/shape/page_number/test_internal.rb +0 -81
- data/test/units/core/shape/styles/test_base.rb +0 -191
- data/test/units/core/shape/styles/test_basic.rb +0 -24
- data/test/units/core/shape/styles/test_graphic.rb +0 -50
- data/test/units/core/shape/styles/test_text.rb +0 -97
- data/test/units/core/shape/text/test_format.rb +0 -44
- data/test/units/core/shape/text/test_internal.rb +0 -20
- data/test/units/core/shape/text_block/formatter/test_basic.rb +0 -24
- data/test/units/core/shape/text_block/formatter/test_datetime.rb +0 -49
- data/test/units/core/shape/text_block/formatter/test_number.rb +0 -76
- data/test/units/core/shape/text_block/formatter/test_padding.rb +0 -77
- data/test/units/core/shape/text_block/test_format.rb +0 -169
- data/test/units/core/shape/text_block/test_formatter.rb +0 -28
- data/test/units/core/shape/text_block/test_interface.rb +0 -63
- data/test/units/core/shape/text_block/test_internal.rb +0 -128
- data/test/units/core/test_shape.rb +0 -52
- data/test/units/core/test_utils.rb +0 -68
- data/test/units/generator/pdf/document/graphics/test_attributes.rb +0 -135
- data/test/units/generator/pdf/document/graphics/test_basic.rb +0 -46
- data/test/units/generator/pdf/document/graphics/test_image.rb +0 -46
- data/test/units/generator/pdf/document/graphics/test_text.rb +0 -171
- data/test/units/generator/pdf/document/test_font.rb +0 -110
- data/test/units/generator/pdf/document/test_graphics.rb +0 -42
- data/test/units/generator/pdf/document/test_page.rb +0 -122
- data/test/units/generator/pdf/document/test_parse_color.rb +0 -30
- data/test/units/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +0 -41
- data/test/units/generator/pdf/prawn_ext/test_width_of.rb +0 -22
- data/test/units/generator/pdf/test_document.rb +0 -22
- data/test/units/generator/test_pdf.rb +0 -26
- data/test/units/layout/test_base.rb +0 -41
- data/test/units/layout/test_format.rb +0 -100
- data/test/units/layout/test_legacy_schema.rb +0 -576
- data/test/units/layout/test_version.rb +0 -26
- data/test/units/report/test_base.rb +0 -248
- data/test/units/report/test_internal.rb +0 -206
- data/test/units/test_config.rb +0 -36
- data/test/units/test_layout.rb +0 -12
- 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
|