zena 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,6 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class NodesControllerTest < Zena::Controller::TestCase
4
+ include Zena::Use::Urls::Common
4
5
  context 'An anonymous user' do
5
6
  setup do
6
7
  login(:anon)
@@ -165,22 +166,21 @@ class NodesControllerTest < Zena::Controller::TestCase
165
166
 
166
167
  context 'asking for show' do
167
168
  subject do
169
+ @stamp = make_cachestamp(secure(Node) { Node.find(nodes_id(:projects))}, nil)
168
170
  {
169
171
  :action => 'show', :controller => 'nodes',
170
- :path => ["page#{nodes_zip(:projects)}_info.js"],
172
+ :path => ["page#{nodes_zip(:projects)}_info.#{@stamp}.js"],
171
173
  :prefix => 'en'
172
174
  }
173
175
  end
174
176
 
175
177
  should 'recognize show page' do
176
- assert_recognizes subject, "/en/page#{nodes_zip(:projects)}_info.js"
178
+ assert_recognizes subject, "/en/page#{nodes_zip(:projects)}_info.#{@stamp}.js"
177
179
  end
178
180
 
179
181
  should 'insert cachestamp and render template' do
180
182
  get_subject
181
- #
182
- assert_redirected_to "/en/page18_info.js?#{nodes(:projects).updated_at.to_i}"
183
- get 'show', :path => subject[:path], :cachestamp => nodes(:projects).updated_at.to_i.to_s, :prefix => 'en'
183
+ get 'show', :path => subject[:path], :prefix => 'en'
184
184
  assert_response :success
185
185
  assert_equal '{some:"json"}', @response.body
186
186
  end
@@ -650,12 +650,12 @@ class NodesControllerTest < Zena::Controller::TestCase
650
650
  end # trying to destroy an inaccessible node
651
651
  end # A user
652
652
 
653
-
653
+
654
654
  def test_foo
655
- assert_generates '/en/img.jpg?1234', :controller => :nodes, :action => :show, :prefix => 'en', :path => ["img.jpg"], :cachestamp => '1234'
655
+ assert_generates '/en/img.ff823.jpg', :controller => :nodes, :action => :show, :prefix => 'en', :path => ["img.ff823.jpg"]
656
656
  assert_recognizes(
657
- {:controller => 'nodes', :action => 'show', :prefix => 'en', :path => ["img.jpg"], :cachestamp => '1234'},
658
- '/en/img.jpg?1234'
657
+ {:controller => 'nodes', :action => 'show', :prefix => 'en', :path => ["img.ff823.jpg"]},
658
+ '/en/img.ff823.jpg'
659
659
  )
660
660
  end
661
661
 
@@ -664,12 +664,12 @@ class NodesControllerTest < Zena::Controller::TestCase
664
664
  node = secure!(Node) { nodes(:bird_jpg) }
665
665
  get 'show', :prefix => 'oo', :path => ["image#{node.zip}.jpg"]
666
666
  # missing cache info
667
- assert_redirected_to "/en/image#{node.zip}.jpg?#{node.updated_at.to_i}"
667
+ assert_redirected_to "/en/image#{node.zip}.#{make_cachestamp(node,nil)}.jpg"
668
668
  # bad cache info
669
- get 'show', :prefix => 'en', :path => ["image#{node.zip}.jpg"], :cachestamp => '1234'
670
- assert_redirected_to "/en/image#{node.zip}.jpg?#{node.updated_at.to_i}"
669
+ get 'show', :prefix => 'en', :path => ["image#{node.zip}.1234.jpg"]
670
+ assert_redirected_to "/en/image#{node.zip}.#{make_cachestamp(node,nil)}.jpg"
671
671
  # cache info ok
672
- get 'show', :prefix => 'en', :path => ["image#{node.zip}.jpg"], :cachestamp => node.updated_at.to_i
672
+ get 'show', :prefix => 'en', :path => ["image#{node.zip}.#{make_cachestamp(node,nil)}.jpg"]
673
673
  assert_response :success
674
674
  end
675
675
 
@@ -678,12 +678,12 @@ class NodesControllerTest < Zena::Controller::TestCase
678
678
  node = secure!(Node) { nodes(:bird_jpg) }
679
679
  get 'show', :prefix => 'oo', :path => ["image#{node.zip}_pv.jpg"]
680
680
  # missing cache info, can use public image
681
- assert_redirected_to "/en/image#{node.zip}_pv.jpg?#{node.updated_at.to_i + Iformat['pv'][:hash_id]}"
681
+ assert_redirected_to "/en/image#{node.zip}_pv.#{make_cachestamp(node,'pv')}.jpg"
682
682
  # bad cache info
683
- get 'show', :prefix => 'en', :path => ["image#{node.zip}.jpg"], :cachestamp => '1234'
684
- assert_redirected_to "/en/image#{node.zip}.jpg?#{node.updated_at.to_i}"
683
+ get 'show', :prefix => 'en', :path => ["image#{node.zip}.1234.jpg"]
684
+ assert_redirected_to "/en/image#{node.zip}.#{make_cachestamp(node,nil)}.jpg"
685
685
  # cache info ok
686
- get 'show', :prefix => 'en', :path => ["image#{node.zip}.jpg"], :cachestamp => node.updated_at.to_i
686
+ get 'show', :prefix => 'en', :path => ["image#{node.zip}.#{make_cachestamp(node,nil)}.jpg"]
687
687
  assert_response :success
688
688
  end
689
689
 
@@ -692,12 +692,12 @@ class NodesControllerTest < Zena::Controller::TestCase
692
692
  node = secure!(Node) { nodes(:style_css) }
693
693
  get 'show', :prefix => 'oo', :path => ["textdocument#{node.zip}.css"]
694
694
  # missing cache info, should use public lang
695
- assert_redirected_to "/en/textdocument#{node.zip}.css?#{node.updated_at.to_i}"
695
+ assert_redirected_to "/en/textdocument#{node.zip}.#{make_cachestamp(node,nil)}.css"
696
696
  # bad cache info
