zena 1.0.0.rc2 → 1.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (274) hide show
  1. data/History.txt +23 -0
  2. data/README.rdoc +1 -1
  3. data/app/controllers/columns_controller.rb +3 -31
  4. data/app/controllers/comments_controller.rb +8 -3
  5. data/app/controllers/data_entries_controller.rb +1 -1
  6. data/app/controllers/documents_controller.rb +2 -2
  7. data/app/controllers/nodes_controller.rb +29 -12
  8. data/app/controllers/relations_controller.rb +2 -2
  9. data/app/controllers/sites_controller.rb +1 -1
  10. data/app/controllers/user_sessions_controller.rb +6 -3
  11. data/app/controllers/users_controller.rb +18 -16
  12. data/app/controllers/versions_controller.rb +20 -18
  13. data/app/controllers/virtual_classes_controller.rb +103 -17
  14. data/app/helpers/users_helper.rb +1 -1
  15. data/app/models/column.rb +19 -50
  16. data/app/models/comment.rb +2 -1
  17. data/app/models/node.rb +45 -22
  18. data/app/models/relation.rb +13 -0
  19. data/app/models/relation_proxy.rb +3 -2
  20. data/app/models/role.rb +213 -4
  21. data/app/models/site.rb +18 -11
  22. data/app/models/template.rb +37 -35
  23. data/app/models/version.rb +1 -1
  24. data/app/models/virtual_class.rb +154 -86
  25. data/app/views/columns/_li.html.erb +1 -1
  26. data/app/views/columns/index.html.erb +1 -9
  27. data/app/views/comments/index.rhtml +10 -8
  28. data/app/views/documents/_crop.rhtml +5 -6
  29. data/app/views/documents/crop_form.rjs +3 -2
  30. data/app/views/groups/index.rhtml +1 -1
  31. data/app/views/iformats/index.rhtml +1 -1
  32. data/app/views/nodes/_import_results.rhtml +1 -1
  33. data/app/views/nodes/_parent.rhtml +1 -2
  34. data/app/views/nodes/update.rjs +3 -4
  35. data/app/views/relations/index.erb +1 -1
  36. data/app/views/sites/index.erb +1 -1
  37. data/app/views/templates/drive_tabs/_drive.rhtml +0 -2
  38. data/app/views/templates/edit_tabs/_image.rhtml +1 -1
  39. data/app/views/templates/edit_tabs/_title.rhtml +0 -6
  40. data/app/views/users/index.rhtml +1 -1
  41. data/app/views/users/preferences.html.erb +2 -2
  42. data/app/views/versions/backup.rjs +1 -1
  43. data/app/views/versions/custom_tab.rhtml +9 -4
  44. data/app/views/versions/destroy.rjs +2 -2
  45. data/app/views/versions/update.rjs +2 -9
  46. data/app/views/virtual_classes/_form.erb +3 -2
  47. data/app/views/virtual_classes/import_prepare.html.erb +13 -0
  48. data/app/views/virtual_classes/index.erb +28 -8
  49. data/app/views/zafu/default/Node-+adminLayout.zafu +1 -13
  50. data/app/views/zafu/default/Node-+login.zafu +1 -0
  51. data/app/views/zafu/default/Node-+notFound.zafu +1 -1
  52. data/app/views/zafu/default/Node-+popupLayout.zafu +1 -2
  53. data/app/views/zafu/default/Node-+search.zafu +1 -1
  54. data/app/views/zafu/default/Node-admin.zafu +205 -0
  55. data/app/views/zafu/default/Node.zafu +11 -11
  56. data/bricks/captcha/lib/bricks/captcha.rb +3 -2
  57. data/bricks/mongrel/zena/init.rb +2 -1
  58. data/bricks/pdf/README +5 -5
  59. data/bricks/pdf/lib/bricks/pdf/engine/prince.rb +2 -2
  60. data/bricks/pdf/lib/bricks/pdf/engine/xhtml2pdf.rb +2 -2
  61. data/bricks/pdf/lib/bricks/pdf/install.rb +5 -5
  62. data/bricks/pdf/lib/bricks/pdf.rb +11 -11
  63. data/bricks/pdf/test/engines/test_prince.rb +4 -4
  64. data/bricks/pdf/test/engines/test_xhtml2pdf.rb +4 -4
  65. data/bricks/pdf/test/shoulda_macros/shoulda_pdf.rb +2 -2
  66. data/bricks/pdf/zena/init.rb +2 -2
  67. data/bricks/pdf/zena/tasks.rb +2 -2
  68. data/bricks/sphinx/lib/bricks/sphinx.rb +6 -2
  69. data/bricks/sphinx/zena/{sphinx.yml → sphinx.yml.erb} +2 -2
  70. data/bricks/sphinx/zena/tasks.rb +28 -2
  71. data/bricks/tags/lib/bricks/tags.rb +16 -1
  72. data/bricks/tags/zena/test/unit/tags_test.rb +15 -0
  73. data/bricks/tags/zena/test/zafu/tags.yml +5 -1
  74. data/bricks/worker/lib/bricks/worker.rb +39 -0
  75. data/bricks/worker/zena/deploy.rb +0 -2
  76. data/bricks/worker/zena/init.rb +1 -0
  77. data/bricks/worker/zena/test/sites/zena/delayed_jobs.yml +16 -0
  78. data/bricks/worker/zena/test/zafu/worker.yml +8 -0
  79. data/bricks/zena/zena/migrate/01_base.rb +36 -60
  80. data/bricks/zena/zena/migrate/02_zerox1_schema.rb +388 -0
  81. data/bricks/zena/zena/migrate/03_zerox1_data.rb +380 -0
  82. data/bricks/zena/zena/migrate/20110315161158_add_reverse_scope_to_roles.rb +9 -0
  83. data/config/database_example.yml +1 -1
  84. data/config/environment.rb +1 -1
  85. data/config/gems.yml +17 -14
  86. data/db/init/base/skins/default/Node-+index.zafu +8 -1
  87. data/db/init/base/skins/default/Node-+login.zafu +1 -0
  88. data/db/init/base/skins/default/Node-+popupLayout.zafu +1 -2
  89. data/db/init/base/skins/default/Node-+search.zafu +2 -2
  90. data/db/init/base/skins/default/Node.zafu +9 -9
  91. data/db/init/base/skins/default/{favicon.png → img/favicon.png} +0 -0
  92. data/db/init/base/skins/default/{style.css → img/style.css} +0 -0
  93. data/db/init/base/skins/default/img/translations.yml +11 -0
  94. data/db/init/base/skins/default/notes.zafu +7 -9
  95. data/doc/zafu_changes.yml +12 -0
  96. data/lib/bricks/loader.rb +38 -15
  97. data/lib/tasks/zena.rake +74 -24
  98. data/lib/zena/acts/enrollable.rb +4 -1
  99. data/lib/zena/acts/secure.rb +2 -48
  100. data/lib/zena/acts/serializable.rb +13 -1
  101. data/lib/zena/app.rb +9 -0
  102. data/lib/zena/code_syntax.rb +154 -151
  103. data/lib/zena/console.rb +141 -0
  104. data/lib/zena/controller/test_case.rb +1 -1
  105. data/lib/zena/db_helper/abstract_db.rb +17 -5
  106. data/lib/zena/db_helper/mysql.rb +14 -12
  107. data/lib/zena/db_helper/postgresql.rb +1 -2
  108. data/lib/zena/db_helper/sqlite3.rb +6 -6
  109. data/lib/zena/deploy/awstats.conf.rhtml +1 -1
  110. data/lib/zena/deploy/httpd.rhtml +6 -1
  111. data/lib/zena/deploy/vhost.rhtml +9 -1
  112. data/lib/zena/deploy.rb +12 -7
  113. data/lib/zena/foxy_parser.rb +3 -1
  114. data/lib/zena/info.rb +1 -1
  115. data/lib/zena/parser/zafu_tags.rb +1 -0
  116. data/lib/zena/parser/zazen_rules.rb +1 -1
  117. data/lib/zena/remote/node.rb +15 -3
  118. data/lib/zena/remote/serializable_array.rb +19 -0
  119. data/lib/zena/remote.rb +1 -0
  120. data/lib/zena/routes.rb +7 -2
  121. data/lib/zena/site_worker.rb +11 -1
  122. data/lib/zena/unit/test_case.rb +68 -0
  123. data/lib/zena/use/action.rb +6 -2
  124. data/lib/zena/use/ajax.rb +127 -53
  125. data/lib/zena/use/ancestry.rb +11 -8
  126. data/lib/zena/use/calendar.rb +265 -129
  127. data/lib/zena/use/conditional.rb +1 -1
  128. data/lib/zena/use/context.rb +5 -5
  129. data/lib/zena/use/dates.rb +172 -60
  130. data/lib/zena/use/display.rb +70 -39
  131. data/lib/zena/use/error_rendering.rb +1 -3
  132. data/lib/zena/use/field_index.rb +4 -1
  133. data/lib/zena/use/forms.rb +94 -72
  134. data/lib/zena/use/fulltext.rb +16 -24
  135. data/lib/zena/use/html_tags.rb +20 -12
  136. data/lib/zena/use/i18n.rb +37 -37
  137. data/lib/zena/use/image_builder.rb +8 -1
  138. data/lib/zena/use/ml_index.rb +16 -16
  139. data/lib/zena/use/prop_eval.rb +10 -5
  140. data/lib/zena/use/query_builder.rb +55 -23
  141. data/lib/zena/use/query_node.rb +51 -25
  142. data/lib/zena/use/refactor.rb +2 -28
  143. data/lib/zena/use/relations.rb +1 -1
  144. data/lib/zena/use/rendering.rb +29 -0
  145. data/lib/zena/use/scope_index.rb +75 -14
  146. data/lib/zena/use/search.rb +5 -10
  147. data/lib/zena/use/test_helper.rb +2 -2
  148. data/lib/zena/use/urls.rb +125 -104
  149. data/lib/zena/use/workflow.rb +2 -1
  150. data/lib/zena/use/zafu_attributes.rb +2 -2
  151. data/lib/zena/use/zafu_safe_definitions.rb +20 -0
  152. data/lib/zena/use/zafu_templates.rb +20 -6
  153. data/lib/zena/use/zazen.rb +31 -20
  154. data/lib/zena/view/test_case.rb +5 -0
  155. data/lib/zena/zafu_compiler.rb +24 -2
  156. data/lib/zena.rb +12 -6
  157. data/locale/de/LC_MESSAGES/zena.mo +0 -0
  158. data/locale/de/zena.po +1345 -1164
  159. data/locale/en/LC_MESSAGES/zena.mo +0 -0
  160. data/locale/en/zena.po +1275 -1129
  161. data/locale/fr/LC_MESSAGES/zena.mo +0 -0
  162. data/locale/fr/zena.mo +0 -0
  163. data/locale/fr/zena.po +1617 -1441
  164. data/locale/log.txt +9 -0
  165. data/locale/zena.pot +957 -748
  166. data/public/javascripts/prototype.js +1 -1
  167. data/public/javascripts/zena.js +99 -44
  168. data/public/stylesheets/admin.css +6 -4
  169. data/public/stylesheets/backend.css +71 -0
  170. data/public/stylesheets/calendar.css +24 -25
  171. data/public/stylesheets/code.css +11 -6
  172. data/public/stylesheets/comment.css +2 -1
  173. data/public/stylesheets/popup.css +7 -8
  174. data/test/custom_queries/complex.host.yml +15 -1
  175. data/test/fixtures/files/Node-test.zafu +29 -28
  176. data/test/fixtures/files/translations_de.yml +12 -1
  177. data/test/fixtures/files/translations_fr.yml +12 -1
  178. data/test/functional/comments_controller_test.rb +9 -0
  179. data/test/functional/iformats_controller_test.rb +1 -1
  180. data/test/functional/nodes_controller_test.rb +124 -35
  181. data/test/functional/users_controller_test.rb +132 -3
  182. data/test/functional/virtual_classes_controller_test.rb +75 -4
  183. data/test/integration/navigation_test.rb +51 -9
  184. data/test/integration/query_node/basic.yml +19 -7
  185. data/test/integration/query_node/complex.yml +1 -1
  186. data/test/integration/query_node/dates.yml +27 -1
  187. data/test/integration/query_node/filters.yml +1 -1
  188. data/test/integration/query_node/relations.yml +13 -4
  189. data/test/integration/query_node_test.rb +4 -0
  190. data/test/integration/xml_api_test.rb +6 -1
  191. data/test/integration/zafu_compiler/action.yml +3 -3
  192. data/test/integration/zafu_compiler/ajax.yml +103 -22
  193. data/test/integration/zafu_compiler/basic.yml +0 -52
  194. data/test/integration/zafu_compiler/calendar.yml +44 -20
  195. data/test/integration/zafu_compiler/comments.yml +53 -0
  196. data/test/integration/zafu_compiler/complex.yml +11 -11
  197. data/test/integration/zafu_compiler/complex_ok.yml +16 -3
  198. data/test/integration/zafu_compiler/conditional.yml +15 -5
  199. data/test/integration/zafu_compiler/context.yml +9 -0
  200. data/test/integration/zafu_compiler/dates.yml +43 -15
  201. data/test/integration/zafu_compiler/display.yml +60 -6
  202. data/test/integration/zafu_compiler/errors.yml +6 -2
  203. data/test/integration/zafu_compiler/forms.yml +45 -6
  204. data/test/integration/zafu_compiler/i18n.yml +8 -1
  205. data/test/integration/zafu_compiler/meta.yml +38 -0
  206. data/test/integration/zafu_compiler/query.yml +43 -4
  207. data/test/integration/zafu_compiler/relations.yml +26 -33
  208. data/test/integration/zafu_compiler/rubyless.yml +10 -0
  209. data/test/integration/zafu_compiler/safe_definitions.yml +21 -1
  210. data/test/integration/zafu_compiler/urls.yml +75 -5
  211. data/test/integration/zafu_compiler/version.yml +2 -2
  212. data/test/integration/zafu_compiler/zafu_attributes.yml +5 -1
  213. data/test/integration/zafu_compiler/zazen.yml +14 -6
  214. data/test/integration/zafu_compiler_test.rb +5 -1
  215. data/test/sites/complex/columns.yml +5 -0
  216. data/test/sites/complex/roles.yml +4 -0
  217. data/test/sites/zena/nodes.yml +13 -2
  218. data/test/sites/zena/roles.yml +13 -5
  219. data/test/sites/zena/versions.yml +27 -9
  220. data/test/unit/column_test.rb +51 -5
  221. data/test/unit/iformat_test.rb +2 -2
  222. data/test/unit/node_test.rb +29 -17
  223. data/test/unit/note_test.rb +1 -1
  224. data/test/unit/relation_proxy_test.rb +4 -5
  225. data/test/unit/relation_test.rb +16 -0
  226. data/test/unit/remote_test.rb +2 -2
  227. data/test/unit/role_test.rb +292 -4
  228. data/test/unit/site_test.rb +12 -0
  229. data/test/unit/template_test.rb +1 -1
  230. data/test/unit/text_document_test.rb +1 -1
  231. data/test/unit/virtual_class_test.rb +200 -83
  232. data/test/unit/zena/acts/enrollable_test.rb +26 -31
  233. data/test/unit/zena/use/calendar_test.rb +90 -37
  234. data/test/unit/zena/use/field_index_test.rb +28 -0
  235. data/test/unit/zena/use/html_tags_test.rb +7 -3
  236. data/test/unit/zena/use/ml_index_test.rb +2 -16
  237. data/test/unit/zena/use/nested_attributes_alias_view_test.rb +2 -2
  238. data/test/unit/zena/use/prop_eval_test.rb +50 -8
  239. data/test/unit/zena/use/query_node_test.rb +11 -0
  240. data/test/unit/zena/use/rendering_test.rb +72 -0
  241. data/test/unit/zena/use/scope_index_test.rb +37 -2
  242. data/test/unit/zena/use/urls_test.rb +10 -0
  243. data/test/unit/zena/use/zazen_test.rb +3 -3
  244. data/vendor/plugins/gettext_i18n_rails/Gemfile +11 -0
  245. data/vendor/plugins/gettext_i18n_rails/Gemfile.lock +92 -0
  246. data/vendor/plugins/gettext_i18n_rails/Rakefile +12 -17
  247. data/vendor/plugins/gettext_i18n_rails/Readme.md +215 -0
  248. data/vendor/plugins/gettext_i18n_rails/VERSION +1 -1
  249. data/vendor/plugins/gettext_i18n_rails/gettext_i18n_rails.gemspec +38 -34
  250. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb +1 -1
  251. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/backend.rb +30 -14
  252. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/haml_parser.rb +1 -1
  253. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/html_safe_translations.rb +29 -0
  254. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/i18n_hacks.rb +29 -1
  255. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/model_attributes_finder.rb +7 -1
  256. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/railtie.rb +10 -0
  257. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/ruby_gettext_extractor.rb +6 -2
  258. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb +20 -0
  259. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/tasks.rb +120 -0
  260. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails.rb +10 -3
  261. data/vendor/plugins/gettext_i18n_rails/lib/tasks/gettext_rails_i18n.rake +1 -74
  262. data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/active_record_spec.rb +51 -20
  263. data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb +12 -7
  264. data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb +32 -0
  265. data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails_spec.rb +38 -1
  266. data/vendor/plugins/gettext_i18n_rails/spec/rails2/Gemfile +11 -0
  267. data/vendor/plugins/gettext_i18n_rails/spec/spec_helper.rb +1 -8
  268. data/zena.gemspec +2241 -2217
  269. metadata +123 -83
  270. data/.gitignore +0 -36
  271. data/app/views/nodes/_dates.rhtml +0 -13
  272. data/db/init/base/skins/default/Node-+adminLayout.zafu +0 -46
  273. data/db/init/base/skins/default/Node-tree.zafu +0 -19
  274. data/vendor/plugins/gettext_i18n_rails/README.markdown +0 -143
