zena 1.2.2 → 1.2.3

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 (143) hide show
  1. data/History.txt +25 -0
  2. data/app/controllers/documents_controller.rb +3 -25
  3. data/app/controllers/nodes_controller.rb +34 -24
  4. data/app/controllers/user_sessions_controller.rb +5 -4
  5. data/app/controllers/versions_controller.rb +44 -17
  6. data/app/models/acl.rb +2 -7
  7. data/app/models/group.rb +6 -2
  8. data/app/models/link.rb +14 -0
  9. data/app/models/node.rb +2 -2
  10. data/app/models/site.rb +13 -4
  11. data/app/models/text_document.rb +1 -1
  12. data/app/models/user.rb +11 -2
  13. data/app/models/virtual_class.rb +1 -1
  14. data/app/views/groups/_form.rhtml +6 -6
  15. data/app/views/nodes/render_error.rhtml +15 -0
  16. data/app/views/templates/document_create_tabs/_file.rhtml +1 -1
  17. data/app/views/templates/document_create_tabs/_import.rhtml +1 -1
  18. data/app/views/templates/document_create_tabs/_template.rhtml +1 -1
  19. data/app/views/templates/document_create_tabs/_text_document.rhtml +1 -1
  20. data/app/views/templates/edit_tabs/_title.rhtml +1 -1
  21. data/app/views/zafu/default/Node-admin.zafu +1 -1
  22. data/bricks/acls/zena/test/integration/acl_integration_test.rb +2 -2
  23. data/bricks/acls/zena/test/unit/acl_test.rb +2 -1
  24. data/bricks/fs_skin/zena/migrate/20110702010330_add_fs_skin_to_idx_templates.rb +1 -0
  25. data/bricks/fs_skin/zena/skins/blog/img/style.css +4 -4
  26. data/bricks/grid/lib/bricks/grid.rb +9 -3
  27. data/bricks/passenger/zena/deploy.rb +2 -1
  28. data/bricks/pdf/lib/bricks/pdf.rb +1 -1
  29. data/bricks/tags/zena/test/zafu/tags.yml +5 -1
  30. data/bricks/zena/zena/migrate/20120904071601_change_link_status_to_float.rb +13 -0
  31. data/config/bricks.yml +10 -10
  32. data/config/deploy.rb +1 -5
  33. data/config/gems.yml +2 -2
  34. data/db/init/base/skins/default/Node.zafu +7 -3
  35. data/db/init/base/skins/default/notes.zafu +3 -1
  36. data/lib/zafu/all.rb +0 -9
  37. data/lib/zafu/compiler.rb +0 -4
  38. data/lib/zafu/controller_methods.rb +0 -2
  39. data/lib/zafu/handler.rb +0 -5
  40. data/lib/zafu/markup.rb +4 -6
  41. data/lib/zafu/ordered_hash.rb +3 -2
  42. data/lib/zafu/parsing_rules.rb +1 -3
  43. data/lib/zafu/process/ajax.rb +4 -2
  44. data/lib/zafu/process/context.rb +34 -4
  45. data/lib/zafu/process/forms.rb +2 -2
  46. data/lib/zafu/process/ruby_less_processing.rb +5 -10
  47. data/lib/zafu/template.rb +0 -2
  48. data/lib/zafu/test_helper.rb +0 -2
  49. data/lib/zafu/view_methods.rb +0 -1
  50. data/lib/zafu.rb +1 -1
  51. data/lib/zena/acts/secure_node.rb +5 -4
  52. data/lib/zena/console.rb +19 -17
  53. data/lib/zena/core_ext/string.rb +3 -2
  54. data/lib/zena/deploy/app_init.rhtml +6 -1
  55. data/lib/zena/deploy/httpd.rhtml +16 -13
  56. data/lib/zena/deploy/stats.vhost.rhtml +1 -1
  57. data/lib/zena/deploy/vhost.rhtml +31 -11
  58. data/lib/zena/deploy/vhost_ssl_redir.rhtml +12 -0
  59. data/lib/zena/deploy/vhost_www.rhtml +1 -1
  60. data/lib/zena/deploy.rb +55 -11
  61. data/lib/zena/info.rb +1 -1
  62. data/lib/zena/parser/zazen_rules.rb +18 -9
  63. data/lib/zena/routes.rb +1 -3
  64. data/lib/zena/site_worker.rb +8 -1
  65. data/lib/zena/use/ajax.rb +29 -3
  66. data/lib/zena/use/ancestry.rb +2 -1
  67. data/lib/zena/use/authlogic.rb +12 -18
  68. data/lib/zena/use/context.rb +1 -1
  69. data/lib/zena/use/dates.rb +28 -18
  70. data/lib/zena/use/display.rb +49 -7
  71. data/lib/zena/use/forms.rb +51 -18
  72. data/lib/zena/use/html_tags.rb +6 -6
  73. data/lib/zena/use/i18n.rb +13 -4
  74. data/lib/zena/use/image_builder.rb +2 -0
  75. data/lib/zena/use/query_builder.rb +39 -14
  76. data/lib/zena/use/query_link.rb +57 -0
  77. data/lib/zena/use/query_node.rb +68 -32
  78. data/lib/zena/use/relations.rb +25 -15
  79. data/lib/zena/use/rendering.rb +66 -15
  80. data/lib/zena/use/upload.rb +34 -5
  81. data/lib/zena/use/urls.rb +28 -25
  82. data/lib/zena/use/version_hash.rb +14 -2
  83. data/lib/zena/use/zafu_safe_definitions.rb +72 -3
  84. data/lib/zena/use/zazen.rb +16 -4
  85. data/lib/zena.rb +1 -0
  86. data/public/javascripts/grid.js +213 -64
  87. data/public/javascripts/raphael.js +10 -0
  88. data/public/javascripts/zena.js +146 -22
  89. data/public/stylesheets/reset.css +12 -12
  90. data/public/stylesheets/zena.css +1 -1
  91. data/test/custom_queries/complex.host.yml +19 -0
  92. data/test/fixtures/files/TestNode.zafu +40 -4
  93. data/test/functional/nodes_controller_test.rb +84 -39
  94. data/test/functional/versions_controller_test.rb +2 -2
  95. data/test/integration/navigation_test.rb +61 -35
  96. data/test/integration/query_node/basic.yml +7 -7
  97. data/test/integration/query_node/comments.yml +1 -1
  98. data/test/integration/query_node/complex.yml +3 -3
  99. data/test/integration/query_node/filters.yml +32 -8
  100. data/test/integration/query_node/idx_key_value.yml +10 -10
  101. data/test/integration/query_node/idx_scope.yml +7 -7
  102. data/test/integration/query_node/relations.yml +4 -4
  103. data/test/integration/zafu_compiler/ajax.yml +19 -11
  104. data/test/integration/zafu_compiler/apphelper.yml +1 -1
  105. data/test/integration/zafu_compiler/asset.yml +2 -2
  106. data/test/integration/zafu_compiler/comments.yml +1 -1
  107. data/test/integration/zafu_compiler/dates.yml +1 -1
  108. data/test/integration/zafu_compiler/display.yml +49 -21
  109. data/test/integration/zafu_compiler/eval.yml +4 -4
  110. data/test/integration/zafu_compiler/forms.yml +25 -11
  111. data/test/integration/zafu_compiler/i18n.yml +5 -0
  112. data/test/integration/zafu_compiler/meta.yml +3 -3
  113. data/test/integration/zafu_compiler/query.yml +27 -9
  114. data/test/integration/zafu_compiler/relations.yml +9 -9
  115. data/test/integration/zafu_compiler/roles.yml +6 -6
  116. data/test/integration/zafu_compiler/rubyless.yml +7 -2
  117. data/test/integration/zafu_compiler/safe_definitions.yml +33 -4
  118. data/test/integration/zafu_compiler/security.yml +46 -1
  119. data/test/integration/zafu_compiler/urls.yml +28 -13
  120. data/test/integration/zafu_compiler/user.yml +12 -7
  121. data/test/integration/zafu_compiler/zafu_attributes.yml +1 -1
  122. data/test/integration/zafu_compiler/zazen.yml +5 -5
  123. data/test/integration/zafu_compiler_test.rb +18 -0
  124. data/test/selenium/Filter/filter3.rsel +20 -0
  125. data/test/selenium/Filter/filter4.rsel +20 -0
  126. data/test/sites/zena/versions.yml +2 -0
  127. data/test/unit/exif_data_test.rb +6 -1
  128. data/test/unit/group_test.rb +18 -3
  129. data/test/unit/node_test.rb +0 -7
  130. data/test/unit/project_test.rb +4 -0
  131. data/test/unit/relation_proxy_test.rb +2 -2
  132. data/test/unit/remote_test.rb +0 -9
  133. data/test/unit/role_test.rb +1 -1
  134. data/test/unit/string_hash_test.rb +1 -1
  135. data/test/unit/text_document_test.rb +13 -13
  136. data/test/unit/zena/use/html_tags_test.rb +6 -6
  137. data/test/unit/zena/use/rendering_test.rb +20 -10
  138. data/test/unit/zena/use/urls_test.rb +21 -18
  139. data/test/unit/zena/use/zafu_template_test.rb +0 -5
  140. data/test/unit/zena/use/zazen_test.rb +25 -25
  141. data/zena.gemspec +63 -57
  142. metadata +136 -130
  143. data/test/functional/nodes_controller_commit_test.rb +0 -67