697
- get 'show', :prefix => 'en', :path => ["textdocument#{node.zip}.css"], :cachestamp => '1234'
698
- assert_redirected_to "/en/textdocument#{node.zip}.css?#{node.updated_at.to_i}"
697
+ get 'show', :prefix => 'en', :path => ["textdocument#{node.zip}.1234.css"]
698
+ assert_redirected_to "/en/textdocument#{node.zip}.#{make_cachestamp(node,nil)}.css"
699
699
  # cache info ok
700
- get 'show', :prefix => 'en', :path => ["textdocument#{node.zip}.css"], :cachestamp => node.updated_at.to_i
700
+ get 'show', :prefix => 'en', :path => ["textdocument#{node.zip}.#{make_cachestamp(node,nil)}.css"]
701
701
  assert_response :success
702
702
  end
703
703
 
@@ -708,16 +708,16 @@ class NodesControllerTest < Zena::Controller::TestCase
708
708
  node = secure!(Node) { nodes(:bird_jpg) }
709
709
  get 'show', :prefix => 'en', :path => ["image#{node.zip}.jpg"]
710
710
  # missing cache info
711
- assert_redirected_to "/en/image#{node.zip}.jpg?#{node.updated_at.to_i}"
711
+ assert_redirected_to "/en/image#{node.zip}.#{make_cachestamp(node,nil)}.jpg"
712
712
  assert !File.exist?("#{SITES_ROOT}/test.host/public/en/image#{node.zip}.jpg")
713
713
  # bad cache info
714
- get 'show', :prefix => 'en', :path => ["image#{node.zip}.jpg"], :cachestamp => '1234'
715
- assert_redirected_to "/en/image#{node.zip}.jpg?#{node.updated_at.to_i}"
716
- assert !File.exist?("#{SITES_ROOT}/test.host/public/en/image#{node.zip}.jpg")
714
+ get 'show', :prefix => 'en', :path => ["image#{node.zip}.1234.jpg"]
715
+ assert_redirected_to "/en/image#{node.zip}.#{make_cachestamp(node,nil)}.jpg"
716
+ assert !File.exist?("#{SITES_ROOT}/test.host/public/en/image#{node.zip}.#{make_cachestamp(node,nil)}.jpg")
717
717
  # cache info ok
718
- get 'show', :prefix => 'en', :path => ["image#{node.zip}.jpg"], :cachestamp => node.updated_at.to_i
718
+ get 'show', :prefix => 'en', :path => ["image#{node.zip}.#{make_cachestamp(node,nil)}.jpg"]
719
719
  assert_response :success
720
- assert File.exist?(make_cache_path("#{SITES_ROOT}/test.host/public/en/image#{node.zip}.jpg", node))
720
+ assert File.exist?("#{SITES_ROOT}/test.host/public/en/image#{node.zip}.#{make_cachestamp(node,nil)}.jpg")
721
721
  end
722
722
  end
723
723
  end
@@ -778,10 +778,6 @@ END:VCALENDAR
778
778
  end
779
779
  end
780
780
 
781
- def make_cache_path(file, node)
782
- "#{file}.#{node.updated_at.to_i}"
783
- end
784
-
785
781
  def test_cache_css_auto_publish
786
782
  test_site('zena')
787
783
  Site.connection.execute "UPDATE sites set auto_publish = #{Zena::Db::TRUE}, redit_time = 7200 WHERE id = #{sites_id(:zena)}"
@@ -789,14 +785,15 @@ END:VCALENDAR
789
785
  login(:tiger)
790
786
  node = secure!(Node) { nodes(:style_css) }
791
787
  without_files('/test.host/public') do
792
- name = "textdocument#{node.zip}.css"
793
- filename = "#{SITES_ROOT}/test.host/public/en/#{name}"
788
+ name = 'textdocument54.11fbc.css'
789
+ base = "#{SITES_ROOT}/test.host/public/en"
790
+ filename = [base, name].join('/')
794
791
  with_caching do
795
792
  assert !File.exist?(filename)
796
- get 'show', :prefix => 'en', :path => [name], :cachestamp => node.updated_at.to_i
793
+ get 'show', :prefix => 'en', :path => [name]
797
794
  assert_response :success