@@ -135,10 +135,23 @@ class VirtualClassesControllerTest < Zena::Controller::TestCase
135
135
 
136
136
  should 'save name and kpath' do
137
137
  put_subject
138
- vclass = assigns(:virtual_class)
138
+ vclass = roles(:Letter)
139
139
  assert_equal 'Life', vclass.name
140
140
  assert_equal 'NNL', vclass.kpath
141
141
  end
142
+
143
+ context 'by changing prop_eval' do
144
+ subject do
145
+ {:action => :update, :id => roles_id(:Letter), :virtual_class => { :prop_eval => '{"title" => "what"}'}}
146
+ end
147
+
148
+ should 'change prop_eval' do
149
+ put_subject
150
+ vclass = roles(:Letter)
151
+ assert_equal '{"title" => "what"}', vclass.prop_eval
152
+ end
153
+ end # by changing prop_eval
154
+
142
155
 
143
156
  # TODO: What happens to properties for a class if kpath changes ?
144
157
  end # updating a virtual class
@@ -180,17 +193,75 @@ class VirtualClassesControllerTest < Zena::Controller::TestCase
180
193
  end
181
194
  end # destroying a virtual class
182
195
 
196
+ context 'prepare import for role definitions' do
197
+ subject do
198
+ {:action => :import_prepare, :attachment => uploaded_fixture('vclasses.yml', 'text/yaml')}
199
+ end
200
+
201
+ should 'create a diff' do
202
+ assert_difference('::Role.count', 0) do
203
+ post_subject
204
+ assert_response :success
205
+ diff = assigns(:diff)
206
+ assert_match(/<ins class="differ">Foo/, diff)
207
+ end
208
+ end
209
+ end # importing virtual class definitions
210
+
183
211
  context 'importing virtual class definitions' do