@@ -51,7 +51,12 @@ class ExifDataTest < Test::Unit::TestCase
51
51
 
52
52
  def test_to_json_should_ignore_symbols
53
53
  e = ExifData.new("Make" => "SONY", "DateTime" => "1998:10:01 10:15:30")
54
- assert_equal '{"data":{"Make":"SONY","DateTime":"1998:10:01 10:15:30"},"json_class":"ExifData"}', e.to_json
54
+ # '{"data":{"Make":"SONY","DateTime":"1998:10:01 10:15:30"},"json_class":"ExifData"}'
55
+ keys = []
56
+ e.to_json.gsub(/"([^"]+)"/) do |m|
57
+ keys << m
58
+ end
59
+ assert_equal '"1998:10:01 10:15:30","DateTime","ExifData","Make","SONY","data","json_class"', keys.sort.join(',')
55
60
  end
56
61
 
57
62
  def test_gps_longitude
@@ -107,12 +107,27 @@ class GroupTest < Zena::Unit::TestCase
107
107
  assert groups(:admin).users.include?(users(:ant))
108
108
  end
109
109
 
110
- def test_cannot_update_site_or_public
110
+ def test_cannot_update_site_or_public_user_ids
111
111
  login(:lion)
112
112
  group = groups(:public)
113
- assert !group.update_attributes(:user_ids=>[])
113
+ # ignores user_ids
114
+ assert group.update_attributes(:user_ids=>[])
115
+ assert_equal [users_id(:ant), users_id(:anon), users_id(:tiger), users_id(:lion)].sort, group.user_ids.sort
114
116
  group = groups(:workers)
115
- assert !group.update_attributes(:user_ids=>[])
117
+ # ignores user_ids
118
+ assert group.update_attributes(:user_ids=>[])
119
+ assert_equal [users_id(:ant), users_id(:tiger), users_id(:lion)].sort, group.user_ids.sort
120
+ end
121
+
122
+ def test_can_update_site_or_public_name
123
+ login(:lion)
124
+ group = groups(:public)
125
+ assert group.update_attributes(:name=>'pub')
126
+ assert_equal 'pub', groups(:public).name
127
+
128
+ group = groups(:workers)
129
+ assert group.update_attributes(:name=>'logged-in', :user_ids => [])
130
+ assert_equal 'logged-in', groups(:workers).name
116
131
  end