798
- cache1 = make_cache_path(filename, node)
799
- assert File.exist?(cache1) # cached page created
795
+ cache1 = filename
796
+ assert File.exist?(cache1), "Cache exists #{cache1}" # cached page created
800
797
  assert_match %r[body \{ background: #eee; color:#444;], File.read(cache1)
801
798
  put 'save_text', :id => nodes_zip(:style_css), :node => {'text' => '/* empty */'}
802
799
  node = assigns['node']
@@ -804,9 +801,12 @@ END:VCALENDAR
804
801
  assert_equal Zena::Status::Pub, node.version.status
805
802
  assert_equal versions_id(:style_css_en), node.version.id # auto publish
806
803
  assert !File.exist?(cache1) # old cached page removed
807
- get 'show', :prefix => 'en', :path => [name], :cachestamp => node.updated_at.to_i
804
+ name2 = "textdocument54.#{make_cachestamp(node, nil)}.css"
805
+ get 'show', :prefix => 'en', :path => [name]
806
+ assert_redirected_to "/en/#{name2}"
807
+ get 'show', :prefix => 'en', :path => [name2]
808
808
  assert_response :success
809
- cache2 = make_cache_path(filename, node)
809
+ cache2 = [base, name2].join('/')
810
810
  assert File.exist?(cache2) # cached page created again
811
811
  assert_match %r[/\* empty \*/], File.read(cache2)
812
812
  end
@@ -859,6 +859,51 @@ END:VCALENDAR
859
859
  assert_match %r{deux}, doc_versions[1].text
860
860
  end
861
861
  end
862
+
863
+ def test_import_xhtml
864
+ without_files('/test.host/data') do
865
+ without_files('/test.host/zafu') do
866
+ login(:lion)
867
+ post 'import', :id => nodes(:skins).zip, :node => {:klass => 'Skin', :v_status => Zena::Status::Pub}, :attachment => uploaded_archive('jet_30.zip')
868
+
869
+ node_list = assigns(:nodes)
870
+ nodes = {}
871
+ node_list.each do |n|
872
+ nodes[n.title] = n
873
+ end
874
+ assert skin = nodes['jet_30']
875
+ assert_kind_of Skin, skin
876
+ assert zafu = nodes['Node']
877
+ assert_kind_of Template, zafu
878
+ assert_equal 'html', zafu.format
879
+ assert_equal 'Node', zafu.target_klass
880
+ assert_equal 'N', zafu.tkpath
881
+ assert style = nodes['style']
882
+ assert_kind_of TextDocument, style
883
+ assert navBar = nodes['nav_bar']
884
+ assert_kind_of Image, navBar
885
+ assert xhtmlBgHover = nodes['xhtml_bg_hover']
886
+ assert_kind_of Image, xhtmlBgHover
887
+ assert topIcon = nodes['top_icon']
888
+ assert_kind_of Image, topIcon
889
+ ['lft_pic1', 'lft_pic2', 'lft_pic3'].each do |p|
890
+ assert nodes[p]
891
+ assert_kind_of Image, nodes[p]
892
+ end
893
+ assert_match %r{#header ul\{\s*background:url\('/en/image#{navBar.zip}.[0-9a-f]+.gif'\)}m, style.text
894
+ assert_match %r{a\.xht:hover\{\s*background:url\('/en/image#{xhtmlBgHover.zip}.[0-9a-f]+.gif'\)}, style.text
895
+
896
+ # use this template
897
+ status = nodes(:status)
898
+ status.visitor = Thread.current[:visitor]
899
+ assert status.update_attributes(:skin_id => skin.id, :inherit => 0)
900
+ get 'show', 'prefix'=>'oo', 'path'=>['projects-list', 'Clean-Water-project', "page#{status.zip}.html"]
901
+ assert_response :success
902
+
903
+ assert_match %r{posuere eleifend arcu</p>\s*<img [^>]*src\s*=\s*./en/image#{topIcon.zip}.[0-9a-f]+.gif}, @response.body
904
+ end
905
+ end
906
+ end
862
907
 
863
908
  def test_edit_attribute_publish
864
909
  login(:tiger)
@@ -970,7 +1015,7 @@ END:VCALENDAR
970
1015
 
971
1016
  def test_search_qb
972
1017
  login(:anon)
973
- get 'search', 'qb' => 'nodes where (set_tag_id = 33 and hot_id = 22) in site'
1018
+ get 'search', 'qb' => 'projects where (set_tag.id = 33 and hot.id = 22) in site'
974
1019
  assert_response :success
975
1020
  assert nodes = assigns(:nodes)
976
1021
  assert_equal [nodes_id(:cleanWater)], nodes.map(&:id)
@@ -88,8 +88,8 @@ class VersionsControllerTest < Zena::Controller::TestCase
88
88
 
89
89
  res =<<-END_CSS
90
90
  body { font-size:10px; }
91
- #header { background:url('/en/image30.jpg?1144713600') }
92
- #footer { background:url('/en/image31.jpg?1144713600') }
91
+ #header { background:url('/en/image30.11fbc.jpg') }
92
+ #footer { background:url('/en/image31.11fbc.jpg') }
93
93
  END_CSS
94
94
  assert_equal res, node.text
95
95
  get 'edit', :node_id => node.zip, :id => 0, :unparse_assets => 'true'
@@ -23,8 +23,7 @@ class NavigationTest < Zena::Integration::TestCase
23
23
  assert_redirected_to 'http://test.host/oo'
24
24
  follow_redirect!
25
25
  assert_response :success
26
- get 'http://test.host/fr/textdocument54.css?1144713600' # data with timestamp
27
- assert_response :success
26
+ get 'http://test.host/fr/textdocument54.11fbc.css' # data with timestamp
28
27
  end
29
28
 
30
29
  def test_should_not_redirect_to_css
@@ -54,7 +53,7 @@ class NavigationTest < Zena::Integration::TestCase
54
53
 
55
54
  subject do
56
55
  [
57
- "http://localhost:1234/oo/project19.html",
56
+ "http://test.host:1234/oo/project19.html",
58
57
  {},
59
58
  @headers
60
59
  ]
@@ -71,7 +70,7 @@ class NavigationTest < Zena::Integration::TestCase
71
70
  context 'but invalid host' do
72
71
  subject do
73
72
  [
74
- "http://test.host:1234/oo/project19.html",
73
+ "http://ocean.host:1234/oo/project19.html",
75
74
  {},
76
75
  @headers
77
76
  ]
@@ -82,8 +81,8 @@ class NavigationTest < Zena::Integration::TestCase
82
81
  reset!
83
82
  get *subject
84
83
  assert_response :redirect
85
- assert_redirected_to 'http://test.host/login'
86
- assert_equal users_id(:anon), visitor.id
84
+ assert_redirected_to 'http://ocean.host/login'
85
+ assert_equal users_id(:incognito), visitor.id
87
86
  end
88
87
  end # but invalid host
89
88
  end # with a valid http auth
@@ -103,35 +102,6 @@ class NavigationTest < Zena::Integration::TestCase
103
102
  end
104
103
  end # Rescue template rendering
105
104
 
106
-
107
- # HTTP_AUTH disabled
108
- # def test_authorize_http_auth
109
- # Site.connection.execute "UPDATE sites SET http_auth = 1 WHERE id = #{sites_id(:zena)}"
110
- # get 'http://test.host/'
111
- # assert_redirected_to 'http://test.host/en'
112
- # follow_redirect!
113
- # assert_response :success
114
- #
115
- # # 1. site forces authentication
116
- # Site.connection.execute "UPDATE sites SET authentication = 1 WHERE id = #{sites_id(:zena)}"
117
- # get 'http://test.host/'
118
- # assert_response 401 # http_auth
119
- #
120
- # reset!
121
- # post 'http://test.host/session', :login => 'tiger', :password => 'tiger'
122
- # assert_redirected_to "http://test.host/users/#{users_id(:tiger)}"
123
- #
124
- # # 2. navigating out of '/oo' but logged in and format is not data
125
- # get 'http://test.host/fr'
126
- # assert_redirected_to 'http://test.host/oo'
127
- # follow_redirect!
128
- # assert_response :success
129
- # assert_equal 'fr', session[:lang]
130
- # get 'http://test.host/en/textdocument53.css' # data
131
- # assert_response :success
132
- # assert_equal 'fr', session[:lang]
133
- # end
134
-
135
105
  def test_out_of_oo_custom_base_set_lang
136
106
  post 'http://test.host/session', :login => 'tiger', :password => 'tiger'
137
107
  assert_redirected_to "http://test.host/oo"
@@ -440,6 +410,62 @@ class NavigationTest < Zena::Integration::TestCase
440
410
  follow_redirect!
441
411
  assert_response :missing
442
412
  end
413
+
414
+ def test_cache_root
415
+ without_files('test.host/public') do
416
+ preserving_files('/test.host/data') do
417
+ with_caching do
418
+ login(:anon)
419
+ root_path = "#{SITES_ROOT}#{visitor.site.public_path}/en.html"
420
+ assert !File.exists?(root_path), "No cached file yet"
421
+ get 'http://test.host/en'
422
+ assert_response :success
423
+
424
+ # en.html exist
425
+ assert File.exists?(root_path), "Cached file created"
426
+ end
427
+ end
428
+ end
429
+ end
430
+
431
+ def test_cache_query_string
432
+ without_files('test.host/public') do
433
+ preserving_files('/test.host/data') do
434
+ with_caching do
435
+ login(:anon)
436
+ base = "#{SITES_ROOT}#{visitor.site.public_path}"
437
+ good = {
438
+ '/en?p=1' => '/enp=1.html',
439
+ '/en?p=2' => '/enp=2.html',
440
+ '/en?p=9' => '/enp=9.html',
441
+ '/en/blog29.html?p=2' => '/en/blog29.htmlp=2.html',
442
+ }
443
+
444
+ bad = {
445
+ '/en?x=1' => '/en.htmlx=1.html',
446
+ '/en?ap=2' => '/en.htmlap=2.html',
447
+ '/en?p=99' => '/en.htmlp=99.html',
448
+ '/en/blog29.html?p=21' => '/en/blog29.htmlp=21.html',
449
+ '/en/blog29.html?x=2' => '/en/blog29.htmlx=2.html',
450
+ }
451
+
452
+ good.each do |p, c|
453
+ assert !File.exists?(base + c), "No cached file #{c} yet"
454
+ get "http://test.host#{p}"
455
+ assert_response :success
456
+ assert File.exists?(base + c), "Cached file #{c} created"
457
+ end
458
+
459
+ bad.each do |p, c|
460
+ assert !File.exists?(base + c), "No cached file #{c} yet"
461
+ get "http://test.host#{p}"
462
+ assert_response :success
463
+ assert !File.exists?(base + c), "No cached file #{c} created"
464
+ end
465
+ end
466
+ end
467
+ end
468
+ end
443
469
 
444
470
  def test_should_not_change_session_lang_on_login
445
471
  get 'http://test.host/'
@@ -44,7 +44,7 @@ pages_or_letters:
44
44
  context:
45
45
  node: zena
46
46
  src: pages or letters
47
- sql: "[%Q{SELECT nodes.* FROM nodes WHERE #{secure_scope('nodes')} AND ((nodes.kpath LIKE 'NP%' AND nodes.parent_id = ?) OR (nodes.kpath LIKE 'NNL%' AND nodes.parent_id = ?)) GROUP BY id ORDER BY nodes.zip ASC}, @node.id, @node.id]"
47
+ sql: "[%Q{SELECT nodes.* FROM nodes WHERE #{secure_scope('nodes')} AND ((nodes.kpath LIKE 'NP%' AND nodes.parent_id = ?) OR (nodes.kpath LIKE 'NNL%' AND nodes.parent_id = ?)) GROUP BY nodes.id ORDER BY nodes.zip ASC}, @node.id, @node.id]"
48
48
  res: "people, projects list, Collections, Kill the bugs, Nature, zena enhancements, Skins (layout themes)"
49
49
 
50
50
  project:
@@ -62,19 +62,19 @@ min:
62
62
 
63
63
  many_alternatives:
64
64
  src: tagged in site or images in site or tags in site
65
- sql: "%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links,nodes WHERE #{secure_scope('nodes')} AND ((nodes.id = links.source_id AND links.relation_id = _ID(node_has_tags)) OR (nodes.kpath LIKE 'NDI%' AND links.id = 0) OR (nodes.kpath LIKE 'NPT%' AND links.id = 0)) GROUP BY nodes.id ORDER BY nodes.zip ASC}"
65
+ sql: "%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links JOIN nodes WHERE #{secure_scope('nodes')} AND ((nodes.id = links.source_id AND links.relation_id = _ID(node_has_tags)) OR (nodes.kpath LIKE 'NDI%' AND links.id = 0) OR (nodes.kpath LIKE 'NPT%' AND links.id = 0)) GROUP BY nodes.id ORDER BY nodes.zip ASC}"
66
66
  # res: "art, bird, Clean Water project, flower, it's a lake, menu, news, opening, tree"
67
67
 
68
68
  alternatives_same_join:
69
69
  src: tagged in site or icons
70
- sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links,nodes WHERE #{secure_scope('nodes')} AND ((nodes.id = links.source_id AND links.relation_id = _ID(node_has_tags)) OR (nodes.id = links.target_id AND links.relation_id = _ID(node_has_an_icon) AND links.source_id = ?)) GROUP BY nodes.id ORDER BY nodes.zip ASC}, @node.id]"
70
+ sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links JOIN nodes WHERE #{secure_scope('nodes')} AND ((nodes.id = links.source_id AND links.relation_id = _ID(node_has_tags)) OR (nodes.id = links.target_id AND links.relation_id = _ID(node_has_an_icon) AND links.source_id = ?)) GROUP BY nodes.id ORDER BY nodes.zip ASC}, @node.id]"
71
71
  res: "Clean Water project, it's a lake, super ouverture"
72
72
 
73
73
  same_name_as_class:
74
74
  context:
75
75
  node: 'opening'
76
76
  src: "set_tags"
77
- sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links,nodes WHERE #{secure_scope('nodes')} AND nodes.id = links.target_id AND links.relation_id = _ID(node_has_tags) AND links.source_id = ? ORDER BY nodes.zip ASC}, @node.id]"
77
+ sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links JOIN nodes WHERE #{secure_scope('nodes')} AND nodes.id = links.target_id AND links.relation_id = _ID(node_has_tags) AND links.source_id = ? ORDER BY nodes.zip ASC}, @node.id]"
78
78
  res: "Art, News list"
79
79
 
80
80
 
@@ -109,19 +109,19 @@ children_with_order_clause:
109
109
  notes_or_news:
110
110
  context:
111
111
  class: Project
112
- sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links,nodes WHERE #{secure_scope('nodes')} AND ((nodes.kpath LIKE 'NN%' AND nodes.parent_id = ? AND links.id = 0) OR (nodes.id = links.source_id AND links.relation_id = _ID(note_has_calendars) AND links.target_id = ?)) GROUP BY nodes.id ORDER BY nodes.zip ASC}, @node.id, @node.id]"
112
+ sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links JOIN nodes WHERE #{secure_scope('nodes')} AND ((nodes.kpath LIKE 'NN%' AND nodes.parent_id = ? AND links.id = 0) OR (nodes.id = links.source_id AND links.relation_id = _ID(note_has_calendars) AND links.target_id = ?)) GROUP BY nodes.id ORDER BY nodes.zip ASC}, @node.id, @node.id]"
113
113
 
114
114
  news_or_notes:
115
115
  context:
116
116
  class: Project
117
- sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links,nodes WHERE #{secure_scope('nodes')} AND ((nodes.id = links.source_id AND links.relation_id = _ID(note_has_calendars) AND links.target_id = ?) OR (nodes.kpath LIKE 'NN%' AND nodes.parent_id = ? AND links.id = 0)) GROUP BY nodes.id ORDER BY nodes.zip ASC}, @node.id, @node.id]"
117
+ sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links JOIN nodes WHERE #{secure_scope('nodes')} AND ((nodes.id = links.source_id AND links.relation_id = _ID(note_has_calendars) AND links.target_id = ?) OR (nodes.kpath LIKE 'NN%' AND nodes.parent_id = ? AND links.id = 0)) GROUP BY nodes.id ORDER BY nodes.zip ASC}, @node.id, @node.id]"
118
118
 
119
119
  order_l_status:
120
120
  context:
121
121
  node: art
122
122
  class: Tag
123
123
  src: "tagged order by l_status ASC, zip ASC"
124
- sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links,nodes WHERE #{secure_scope('nodes')} AND nodes.id = links.source_id AND links.relation_id = _ID(node_has_tags) AND links.target_id = ? ORDER BY links.status ASC, nodes.zip ASC}, @node.id]"
124
+ sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links JOIN nodes WHERE #{secure_scope('nodes')} AND nodes.id = links.source_id AND links.relation_id = _ID(node_has_tags) AND links.target_id = ? ORDER BY links.status ASC, nodes.zip ASC}, @node.id]"
125
125
  res: "super ouverture, Clean Water project"
126
126
 
127
127
  order_random:
@@ -9,7 +9,7 @@ default:
9
9
  comments_from_nodes_in_site:
10
10
  context:
11
11
  visitor: lion
12
- sql: "Comment: %Q{SELECT comments.* FROM comments,discussions,nodes AS no1 WHERE comments.discussion_id = discussions.id AND discussions.node_id = no1.id AND #{secure_scope('no1')} GROUP BY comments.id ORDER BY comments.created_at ASC}"
12
+ sql: "Comment: %Q{SELECT comments.* FROM comments JOIN discussions JOIN nodes AS no1 WHERE comments.discussion_id = discussions.id AND discussions.node_id = no1.id AND #{secure_scope('no1')} GROUP BY comments.id ORDER BY comments.created_at ASC}"
13
13
  res: "Comment: I agree, I think this is bad, OK for me, Why ?, Travailleurs, unissez-vous !, Nice site, What about rivers ?, re: What about rivers ?, I want to become queen"
14
14
 
15
15
  does_not_see_secret:
@@ -49,7 +49,7 @@ all_courses_for_mike:
49
49
  class: Employee
50
50
  src: assigned_courses from pages in project from assigned_jobs
51
51
  # TODO: optimization
52
- #sql: "[%Q{SELECT no1.*,li1.id AS link_id,links.status AS l_status,links.comment AS l_comment,links.date AS l_date FROM links,nodes,nodes AS no1,links AS li1 WHERE no1.id = li1.target_id AND li1.relation_id = 512923747 AND li1.source_id = nodes.id AND nodes.kpath LIKE 'NP%' AND nodes.project_id = links.target_id AND links.relation_id = 813976280 AND links.source_id = \#{@node.id} AND (\#{@node.secure_scope('no1')}) GROUP BY no1.id ORDER BY no1.position ASC, no1.node_name ASC}]"
52
+ #sql: "[%Q{SELECT no1.*,li1.id AS link_id,links.status AS l_status,links.comment AS l_comment,links.date AS l_date FROM links JOIN nodes JOIN nodes AS no1,links AS li1 WHERE no1.id = li1.target_id AND li1.relation_id = 512923747 AND li1.source_id = nodes.id AND nodes.kpath LIKE 'NP%' AND nodes.project_id = links.target_id AND links.relation_id = 813976280 AND links.source_id = \#{@node.id} AND (\#{@node.secure_scope('no1')}) GROUP BY no1.id ORDER BY no1.position ASC, no1.node_name ASC}]"
53
53
  res: "problem formulation, information transmission, secure a site, how to use the winch, how to use the radio, fiber junction, responsabilities management, motivate your team, our vision"
54
54
 
55
55
  all_achieved_formations_for_roger:
@@ -63,8 +63,8 @@ custom_query_form_date:
63
63
  context:
64
64
  node: roger
65
65
  class: Employee
66
- src: emp_form_dates order by title ASC
67
- res: "dangerous transportations, engine maintenance, fiber junction, how to use the radio, how to use the winch, information transmission, problem formulation, secure a site"
66
+ src: det_programs order by title ASC
67
+ res: ""
68
68
 
69
69
  custom_query_form_with_where:
70
70
  context:
@@ -27,7 +27,7 @@ filter_l_status:
27
27
  node: art
28
28
  class: Tag
29
29
  src: "tagged where l_status > 5"
30
- sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links,nodes WHERE #{secure_scope('nodes')} AND links.status > 5 AND nodes.id = links.source_id AND links.relation_id = _ID(node_has_tags) AND links.target_id = ? ORDER BY nodes.zip ASC}, @node.id]"
30
+ sql: "[%Q{SELECT nodes.*,links.id AS `link_id`,links.status AS `l_status`,links.comment AS `l_comment`,links.date AS `l_date` FROM links JOIN nodes WHERE #{secure_scope('nodes')} AND links.status > 5 AND nodes.id = links.source_id AND links.relation_id = _ID(node_has_tags) AND links.target_id = ? ORDER BY nodes.zip ASC}, @node.id]"
31
31
  res: "Clean Water project"
32
32
 
33
33
  param_filter:
@@ -79,8 +79,8 @@ negative_value:
79
79
  sql: "%Q{SELECT nodes.* FROM nodes WHERE #{secure_scope('nodes')} AND nodes.custom_a <> -10 AND nodes.kpath LIKE 'NN%' ORDER BY nodes.zip ASC}"
80
80
 
81
81
  filter_through_links:
82
- src: "nodes where (set_tag_id = 33 and hot_id = 22) in site"
83
- sql: "/jn1\.zip = 33 AND jn2\.zip = 22.*nodes.id = links.source_id/"
82
+ src: "projects where (set_tag.id = 33 and hot.id = 22) in site"
83
+ sql: "/.*li1.source_id = nodes.id.*li2.source_id = nodes.id.*jn1\.zip = 33 AND jn2\.zip = 22/"
84
84
  res: "Clean Water project"
85
85
 
86
86
  filter_with_fullpath:
@@ -91,7 +91,7 @@ filter_with_fullpath:
91
91
 
92
92
  class_filter:
93
93
  src: "nodes where class like Image or class = Project in site"
94
- sql: "%Q{SELECT nodes.* FROM nodes WHERE #{secure_scope('nodes')} AND (nodes.kpath LIKE 'NDI%' OR nodes.kpath = 'NPP') GROUP BY id ORDER BY nodes.zip ASC}"
94
+ sql: "%Q{SELECT nodes.* FROM nodes WHERE #{secure_scope('nodes')} AND (nodes.kpath LIKE 'NDI%' OR nodes.kpath = 'NPP') GROUP BY nodes.id ORDER BY nodes.zip ASC}"
95
95
  res: "Zena the wild CMS, Clean Water project, it's a lake, bird, flower, Autumn Tree"
96
96
 
97
97
  class_filter_with_quotes:
@@ -104,7 +104,7 @@ klass_filter:
104
104
 
105
105
  role_filter:
106
106
  src: "nodes where role = Original in site"
107
- sql: "%Q{SELECT nodes.* FROM nodes,nodes_roles WHERE #{secure_scope('nodes')} AND (nodes_roles.node_id = nodes.id AND nodes_roles.role_id = 493147733) ORDER BY nodes.zip ASC}"
107
+ sql: "%Q{SELECT nodes.* FROM nodes JOIN nodes_roles WHERE #{secure_scope('nodes')} AND (nodes_roles.node_id = nodes.id AND nodes_roles.role_id = 493147733) ORDER BY nodes.zip ASC}"
108
108
  res: 'Autumn Tree'
109
109
 
110
110
  role_filter_string:
@@ -113,13 +113,37 @@ role_filter_string:
113
113
 
114
114
  role_as_relation_filter:
115
115
  src: "originals in site"
116
- sql: "%Q{SELECT nodes.* FROM nodes,nodes_roles WHERE #{secure_scope('nodes')} AND nodes_roles.role_id = 493147733 AND nodes_roles.node_id = nodes.id ORDER BY nodes.zip ASC}"
116
+ sql: "%Q{SELECT nodes.* FROM nodes JOIN nodes_roles WHERE #{secure_scope('nodes')} AND nodes_roles.role_id = 493147733 AND nodes_roles.node_id = nodes.id ORDER BY nodes.zip ASC}"
117
117
  res: 'Autumn Tree'
118
118
 
119
+ relation_filter:
120
+ context:
121
+ node: status
122
+ params:
123
+ list: 22
124
+ src: "projects where hot.id in (#{params[:list]}) in site"
125
+ sql: "[%Q{SELECT nodes.* FROM nodes LEFT JOIN links AS li1 ON li1.source_id = nodes.id AND li1.relation_id = 126629661 LEFT JOIN nodes AS jn1 ON jn1.id = li1.target_id WHERE #{secure_scope('nodes')} AND jn1.zip IN (?) AND nodes.kpath LIKE 'NPP%' GROUP BY nodes.id ORDER BY nodes.zip ASC}, params[:list]]"
126
+ res: "Clean Water project"
127
+
128
+ relation_filter_null:
129
+ context:
130
+ node: status
131
+ src: "projects where hot.id is null in site"
132
+ sql: "%Q{SELECT nodes.* FROM nodes LEFT JOIN links AS li1 ON li1.source_id = nodes.id AND li1.relation_id = 126629661 LEFT JOIN nodes AS jn1 ON jn1.id = li1.target_id WHERE #{secure_scope('nodes')} AND jn1.zip IS NULL AND nodes.kpath LIKE 'NPP%' GROUP BY nodes.id ORDER BY nodes.zip ASC}"
133
+ # NOT CleanWater
134
+ res: "Zena the wild CMS, a wiki with Zena"
135
+
136
+ relation_filter_attr:
137
+ context:
138
+ node: status
139
+ src: "projects where hot.title = 'Etat des travaux' in site"
140
+ sql: "/ON ml1.node_id = jn1.id AND ml1.key = 'title' AND ml1.lang = 'fr'.*ml1.value = 'Etat des travaux'/"
141
+ res: "Clean Water project"
142
+
119
143
  filter_by_parent:
120
144
  src: "nodes where parent_id = 11 in site"
121
145
  # nodes where parent.zip = ...
122
- sql: "%Q{SELECT nodes.* FROM nodes,nodes AS jn1 WHERE #{secure_scope('nodes')} AND jn1.zip = 11 AND jn1.id = nodes.parent_id AND jn1.site_id = nodes.site_id ORDER BY nodes.zip ASC}"
146
+ sql: "%Q{SELECT nodes.* FROM nodes LEFT JOIN nodes AS jn1 ON jn1.id = nodes.parent_id AND jn1.site_id = nodes.site_id WHERE #{secure_scope('nodes')} AND jn1.zip = 11 ORDER BY nodes.zip ASC}"
123
147
  res: 'people, projects list, Collections, Kill the bugs, Nature, zena enhancements, Skins (layout themes)'
124
148
  #many_role_filter:
125
149
  # This is not working (or clause on 'indexed' fields is not supported right now)
@@ -129,7 +153,7 @@ filter_by_parent:
129
153
 
130
154
  quoted_literal:
131
155
  src: "nodes where tag=\"10'000\" in site"
132
- sql: "%Q{SELECT nodes.* FROM links AS ta1,nodes WHERE #{secure_scope('nodes')} AND ta1.comment = '10\\\\'000' AND nodes.id = ta1.source_id AND ta1.relation_id IS NULL ORDER BY nodes.zip ASC}"
156
+ sql: "%Q{SELECT nodes.* FROM nodes LEFT JOIN links AS ta1 ON nodes.id = ta1.source_id AND ta1.relation_id IS NULL WHERE #{secure_scope('nodes')} AND ta1.comment = '10\\\\'000' ORDER BY nodes.zip ASC}"
133
157
  res: ''
134
158
  # filters on ml strings are in properties.yml
135
159
 
@@ -6,17 +6,17 @@ default:
6
6
 
7
7
  ml_title_where:
8
8
  src: "nodes where title like 'Etat%' in site"
9
- sql: "%Q{SELECT nodes.* FROM idx_nodes_ml_strings AS ml1,nodes WHERE #{secure_scope('nodes')} AND ml1.value LIKE 'Etat%' AND ml1.lang = 'fr' AND ml1.key = 'title' AND ml1.node_id = nodes.id ORDER BY nodes.zip ASC}"
9
+ sql: "%Q{SELECT nodes.* FROM nodes LEFT JOIN idx_nodes_ml_strings AS ml1 ON ml1.node_id = nodes.id AND ml1.key = 'title' AND ml1.lang = 'fr' WHERE #{secure_scope('nodes')} AND ml1.value LIKE 'Etat%' ORDER BY nodes.zip ASC}"
10
10
  res: 'Etat des travaux'
11
11
 
12
12
  ml_title_where_with_or:
13
13
  src: "nodes where title like 'Etat%' or class = Letter in site"
14
- sql: "%Q{SELECT nodes.* FROM idx_nodes_ml_strings AS ml1,nodes WHERE #{secure_scope('nodes')} AND ((ml1.value LIKE 'Etat%' AND ml1.lang = 'fr' AND ml1.key = 'title' AND ml1.node_id = nodes.id) OR (nodes.kpath = 'NNL' AND ml1.node_id = 0)) GROUP BY nodes.id ORDER BY nodes.zip ASC}"
14
+ sql: "%Q{SELECT nodes.* FROM nodes LEFT JOIN idx_nodes_ml_strings AS ml1 ON ml1.node_id = nodes.id AND ml1.key = 'title' AND ml1.lang = 'fr' WHERE #{secure_scope('nodes')} AND (ml1.value LIKE 'Etat%' OR nodes.kpath = 'NNL') GROUP BY nodes.id ORDER BY nodes.zip ASC}"
15
15
  res: 'Etat des travaux, zena enhancements'
16
16
 
17
17
  name_where:
18
18
  src: "contacts where name like 'Inv%' in site"
19
- sql: "%Q{SELECT nodes.* FROM idx_nodes_strings AS st1,nodes WHERE #{secure_scope('nodes')} AND st1.value LIKE 'Inv%' AND st1.key = 'name' AND st1.node_id = nodes.id AND nodes.kpath LIKE 'NRC%' ORDER BY nodes.zip ASC}"
19
+ sql: "%Q{SELECT nodes.* FROM nodes LEFT JOIN idx_nodes_strings AS st1 ON st1.node_id = nodes.id AND st1.key = 'name' WHERE #{secure_scope('nodes')} AND st1.value LIKE 'Inv%' AND nodes.kpath LIKE 'NRC%' ORDER BY nodes.zip ASC}"
20
20
  res: 'Solenopsis Invicta'
21
21
 
22
22
  # TODO: Only implement with a proper use case. Ref [#190]
@@ -31,13 +31,13 @@ ml_title_order:
31
31
  context:
32
32
  node: 'cleanWater'
33
33
  src: "pages in site order by title asc limit 7"
34
- sql: "%Q{SELECT nodes.* FROM idx_nodes_ml_strings AS ml1,nodes WHERE #{secure_scope('nodes')} AND ml1.lang = 'fr' AND ml1.key = 'title' AND ml1.node_id = nodes.id AND nodes.kpath LIKE 'NP%' ORDER BY ml1.value ASC LIMIT 7}"
34
+ sql: "%Q{SELECT nodes.* FROM nodes LEFT JOIN idx_nodes_ml_strings AS ml1 ON ml1.node_id = nodes.id AND ml1.key = 'title' AND ml1.lang = 'fr' WHERE #{secure_scope('nodes')} AND nodes.kpath LIKE 'NP%' ORDER BY ml1.value ASC LIMIT 7}"
35
35
  res: "a wiki with Zena, Art, Clean Water project, Collections, crocodiles, Default skin, Etat des travaux"
36
36
 
37
37
 
38
38
  ml_title_filter_in_relation:
39
39
  src: "references where title = 'important'"
40
- sql: "/idx_nodes_ml_strings AS ml1.*ml1.value = 'important'.*lang = 'fr'.*key = 'title'.*nodes.id = links.target_id.*source_id = \?/"
40
+ sql: "/idx_nodes_ml_strings AS ml1.*key = 'title'.*lang = 'fr'.*ml1.value = 'important'.*nodes.id = links.target_id.*source_id = \?/"
41
41
  res: ""
42
42
 
43
43
 
@@ -45,19 +45,19 @@ filter_ml_string:
45
45
  context:
46
46
  lang: 'de'
47
47
  src: "nodes where title = 'foo' in site"
48
- sql: "%Q{SELECT nodes.* FROM idx_nodes_ml_strings AS ml1,nodes WHERE #{secure_scope('nodes')} AND ml1.value = 'foo' AND ml1.lang = 'fr' AND ml1.key = 'title' AND ml1.node_id = nodes.id ORDER BY nodes.zip ASC}"
48
+ sql: "%Q{SELECT nodes.* FROM nodes LEFT JOIN idx_nodes_ml_strings AS ml1 ON ml1.node_id = nodes.id AND ml1.key = 'title' AND ml1.lang = 'fr' WHERE #{secure_scope('nodes')} AND ml1.value = 'foo' ORDER BY nodes.zip ASC}"
49
49
 
50
50
  filter_ml_string_order:
51
51
  context:
52
52
  lang: 'de'
53
53
  src: "nodes where title = 'foo' in site order by title"
54
- sql: "%Q{SELECT nodes.* FROM idx_nodes_ml_strings AS ml1,nodes WHERE #{secure_scope('nodes')} AND ml1.value = 'foo' AND ml1.lang = 'fr' AND ml1.key = 'title' AND ml1.node_id = nodes.id ORDER BY ml1.value}"
54
+ sql: "%Q{SELECT nodes.* FROM nodes LEFT JOIN idx_nodes_ml_strings AS ml1 ON ml1.node_id = nodes.id AND ml1.key = 'title' AND ml1.lang = 'fr' WHERE #{secure_scope('nodes')} AND ml1.value = 'foo' ORDER BY ml1.value}"
55
55
 
56
56
  filter_ml_string_twice:
57
57
  context:
58
58
  lang: 'de'
59
59
  src: "nodes where title = 'foo' and title = 'baz' in site"
60
- sql: "%Q{SELECT nodes.* FROM idx_nodes_ml_strings AS ml1,nodes WHERE #{secure_scope('nodes')} AND ml1.value = 'foo' AND ml1.value = 'baz' AND ml1.lang = 'fr' AND ml1.key = 'title' AND ml1.node_id = nodes.id ORDER BY nodes.zip ASC}"
60
+ sql: "%Q{SELECT nodes.* FROM nodes LEFT JOIN idx_nodes_ml_strings AS ml1 ON ml1.node_id = nodes.id AND ml1.key = 'title' AND ml1.lang = 'fr' WHERE #{secure_scope('nodes')} AND ml1.value = 'foo' AND ml1.value = 'baz' ORDER BY nodes.zip ASC}"
61
61
 
62
62
 
63
63
  ml_title_with_name:
@@ -67,11 +67,11 @@ ml_title_with_name:
67
67
 
68
68
  ml_title_with_name_with_sort:
69
69
  src: "contacts where title like '%Invicta%' or name = 'Leo Verneyi' in site order by title"
70
- sql: "/ml1.*ml2.*st1/"
70
+ sql: "/ml1.*st1/"
71
71
  res: 'Panthera Leo Verneyi, Solenopsis Invicta'
72
72
 
73
73
  # Group by property
74
74
  group_by_ml_title:
75
75
  src: 'contacts in site group by title'
76
- sql: "%Q{SELECT nodes.* FROM idx_nodes_ml_strings AS ml1,nodes WHERE #{secure_scope('nodes')} AND ml1.lang = 'fr' AND ml1.key = 'title' AND ml1.node_id = nodes.id AND nodes.kpath LIKE 'NRC%' GROUP BY ml1.value ORDER BY nodes.zip ASC}"
76
+ sql: "%Q{SELECT nodes.* FROM nodes LEFT JOIN idx_nodes_ml_strings AS ml1 ON ml1.node_id = nodes.id AND ml1.key = 'title' AND ml1.lang = 'fr' WHERE #{secure_scope('nodes')} AND nodes.kpath LIKE 'NRC%' GROUP BY ml1.value ORDER BY nodes.zip ASC}"
77
77
  res: "Solenopsis Invicta, Panthera Tigris Sumatran, Panthera Leo Verneyi, The lake we love, Mr nobody"