184
212
  subject do
185
- {:action => :import, :attachment => uploaded_fixture('vclasses.yml', 'text/yaml')}
213
+ {:action => :import, :roles => {
214
+ 'Node' => {
215
+ 'Note' => {
216
+ 'Foo' => {
217
+ 'type' => 'VirtualClass',
218
+ },
219
+ 'Bar' => {
220
+ 'type' => 'Role',
221
+ }
222
+ }
223
+ }
224
+ }.to_yaml}
186
225
  end
187
226
 
188
227
  should 'create virtual classes' do
189
- assert_difference('VirtualClass.count', 3) do
190
- post_subject
228
+ assert_difference('VirtualClass.count', 1) do
229
+ assert_difference('Role.count', 2) do
230
+ post_subject
231
+ end
191
232
  end
192
233
  end
193
234
  end # importing virtual class definitions
235
+
236
+ context 'exporting virtual class definitions' do
237
+ subject do
238
+ {:action => :export}
239
+ end
240
+
241
+ should 'dump virtual classes to yaml' do
242
+ get_subject
243
+ res = YAML.load @response.body
244
+ assert_equal 'VirtualClass', res['Node']['Page']['Project']['Blog']['type']
245
+ assert_equal res['Node']['Original'], roles(:Original).export
246
+ end
247
+ end # importing virtual class definitions
248
+
249
+ context 'with roles on vclass' do
250
+ setup do
251
+ secure!(::Role) { ::Role.create('name' => 'Address', 'superclass' => 'Contact')}
252
+ end
253
+
254
+ context 'exporting virtual class definitions' do
255
+ subject do
256
+ {:action => :export}
257
+ end
258
+
259
+ should 'not have role duplicates in yaml' do
260
+ get_subject
261
+ assert_no_match %r{Address.*Address}m, @response.body
262
+ end
263
+ end # exporting virtual class definitions
264
+ end # with roles on vclass
194
265
  end # that is an admin