117
132
 
118
133
  def test_cannot_destroy_group_with_nodes
@@ -1369,13 +1369,6 @@ done: \"I am done\""
1369
1369
  end
1370
1370
  end
1371
1371
 
1372
- # FIXME: write test
1373
- def test_assets
1374
- print 'P'
1375
- # sweep_cache (save) => remove asset folder
1376
- # render math ?
1377
- end
1378
-
1379
1372
  def find_node_by_pseudo(string, base_node = nil)
1380
1373
  secure(Node) { Node.find_node_by_pseudo(string, base_node || @node) }
1381
1374
  end
@@ -15,6 +15,10 @@ class ProjectTest < Zena::Unit::TestCase
15
15
  end
16
16
 
17
17
  def test_update_set_project_id_on_update
18
+ login(:lion)
19
+ # Memory based cache leaks. Make sure we start with a clean cache.
20
+ VirtualClass.expire_cache!
21
+
18
22
  login(:tiger)
19
23
  node = secure!(Project) { Project.find(nodes_id(:cleanWater))}
20
24
  assert_equal nodes_id(:cleanWater), node.get_project_id
@@ -232,12 +232,12 @@ class RelationProxyTest < Zena::Unit::TestCase
232
232
  node = secure!(Node) { nodes(:cleanWater) }
233
233
  assert_equal 'very hot', node.find(:first, 'hot').l_comment
234
234
  # modify again
235
- node.update_attributes(:link_id => links_id(:status_hot_for_cleanWater), :l_comment => 'very hot', :l_status => '45')
235
+ node.update_attributes(:link_id => links_id(:status_hot_for_cleanWater), :l_comment => 'not hot', :l_status => '45')
236
236
  assert node.save
237
237
  # reload
238
238
  hot = node.find(:first, 'hot')
239
239
  node = secure!(Node) { nodes(:cleanWater) }
240
- assert_equal 'very hot', hot.l_comment
240
+ assert_equal 'not hot', hot.l_comment
241
241
  assert_equal 45, hot.l_status
242
242
  end
243
243
 
@@ -58,15 +58,6 @@ class RemoteTest < Zena::Integration::TestCase
58
58
  assert_equal ['News list'], subject.all('title like "%w%"').map(&:title)
59
59
  end
60
60
  end # finding nodes
61
-
62
- context 'getting Klass attributes' do
63
- should 'return list of properties' do
64
- # TODO
65
- print 'P'
66
- #assert_equal {}, subject.properties
67
- end
68
- end # getting Klass attributes
69
-
70
61
  end # and a remote class
71
62
 
72
63
 
@@ -278,7 +278,7 @@ class RoleTest < Zena::Unit::TestCase
278
278
  e = assert_raise(Exception) do
