htmlgrid 1.1.6 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TooltipDialog.txt +73 -0
- data/interaction_no_inline.txt +1216 -0
- data/lib/htmlgrid/booleanvalue.rb +14 -14
- data/lib/htmlgrid/button.rb +9 -9
- data/lib/htmlgrid/centeredcomposite.rb +21 -20
- data/lib/htmlgrid/component.rb +214 -197
- data/lib/htmlgrid/composite.rb +332 -301
- data/lib/htmlgrid/datevalue.rb +12 -12
- data/lib/htmlgrid/div.rb +9 -9
- data/lib/htmlgrid/divcomposite.rb +44 -43
- data/lib/htmlgrid/divform.rb +8 -8
- data/lib/htmlgrid/divlist.rb +17 -19
- data/lib/htmlgrid/divtemplate.rb +6 -6
- data/lib/htmlgrid/dojotoolkit.rb +86 -53
- data/lib/htmlgrid/errormessage.rb +47 -43
- data/lib/htmlgrid/form.rb +70 -62
- data/lib/htmlgrid/formlist.rb +14 -14
- data/lib/htmlgrid/grid.rb +111 -67
- data/lib/htmlgrid/image.rb +17 -16
- data/lib/htmlgrid/infomessage.rb +15 -14
- data/lib/htmlgrid/input.rb +34 -32
- data/lib/htmlgrid/inputcheckbox.rb +13 -13
- data/lib/htmlgrid/inputcurrency.rb +9 -9
- data/lib/htmlgrid/inputdate.rb +11 -11
- data/lib/htmlgrid/inputfile.rb +13 -12
- data/lib/htmlgrid/inputradio.rb +9 -9
- data/lib/htmlgrid/inputtext.rb +10 -10
- data/lib/htmlgrid/javascript.rb +17 -16
- data/lib/htmlgrid/label.rb +53 -49
- data/lib/htmlgrid/labeltext.rb +8 -8
- data/lib/htmlgrid/link.rb +31 -27
- data/lib/htmlgrid/list.rb +121 -110
- data/lib/htmlgrid/namedcomponent.rb +28 -25
- data/lib/htmlgrid/pass.rb +11 -11
- data/lib/htmlgrid/passthru.rb +20 -17
- data/lib/htmlgrid/popuplink.rb +41 -39
- data/lib/htmlgrid/reset.rb +8 -8
- data/lib/htmlgrid/richtext.rb +22 -20
- data/lib/htmlgrid/select.rb +28 -26
- data/lib/htmlgrid/span.rb +9 -9
- data/lib/htmlgrid/spancomposite.rb +18 -18
- data/lib/htmlgrid/spanlist.rb +9 -9
- data/lib/htmlgrid/staticinput.rb +14 -13
- data/lib/htmlgrid/submit.rb +9 -9
- data/lib/htmlgrid/template.rb +124 -112
- data/lib/htmlgrid/text.rb +9 -9
- data/lib/htmlgrid/textarea.rb +19 -17
- data/lib/htmlgrid/ulcomposite.rb +22 -22
- data/lib/htmlgrid/ullist.rb +9 -9
- data/lib/htmlgrid/urllink.rb +38 -36
- data/lib/htmlgrid/value.rb +9 -9
- data/lib/htmlgrid/version.rb +2 -2
- data/test/stub/cgi.rb +10 -7
- data/test/suite.rb +3 -3
- data/test/test_add_row.rb +12 -13
- data/test/test_component.rb +141 -91
- data/test/test_composite.rb +85 -46
- data/test/test_datevalue.rb +28 -24
- data/test/test_divlist.rb +126 -0
- data/test/test_dojotoolkit.rb +41 -26
- data/test/test_form.rb +89 -73
- data/test/test_formlist.rb +77 -65
- data/test/test_grid.rb +256 -208
- data/test/test_input.rb +37 -31
- data/test/test_interaction_list.rb +106 -70
- data/test/test_label.rb +91 -77
- data/test/test_list.rb +110 -95
- data/test/test_select.rb +35 -30
- data/test/test_template.rb +66 -55
- data/test/test_text.rb +36 -31
- metadata +20 -3
data/lib/htmlgrid/value.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
|
3
3
|
#
|
4
4
|
# HtmlGrid -- HyperTextMarkupLanguage Framework
|
5
5
|
# Copyright (C) 2003 ywesee - intellectual capital connected
|
@@ -22,15 +22,15 @@
|
|
22
22
|
# ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
|
23
23
|
# htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
|
24
24
|
#
|
25
|
-
# Value -- htmlgrid -- 19.11.2002 -- hwyss@ywesee.com
|
25
|
+
# Value -- htmlgrid -- 19.11.2002 -- hwyss@ywesee.com
|
26
26
|
|
27
|
-
require
|
27
|
+
require "htmlgrid/namedcomponent"
|
28
28
|
|
29
29
|
module HtmlGrid
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
class Value < NamedComponent
|
31
|
+
LABEL = true
|
32
|
+
def init
|
33
|
+
@value = @model.send(@name) if @model.respond_to?(@name)
|
34
|
+
end
|
35
|
+
end
|
36
36
|
end
|
data/lib/htmlgrid/version.rb
CHANGED
data/test/stub/cgi.rb
CHANGED
@@ -21,23 +21,26 @@
|
|
21
21
|
# ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
|
22
22
|
# htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
|
23
23
|
#
|
24
|
-
# CGI -- htmlgrid -- hwyss@ywesee.com
|
24
|
+
# CGI -- htmlgrid -- hwyss@ywesee.com
|
25
25
|
|
26
|
-
require
|
26
|
+
require "cgi"
|
27
27
|
|
28
28
|
class CGI
|
29
29
|
attr_accessor :params
|
30
|
-
|
31
|
-
def initialize throwaway=nil
|
32
|
-
|
33
|
-
|
30
|
+
alias_method :old_initialize, :initialize
|
31
|
+
def initialize throwaway = nil
|
32
|
+
ARGV.push("")
|
33
|
+
old_initialize("html4")
|
34
34
|
end
|
35
|
+
|
35
36
|
def cookies
|
36
37
|
{}
|
37
38
|
end
|
39
|
+
|
38
40
|
def []key
|
39
|
-
@params[key]
|
41
|
+
@params[key]
|
40
42
|
end
|
43
|
+
|
41
44
|
def []=key, value
|
42
45
|
@params[key] = value
|
43
46
|
end
|
data/test/suite.rb
CHANGED
@@ -21,10 +21,10 @@
|
|
21
21
|
# ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
|
22
22
|
# htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
|
23
23
|
#
|
24
|
-
# suite.rb -- htmlgrid -- 20.11.2002 -- hwyss@ywesee.com
|
24
|
+
# suite.rb -- htmlgrid -- 20.11.2002 -- hwyss@ywesee.com
|
25
25
|
|
26
|
-
$: <<
|
26
|
+
$: << __dir__
|
27
27
|
|
28
28
|
Dir.foreach(File.dirname(__FILE__)) { |file|
|
29
|
-
|
29
|
+
require file if /^test_.*\.rb$/o.match?(file)
|
30
30
|
}
|
data/test/test_add_row.rb
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$: << File.expand_path('../lib', File.dirname(__FILE__))
|
2
|
+
$: << File.expand_path("../lib", File.dirname(__FILE__))
|
4
3
|
$: << File.dirname(__FILE__)
|
5
4
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
5
|
+
require "minitest/autorun"
|
6
|
+
require "stub/cgi"
|
7
|
+
require "htmlgrid/composite"
|
8
|
+
require "htmlgrid/inputtext"
|
9
|
+
require "htmlgrid/form"
|
11
10
|
|
12
11
|
module RowTest
|
13
12
|
class StubComposite < HtmlGrid::Composite
|
14
13
|
attr_writer :container
|
15
14
|
COMPONENTS = {
|
16
|
-
[0, 0, 1] => :foo
|
15
|
+
[0, 0, 1] => :foo
|
17
16
|
}
|
18
17
|
LABELS = true
|
19
18
|
SYMBOL_MAP = {
|
20
|
-
:
|
19
|
+
bar: HtmlGrid::InputText
|
21
20
|
}
|
22
21
|
attr_reader :model, :session
|
23
22
|
public :resolve_offset, :labels?
|
24
23
|
|
25
24
|
def init
|
26
|
-
@barcount=0
|
25
|
+
@barcount = 0
|
27
26
|
super
|
28
27
|
end
|
29
28
|
|
@@ -31,7 +30,7 @@ module RowTest
|
|
31
30
|
1.upto(2).each { |idx|
|
32
31
|
@grid.add(baz(model), 0, idx, 0)
|
33
32
|
}
|
34
|
-
|
33
|
+
"Foo"
|
35
34
|
end
|
36
35
|
|
37
36
|
private
|
@@ -55,7 +54,7 @@ module RowTest
|
|
55
54
|
end
|
56
55
|
|
57
56
|
def base_url
|
58
|
-
|
57
|
+
"http://www.oddb.org/de/gcc"
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
@@ -84,7 +83,7 @@ module RowTest
|
|
84
83
|
end
|
85
84
|
|
86
85
|
def test_to_html
|
87
|
-
assert_equal(<<-EXP.gsub(/\n|^\s*/,
|
86
|
+
assert_equal(<<-EXP.gsub(/\n|^\s*/, ""), @composite.to_html(CGI.new))
|
88
87
|
<TABLE cellspacing="0">
|
89
88
|
<TR><TD>Foo</TD></TR><TR><TD>Baz1</TD></TR><TR><TD>Baz2</TD></TR>
|
90
89
|
</TABLE>
|
data/test/test_component.rb
CHANGED
@@ -27,9 +27,9 @@ $: << File.expand_path("../lib", File.dirname(__FILE__))
|
|
27
27
|
$: << File.expand_path("../ext", File.dirname(__FILE__))
|
28
28
|
$: << File.dirname(__FILE__)
|
29
29
|
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
30
|
+
require "minitest/autorun"
|
31
|
+
require "htmlgrid/component"
|
32
|
+
require "stub/cgi"
|
33
33
|
|
34
34
|
module HtmlGrid
|
35
35
|
class Component
|
@@ -38,110 +38,160 @@ module HtmlGrid
|
|
38
38
|
end
|
39
39
|
|
40
40
|
class TestComponent < Minitest::Test
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
41
|
+
STRING_WITH_SHARP = "Test_#_gartenhat"
|
42
|
+
STRING_WITH_PLUS = "Test_+_plus"
|
43
|
+
STRING_WITH_UMLAUT = "Test_with_Umlaut_üé"
|
44
|
+
class StubAttributeComponent < HtmlGrid::Component
|
45
|
+
HTML_ATTRIBUTES = {"key" => "val"}
|
46
|
+
end
|
47
|
+
|
48
|
+
class StubInitComponent < HtmlGrid::Component
|
49
|
+
attr_reader :init_called
|
50
|
+
def init
|
51
|
+
@init_called = true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class StubLabelComponent < HtmlGrid::Component
|
56
|
+
LABEL = true
|
57
|
+
end
|
58
|
+
|
59
|
+
class StubContainer
|
60
|
+
attr_accessor :onsubmit
|
61
|
+
end
|
62
|
+
|
63
|
+
class ToHTMLreturnFrozen
|
64
|
+
def initialize content
|
65
|
+
@content = content
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_html(what)
|
69
|
+
@content.to_s.freeze
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def setup
|
74
|
+
@component = HtmlGrid::Component.new(nil, nil)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_initialize1
|
61
78
|
HtmlGrid::Component.new("foo", "bar")
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
79
|
+
comp = HtmlGrid::Component.new("foo", "bar")
|
80
|
+
assert_equal("foo", comp.model)
|
81
|
+
assert_equal("bar", comp.session)
|
82
|
+
assert_nil(comp.container)
|
83
|
+
assert_equal(false, comp.label?)
|
67
84
|
comp.label = true
|
68
|
-
|
69
|
-
|
70
|
-
|
85
|
+
assert_equal(true, comp.label?)
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_initialize2
|
71
89
|
HtmlGrid::Component.new("foo", "bar", "baz")
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
90
|
+
comp = HtmlGrid::Component.new("foo", "bar", "baz")
|
91
|
+
assert_equal("foo", comp.model)
|
92
|
+
assert_equal("bar", comp.session)
|
93
|
+
assert_equal("baz", comp.container)
|
94
|
+
end
|
95
|
+
|
77
96
|
def test_to_html
|
78
97
|
comp = HtmlGrid::Component.new("foo", "bar", "baz").to_html(CGI.new)
|
79
98
|
assert_equal("", comp)
|
80
99
|
end
|
100
|
+
|
101
|
+
# Next is test for https://github.com/zdavatz/oddb.org/issues/118 FrozenError at /de/just-medical
|
102
|
+
def test_to_html_frozen_empty
|
103
|
+
comp = HtmlGrid::Component.new("context")
|
104
|
+
comp.value = ToHTMLreturnFrozen.new("")
|
105
|
+
result = comp.to_html(CGI.new)
|
106
|
+
assert_equal("", result)
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_gartenhag_to_html
|
110
|
+
comp = HtmlGrid::Component.new("context")
|
111
|
+
comp.value = STRING_WITH_SHARP
|
112
|
+
result = comp.to_html(CGI.new)
|
113
|
+
assert_equal(STRING_WITH_SHARP, result)
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_minus_to_html
|
117
|
+
comp = HtmlGrid::Component.new("context")
|
118
|
+
comp.value = STRING_WITH_PLUS
|
119
|
+
result = comp.to_html(CGI.new)
|
120
|
+
assert_equal(STRING_WITH_PLUS, result)
|
121
|
+
end
|
122
|
+
|
81
123
|
def test_umlaut_to_html
|
82
|
-
comp = HtmlGrid::Component.new(
|
124
|
+
comp = HtmlGrid::Component.new("context")
|
83
125
|
comp.value = STRING_WITH_UMLAUT
|
84
126
|
result = comp.to_html(CGI.new)
|
85
127
|
assert_equal(STRING_WITH_UMLAUT, result)
|
86
128
|
end
|
129
|
+
|
87
130
|
def test_escaped_STRING_WITH_UMLAUT_to_html
|
88
|
-
comp = HtmlGrid::Component.new(
|
89
|
-
comp.value =CGI.escape(STRING_WITH_UMLAUT)
|
131
|
+
comp = HtmlGrid::Component.new("context")
|
132
|
+
comp.value = CGI.escape(STRING_WITH_UMLAUT)
|
90
133
|
result = comp.to_html(CGI.new)
|
91
134
|
assert_equal(STRING_WITH_UMLAUT, result)
|
92
135
|
end
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
136
|
+
|
137
|
+
def test_initialize3
|
138
|
+
comp = StubAttributeComponent.new("foo", "bar")
|
139
|
+
expected = {"key" => "val"}
|
140
|
+
assert_respond_to(comp, :attributes)
|
141
|
+
assert_equal(expected, comp.attributes)
|
142
|
+
assert_equal(expected, StubAttributeComponent::HTML_ATTRIBUTES)
|
99
143
|
comp.attributes.store("other", "val")
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
144
|
+
expected2 = {"key" => "val", "other" => "val"}
|
145
|
+
assert_equal(expected2, comp.attributes)
|
146
|
+
assert_equal(expected, StubAttributeComponent::HTML_ATTRIBUTES)
|
147
|
+
assert_equal({}, @component.attributes)
|
148
|
+
assert_equal({}, HtmlGrid::Component::HTML_ATTRIBUTES)
|
105
149
|
@component.attributes.store("third", "val")
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
150
|
+
expected = {"third" => "val"}
|
151
|
+
assert_equal(expected, @component.attributes)
|
152
|
+
assert_equal({}, HtmlGrid::Component::HTML_ATTRIBUTES)
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_initialize4
|
156
|
+
comp = StubInitComponent.new("foo", "bar")
|
157
|
+
assert_equal(true, comp.init_called)
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_initialize5
|
161
|
+
comp = StubLabelComponent.new(nil, nil)
|
162
|
+
assert_equal(true, comp.label?)
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_escape
|
166
|
+
txt = "Guten Tag! & wie gehts uns denn heute? '<' schlechter oder '>' besser?"
|
167
|
+
control = txt.dup
|
168
|
+
expected = "Guten Tag! & wie gehts uns denn heute? '<' schlechter oder '>' besser?"
|
169
|
+
assert_equal(expected, @component.escape(txt))
|
170
|
+
assert_equal(control, txt)
|
171
|
+
assert_equal(expected, @component.escape(txt))
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_escape_symbols
|
175
|
+
txt = "\263"
|
176
|
+
expected = "≥"
|
177
|
+
assert_equal(expected, @component.escape_symbols(txt))
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_onsubmit
|
181
|
+
@component.onsubmit = "submitted"
|
182
|
+
assert_equal({}, @component.attributes)
|
183
|
+
cont = StubContainer.new
|
184
|
+
comp = HtmlGrid::Component.new("foo", "bar", cont)
|
185
|
+
comp.onsubmit = "submitted"
|
186
|
+
assert_equal("submitted", cont.onsubmit)
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_set_attribute
|
190
|
+
assert_equal({}, @component.attributes)
|
191
|
+
@component.set_attribute("href", "http://www.ywesee.com")
|
192
|
+
expected = {
|
193
|
+
"href" => "http://www.ywesee.com"
|
194
|
+
}
|
195
|
+
assert_equal(expected, @component.attributes)
|
196
|
+
end
|
147
197
|
end
|
data/test/test_composite.rb
CHANGED
@@ -23,16 +23,16 @@
|
|
23
23
|
#
|
24
24
|
# TestComposite -- htmlgrid -- 24.10.2002 -- hwyss@ywesee.com
|
25
25
|
|
26
|
-
$: << File.expand_path(
|
26
|
+
$: << File.expand_path("../lib", File.dirname(__FILE__))
|
27
27
|
$: << File.dirname(__FILE__)
|
28
28
|
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
29
|
+
require "minitest/autorun"
|
30
|
+
require "stub/cgi"
|
31
|
+
require "htmlgrid/composite"
|
32
|
+
require "htmlgrid/inputtext"
|
33
|
+
require "htmlgrid/form"
|
34
|
+
require "htmlgrid/button"
|
35
|
+
require "test_helper"
|
36
36
|
|
37
37
|
module CompositeTest
|
38
38
|
class StubComposite < HtmlGrid::Composite
|
@@ -42,73 +42,88 @@ module CompositeTest
|
|
42
42
|
[0, 0, 1] => :foo,
|
43
43
|
[0, 0, 2] => :baz,
|
44
44
|
[0, 1, 0] => :baz,
|
45
|
-
[0, 1, 1] => :baz
|
45
|
+
[0, 1, 1] => :baz
|
46
46
|
}
|
47
47
|
LABELS = true
|
48
48
|
SYMBOL_MAP = {
|
49
|
-
:
|
49
|
+
bar: HtmlGrid::InputText
|
50
50
|
}
|
51
51
|
attr_reader :model, :session
|
52
52
|
public :resolve_offset, :labels?
|
53
53
|
def init
|
54
|
-
@barcount=0
|
54
|
+
@barcount = 0
|
55
55
|
super
|
56
56
|
end
|
57
|
+
|
57
58
|
def foo(model, lookandfeel)
|
58
59
|
"Foo"
|
59
60
|
end
|
61
|
+
|
60
62
|
def baz(model, lookandfeel)
|
61
63
|
@barcount += 1
|
62
64
|
"Baz#{@barcount}"
|
63
65
|
end
|
66
|
+
|
64
67
|
def back
|
65
68
|
super
|
66
69
|
end
|
67
70
|
end
|
71
|
+
|
68
72
|
class StubCompositeComponent < HtmlGrid::Component
|
69
73
|
def to_html(context)
|
70
|
-
context.a(@attributes) {
|
74
|
+
context.a(@attributes) { "brafoo" }
|
71
75
|
end
|
72
76
|
end
|
77
|
+
|
73
78
|
class StubComposite2 < HtmlGrid::Composite
|
74
79
|
COMPONENTS = {
|
75
|
-
[0, 0] => StubCompositeComponent
|
80
|
+
[0, 0] => StubCompositeComponent
|
76
81
|
}
|
77
82
|
end
|
83
|
+
|
78
84
|
class StubComposite3 < StubComposite2
|
79
|
-
COMPONENT_CSS_MAP = {[0, 0, 4, 4] =>
|
85
|
+
COMPONENT_CSS_MAP = {[0, 0, 4, 4] => "standard"}
|
80
86
|
end
|
87
|
+
|
81
88
|
class StubComposite4 < StubComposite3
|
82
|
-
CSS_MAP = {[0, 0] =>
|
83
|
-
COMPONENT_CSS_MAP = {[0, 0, 4, 4] =>
|
89
|
+
CSS_MAP = {[0, 0] => "dradnats"}
|
90
|
+
COMPONENT_CSS_MAP = {[0, 0, 4, 4] => "standard"}
|
84
91
|
end
|
92
|
+
|
85
93
|
class StubCompositeNoLabel < HtmlGrid::Composite
|
86
94
|
LABELS = false
|
87
95
|
COMPONENTS = {}
|
88
96
|
public :labels?
|
89
97
|
end
|
98
|
+
|
90
99
|
class StubCompositeModel
|
91
100
|
def qux
|
92
|
-
|
101
|
+
"qux"
|
93
102
|
end
|
94
103
|
end
|
104
|
+
|
95
105
|
class StubCompositeLookandfeel
|
96
106
|
def event_url(one)
|
97
|
-
|
107
|
+
"event_url"
|
98
108
|
end
|
109
|
+
|
99
110
|
def attributes(key)
|
100
111
|
{}
|
101
112
|
end
|
113
|
+
|
102
114
|
def lookup(key)
|
103
115
|
end
|
116
|
+
|
104
117
|
def base_url
|
105
|
-
|
118
|
+
"http://www.oddb.org/de/gcc"
|
106
119
|
end
|
107
120
|
end
|
121
|
+
|
108
122
|
class StubCompositeSession
|
109
123
|
def lookandfeel
|
110
124
|
StubCompositeLookandfeel.new
|
111
125
|
end
|
126
|
+
|
112
127
|
def error(key)
|
113
128
|
end
|
114
129
|
end
|
@@ -121,36 +136,41 @@ module CompositeTest
|
|
121
136
|
}
|
122
137
|
EVENT = :foo
|
123
138
|
end
|
139
|
+
|
124
140
|
class StubCompositeColspan1 < HtmlGrid::Composite
|
125
141
|
COMPONENTS = {}
|
126
142
|
end
|
143
|
+
|
127
144
|
class StubCompositeColspan2 < HtmlGrid::Composite
|
128
145
|
COMPONENTS = {
|
129
|
-
[0, 0] => :foo
|
146
|
+
[0, 0] => :foo
|
130
147
|
}
|
131
148
|
end
|
149
|
+
|
132
150
|
class StubCompositeColspan3 < HtmlGrid::Composite
|
133
151
|
COMPONENTS = {
|
134
152
|
[0, 0] => :foo,
|
135
|
-
[1, 0] => :bar
|
153
|
+
[1, 0] => :bar
|
136
154
|
}
|
137
155
|
end
|
156
|
+
|
138
157
|
class StubCompositeColspan4 < HtmlGrid::Composite
|
139
158
|
COMPONENTS = {
|
140
159
|
[0, 0] => :foo,
|
141
|
-
[2, 0] => :bar
|
160
|
+
[2, 0] => :bar
|
142
161
|
}
|
143
162
|
end
|
144
163
|
|
145
164
|
class TestComposite < Minitest::Test
|
146
165
|
def setup
|
147
166
|
@composite = StubComposite.new(
|
148
|
-
StubCompositeModel.new, StubCompositeSession.new
|
167
|
+
StubCompositeModel.new, StubCompositeSession.new
|
168
|
+
)
|
149
169
|
end
|
150
170
|
|
151
171
|
def test_component_session_fallback_assignment_without_session_argment
|
152
172
|
StubComposite.component(StubComposite, :qux)
|
153
|
-
model
|
173
|
+
model = StubCompositeModel.new
|
154
174
|
session1 = StubCompositeSession.new
|
155
175
|
composite = StubComposite.new(model, session1)
|
156
176
|
# via instance variable (without argument)
|
@@ -165,102 +185,121 @@ module CompositeTest
|
|
165
185
|
end
|
166
186
|
|
167
187
|
def test_create_method
|
168
|
-
foo = nil
|
169
188
|
foo = @composite.create(:foo, @composite.model)
|
170
189
|
assert_equal("Foo", foo)
|
171
190
|
end
|
191
|
+
|
172
192
|
def test_create_symbol
|
173
|
-
bar = nil
|
174
193
|
bar = @composite.create(:bar, @composite.model)
|
175
194
|
assert_equal(HtmlGrid::InputText, bar.class)
|
176
195
|
end
|
196
|
+
|
177
197
|
def test_full_colspan1
|
178
198
|
composite = StubCompositeColspan1.new(
|
179
|
-
StubCompositeModel.new, StubCompositeSession.new
|
199
|
+
StubCompositeModel.new, StubCompositeSession.new
|
200
|
+
)
|
180
201
|
composite.full_colspan
|
181
202
|
assert_nil(composite.full_colspan)
|
182
203
|
end
|
204
|
+
|
183
205
|
def test_full_colspan2
|
184
206
|
composite = StubCompositeColspan2.new(
|
185
|
-
StubCompositeModel.new, StubCompositeSession.new
|
207
|
+
StubCompositeModel.new, StubCompositeSession.new
|
208
|
+
)
|
186
209
|
composite.full_colspan
|
187
210
|
assert_nil(composite.full_colspan)
|
188
211
|
end
|
212
|
+
|
189
213
|
def test_full_colspan3
|
190
214
|
composite = StubCompositeColspan3.new(
|
191
|
-
StubCompositeModel.new, StubCompositeSession.new
|
215
|
+
StubCompositeModel.new, StubCompositeSession.new
|
216
|
+
)
|
192
217
|
composite.full_colspan
|
193
218
|
assert_equal(2, composite.full_colspan)
|
194
219
|
end
|
220
|
+
|
195
221
|
def test_full_colspan4
|
196
222
|
composite = StubCompositeColspan4.new(
|
197
|
-
StubCompositeModel.new, StubCompositeSession.new
|
223
|
+
StubCompositeModel.new, StubCompositeSession.new
|
224
|
+
)
|
198
225
|
composite.full_colspan
|
199
226
|
assert_equal(3, composite.full_colspan)
|
200
227
|
end
|
228
|
+
|
201
229
|
def test_labels1
|
202
230
|
composite = StubCompositeNoLabel.new(
|
203
|
-
StubCompositeModel.new, StubCompositeSession.new
|
231
|
+
StubCompositeModel.new, StubCompositeSession.new
|
232
|
+
)
|
204
233
|
assert_equal(false, composite.labels?)
|
205
234
|
end
|
235
|
+
|
206
236
|
def test_labels2
|
207
237
|
assert_equal(true, @composite.labels?)
|
208
238
|
end
|
239
|
+
|
209
240
|
def test_to_html
|
210
|
-
assert_equal(<<-EXP.gsub(/\n|^\s*/,
|
241
|
+
assert_equal(<<-EXP.gsub(/\n|^\s*/, ""), @composite.to_html(CGI.new))
|
211
242
|
<TABLE cellspacing="0">
|
212
243
|
<TR><TD>Baz1FooBaz2</TD></TR><TR><TD>Baz3Baz4</TD></TR>
|
213
244
|
</TABLE>
|
214
245
|
EXP
|
215
246
|
end
|
247
|
+
|
216
248
|
def test_resolve_offset
|
217
|
-
matrix = [1,2,3,4]
|
249
|
+
matrix = [1, 2, 3, 4]
|
218
250
|
assert_equal(matrix, @composite.resolve_offset(matrix))
|
219
|
-
offset = [5,6]
|
220
|
-
expected = [6,8,3,4]
|
251
|
+
offset = [5, 6]
|
252
|
+
expected = [6, 8, 3, 4]
|
221
253
|
assert_equal(expected, @composite.resolve_offset(matrix, offset))
|
222
254
|
end
|
255
|
+
|
223
256
|
def test_event
|
224
257
|
@composite.event
|
225
258
|
@composite.container = StubCompositeForm.new(
|
226
|
-
@composite.model, @composite.session
|
259
|
+
@composite.model, @composite.session
|
260
|
+
)
|
227
261
|
assert_equal(:foo, @composite.event)
|
228
262
|
end
|
263
|
+
|
229
264
|
def test_component_css_map
|
230
265
|
table = StubComposite2.new(
|
231
|
-
StubCompositeModel.new, StubCompositeSession.new
|
232
|
-
|
266
|
+
StubCompositeModel.new, StubCompositeSession.new
|
267
|
+
)
|
268
|
+
assert_equal(<<-EXP.gsub(/\n|^\s*/, ""), table.to_html(CGI.new))
|
233
269
|
<TABLE cellspacing="0">
|
234
270
|
<TR><TD><A>brafoo</A></TD></TR>
|
235
271
|
</TABLE>
|
236
272
|
EXP
|
237
273
|
table = StubComposite3.new(
|
238
|
-
StubCompositeModel.new, StubCompositeSession.new
|
239
|
-
|
274
|
+
StubCompositeModel.new, StubCompositeSession.new
|
275
|
+
)
|
276
|
+
assert_equal(<<-EXP.gsub(/\n|^\s*/, ""), table.to_html(CGI.new))
|
240
277
|
<TABLE cellspacing="0">
|
241
278
|
<TR><TD><A class="standard">brafoo</A></TD></TR>
|
242
279
|
</TABLE>
|
243
280
|
EXP
|
244
281
|
table = StubComposite4.new(
|
245
|
-
StubCompositeModel.new, StubCompositeSession.new
|
246
|
-
|
282
|
+
StubCompositeModel.new, StubCompositeSession.new
|
283
|
+
)
|
284
|
+
assert_equal(<<-EXP.gsub(/\n|^\s*/, ""), table.to_html(CGI.new))
|
247
285
|
<TABLE cellspacing=\"0\"><TR><TD class=\"dradnats\"><A class=\"standard\">brafoo</A></TD></TR></TABLE>
|
248
286
|
EXP
|
249
287
|
end
|
288
|
+
|
250
289
|
def test_to_back
|
251
|
-
if RUBY_VERSION.split(".").first.eql?(
|
252
|
-
|
290
|
+
expected = if RUBY_VERSION.split(".").first.eql?("1")
|
291
|
+
<<-EXP.gsub(/\n|^\s{10}/, "")
|
253
292
|
<INPUT type="button" name="back"
|
254
293
|
onClick="document.location.href='event_url';">
|
255
294
|
EXP
|
256
295
|
else
|
257
296
|
# It looks like Ruby 2.x escapes the ' which is not strictly necessary
|
258
|
-
|
297
|
+
<<-EXP.gsub(/\n|^\s{10}/, "")
|
259
298
|
<INPUT type="button" name="back"
|
260
299
|
onClick="document.location.href='event_url';">
|
261
300
|
EXP
|
262
301
|
end
|
263
|
-
html = @composite.back
|
302
|
+
html = @composite.back.to_html(CGI.new)
|
264
303
|
assert_equal(expected, html)
|
265
304
|
end
|
266
305
|
end
|