195
266
  end # A logged in user
196
267
  end
@@ -96,7 +96,7 @@ class NavigationTest < Zena::Integration::TestCase
96
96
  @visitor = users(:tiger)
97
97
  Thread.current[:visitor] = nil
98
98
  end
99
-
99
+
100
100
  should 'render home page' do
101
101
  get 'http://test.host/oo'
102
102
  assert_response :success
@@ -255,6 +255,43 @@ class NavigationTest < Zena::Integration::TestCase
255
255
  assert_equal 'fr', session[:lang]
256
256
  end
257
257
 
258
+ context 'On a page with custom base' do
259
+ setup do
260
+ login(:lion)
261
+ assert_equal users(:lion).id, visitor.id
262
+ # add a publication in 'fr'
263
+ visitor.lang = 'fr'
264
+ node = secure!(Node) { nodes(:cleanWater) }
265
+ node.update_attributes(:title => 'Eau propre', :v_status => Zena::Status[:pub])
266
+ logout
267
+ end
268
+
269
+ subject do
270
+ 'http://test.host/projects-list/Clean-Water-project'
271
+ end
272
+
273
+ should 'get response' do
274
+ get subject
275
+ assert_redirected_to '/en/projects-list/Clean-Water-project'
276
+ follow_redirect!
277
+ assert_response :success
278
+ end
279
+
280
+ context 'in the wrong language' do
281
+ should 'redirect to translated page' do
282
+ # Set 'fr' session lang
283
+ get 'http://test.host/fr'
284
+ get subject
285
+ assert_redirected_to '/fr/projects-list/Clean-Water-project'
286
+ follow_redirect!
287
+ assert_redirected_to '/fr/projects-list/Eau-propre'
288
+ follow_redirect!
289
+ assert_response :success
290
+ end
291
+ end # in the wrong language
292
+
293
+ end # On a page with custom base
294
+
258
295
  def test_url_with_custom_base
