runo 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -118
- data/bin/runo +4 -29
- data/lib/dummy.rb +0 -0
- metadata +12 -278
- data/lib/_error.rb +0 -14
- data/lib/_field.rb +0 -260
- data/lib/_i18n.rb +0 -144
- data/lib/_parser.rb +0 -256
- data/lib/_path.rb +0 -86
- data/lib/_storage/_storage.rb +0 -215
- data/lib/_storage/file.rb +0 -201
- data/lib/_storage/sequel.rb +0 -174
- data/lib/_storage/temp.rb +0 -73
- data/lib/_widget/action_create.rb +0 -23
- data/lib/_widget/action_login.rb +0 -22
- data/lib/_widget/action_signup.rb +0 -16
- data/lib/_widget/action_update.rb +0 -16
- data/lib/_widget/crumb.rb +0 -24
- data/lib/_widget/done.rb +0 -16
- data/lib/_widget/login.rb +0 -25
- data/lib/_widget/me.rb +0 -31
- data/lib/_widget/message.rb +0 -51
- data/lib/_widget/navi.rb +0 -88
- data/lib/_widget/submit.rb +0 -49
- data/lib/_widget/view_ym.rb +0 -77
- data/lib/_workflow/_workflow.rb +0 -89
- data/lib/_workflow/attachment.rb +0 -50
- data/lib/_workflow/blog.rb +0 -28
- data/lib/_workflow/contact.rb +0 -23
- data/lib/_workflow/forum.rb +0 -26
- data/lib/_workflow/register.rb +0 -39
- data/lib/meta/_meta.rb +0 -20
- data/lib/meta/group.rb +0 -19
- data/lib/meta/id.rb +0 -59
- data/lib/meta/owner.rb +0 -21
- data/lib/meta/timestamp.rb +0 -118
- data/lib/runo.rb +0 -396
- data/lib/scalar/checkbox.rb +0 -68
- data/lib/scalar/file.rb +0 -144
- data/lib/scalar/img.rb +0 -112
- data/lib/scalar/password.rb +0 -58
- data/lib/scalar/radio.rb +0 -47
- data/lib/scalar/select.rb +0 -47
- data/lib/scalar/text.rb +0 -38
- data/lib/scalar/textarea.rb +0 -35
- data/lib/scalar/textarea_pre.rb +0 -14
- data/lib/scalar/textarea_wiki.rb +0 -173
- data/lib/set/_set.rb +0 -196
- data/lib/set/dynamic.rb +0 -177
- data/lib/set/static.rb +0 -102
- data/lib/set/static_folder.rb +0 -96
- data/locale/en/index.po +0 -242
- data/locale/index.pot +0 -243
- data/locale/ja/index.po +0 -242
- data/locale/lazy_parser.rb +0 -54
- data/skel/config.ru +0 -27
- data/skel/skin/_users/00000000_frank-avatar.jpg +0 -0
- data/skel/skin/_users/00000000_frank-avatar_small.jpg +0 -0
- data/skel/skin/_users/00000000_frank.yaml +0 -12
- data/skel/skin/_users/00000000_root-avatar.jpg +0 -0
- data/skel/skin/_users/00000000_root-avatar_small.jpg +0 -0
- data/skel/skin/_users/00000000_root.yaml +0 -11
- data/skel/skin/_users/css/users.css +0 -21
- data/skel/skin/_users/css/users.less +0 -25
- data/skel/skin/_users/done.html +0 -42
- data/skel/skin/_users/index.html +0 -46
- data/skel/skin/_users/index.yaml +0 -3
- data/skel/skin/_users/summary.html +0 -40
- data/skel/skin/css/base.css +0 -93
- data/skel/skin/css/base.less +0 -139
- data/skel/skin/css/coax.css +0 -199
- data/skel/skin/css/coax.less +0 -244
- data/skel/skin/examples/blog/20091214_0001.yaml +0 -8
- data/skel/skin/examples/blog/20100630_0001.yaml +0 -8
- data/skel/skin/examples/blog/20100630_0002.yaml +0 -14
- data/skel/skin/examples/blog/20100701_0001.yaml +0 -8
- data/skel/skin/examples/blog/20100701_0002-a-20100701_0001-f.jpg +0 -0
- data/skel/skin/examples/blog/20100701_0002-a-20100701_0001-f_small.jpg +0 -0
- data/skel/skin/examples/blog/20100701_0002.yaml +0 -19
- data/skel/skin/examples/blog/frank/20100701_0001.yaml +0 -10
- data/skel/skin/examples/blog/frank/index.yaml +0 -4
- data/skel/skin/examples/blog/index.html +0 -51
- data/skel/skin/examples/blog/rss.xml +0 -18
- data/skel/skin/examples/contact/20100701_0001-file.txt +0 -1
- data/skel/skin/examples/contact/20100701_0001.yaml +0 -15
- data/skel/skin/examples/contact/20100701_0002.yaml +0 -8
- data/skel/skin/examples/contact/20100701_0003.yaml +0 -9
- data/skel/skin/examples/contact/index.html +0 -47
- data/skel/skin/examples/contact/js/contact.js +0 -13
- data/skel/skin/examples/contact/summary.html +0 -54
- data/skel/skin/examples/forum/20100701_0001.yaml +0 -41
- data/skel/skin/examples/forum/20100701_0002.yaml +0 -25
- data/skel/skin/examples/forum/index.html +0 -68
- data/skel/skin/examples/forum/summary.html +0 -47
- data/skel/skin/examples/index.html +0 -73
- data/skel/skin/index.html +0 -39
- data/skel/skin/js/base.js +0 -50
- data/t/locale/de/index.po +0 -19
- data/t/locale/en-GB/index.po +0 -25
- data/t/locale/ja/index.po +0 -30
- data/t/skin/_users/00000000_test.yaml +0 -3
- data/t/skin/_users/index.html +0 -13
- data/t/skin/foo/20091120_0001.yaml +0 -7
- data/t/skin/foo/bar/20091120_0001.yaml +0 -5
- data/t/skin/foo/bar/index.yaml +0 -5
- data/t/skin/foo/baz/css/baz.css +0 -1
- data/t/skin/foo/css/foo.css +0 -1
- data/t/skin/foo/index.html +0 -14
- data/t/skin/foo/index.yaml +0 -7
- data/t/skin/foo/not_css/foo.css +0 -1
- data/t/skin/foo/qux/index.html +0 -8
- data/t/skin/foo/qux/moo/index.html +0 -6
- data/t/skin/foo/sub-20100306_0001.yaml +0 -3
- data/t/skin/index.yaml +0 -3
- data/t/skin/t_attachment/index.html +0 -13
- data/t/skin/t_contact/done.html +0 -6
- data/t/skin/t_contact/index.html +0 -9
- data/t/skin/t_file/index.html +0 -16
- data/t/skin/t_img/index.html +0 -14
- data/t/skin/t_img/test.jpg +0 -0
- data/t/skin/t_select/index.html +0 -9
- data/t/skin/t_store/index.html +0 -9
- data/t/skin/t_summary/20100326_0001.yaml +0 -3
- data/t/skin/t_summary/create.html +0 -9
- data/t/skin/t_summary/index.html +0 -9
- data/t/skin/t_summary/summary.html +0 -9
- data/t/t.rb +0 -27
- data/t/test_checkbox.rb +0 -273
- data/t/test_field.rb +0 -330
- data/t/test_file.rb +0 -900
- data/t/test_id.rb +0 -215
- data/t/test_img.rb +0 -328
- data/t/test_meta.rb +0 -57
- data/t/test_parser.rb +0 -1516
- data/t/test_password.rb +0 -188
- data/t/test_radio.rb +0 -226
- data/t/test_role.rb +0 -249
- data/t/test_runo.rb +0 -768
- data/t/test_runo_call.rb +0 -1281
- data/t/test_runo_i18n.rb +0 -325
- data/t/test_select.rb +0 -182
- data/t/test_set_complex.rb +0 -527
- data/t/test_set_dynamic.rb +0 -1504
- data/t/test_set_folder.rb +0 -515
- data/t/test_set_permit.rb +0 -246
- data/t/test_set_static.rb +0 -468
- data/t/test_storage.rb +0 -915
- data/t/test_text.rb +0 -125
- data/t/test_textarea.rb +0 -138
- data/t/test_timestamp.rb +0 -473
- data/t/test_workflow.rb +0 -367
data/t/test_text.rb
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
# Author:: Akira FUNAI
|
4
|
-
# Copyright:: Copyright (c) 2009 Akira FUNAI
|
5
|
-
|
6
|
-
require "#{::File.dirname __FILE__}/t"
|
7
|
-
|
8
|
-
class TC_Text < Test::Unit::TestCase
|
9
|
-
|
10
|
-
def setup
|
11
|
-
meta = nil
|
12
|
-
Runo::Parser.gsub_scalar('$(foo text 3 1..5)') {|id, m|
|
13
|
-
meta = m
|
14
|
-
''
|
15
|
-
}
|
16
|
-
@f = Runo::Field.instance meta
|
17
|
-
end
|
18
|
-
|
19
|
-
def teardown
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_meta
|
23
|
-
assert_equal(
|
24
|
-
3,
|
25
|
-
@f[:size],
|
26
|
-
'Text#initialize should set :size from the token'
|
27
|
-
)
|
28
|
-
assert_equal(
|
29
|
-
1,
|
30
|
-
@f[:min],
|
31
|
-
'Text#initialize should set :min from the range token'
|
32
|
-
)
|
33
|
-
assert_equal(
|
34
|
-
5,
|
35
|
-
@f[:max],
|
36
|
-
'Text#initialize should set :max from the range token'
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_val_cast
|
41
|
-
assert_equal(
|
42
|
-
'',
|
43
|
-
@f.val,
|
44
|
-
'Text#val_cast should cast the given val to String'
|
45
|
-
)
|
46
|
-
|
47
|
-
@f.load 123
|
48
|
-
assert_equal(
|
49
|
-
'123',
|
50
|
-
@f.val,
|
51
|
-
'Text#val_cast should cast the given val to String'
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_get
|
56
|
-
@f.load 'bar'
|
57
|
-
assert_equal(
|
58
|
-
'bar',
|
59
|
-
@f.get,
|
60
|
-
'Text#get should return proper string'
|
61
|
-
)
|
62
|
-
assert_equal(
|
63
|
-
'<span class="text"><input type="text" name="" value="bar" size="3" /></span>',
|
64
|
-
@f.get(:action => :update),
|
65
|
-
'Text#get should return proper string'
|
66
|
-
)
|
67
|
-
|
68
|
-
@f.load '<bar>'
|
69
|
-
assert_equal(
|
70
|
-
'<bar>',
|
71
|
-
@f.get,
|
72
|
-
'Text#get should escape the special characters'
|
73
|
-
)
|
74
|
-
assert_equal(
|
75
|
-
'<span class="text"><input type="text" name="" value="<bar>" size="3" /></span>',
|
76
|
-
@f.get(:action => :update),
|
77
|
-
'Text#get should escape the special characters'
|
78
|
-
)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_errors
|
82
|
-
@f.load ''
|
83
|
-
@f[:min] = 0
|
84
|
-
assert_equal(
|
85
|
-
[],
|
86
|
-
@f.errors,
|
87
|
-
'Text#errors should return the errors of the current val'
|
88
|
-
)
|
89
|
-
@f[:min] = 1
|
90
|
-
assert_equal(
|
91
|
-
['mandatory'],
|
92
|
-
@f.errors,
|
93
|
-
'Text#errors should return the errors of the current val'
|
94
|
-
)
|
95
|
-
|
96
|
-
@f.load 'a'
|
97
|
-
@f[:min] = 1
|
98
|
-
assert_equal(
|
99
|
-
[],
|
100
|
-
@f.errors,
|
101
|
-
'Text#errors should return the errors of the current val'
|
102
|
-
)
|
103
|
-
@f[:min] = 2
|
104
|
-
assert_equal(
|
105
|
-
['too short: 2 characters minimum'],
|
106
|
-
@f.errors,
|
107
|
-
'Text#errors should return the errors of the current val'
|
108
|
-
)
|
109
|
-
|
110
|
-
@f.load 'abcde'
|
111
|
-
@f[:max] = 5
|
112
|
-
assert_equal(
|
113
|
-
[],
|
114
|
-
@f.errors,
|
115
|
-
'Text#errors should return the errors of the current val'
|
116
|
-
)
|
117
|
-
@f[:max] = 4
|
118
|
-
assert_equal(
|
119
|
-
['too long: 4 characters maximum'],
|
120
|
-
@f.errors,
|
121
|
-
'Text#errors should return the errors of the current val'
|
122
|
-
)
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
data/t/test_textarea.rb
DELETED
@@ -1,138 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
# Author:: Akira FUNAI
|
4
|
-
# Copyright:: Copyright (c) 2009 Akira FUNAI
|
5
|
-
|
6
|
-
require "#{::File.dirname __FILE__}/t"
|
7
|
-
|
8
|
-
class TC_Textarea < Test::Unit::TestCase
|
9
|
-
|
10
|
-
def setup
|
11
|
-
meta = nil
|
12
|
-
Runo::Parser.gsub_scalar('$(foo textarea 76*8 1..1024)') {|id, m|
|
13
|
-
meta = m
|
14
|
-
''
|
15
|
-
}
|
16
|
-
@f = Runo::Field.instance meta
|
17
|
-
end
|
18
|
-
|
19
|
-
def teardown
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_meta
|
23
|
-
assert_equal(
|
24
|
-
76,
|
25
|
-
@f[:width],
|
26
|
-
'Textarea#initialize should set :width from the dimension token'
|
27
|
-
)
|
28
|
-
assert_equal(
|
29
|
-
8,
|
30
|
-
@f[:height],
|
31
|
-
'Textarea#initialize should set :height from the dimension token'
|
32
|
-
)
|
33
|
-
assert_equal(
|
34
|
-
1,
|
35
|
-
@f[:min],
|
36
|
-
'Text#initialize should set :min from the range token'
|
37
|
-
)
|
38
|
-
assert_equal(
|
39
|
-
1024,
|
40
|
-
@f[:max],
|
41
|
-
'Text#initialize should set :max from the range token'
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_val_cast
|
46
|
-
assert_equal(
|
47
|
-
'',
|
48
|
-
@f.val,
|
49
|
-
'Textarea#val_cast should cast the given val to String'
|
50
|
-
)
|
51
|
-
|
52
|
-
@f.load 123
|
53
|
-
assert_equal(
|
54
|
-
'123',
|
55
|
-
@f.val,
|
56
|
-
'Textarea#val_cast should cast the given val to String'
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_get
|
61
|
-
@f.load 'bar'
|
62
|
-
assert_equal(
|
63
|
-
'bar',
|
64
|
-
@f.get,
|
65
|
-
'Textarea#get should return proper string'
|
66
|
-
)
|
67
|
-
assert_equal(
|
68
|
-
<<'_html',
|
69
|
-
<span class="textarea">
|
70
|
-
<textarea name="" cols="76" rows="8">bar</textarea>
|
71
|
-
</span>
|
72
|
-
_html
|
73
|
-
@f.get(:action => :update),
|
74
|
-
'Textarea#get should return proper string'
|
75
|
-
)
|
76
|
-
|
77
|
-
@f.load '<bar>'
|
78
|
-
assert_equal(
|
79
|
-
'<bar>',
|
80
|
-
@f.get,
|
81
|
-
'Textarea#get should escape the special characters'
|
82
|
-
)
|
83
|
-
assert_equal(
|
84
|
-
<<'_html',
|
85
|
-
<span class="textarea">
|
86
|
-
<textarea name="" cols="76" rows="8"><bar></textarea>
|
87
|
-
</span>
|
88
|
-
_html
|
89
|
-
@f.get(:action => :update),
|
90
|
-
'Textarea#get should escape the special characters'
|
91
|
-
)
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_errors
|
95
|
-
@f.load ''
|
96
|
-
@f[:min] = 0
|
97
|
-
assert_equal(
|
98
|
-
[],
|
99
|
-
@f.errors,
|
100
|
-
'Text#errors should return the errors of the current val'
|
101
|
-
)
|
102
|
-
@f[:min] = 1
|
103
|
-
assert_equal(
|
104
|
-
['mandatory'],
|
105
|
-
@f.errors,
|
106
|
-
'Text#errors should return the errors of the current val'
|
107
|
-
)
|
108
|
-
|
109
|
-
@f.load 'a'
|
110
|
-
@f[:min] = 1
|
111
|
-
assert_equal(
|
112
|
-
[],
|
113
|
-
@f.errors,
|
114
|
-
'Text#errors should return the errors of the current val'
|
115
|
-
)
|
116
|
-
@f[:min] = 2
|
117
|
-
assert_equal(
|
118
|
-
['too short: 2 characters minimum'],
|
119
|
-
@f.errors,
|
120
|
-
'Text#errors should return the errors of the current val'
|
121
|
-
)
|
122
|
-
|
123
|
-
@f.load 'abcde'
|
124
|
-
@f[:max] = 5
|
125
|
-
assert_equal(
|
126
|
-
[],
|
127
|
-
@f.errors,
|
128
|
-
'Text#errors should return the errors of the current val'
|
129
|
-
)
|
130
|
-
@f[:max] = 4
|
131
|
-
assert_equal(
|
132
|
-
['too long: 4 characters maximum'],
|
133
|
-
@f.errors,
|
134
|
-
'Text#errors should return the errors of the current val'
|
135
|
-
)
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
data/t/test_timestamp.rb
DELETED
@@ -1,473 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
# Author:: Akira FUNAI
|
4
|
-
# Copyright:: Copyright (c) 2009 Akira FUNAI
|
5
|
-
|
6
|
-
require "#{::File.dirname __FILE__}/t"
|
7
|
-
|
8
|
-
class TC_Timestamp < Test::Unit::TestCase
|
9
|
-
|
10
|
-
def setup
|
11
|
-
meta = nil
|
12
|
-
Runo::Parser.gsub_scalar('$(foo meta-timestamp 16)') {|id, m|
|
13
|
-
meta = m
|
14
|
-
''
|
15
|
-
}
|
16
|
-
@f = Runo::Field.instance meta
|
17
|
-
end
|
18
|
-
|
19
|
-
def teardown
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_meta
|
23
|
-
meta = nil
|
24
|
-
Runo::Parser.gsub_scalar('$(foo meta-timestamp can_edit)') {|id, m|
|
25
|
-
meta = m
|
26
|
-
''
|
27
|
-
}
|
28
|
-
f = Runo::Field.instance meta
|
29
|
-
assert_equal(
|
30
|
-
true,
|
31
|
-
f[:can_edit],
|
32
|
-
'Timestamp#initialize should set :can_edit from the tokens'
|
33
|
-
)
|
34
|
-
|
35
|
-
meta = nil
|
36
|
-
Runo::Parser.gsub_scalar('$(foo meta-timestamp can_update)') {|id, m|
|
37
|
-
meta = m
|
38
|
-
''
|
39
|
-
}
|
40
|
-
f = Runo::Field.instance meta
|
41
|
-
assert_equal(
|
42
|
-
true,
|
43
|
-
f[:can_update],
|
44
|
-
'Timestamp#initialize should set :can_update from the tokens'
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_val_cast
|
49
|
-
v = nil
|
50
|
-
assert_equal(
|
51
|
-
{},
|
52
|
-
@f.send(:val_cast, v),
|
53
|
-
'Timestamp#val_cast should return an empty hash if the val is not a hash nor a string'
|
54
|
-
)
|
55
|
-
|
56
|
-
v = {
|
57
|
-
'created' => Time.local(2010, 4, 1),
|
58
|
-
'updated' => Time.local(2010, 4, 3),
|
59
|
-
'published' => Time.local(2010, 4, 2),
|
60
|
-
}
|
61
|
-
assert_equal(
|
62
|
-
v,
|
63
|
-
@f.send(:val_cast, v),
|
64
|
-
'Timestamp#val_cast should pass through if the val is a hash'
|
65
|
-
)
|
66
|
-
|
67
|
-
v = 'true'
|
68
|
-
assert_equal(
|
69
|
-
{'published' => :same_as_updated},
|
70
|
-
@f.send(:val_cast, v),
|
71
|
-
"Timestamp#val_cast should set v['published'] to :same_as_updated if the val is 'true'"
|
72
|
-
)
|
73
|
-
|
74
|
-
v = '2010/4/26'
|
75
|
-
assert_equal(
|
76
|
-
{'published' => Time.local(2010, 4, 26)},
|
77
|
-
@f.send(:val_cast, v),
|
78
|
-
"Timestamp#val_cast should cast the val to v['published'] if the val represents a date"
|
79
|
-
)
|
80
|
-
v = '2010-4-26'
|
81
|
-
assert_equal(
|
82
|
-
{'published' => Time.local(2010, 4, 26)},
|
83
|
-
@f.send(:val_cast, v),
|
84
|
-
"Timestamp#val_cast should cast the val to v['published'] if the val represents a date"
|
85
|
-
)
|
86
|
-
v = '2010-4-26 20:14'
|
87
|
-
assert_equal(
|
88
|
-
{'published' => Time.local(2010, 4, 26, 20, 14)},
|
89
|
-
@f.send(:val_cast, v),
|
90
|
-
"Timestamp#val_cast should cast the val to v['published'] if the val represents a date"
|
91
|
-
)
|
92
|
-
v = '2010-4-26 20:14:45'
|
93
|
-
assert_equal(
|
94
|
-
{'published' => Time.local(2010, 4, 26, 20, 14, 45)},
|
95
|
-
@f.send(:val_cast, v),
|
96
|
-
"Timestamp#val_cast should cast the val to v['published'] if the val represents a date"
|
97
|
-
)
|
98
|
-
|
99
|
-
v = '2010-4-89'
|
100
|
-
assert_equal(
|
101
|
-
{},
|
102
|
-
@f.send(:val_cast, v),
|
103
|
-
'Timestamp#val_cast should return an empty hash if the given date is out of range'
|
104
|
-
)
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_get
|
108
|
-
@f.load(
|
109
|
-
'created' => Time.local(2010, 4, 25),
|
110
|
-
'updated' => Time.local(2010, 4, 27),
|
111
|
-
'published' => Time.local(2010, 4, 26, 20, 14, 45)
|
112
|
-
)
|
113
|
-
assert_equal(
|
114
|
-
'2010-04-26T20:14:45',
|
115
|
-
@f.get,
|
116
|
-
'Timestamp#get should return proper string'
|
117
|
-
)
|
118
|
-
assert_equal(
|
119
|
-
'2010-04-25T00:00:00',
|
120
|
-
@f.get(:action => :created),
|
121
|
-
'Timestamp#get should return proper string'
|
122
|
-
)
|
123
|
-
assert_equal(
|
124
|
-
'2010-04-27T00:00:00',
|
125
|
-
@f.get(:action => :updated),
|
126
|
-
'Timestamp#get should return proper string'
|
127
|
-
)
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_get_rfc2822
|
131
|
-
@f.load(
|
132
|
-
'created' => Time.local(2010, 4, 25),
|
133
|
-
'updated' => Time.local(2010, 4, 27),
|
134
|
-
'published' => Time.local(2010, 4, 26, 20, 14, 45)
|
135
|
-
)
|
136
|
-
assert_match(
|
137
|
-
/^Mon, 26 Apr 2010 20:14:45 [\+\-]\d{4}$/,
|
138
|
-
@f.get(:action => :rfc2822),
|
139
|
-
'Timestamp#get should return proper string'
|
140
|
-
)
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_get_create
|
144
|
-
@f.load_default
|
145
|
-
|
146
|
-
@f[:can_edit] = nil
|
147
|
-
@f[:can_update] = nil
|
148
|
-
assert_nil(
|
149
|
-
@f.get(:action => :create),
|
150
|
-
'Timestamp#_g_create should return nil unless [:can_edit]'
|
151
|
-
)
|
152
|
-
|
153
|
-
@f[:can_edit] = true
|
154
|
-
@f[:can_update] = nil
|
155
|
-
assert_equal(
|
156
|
-
'<span class="meta-timestamp"><input type="text" name="" value="" size="16" /></span>',
|
157
|
-
@f.get(:action => :create),
|
158
|
-
'Timestamp#_g_create should return proper string'
|
159
|
-
)
|
160
|
-
|
161
|
-
@f[:can_edit] = nil
|
162
|
-
@f[:can_update] = true
|
163
|
-
assert_nil(
|
164
|
-
@f.get(:action => :create),
|
165
|
-
'Timestamp#_g_create should return nil if [:can_update]'
|
166
|
-
)
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_get_update
|
170
|
-
@f.load_default
|
171
|
-
|
172
|
-
@f[:can_edit] = nil
|
173
|
-
@f[:can_update] = nil
|
174
|
-
assert_nil(
|
175
|
-
@f.get(:action => :update),
|
176
|
-
'Timestamp#_g_update should return nil unless [:can_edit] or [:can_update]'
|
177
|
-
)
|
178
|
-
|
179
|
-
@f[:can_edit] = true
|
180
|
-
@f[:can_update] = nil
|
181
|
-
assert_equal(
|
182
|
-
'<span class="meta-timestamp"><input type="text" name="" value="" size="16" /></span>',
|
183
|
-
@f.get(:action => :update),
|
184
|
-
'Timestamp#_g_update should return proper string'
|
185
|
-
)
|
186
|
-
|
187
|
-
@f[:can_edit] = nil
|
188
|
-
@f[:can_update] = true
|
189
|
-
assert_equal(
|
190
|
-
<<'_html',
|
191
|
-
<span class="meta-timestamp">
|
192
|
-
<input type="checkbox" id="timestamp_" name="" value="true" />
|
193
|
-
<label for="timestamp_">update the timestamp</label>
|
194
|
-
</span>
|
195
|
-
_html
|
196
|
-
@f.get(:action => :update),
|
197
|
-
'Timestamp#_g_update should return proper string'
|
198
|
-
)
|
199
|
-
|
200
|
-
@f[:can_edit] = true
|
201
|
-
@f[:can_update] = nil
|
202
|
-
@f.load('published' => Time.local(2010, 4, 25))
|
203
|
-
assert_equal(
|
204
|
-
'<span class="meta-timestamp"><input type="text" name="" value="2010-04-25 00:00:00" size="16" /></span>',
|
205
|
-
@f.get(:action => :update),
|
206
|
-
'Timestamp#_g_update should return proper string'
|
207
|
-
)
|
208
|
-
@f.update '2010-4-89'
|
209
|
-
assert_equal(
|
210
|
-
<<'_html'.chomp,
|
211
|
-
<span class="meta-timestamp error"><input type="text" name="" value="2010-4-89" size="16" /><span class="error_message">out of range</span>
|
212
|
-
</span>
|
213
|
-
_html
|
214
|
-
@f.get(:action => :update),
|
215
|
-
'Timestamp#_g_update should return proper string'
|
216
|
-
)
|
217
|
-
|
218
|
-
@f.update '<2010-4-9>'
|
219
|
-
assert_equal(
|
220
|
-
<<'_html'.chomp,
|
221
|
-
<span class="meta-timestamp error"><input type="text" name="" value="<2010-4-9>" size="16" /><span class="error_message">wrong format</span>
|
222
|
-
</span>
|
223
|
-
_html
|
224
|
-
@f.get(:action => :update),
|
225
|
-
'Timestamp#_g_update should escape the special chars'
|
226
|
-
)
|
227
|
-
end
|
228
|
-
|
229
|
-
def test_errors
|
230
|
-
@f.load nil
|
231
|
-
assert_equal(
|
232
|
-
[],
|
233
|
-
@f.errors,
|
234
|
-
'Timestamp#errors should return the errors of the current val'
|
235
|
-
)
|
236
|
-
@f.load ''
|
237
|
-
assert_equal(
|
238
|
-
[],
|
239
|
-
@f.errors,
|
240
|
-
'Timestamp#errors should return the errors of the current val'
|
241
|
-
)
|
242
|
-
@f.load '2010-4-26 20:14:45'
|
243
|
-
assert_equal(
|
244
|
-
[],
|
245
|
-
@f.errors,
|
246
|
-
'Timestamp#errors should return the errors of the current val'
|
247
|
-
)
|
248
|
-
|
249
|
-
@f.load 'someday'
|
250
|
-
assert_equal(
|
251
|
-
['wrong format'],
|
252
|
-
@f.errors,
|
253
|
-
'Timestamp#errors should return the errors of the current val'
|
254
|
-
)
|
255
|
-
@f.load '2010-4-89'
|
256
|
-
assert_equal(
|
257
|
-
['out of range'],
|
258
|
-
@f.errors,
|
259
|
-
'Timestamp#errors should return the errors of the current val'
|
260
|
-
)
|
261
|
-
end
|
262
|
-
|
263
|
-
def test_load
|
264
|
-
@f.load(
|
265
|
-
'created' => Time.local(2010, 4, 1),
|
266
|
-
'updated' => Time.local(2010, 4, 3),
|
267
|
-
'published' => Time.local(2010, 4, 2)
|
268
|
-
)
|
269
|
-
assert_equal(
|
270
|
-
{
|
271
|
-
'created' => Time.local(2010, 4, 1),
|
272
|
-
'updated' => Time.local(2010, 4, 3),
|
273
|
-
'published' => Time.local(2010, 4, 2)
|
274
|
-
},
|
275
|
-
@f.val,
|
276
|
-
'Timestamp#load should load the given val like a normal field'
|
277
|
-
)
|
278
|
-
assert_nil(
|
279
|
-
@f.action,
|
280
|
-
'Timestamp#load should not set @action'
|
281
|
-
)
|
282
|
-
assert_equal(
|
283
|
-
:load,
|
284
|
-
@f.result,
|
285
|
-
'Timestamp#load should set @result like a normal field'
|
286
|
-
)
|
287
|
-
end
|
288
|
-
|
289
|
-
def test_create
|
290
|
-
@f.create nil
|
291
|
-
assert_equal(
|
292
|
-
@f.val['updated'],
|
293
|
-
@f.val['created'],
|
294
|
-
'Timestamp#create should set the default vals'
|
295
|
-
)
|
296
|
-
assert_equal(
|
297
|
-
@f.val['published'],
|
298
|
-
@f.val['created'],
|
299
|
-
'Timestamp#create should set the default vals'
|
300
|
-
)
|
301
|
-
assert_nil(
|
302
|
-
@f.action,
|
303
|
-
"Timestamp#create should not set @action without v['published']"
|
304
|
-
)
|
305
|
-
assert_nil(
|
306
|
-
@f.result,
|
307
|
-
'Timestamp#create should not set @result'
|
308
|
-
)
|
309
|
-
end
|
310
|
-
|
311
|
-
def test_create_with_date
|
312
|
-
@f[:can_edit] = true
|
313
|
-
@f.create '2010/4/26'
|
314
|
-
assert_equal(
|
315
|
-
@f.val['updated'],
|
316
|
-
@f.val['created'],
|
317
|
-
'Timestamp#create should set the default vals'
|
318
|
-
)
|
319
|
-
assert_equal(
|
320
|
-
Time.local(2010, 4, 26),
|
321
|
-
@f.val['published'],
|
322
|
-
"Timestamp#create should set @val['published'] if v['published'] is a date"
|
323
|
-
)
|
324
|
-
assert_equal(
|
325
|
-
:create,
|
326
|
-
@f.action,
|
327
|
-
"Timestamp#create should set @action if v['published'] is a date"
|
328
|
-
)
|
329
|
-
end
|
330
|
-
|
331
|
-
def test_create_with_check
|
332
|
-
@f[:can_update] = true
|
333
|
-
@f.create 'true'
|
334
|
-
assert_equal(
|
335
|
-
@f.val['updated'],
|
336
|
-
@f.val['created'],
|
337
|
-
'Timestamp#create should set the default vals'
|
338
|
-
)
|
339
|
-
assert_equal(
|
340
|
-
@f.val['published'],
|
341
|
-
@f.val['created'],
|
342
|
-
'Timestamp#create should set the default vals'
|
343
|
-
)
|
344
|
-
assert_nil(
|
345
|
-
@f.action,
|
346
|
-
"Timestamp#create should not set @action if v['published'] is not a date"
|
347
|
-
)
|
348
|
-
end
|
349
|
-
|
350
|
-
def test_update
|
351
|
-
@f.load(
|
352
|
-
'created' => Time.local(2010, 4, 1),
|
353
|
-
'updated' => Time.local(2010, 4, 3),
|
354
|
-
'published' => Time.local(2010, 4, 2)
|
355
|
-
)
|
356
|
-
|
357
|
-
@f.update nil
|
358
|
-
assert_equal(
|
359
|
-
Time.local(2010, 4, 1),
|
360
|
-
@f.val['created'],
|
361
|
-
"Timestamp#update should keep @val['created']"
|
362
|
-
)
|
363
|
-
assert_not_equal(
|
364
|
-
Time.local(2010, 4, 3),
|
365
|
-
@f.val['updated'],
|
366
|
-
"Timestamp#update should updated @val['updated']"
|
367
|
-
)
|
368
|
-
assert_equal(
|
369
|
-
Time.local(2010, 4, 2),
|
370
|
-
@f.val['published'],
|
371
|
-
"Timestamp#update should keep @val['published']"
|
372
|
-
)
|
373
|
-
assert_nil(
|
374
|
-
@f.action,
|
375
|
-
"Timestamp#update should not set @action without v['published']"
|
376
|
-
)
|
377
|
-
assert_nil(
|
378
|
-
@f.result,
|
379
|
-
'Timestamp#update should not set @result'
|
380
|
-
)
|
381
|
-
end
|
382
|
-
|
383
|
-
def test_update_with_date
|
384
|
-
@f[:can_edit] = true
|
385
|
-
@f.load(
|
386
|
-
'created' => Time.local(2010, 4, 1),
|
387
|
-
'updated' => Time.local(2010, 4, 3),
|
388
|
-
'published' => Time.local(2010, 4, 2)
|
389
|
-
)
|
390
|
-
|
391
|
-
@f.update '2010/4/26'
|
392
|
-
assert_equal(
|
393
|
-
Time.local(2010, 4, 1),
|
394
|
-
@f.val['created'],
|
395
|
-
"Timestamp#update should keep @val['created']"
|
396
|
-
)
|
397
|
-
assert_not_equal(
|
398
|
-
Time.local(2010, 4, 3),
|
399
|
-
@f.val['updated'],
|
400
|
-
"Timestamp#update should updated @val['updated']"
|
401
|
-
)
|
402
|
-
assert_equal(
|
403
|
-
Time.local(2010, 4, 26),
|
404
|
-
@f.val['published'],
|
405
|
-
"Timestamp#update should set @val['published'] if v['published'] is a date"
|
406
|
-
)
|
407
|
-
assert_equal(
|
408
|
-
:update,
|
409
|
-
@f.action,
|
410
|
-
"Timestamp#update should set @action if v['published'] is a date"
|
411
|
-
)
|
412
|
-
assert_nil(
|
413
|
-
@f.result,
|
414
|
-
'Timestamp#update should not set @result'
|
415
|
-
)
|
416
|
-
end
|
417
|
-
|
418
|
-
def test_update_can_not_edit
|
419
|
-
@f[:can_edit] = false
|
420
|
-
@f.load(
|
421
|
-
'created' => Time.local(2010, 4, 1),
|
422
|
-
'updated' => Time.local(2010, 4, 3),
|
423
|
-
'published' => Time.local(2010, 4, 2)
|
424
|
-
)
|
425
|
-
|
426
|
-
@f.update '2010/4/26'
|
427
|
-
assert_equal(
|
428
|
-
Time.local(2010, 4, 2),
|
429
|
-
@f.val['published'],
|
430
|
-
"Timestamp#update should not set @val['published'] unless my[:can_edit]"
|
431
|
-
)
|
432
|
-
assert_nil(
|
433
|
-
@f.action,
|
434
|
-
"Timestamp#update should not set @action unless my[:can_edit]"
|
435
|
-
)
|
436
|
-
end
|
437
|
-
|
438
|
-
def test_update_with_check
|
439
|
-
@f[:can_update] = true
|
440
|
-
@f.load(
|
441
|
-
'created' => Time.local(2010, 4, 1),
|
442
|
-
'updated' => Time.local(2010, 4, 3),
|
443
|
-
'published' => Time.local(2010, 4, 2)
|
444
|
-
)
|
445
|
-
|
446
|
-
@f.update 'true'
|
447
|
-
assert_equal(
|
448
|
-
Time.local(2010, 4, 1),
|
449
|
-
@f.val['created'],
|
450
|
-
"Timestamp#update should keep @val['created']"
|
451
|
-
)
|
452
|
-
assert_not_equal(
|
453
|
-
Time.local(2010, 4, 3),
|
454
|
-
@f.val['updated'],
|
455
|
-
"Timestamp#update should updated @val['updated']"
|
456
|
-
)
|
457
|
-
assert_equal(
|
458
|
-
@f.val['updated'],
|
459
|
-
@f.val['published'],
|
460
|
-
"Timestamp#update should updated @val['published'] if v['published'] is :same_as_updated"
|
461
|
-
)
|
462
|
-
assert_equal(
|
463
|
-
:update,
|
464
|
-
@f.action,
|
465
|
-
"Timestamp#update should set @action if v['published'] is :same_as_updated"
|
466
|
-
)
|
467
|
-
assert_nil(
|
468
|
-
@f.result,
|
469
|
-
'Timestamp#update should not set @result'
|
470
|
-
)
|
471
|
-
end
|
472
|
-
|
473
|
-
end
|