279
279
  subject.import_columns({
280
280
  'one' => {
281
- 'ptype' => 'stringbar',
281
+ 'ptype' => 'string',
282
282
  },
283
283
  'paper' => {
284
284
  'ptype' => 'integer',
@@ -12,7 +12,7 @@ class StringHashTest < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  should 'convert to json' do
15
- assert_match %r{\{"data":\{"b":"2","a":"1"|"a":"1","b":"2"\},"json_class":"StringHash"\}}, subject.to_json
15
+ assert_match %r{"json_class":"StringHash",\{"data":\{"b":"2","a":"1"|"a":"1","b":"2"\}\}|\{"data":\{"b":"2","a":"1"|"a":"1","b":"2"\},"json_class":"StringHash"\}}, subject.to_json
16
16
  end
17
17
 
18
18
  should 'create from json' do
@@ -27,17 +27,17 @@ class TextDocumentTest < Zena::Unit::TestCase
27
27
  #header { background:url('bird.jpg') }
28
28
  #pv { background:url('bird_pv.jpg') }
29
29
  #footer { background:url('/projects list/a wiki with Zena/flower.jpg') }
30
- #no_stamp { background:url('/en/image30_pv.jpg?100001001345') }
30
+ #no_stamp { background:url('/en/image30_pv.7f6f0.jpg') }
31
31
  END_CSS
32
32
 
33
33
  assert subject.update_attributes(:text => css)
34
34
 
35
35
  parsed_css =<<-END_CSS
36
36
  body { font-size:10px; }
37
- #header { background:url('/en/image30.jpg?1144713600') }
38
- #pv { background:url('/en/image30_pv.jpg?967816914293') }
39
- #footer { background:url('/en/image31.jpg?1144713600') }
40
- #no_stamp { background:url('/en/image30_pv.jpg?967816914293') }
37
+ #header { background:url('/en/image30.11fbc.jpg') }
38
+ #pv { background:url('/en/image30_pv.7f6f0.jpg') }
39
+ #footer { background:url('/en/image31.11fbc.jpg') }
40
+ #no_stamp { background:url('/en/image30_pv.7f6f0.jpg') }
41
41
  END_CSS
42
42
 
43
43
  assert_equal parsed_css, subject.text
@@ -141,11 +141,11 @@ class TextDocumentTest < Zena::Unit::TestCase
141
141
  assert node.errors.empty?
142
142
  res =<<-END_CSS
143
143
  body { font-size:10px; behavior:url("/stylesheets/csshover2.htc?#{File.mtime(File.join(RAILS_ROOT, 'public/stylesheets/csshover2.htc')).to_i}"); }
144
- #header { background:url('/en/image30.jpg?1144713600') }
145
- #pv { background:url('/en/image30_pv.jpg?967816914293') }
146
- #footer { background:url('/en/image31.jpg?1144713600') }
147
- #back { background:url('/en/image31.jpg?1144713600') }
148
- #no_stamp { background:url('/en/image30_pv.jpg?967816914293') }
144
+ #header { background:url('/en/image30.11fbc.jpg') }
145
+ #pv { background:url('/en/image30_pv.7f6f0.jpg') }
146
+ #footer { background:url('/en/image31.11fbc.jpg') }
147
+ #back { background:url('/en/image31.11fbc.jpg') }
148
+ #no_stamp { background:url('/en/image30_pv.7f6f0.jpg') }
149
149
  END_CSS
150
150
  assert_equal res, text
151
151
  text = node.parse_assets(text, helper, 'text')
@@ -186,9 +186,9 @@ class TextDocumentTest < Zena::Unit::TestCase
186
186
  assert node.errors.empty?
187
187
  res =<<-END_CSS
188
188
  body { font-size:10px; }
189
- #header { background:url('/en/image30.jpg?1144713600') }
190
- #tiny { background:url('/en/image30_tiny.jpg?812062401186') }
191
- #footer { background:url('/en/image31.jpg?1144713600') }
189
+ #header { background:url('/en/image30.11fbc.jpg') }
190
+ #tiny { background:url('/en/image30_tiny.0059b.jpg') }
191
+ #footer { background:url('/en/image31.11fbc.jpg') }
192
192
  END_CSS
193
193
  assert_equal res, text
194
194
  end
@@ -24,12 +24,12 @@ class HtmlTagsTest < Zena::View::TestCase
24
24
  assert_match 'img', img_tag(subject)
25
25
  end
26
26
 
27
- should 'append timestamp' do
28
- assert_match %r{\?1144713600}, img_tag(subject)
27
+ should 'use timestamp' do
28
+ assert_match %r{image30.11fbc.jpg}, img_tag(subject)
29
29
  end
30
30
 
31
31
  should 'use IFormat for timestamp' do
32
- assert_match %r{\?967816914293}, img_tag(subject, :mode => 'pv')
32
+ assert_match %r{image30_pv.7f6f0.jpg}, img_tag(subject, :mode => 'pv')
33
33
  end
34
34
 
35
35
  should 'set class from mode' do
@@ -134,7 +134,7 @@ class HtmlTagsTest < Zena::View::TestCase
134
134
  end
135
135
 
136
136
  should 'show notice' do
137
- assert_match %r{Amy & Eve}, flash_messages(:show => 'both')
137
+ assert_match %r{Amy &amp; Eve}, flash_messages(:show => 'both')
138
138
  end
139
139
  end
140
140
 
@@ -222,7 +222,7 @@ class HtmlTagsTest < Zena::View::TestCase
222
222
 
223
223
  def test_alt_with_apos
224
224
  doc = secure!(Node) { nodes(:lake_jpg) }
225
- assert_equal "<img src='/en/projects-list/Clean-Water-project/image24.jpg?1144713600' width='600' height='440' alt='it&apos;s a lake' class='full'/>", img_tag(doc)
225
+ assert_equal "<img src='/en/projects-list/Clean-Water-project/image24.11fbc.jpg' width='600' height='440' alt='it&apos;s a lake' class='full'/>", img_tag(doc)
226
226
  end
227
227
 
228
228
  def test_select_id
@@ -281,7 +281,7 @@ class HtmlTagsTest < Zena::View::TestCase
281
281
  assert_equal [], @controller.js_data
282
282
  img_tag(img, :mode => 'med', :id => 'flop') # med has a popup setting
283
283
  popup_data = JSON.load(@controller.js_data[0][%r{\A.*?(\{.*\}).*\Z},1])
284
- assert_equal '/en/image30_std.jpg?929831698949', popup_data['src']
284
+ assert_equal '/en/image30_std.75a9a.jpg', popup_data['src']
285
285
  assert_equal 400, popup_data['height']
286
286
  assert_equal 440, popup_data['width']
287
287
  end
@@ -54,7 +54,7 @@ class RenderingInControllerTest < Zena::Controller::TestCase
54
54
  def make_template(zafu, mode = 'special')
55
55
  login(:lion)
56
56
  # create template for 'special' mode
57
- secure(Template) { Template.create(:parent_id => nodes_id(:default), :title => "Node-#{mode}.zafu", :text => zafu, :v_status => Zena::Status::Pub) }
57
+ @template = secure(Template) { Template.create(:parent_id => nodes_id(:default), :title => "Node-#{mode}.zafu", :text => zafu, :v_status => Zena::Status::Pub) }
58
58
  end
59
59
 
60
60
  context 'A custom rendering engine' do
@@ -96,7 +96,7 @@ class RenderingInControllerTest < Zena::Controller::TestCase
96
96
 
97
97
  end # A custom rendering engine
98
98
 
99
- context 'Custom rendering options' do
99
+ context 'Custom headers' do
100
100
  subject do
101
101
  login(:lion)
102
102
  # create template for 'special' mode
@@ -117,7 +117,7 @@ class RenderingInControllerTest < Zena::Controller::TestCase
117
117
  assert_equal v, @response.headers[k]
118
118
  end
119
119
  end
120
- end # Custom rendering options
120
+ end # Custom headers
121
121
 
122
122
  context 'special rendering zafu' do
123
123
  subject do
@@ -185,17 +185,17 @@ class RenderingInControllerTest < Zena::Controller::TestCase
185
185
  end # to update
186
186
  end # special rendering zafu
187
187
 
188
- context 'Custom rendering options on html' do
188
+ context 'Custom headers on html' do
189
+ setup do
190
+ make_template %q{<r:headers X-Foobar='my thing' Content-Type='text/css' Content-Disposition='attachment; filename=special_#{title}.csv'/>}, 'bar'
191
+ end
192
+
189
193
  subject do
190
- login(:lion)
191
- # create template for 'special' mode
192
- @template = secure(Template) { Template.create(:parent_id => nodes_id(:default), :title => 'Node-bar.zafu', :text => @zafu, :v_status => Zena::Status::Pub) }
193
194
  login(:anon)
194
195
  {:action => 'show', :controller => 'nodes', :path => ["section#{nodes_zip(:people)}_bar.html"], :prefix => 'en'}
195
196
  end
196
197
 
197
198
  should 'set type and disposition headers' do
198
- @zafu = %q{<r:headers X-Foobar='my thing' Content-Type='text/css' Content-Disposition='attachment; filename=special_#{title}.csv'/>}
199
199
  get_subject
200
200
  assert_response :success
201
201
  {
@@ -206,13 +206,23 @@ class RenderingInControllerTest < Zena::Controller::TestCase
206
206
  assert_equal v, @response.headers[k]
207
207
  end
208
208
  end
209
+ end
210
+
211
+ context 'With a master template' do
212
+ setup do
213
+ make_template %q{MASTER_TEMPLATE[<r:master_template do='id'/>]}, 'baz'
214
+ end
215
+
216
+ subject do
217
+ login(:anon)
218
+ {:action => 'show', :controller => 'nodes', :path => ["section#{nodes_zip(:people)}_baz.html"], :prefix => 'en'}
219
+ end
209
220
 
210
221
  should 'find master template' do
211
- @zafu = %q{MASTER_TEMPLATE[<r:master_template do='id'/>]}
212
222
  get_subject
213
223
  assert_response :success
214
224
  assert_equal "MASTER_TEMPLATE[#{@template.zip}]", @response.body
215
225
  end
216
- end # Custom rendering options
226
+ end # Custom headers on html
217
227
 
218
228
  end
@@ -26,7 +26,7 @@ class UrlsTest < Zena::View::TestCase
26
26
  node = secure!(Node) { nodes(:people) }
27
27
  assert_equal '/en/section12.html', zen_path(node)
28
28
  assert_equal '/en/section12_test.html', zen_path(node, :mode=>'test')
29
- assert_match %r{/tt/section12_test.jpg}, zen_path(node, :mode=>'test', :prefix=>'tt', :format=>'jpg')
29
+ assert_match %r{/tt/section12_test.11fbc.jpg}, zen_path(node, :mode=>'test', :prefix=>'tt', :format=>'jpg')
30
30
  node = secure!(Node) { nodes(:cleanWater) }
31
31
  assert_equal '/en/projects-list/Clean-Water-project', zen_path(node)
32
32
  assert_equal '/en/projects-list/Clean-Water-project_test', zen_path(node, :mode=>'test')
@@ -56,41 +56,43 @@ class UrlsTest < Zena::View::TestCase
56
56
  def test_zen_path_cache_stamp
57
57
  login(:ant)
58
58
  node = secure!(Node) { nodes(:zena) }
59
- assert_equal '/oo/project11.png?1144713600', zen_path(node, :format => 'png')
59
+ assert_equal '/oo/project11.11fbc.png', zen_path(node, :format => 'png')
60
60
  node = secure!(Node) { nodes(:bird_jpg) }
61
- assert_equal '/en/image30.jpg?1144713600', zen_path(node, :format => 'jpg')
61
+ assert_equal '/en/image30.11fbc.jpg', zen_path(node, :format => 'jpg')
62
62
  node = secure!(Node) { nodes(:style_css) }
63
- assert_equal '/en/textdocument54.css?1144713600', zen_path(node, :format => 'css')
63
+ assert_equal '/en/textdocument54.11fbc.css', zen_path(node, :format => 'css')
64
64
 
65
65
  login(:anon)
66
66
  node = secure!(Node) { nodes(:cleanWater) }
67
- assert_equal '/en/projects-list/Clean-Water-project.jpg?1144713600', zen_path(node, :format => 'jpg')
67
+ assert_equal '/en/projects-list/Clean-Water-project.11fbc.jpg', zen_path(node, :format => 'jpg')
68
68
  end
69
69
 
70
70
  def test_make_cachestamp
71
71
  login(:lion)
72
72
 
73
73
  node = secure!(Node) { nodes(:bird_jpg) }
74
- assert_equal '967816914293', make_cachestamp(node, 'pv')
74
+ base = '7f6f0'
75
+ assert_equal base, make_cachestamp(node, 'pv')
75
76
  # update pv
76
77
  imf = Iformat.create(:name => 'pv', :width => 70, :height=> 70, :size=> 'force')
77
78
  assert !imf.new_record?
78
79
  # same hash
79
- assert_equal '967816914293', make_cachestamp(node, 'pv')
80
+ assert_equal base, make_cachestamp(node, 'pv')
80
81
 
81
82
  assert Iformat.update(imf.id, :width => 60)
82
- assert_equal '8889395035', make_cachestamp(node, 'pv')
83
+ assert_equal '14052', make_cachestamp(node, 'pv')
84
+ assert_not_equal base, '14052'
83
85
 
84
86
  assert Iformat.update(imf.id, :width => 70)
85
87
  # should be the same as first
86
- assert_equal '967816914293', make_cachestamp(node, 'pv')
88
+ assert_equal base, make_cachestamp(node, 'pv')
87
89
  end
88
90
 
89
91
  def test_zen_path_cachestamp_image_mode
90
92
  login(:ant)
91
93
  node = secure!(Node) { nodes(:bird_jpg) }
92
- assert_equal "/en/image30.jpg?#{node.updated_at.to_i}", zen_path(node, :format => 'jpg')
93
- assert_equal "/en/image30_pv.jpg?#{node.updated_at.to_i + Iformat['pv'][:hash_id]}", zen_path(node, :format => 'jpg', :mode => 'pv')
94
+ assert_equal "/en/image30.#{make_cachestamp(node,nil)}.jpg", zen_path(node, :format => 'jpg')
95
+ assert_equal "/en/image30_pv.#{make_cachestamp(node, 'pv')}.jpg", zen_path(node, :format => 'jpg', :mode => 'pv')
94
96
  end
95
97
 
96
98
  def test_zen_path_with_anchor
@@ -101,20 +103,20 @@ class UrlsTest < Zena::View::TestCase
101
103
  def test_zen_path_asset
102
104
  login(:ant)
103
105
  node = secure!(Node) { nodes(:zena) }
104
- assert_equal "/oo/project11.abcd.html", zen_path(node, :asset=>'abcd')
106
+ assert_equal "/oo/project11=abcd.html", zen_path(node, :asset=>'abcd')
105
107
  node = secure!(Node) { nodes(:people) }
106
- assert_equal "/oo/section12.m1234.png?1144713600", zen_path(node, :asset=>'m1234', :format=>'png')
108
+ assert_equal "/oo/section12=m1234.#{make_cachestamp(node,nil)}.png", zen_path(node, :asset=>'m1234', :format=>'png')
107
109
 
108
110
  login(:anon)
109
111
  node = secure!(Node) { nodes(:zena) }
110
- assert_equal "/en/project11.abcd.png?1144713600", zen_path(node, :asset=>'abcd', :format=>'png')
112
+ assert_equal "/en/project11=abcd.11fbc.png", zen_path(node, :asset=>'abcd', :format=>'png')
111
113
  node = secure!(Node) { nodes(:people) }
112
- assert_equal "/en/section12.kls.html", zen_path(node, :asset=>'kls')
113
- assert_equal "/tt/section12.foo.jpg?1144713600", zen_path(node, :mode=>'test', :prefix=>'tt', :format=>'jpg', :asset => 'foo')
114
+ assert_equal "/en/section12=kls.html", zen_path(node, :asset=>'kls')
115
+ assert_equal "/tt/section12=foo.11fbc.jpg", zen_path(node, :mode=>'test', :prefix=>'tt', :format=>'jpg', :asset => 'foo')
114
116
  node = secure!(Node) { nodes(:cleanWater) }
115
- assert_equal "/en/projects-list/Clean-Water-project.kls", zen_path(node, :asset => 'kls')
117
+ assert_equal "/en/projects-list/Clean-Water-project=kls", zen_path(node, :asset => 'kls')
116
118
  node = secure!(Node) { nodes(:status) }
117
- assert_equal "/en/projects-list/Clean-Water-project/page22.abcd.png?1144713600", zen_path(node, :asset => 'abcd', :format => 'png')
119
+ assert_equal "/en/projects-list/Clean-Water-project/page22=abcd.11fbc.png", zen_path(node, :asset => 'abcd', :format => 'png')
118
120
  end
119
121
 
120
122
  def test_zen_url
@@ -143,6 +145,7 @@ class UrlsTest < Zena::View::TestCase
143
145
  node = secure!(Node) { nodes(:water_pdf) }
144
146
  assert node.update_attributes( :rgroup_id => groups_id(:workers), :inherit => 0 )
145
147
  assert !node.public?
148
+ assert !node.v_public?
146
149
  assert_equal "/oo/projects-list/Clean-Water-project/document25.pdf", data_path(node)
147
150
  node = secure!(Node) { nodes(:status) }
148
151
  assert_equal "/oo/projects-list/Clean-Water-project/page22.html", data_path(node)
@@ -56,11 +56,6 @@ class ZafuTemplateTest < Zena::View::TestCase
56
56
  visiting(:wiki)
57
57
  assert_match %r{/wiki skin/Node}, @controller.send(:template_url)
58
58
  end
59
-
60
- should 'not insert dev_box for non html content' do
61
- # TODO
62
- print 'P'
63
- end
64
59
  end # with an admin visitor
65
60
 
66
61
  context 'without an admin visitor' do
@@ -49,15 +49,15 @@ class ZazenTest < Zena::View::TestCase
49
49
 
50
50
  def test_make_image
51
51
  # * [!24!] inline image 24. (default format is 'pv' defined in #ImageBuilder). Options are :
52
- assert_equal "<p><img src='/en/projects-list/Clean-Water-project/image24_std.jpg?929831698949' width='545' height='400' alt='it&apos;s a lake' class='std'/></p>", zazen('!24!')
52
+ assert_equal "<p><img src='/en/projects-list/Clean-Water-project/image24_std.75a9a.jpg' width='545' height='400' alt='it&apos;s a lake' class='std'/></p>", zazen('!24!')
53
53
  # ** [!024!] inline image, default format, link to full image.
54
- assert_equal "<p><a class='popup' href='/en/projects-list/Clean-Water-project/image24.jpg?1144713600' target='_blank'><img src='/en/projects-list/Clean-Water-project/image24_std.jpg?929831698949' width='545' height='400' alt='it&apos;s a lake' class='std'/></a></p>", zazen('!024!')
54
+ assert_equal "<p><a class='popup' href='/en/projects-list/Clean-Water-project/image24.11fbc.jpg' target='_blank'><img src='/en/projects-list/Clean-Water-project/image24_std.75a9a.jpg' width='545' height='400' alt='it&apos;s a lake' class='std'/></a></p>", zazen('!024!')
55
55
  end
56
56
 
57
57
  def test_make_image_with_document
58
- assert_match %r{<p><a.*href=.*en/projects-list/Clean-Water-project/document25\.pdf.*img src='/images/ext/pdf.png' width='32' height='32' alt='pdf document' class='doc'/></a></p>}, zazen('!25!')
59
- assert_match %r{<p><a.*href=.*en/projects-list/Clean-Water-project/document25\.pdf.*img src='/images/ext/pdf.png' width='32' height='32' alt='pdf document' class='doc'/></a></p>}, zazen('!025!') # same as '!25!'
60
- assert_match %r{<p><a.*href=.*en/projects-list/Clean-Water-project/document25\.pdf.*img src='/images/ext/pdf_pv.png' width='70' height='70' alt='pdf document' class='doc'/></a></p>}, zazen('!25_pv!')
58
+ assert_match %r{<p><a.*href=.*en/projects-list/Clean-Water-project/document25.pdf.*img src='/images/ext/pdf.png' width='32' height='32' alt='pdf document' class='doc'/></a></p>}, zazen('!25!')
59
+ assert_match %r{<p><a.*href=.*en/projects-list/Clean-Water-project/document25.pdf.*img src='/images/ext/pdf.png' width='32' height='32' alt='pdf document' class='doc'/></a></p>}, zazen('!025!') # same as '!25!'
60
+ assert_match %r{<p><a.*href=.*en/projects-list/Clean-Water-project/document25.pdf.*img src='/images/ext/pdf_pv.png' width='70' height='70' alt='pdf document' class='doc'/></a></p>}, zazen('!25_pv!')
61
61
  end
62
62
 
63
63
  def test_make_bad_image
@@ -66,34 +66,34 @@ class ZazenTest < Zena::View::TestCase
66
66
 
67
67
  def test_make_image_align
68
68
  # ** [!<.24!] or [!<24!] inline image surrounded with <p class='float_left'></p>
69
- assert_match %r{class='img_left'.*img.*/en/projects-list/Clean-Water-project/image24_std.jpg.*class='std'}, zazen('!<.24!')
70
- assert_match %r{class='img_left'.*img.*/en/projects-list/Clean-Water-project/image24_std.jpg.*class='std'}, zazen('!<24!')
69
+ assert_match %r{class='img_left'.*img.*/en/projects-list/Clean-Water-project/image24_std.75a9a.jpg.*class='std'}, zazen('!<.24!')
70
+ assert_match %r{class='img_left'.*img.*/en/projects-list/Clean-Water-project/image24_std.75a9a.jpg.*class='std'}, zazen('!<24!')
71
71
  # ** [!>.24!] inline image surrounded with <p class='float_right'></p>
72
- assert_match %r{class='img_right'.*img.*/en/projects-list/Clean-Water-project/image24_std.jpg.*class='std'}, zazen('!>.24!')
73
- assert_match %r{class='img_right'.*img.*/en/projects-list/Clean-Water-project/image24_std.jpg.*class='std'}, zazen('!>24!')
72
+ assert_match %r{class='img_right'.*img.*/en/projects-list/Clean-Water-project/image24_std.75a9a.jpg.*class='std'}, zazen('!>.24!')
73
+ assert_match %r{class='img_right'.*img.*/en/projects-list/Clean-Water-project/image24_std.75a9a.jpg.*class='std'}, zazen('!>24!')
74
74
  # ** [!=.24!] inline image with <p class='center'></p>
75
- assert_match %r{class='img_center'.*img.*/en/projects-list/Clean-Water-project/image24_std.jpg.*class='std'}, zazen('!=.24!')
76
- assert_match %r{class='img_center'.*img.*/en/projects-list/Clean-Water-project/image24_std.jpg.*class='std'}, zazen('!=24!')
75
+ assert_match %r{class='img_center'.*img.*/en/projects-list/Clean-Water-project/image24_std.75a9a.jpg.*class='std'}, zazen('!=.24!')
76
+ assert_match %r{class='img_center'.*img.*/en/projects-list/Clean-Water-project/image24_std.75a9a.jpg.*class='std'}, zazen('!=24!')
77
77
  end
78
78
 
79
79
  def test_make_iformat
80
80
  # ** [!24_pv!] inline image transformed to format 'pv'. Formats are defined in #ImageBuilder.
81
- assert_match %r{.*img.*/en/projects-list/Clean-Water-project/image24.jpg.*600.*440.*class='full'}, zazen('!24_full!')
82
- assert_match %r{.*img.*/en/projects-list/Clean-Water-project/image24_tiny.jpg.*16.*16.*class='tiny'}, zazen('!24_tiny!')
81
+ assert_match %r{.*img.*/en/projects-list/Clean-Water-project/image24.[0-9a-f]+.jpg.*600.*440.*class='full'}, zazen('!24_full!')
82
+ assert_match %r{.*img.*/en/projects-list/Clean-Water-project/image24_tiny.[0-9a-f]+.jpg.*16.*16.*class='tiny'}, zazen('!24_tiny!')
83
83
  end
84
84
 
85
85
  def test_all_options
86
86
  # ** all the options above can be used together as in [!>.26.std!] : inline image on the right, size 'med'.
87
- assert_match %r{class='img_right'.*img.*/en/projects-list/Clean-Water-project/image24_mini.jpg.*32.*32.*class='mini'}, zazen('!>24_mini!')
88
- assert_match %r{class='img_right'.*img.*/en/projects-list/Clean-Water-project/image24_mini.jpg.*32.*32.*class='mini'}, zazen('!>.24_mini!')
87
+ assert_match %r{class='img_right'.*img.*/en/projects-list/Clean-Water-project/image24_mini.[0-9a-f]+.jpg.*32.*32.*class='mini'}, zazen('!>24_mini!')
88
+ assert_match %r{class='img_right'.*img.*/en/projects-list/Clean-Water-project/image24_mini.[0-9a-f]+.jpg.*32.*32.*class='mini'}, zazen('!>.24_mini!')
89
89
  end
90
90
 
91
91
  def test_make_gallery
92
92
  # ** [![2,3,5]!] gallery : inline preview with javascript inline viewer
93
- assert_match %r{table.*gallery.*Zena.transfer.*image24_pv.jpg.*image24_std.jpg.*image30_pv.jpg.*image30_std.jpg}m, zazen('![24,30]!')
93
+ assert_match %r{table.*gallery.*Zena.transfer.*image24_pv.*image24_std.*image30_pv.*image30_std}m, zazen('![24,30]!')
94
94
  @node = secure!(Node) { Node.find(nodes_id(:wiki)) }
95
95
  # ** [![]!] gallery with all images contained in the current node
96
- assert_match %r{table.*gallery.*Zena.transfer.*image30_pv.jpg.*image30_std.jpg.*image31_pv.jpg.*image31_std.jpg}m, zazen('![]!')
96
+ assert_match %r{table.*gallery.*Zena.transfer.*image30_pv.*image30_std.*image31_pv.*image31_std}m, zazen('![]!')
97
97
  end
98
98
 
99
99
  def test_make_gallery_bad_zips
@@ -118,13 +118,13 @@ class ZazenTest < Zena::View::TestCase
118
118
 
119
119
  def test_image_as_link
120
120
  # * [!26!:37] you can use an image as the source for a link
121
- assert_zazen_match "p a[@href='/en/projects-list/Clean-Water-project'] img.std[@src='/en/image30_std.jpg?929831698949'][@width='440'][@height='400']", '!30!:21'
121
+ assert_zazen_match "p a[@href='/en/projects-list/Clean-Water-project'] img.std[@src='/en/image30_std.75a9a.jpg'][@width='440'][@height='400']", '!30!:21'
122
122
  # * [!26!:www.example.com] use an image for an outgoing link
123
- assert_zazen_match "p a[@href='http://www.example.com'] img.std[@src='/en/image30_std.jpg?929831698949']", '!30!:http://www.example.com'
123
+ assert_zazen_match "p a[@href='http://www.example.com'] img.std[@src='/en/image30_std.75a9a.jpg']", '!30!:http://www.example.com'
124
124
  end
125
125
 
126
126
  def test_full
127
- assert_zazen_match "div.img_left a[@href='/en/projects-list/Clean-Water-project'][@onclick*=window.open] img.std[@src='/en/projects-list/Clean-Water-project/image24_std.jpg?929831698949'][@width='545'][@height='400'][@alt*=lake]", '!<.24_3!:021'
127
+ assert_zazen_match "div.img_left a[@href='/en/projects-list/Clean-Water-project'][@onclick*=window.open] img.std[@src='/en/projects-list/Clean-Water-project/image24_std.75a9a.jpg'][@width='545'][@height='400'][@alt*=lake]", '!<.24_3!:021'
128
128
  end
129
129
 
130
130
  def test_empty_image_ref
@@ -139,7 +139,7 @@ class ZazenTest < Zena::View::TestCase
139
139
 
140
140
  def test_pseudo_id
141
141
  assert_zazen_match "a[@href='/en/contact15.html'][text()='people/Panthera Leo Verneyi']", 'This is a "link"::Leo.'
142
- assert_zazen_match "a[@href='/en/image30_pv.jpg?967816914293'][text()='projects list/a wiki with Zena/bird_pv.jpg']", 'This is a "link"::bir_pv.data.'
142
+ assert_zazen_match "a[@href='/en/image30_pv.7f6f0.jpg'][text()='projects list/a wiki with Zena/bird_pv.jpg']", 'This is a "link"::bir_pv.data.'
143
143
  end
144
144
 
145
145
  context 'An absolute pseudo path' do
@@ -156,7 +156,7 @@ class ZazenTest < Zena::View::TestCase
156
156
  end
157
157
 
158
158
  should 'resolve as image without using the current node' do
159
- assert_match %Q{img[@src='/en/image30_std.jpg?929831698949']}, zazen(%Q{See !#{subject}!})
159
+ assert_match %Q{img[@src='/en/image30_std.75a9a.jpg']}, zazen(%Q{See !#{subject}!})
160
160
  end
161
161
 
162
162
 
@@ -166,7 +166,7 @@ class ZazenTest < Zena::View::TestCase
166
166
  end
167
167
 
168
168
  should 'resolve with mode in image tag' do
169
- assert_equal "<p>See <img src='/en/image30_side.jpg?100321116926' width='220' height='500' alt='bird' class='side'/></p>", zazen(%Q{See !#{subject}!})
169
+ assert_equal "<p>See <img src='/en/image30_side.9698b.jpg' width='220' height='500' alt='bird' class='side'/></p>", zazen(%Q{See !#{subject}!})
170
170
  end
171
171
 
172
172
  should 'resolve with mode as link' do
@@ -174,11 +174,11 @@ class ZazenTest < Zena::View::TestCase
174
174
  end
175
175
 
176
176
  should 'resolve with mode as link to image' do
177
- assert_equal "<p>Read <a href=\"/en/image30_side.html\"><img src='/en/image30_std.jpg?929831698949' width='440' height='400' alt='bird' class='std'/></a></p>", zazen(%Q{Read !30!:#{subject}})
177
+ assert_equal "<p>Read <a href=\"/en/image30_side.html\"><img src='/en/image30_std.75a9a.jpg' width='440' height='400' alt='bird' class='std'/></a></p>", zazen(%Q{Read !30!:#{subject}})
178
178
  end
179
179
 
180
180
  should 'resolve with mode as link and image tag' do
181
- assert_equal "<p>See <a href=\"/en/image30_side.html\"><img src='/en/image30_side.jpg?100321116926' width='220' height='500' alt='bird' class='side'/></a></p>", zazen(%Q{See !#{subject}!:#{subject}})
181
+ assert_equal "<p>See <a href=\"/en/image30_side.html\"><img src='/en/image30_side.9698b.jpg' width='220' height='500' alt='bird' class='side'/></a></p>", zazen(%Q{See !#{subject}!:#{subject}})
182
182
  end
183
183
  end
184
184
  end # An absolute pseudo path