259
296
  get 'http://test.host/en/projects-list/Clean-Water-project'
260
297
  assert_response :success
@@ -395,14 +432,19 @@ class NavigationTest < Zena::Integration::TestCase
395
432
  end
396
433
  end
397
434
 
398
- def login(user = nil)
399
- open_session do |sess|
400
- sess.extend(CustomAssertions)
401
- if user
402
- sess.post 'http://test.host/session', :login=>user.to_s, :password=>user.to_s
403
- sess.follow_redirect!
404
- end
405
- end
435
+ # We use test_helper's login
436
+ # def login(user = nil)
437
+ # open_session do |sess|
438
+ # sess.extend(CustomAssertions)
439
+ # if user
440
+ # sess.post 'http://test.host/session', :login=>user.to_s, :password=>user.to_s
441
+ # sess.follow_redirect!
442
+ # end
443
+ # end
444
+ # end
445
+ def logout
446
+ @visitor = nil
447
+ Thread.current[:visitor] = nil
406
448
  end
407
449
 
408
450
  def anon
@@ -53,19 +53,19 @@ project:
53
53
 
54
54
  many_alternatives:
55
55
  src: tagged in site or images in site or tags in site
56
- 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}"
56
+ 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}"
57
57
  # res: "art, bird, Clean Water project, flower, it's a lake, menu, news, opening, tree"
58
58
 
59
59
  alternatives_same_join:
60
60
  src: tagged in site or icons
61
- 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]"
61
+ 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]"
62
62
  res: "Clean Water project, it's a lake, super ouverture"
63
63
 
64
64
  same_name_as_class:
65
65
  context:
66
66
  node: 'opening'
67
67
  src: "set_tags"
68
- 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]"
68
+ 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]"
69
69
  res: "Art, News list"
70
70
 
71
71
 
@@ -100,21 +100,29 @@ children_with_order_clause:
100
100
  notes_or_news:
101
101
  context:
102
102
  class: Project
103
- 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]"
103
+ 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]"
104
104
 
105
105
  news_or_notes:
106
106
  context:
107
107
  class: Project
108
- 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]"
108
+ 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]"
109
109
 
110
110
  order_l_status:
111
111
  context:
112
112
  node: art
113
113
  class: Tag
114
114
  src: "tagged order by l_status ASC, zip ASC"
115
- 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]"
115
+ 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]"
116
116
  res: "super ouverture, Clean Water project"
117
117
 
118
+ order_random:
119
+ context:
120
+ node: wiki
121
+ src: "nodes order by random limit 1"
122
+ sqlite3: "[%Q{SELECT nodes.* FROM nodes WHERE #{secure_scope('nodes')} AND nodes.parent_id = ? ORDER BY random() LIMIT 1}, @node.id]"
123
+ mysql: "[%Q{SELECT nodes.* FROM nodes WHERE #{secure_scope('nodes')} AND nodes.parent_id = ? ORDER BY RAND() LIMIT 1}, @node.id]"
124
+ res: "/bird|flower/"
125
+
118
126
  paginate_one:
119
127
  src: "nodes in site order by zip limit 2 paginate p"
120
128
  # we sort by zip to avoid collation problems when some DB sort Capital letters first
@@ -128,4 +136,8 @@ paginate_two:
128
136
  p: 2
129
137
  src: "nodes in site order by zip limit 2 paginate p"
130
138
  sql: "[%Q{SELECT nodes.* FROM nodes WHERE #{secure_scope('nodes')} ORDER BY nodes.zip LIMIT 2 OFFSET ?}, ((params[:p].to_i > 0 ? params[:p].to_i : 1)-1)*2]"
131
- res: "Solenopsis Invicta, Panthera Tigris Sumatran"
139
+ res: "Solenopsis Invicta, Panthera Tigris Sumatran"
140
+
141
+ select_index_field:
142
+ src: "nodes select title as ti"
143
+ sql: "/SELECT nodes.*,ml1.value AS `ti`/"
@@ -70,7 +70,7 @@ custom_query_form_with_where:
70
70
  context:
71
71
  node: roger
72
72
  class: Employee
73
- date: 2005-03-01
73
+ date: '2005-03-01'
74
74
  src: "emp_form_dates where last_date is null or (repeat_every is not null and next_date lt #{date} + 6 month)"
75
75
  res: "how to use the winch, secure a site, engine maintenance, information transmission, fiber junction, how to use the radio"
76
76
 
@@ -19,4 +19,30 @@ year:
19
19
 
20
20
  year_on_whatever:
21
21
  src: "nodes where id.year < now.year"
22
- res: '' # no errors
22
+ res: '' # no errors
23
+
24
+ date_tz:
25
+ context:
26
+ date: '2006-04-11 7:0'
27
+ tz: 'Asia/Jakarta'
28
+ # This date is translated to 2006-04-11 0:0 UTC
29
+ src: "nodes where created_at = #{date}"
30
+ res: "crocodiles"
31
+
32
+ date_tz_day_interval:
33
+ context:
34
+ date: '2006-04-11'
35
+ tz: 'Asia/Jakarta'
36
+ # This date is translated to 2006-04-10 17:0 UTC
37
+ src: "nodes where #{date} <= created_at and created_at < #{date} + 1 day"
38
+ sql: '/INTERVAL 1 DAY/'
39
+ res: "crocodiles"
40
+
41
+ date_tz_date:
42
+ context:
43
+ date: '2006-04-11'
44
+ tz: 'Asia/Jakarta'
45
+ # This date is translated to 2006-04-10 17:0 UTC
46
+ src: "nodes where created_at.date = #{date}"
47
+ sql: '/INTERVAL 1 DAY/'
48
+ res: "crocodiles"
@@ -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,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:
@@ -15,11 +15,14 @@ bad_relation:
15
15
 
16
16
  overriden_relation:
17
17
  src: 'references'
18
- 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_references) AND links.source_id = ? ORDER BY nodes.zip ASC}, @node.id]"
18
+ 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_references) AND links.source_id = ? ORDER BY nodes.zip ASC}, @node.id]"
19
19
 
20
20
  link_selects_in_sub_query:
21
21
  src: "icons or images"
22
- 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_an_icon) AND links.source_id = ?) OR (nodes.kpath LIKE 'NDI%' AND nodes.parent_id = ? AND links.id = 0)) GROUP BY nodes.id ORDER BY nodes.zip ASC}, @node.id, @node.id]"
22
+ 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_an_icon) AND links.source_id = ?) OR (nodes.kpath LIKE 'NDI%' AND nodes.parent_id = ? AND links.id = 0)) GROUP BY nodes.id ORDER BY nodes.zip ASC}, @node.id, @node.id]"
23
+
24
+ project:
25
+ sql: "[%Q{SELECT nodes.* FROM nodes WHERE #{secure_scope('nodes')} AND nodes.id = ? ORDER BY nodes.zip ASC}, @node.get_project_id]"
23
26
 
24
27
  projects_from_tags:
25
28
  sql: "/nodes.id = no1.project_id AND no1.kpath LIKE 'NPT%' AND no1.parent_id = ?/"
@@ -57,7 +60,7 @@ root_should_be_project:
57
60
  # Make sure we do not start query on a Project so that we can tell if 'root' properly sets main_class.
58
61
  node: ant
59
62
  src: 'news from root'
60
- 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,nodes AS no1 WHERE #{secure_scope('nodes')} AND nodes.id = links.source_id AND links.relation_id = 488905946 AND links.target_id = no1.id AND no1.id = 850927283 GROUP BY nodes.id ORDER BY nodes.zip ASC}"
63
+ 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,nodes AS no1 WHERE #{secure_scope('nodes')} AND nodes.id = links.source_id AND links.relation_id = 488905946 AND links.target_id = no1.id AND no1.id = 850927283 GROUP BY nodes.id ORDER BY nodes.zip ASC}"
61
64
 
62
65
  start_as_tag:
63
66
  context:
@@ -72,4 +75,10 @@ from_visitor:
72
75
  res: 'Nature'
73
76
 
74
77
  # l_date_as_date:
75
- # src: "select *,if(l_date,l_date,event_at) AS date from (notes or assigned_notes) order by date"
78
+ # src: "select *,if(l_date,l_date,event_at) AS date from (notes or assigned_notes) order by date"
79
+
80
+ project_as_blog:
81
+ # Should scope by path
82
+ # This is the same as "project where class like Blog"
83
+ src: "Blog:project"
84
+ sql: "[%Q{SELECT nodes.* FROM nodes WHERE #{secure_scope('nodes')} AND nodes.kpath LIKE 'NPPB%' AND nodes.id = ? ORDER BY nodes.zip ASC}, @node.get_project_id]"
@@ -29,6 +29,10 @@ class QueryNodeTest < Zena::Unit::TestCase
29
29
  def yt_do_test(file, test)
30
30
  @context = Hash[*(yt_get('context', file, test).map{|k,v| [k.to_sym, v]}.flatten)]
31
31
 
32
+ if @context[:date]
33
+ @context[:date] = @context[:date].to_utc('%Y-%m-%d %H:%M:%S', @context[:tz] ? TZInfo::Timezone.get(@context[:tz]) : visitor.tz)
34
+ end
35
+
32
36
  params = {}
33
37
  (@context[:params] || {}).each do |k,v|
34
38
  params[k.to_sym] = v
@@ -7,6 +7,11 @@ class XmlApiTest < Zena::Integration::TestCase
7
7
  include Zena::Integration::MockResource
8
8
  self.site = 'http://test.host'
9
9
  self.element_name = 'node'
10
+ def initialize(*args)
11
+ super
12
+ hash = self.attributes
13
+ hash['tag_names'] = Zena::Remote::SerializableArray.new('tag_names', 'tag', hash['tag_names'] || [])
14
+ end
10
15
  end
11
16
 
12
17
  class BadTokenResource < ActiveResource::Base
@@ -61,7 +66,7 @@ class XmlApiTest < Zena::Integration::TestCase
61
66
 
62
67
  assert_equal [nodes_zip(:status)], result
63
68
  end
64
-
69
+
65
70
  should 'find the list of nodes with qb' do
66
71
  subject # create index entry for art
67
72
  # create index entry for status
@@ -67,8 +67,8 @@ action:
67
67
  res: "/nodes/22/versions/0/edit.*Open the edition window to edit the node.*Zena.open_window/"
68
68
 
69
69
  swap:
70
- src: "<span do='block' do='swap' attr='custom_a' states='100,-100' do='custom_a'/>"
71
- tem: '/:dom_id => "list1", :t_url => "action/swap/list1"/'
70
+ src: "<span do='block' do='swap' attr='weight' states='100,-100' do='weight'/>"
71
+ tem: '/:dom_id => %Q\{list1\}, :t_url => "action/swap/list1"/'
72
72
  '/action/swap/en/list1.erb': "/<span id='list1'>/"
73
73
 
74
74
  swap_in_each:
@@ -77,4 +77,4 @@ swap_in_each:
77
77
 
78
78
  hand_made_swap:
79
79
  src: "<r:link update='_page' node[origin]='#{next_in_list(origin, \"todo,done\")}' action='update'/>"
80
- tem: "/:_method => .put., :.node\[origin\]. => .#\{next_in_list_s\(@node.prop\['origin'\], .todo,done.\)/"
80
+ tem: "/node\[origin\]. => .#\{next_in_list_s\(@node.prop\['origin'\].*todo,done.*method:.put./"