spontaneous 0.2.0.beta1 → 0.2.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (335) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.locat +42 -0
  4. data/.travis/gemfiles/Gemfile.empty +7 -0
  5. data/.travis.yml +18 -0
  6. data/Gemfile +12 -8
  7. data/LICENSE +1 -1
  8. data/Rakefile +15 -157
  9. data/Readme.markdown +1 -1
  10. data/application/css/core.css.scss +22 -146
  11. data/application/css/definitions.css.scss +7 -3
  12. data/application/css/dialogue.css.scss +26 -1
  13. data/application/css/editing.css.scss +70 -28
  14. data/application/css/font.css.scss +1 -1
  15. data/application/css/popover.css.scss +2 -0
  16. data/application/css/top.css.scss +231 -0
  17. data/application/js/add_alias_dialogue.js +1 -1
  18. data/application/js/add_home_dialogue.js +1 -1
  19. data/application/js/ajax.js +61 -31
  20. data/application/js/box.js +4 -4
  21. data/application/js/conflicted_field_dialogue.js +1 -1
  22. data/application/js/content.js +5 -5
  23. data/application/js/dom.js +5 -0
  24. data/application/js/edit_panel.js +1 -0
  25. data/application/js/editing.js +1 -1
  26. data/application/js/extensions.js +8 -0
  27. data/application/js/field/boolean.js +31 -0
  28. data/application/js/field/file.js +32 -4
  29. data/application/js/field/image.js +24 -9
  30. data/application/js/field/markdown.js +87 -59
  31. data/application/js/field/select.js +1 -1
  32. data/application/js/field/webvideo.js +6 -1
  33. data/application/js/init.js +2 -2
  34. data/application/js/jquery-selection-position.js +130 -0
  35. data/application/js/location.js +4 -25
  36. data/application/js/meta_view/user_admin.js +2 -2
  37. data/application/js/metadata.js +2 -2
  38. data/application/js/page_browser.js +1 -1
  39. data/application/js/panel/root_menu.js +0 -1
  40. data/application/js/popover.js +27 -12
  41. data/application/js/popover_view.js +20 -4
  42. data/application/js/preview.js +31 -16
  43. data/application/js/progress.js +22 -21
  44. data/application/js/publish.js +18 -7
  45. data/application/js/sharded_upload.js +9 -6
  46. data/application/js/spontaneous.js +3 -1
  47. data/application/js/top_bar.js +264 -173
  48. data/application/js/upload.js +12 -5
  49. data/application/js/upload_manager.js +4 -3
  50. data/application/js/user.js +1 -2
  51. data/application/js/views/box_view.js +1 -1
  52. data/application/js/views/page_view.js +16 -5
  53. data/application/js/views/piece_view.js +5 -4
  54. data/application/static/font/fontawesome-webfont-1c66a4738b40ef0f6b1abca0ba9a796d.ttf +0 -0
  55. data/application/views/index.erb +6 -14
  56. data/application/views/login.erb +6 -25
  57. data/application/views/schema_modification_error.html.erb +3 -7
  58. data/db/migrations/20130114120000_create_revision_tables.rb +2 -2
  59. data/db/migrations/20130813111009_increase_path_length.rb +14 -0
  60. data/gem-public_cert.pem +20 -0
  61. data/lib/spontaneous/asset/app_compiler.rb +44 -0
  62. data/lib/spontaneous/asset/environment.rb +225 -0
  63. data/lib/spontaneous/asset.rb +2 -67
  64. data/lib/spontaneous/box.rb +0 -1
  65. data/lib/spontaneous/capistrano/deploy.rb +2 -2
  66. data/lib/spontaneous/capistrano/sync.rb +1 -1
  67. data/lib/spontaneous/cli/init.rb +36 -13
  68. data/lib/spontaneous/cli/server.rb +0 -1
  69. data/lib/spontaneous/cli/site.rb +2 -1
  70. data/lib/spontaneous/cli.rb +3 -1
  71. data/lib/spontaneous/collections/entry_set.rb +4 -12
  72. data/lib/spontaneous/collections/hash_with_fallback.rb +20 -0
  73. data/lib/spontaneous/collections/prototype_set.rb +6 -5
  74. data/lib/spontaneous/crypt.rb +2 -2
  75. data/lib/spontaneous/data_mapper/content_model/associations.rb +115 -63
  76. data/lib/spontaneous/data_mapper.rb +1 -1
  77. data/lib/spontaneous/errors.rb +6 -0
  78. data/lib/spontaneous/extensions/object_space.rb +6 -0
  79. data/lib/spontaneous/facet.rb +1 -0
  80. data/lib/spontaneous/field/base.rb +86 -13
  81. data/lib/spontaneous/field/boolean.rb +65 -0
  82. data/lib/spontaneous/field/file.rb +17 -6
  83. data/lib/spontaneous/field/html.rb +13 -0
  84. data/lib/spontaneous/field/image/size.rb +76 -0
  85. data/lib/spontaneous/field/image.rb +99 -414
  86. data/lib/spontaneous/field/tags.rb +36 -0
  87. data/lib/spontaneous/field/update.rb +1 -1
  88. data/lib/spontaneous/field/webvideo/fallback.rb +41 -0
  89. data/lib/spontaneous/field/webvideo/vimeo.rb +113 -0
  90. data/lib/spontaneous/field/webvideo/vine.rb +94 -0
  91. data/lib/spontaneous/field/webvideo/youtube.rb +133 -0
  92. data/lib/spontaneous/field/webvideo.rb +100 -250
  93. data/lib/spontaneous/field.rb +1 -1
  94. data/lib/spontaneous/generators/site/Gemfile.tt +5 -14
  95. data/lib/spontaneous/generators/site/assets/README.md +20 -0
  96. data/lib/spontaneous/generators/site/assets/css/site.scss +8 -0
  97. data/lib/spontaneous/generators/site/assets/js/site.js +6 -0
  98. data/lib/spontaneous/generators/site/config/deploy.rb.tt +9 -0
  99. data/lib/spontaneous/generators/site/config/user_levels.yml +14 -3
  100. data/lib/spontaneous/generators/site/public/README.md +12 -0
  101. data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +2 -2
  102. data/lib/spontaneous/generators/site.rb +77 -35
  103. data/lib/spontaneous/layout.rb +6 -7
  104. data/lib/spontaneous/loader.rb +21 -13
  105. data/lib/spontaneous/media/file.rb +22 -9
  106. data/lib/spontaneous/media/image/attributes.rb +33 -0
  107. data/lib/spontaneous/media/image/format/gif.rb +4 -0
  108. data/lib/spontaneous/media/image/format/jpg.rb +17 -0
  109. data/lib/spontaneous/media/image/format/png.rb +4 -0
  110. data/lib/spontaneous/media/image/format/webp.rb +26 -0
  111. data/lib/spontaneous/media/image/format.rb +79 -0
  112. data/lib/spontaneous/media/image/optimizer.rb +69 -0
  113. data/lib/spontaneous/media/image/processor.rb +17 -0
  114. data/lib/spontaneous/media/image/renderable.rb +52 -0
  115. data/lib/spontaneous/media/image/skeptick.rb +70 -0
  116. data/lib/spontaneous/media/image.rb +50 -0
  117. data/lib/spontaneous/media/temp_file.rb +4 -0
  118. data/lib/spontaneous/media.rb +1 -0
  119. data/lib/spontaneous/model/core/aliases.rb +14 -8
  120. data/lib/spontaneous/model/core/boxes.rb +5 -2
  121. data/lib/spontaneous/model/core/entries.rb +4 -0
  122. data/lib/spontaneous/model/core/entry.rb +1 -0
  123. data/lib/spontaneous/model/core/fields.rb +5 -2
  124. data/lib/spontaneous/model/core/locks.rb +16 -0
  125. data/lib/spontaneous/model/core/media.rb +1 -15
  126. data/lib/spontaneous/model/core.rb +31 -1
  127. data/lib/spontaneous/model/page/controllers.rb +2 -2
  128. data/lib/spontaneous/model/page/formats.rb +1 -4
  129. data/lib/spontaneous/model/page/layouts.rb +6 -2
  130. data/lib/spontaneous/model/page/locks.rb +8 -2
  131. data/lib/spontaneous/model/page/page_tree.rb +2 -2
  132. data/lib/spontaneous/model/page/paths.rb +74 -9
  133. data/lib/spontaneous/model/page.rb +11 -3
  134. data/lib/spontaneous/model.rb +6 -6
  135. data/lib/spontaneous/output/context/render_cache.rb +23 -0
  136. data/lib/spontaneous/output/context.rb +56 -30
  137. data/lib/spontaneous/output/helpers/script_helper.rb +9 -53
  138. data/lib/spontaneous/output/helpers/stylesheet_helper.rb +8 -40
  139. data/lib/spontaneous/output/template/renderer.rb +17 -5
  140. data/lib/spontaneous/output.rb +0 -1
  141. data/lib/spontaneous/paths.rb +6 -2
  142. data/lib/spontaneous/permissions/access_key.rb +18 -0
  143. data/lib/spontaneous/permissions/user.rb +1 -1
  144. data/lib/spontaneous/permissions.rb +4 -1
  145. data/lib/spontaneous/plugins/application/state.rb +19 -12
  146. data/lib/spontaneous/prototypes/field_prototype.rb +14 -8
  147. data/lib/spontaneous/published_revision.rb +7 -0
  148. data/lib/spontaneous/publishing/immediate.rb +43 -34
  149. data/lib/spontaneous/publishing/revision.rb +9 -6
  150. data/lib/spontaneous/rack/asset_server.rb +20 -0
  151. data/lib/spontaneous/rack/back/alias.rb +46 -0
  152. data/lib/spontaneous/rack/back/application_assets.rb +28 -0
  153. data/lib/spontaneous/rack/back/base.rb +34 -0
  154. data/lib/spontaneous/rack/back/changes.rb +19 -0
  155. data/lib/spontaneous/rack/back/content.rb +54 -0
  156. data/lib/spontaneous/rack/back/events.rb +38 -0
  157. data/lib/spontaneous/rack/back/field.rb +37 -0
  158. data/lib/spontaneous/rack/back/file.rb +118 -0
  159. data/lib/spontaneous/rack/back/helpers.rb +71 -0
  160. data/lib/spontaneous/rack/back/index.rb +16 -0
  161. data/lib/spontaneous/rack/back/login.rb +47 -0
  162. data/lib/spontaneous/rack/back/map.rb +24 -0
  163. data/lib/spontaneous/rack/back/page.rb +46 -0
  164. data/lib/spontaneous/rack/back/preview.rb +43 -0
  165. data/lib/spontaneous/rack/back/schema.rb +30 -0
  166. data/lib/spontaneous/rack/back/site.rb +25 -0
  167. data/lib/spontaneous/rack/back/site_assets.rb +13 -0
  168. data/lib/spontaneous/rack/back/unsupported_browser.rb +7 -0
  169. data/lib/spontaneous/rack/{user_admin.rb → back/user_admin.rb} +2 -5
  170. data/lib/spontaneous/rack/back.rb +85 -764
  171. data/lib/spontaneous/rack/cacheable_file.rb +3 -3
  172. data/lib/spontaneous/rack/front.rb +16 -9
  173. data/lib/spontaneous/rack/middleware/authenticate.rb +65 -0
  174. data/lib/spontaneous/rack/middleware/csrf.rb +66 -0
  175. data/lib/spontaneous/rack/middleware/reloader.rb +52 -0
  176. data/lib/spontaneous/rack/middleware/scope.rb +60 -0
  177. data/lib/spontaneous/rack/middleware.rb +6 -0
  178. data/lib/spontaneous/rack/page_controller.rb +18 -5
  179. data/lib/spontaneous/rack/public.rb +17 -11
  180. data/lib/spontaneous/rack.rb +34 -24
  181. data/lib/spontaneous/revision.rb +29 -2
  182. data/lib/spontaneous/schema/uid.rb +4 -3
  183. data/lib/spontaneous/schema/uid_map.rb +5 -24
  184. data/lib/spontaneous/schema.rb +1 -0
  185. data/lib/spontaneous/search/database.rb +8 -0
  186. data/lib/spontaneous/search/field.rb +1 -1
  187. data/lib/spontaneous/search/index.rb +3 -5
  188. data/lib/spontaneous/server.rb +1 -1
  189. data/lib/spontaneous/simultaneous.rb +1 -1
  190. data/lib/spontaneous/site/features.rb +4 -5
  191. data/lib/spontaneous/site/helpers.rb +22 -5
  192. data/lib/spontaneous/site/instance.rb +2 -2
  193. data/lib/spontaneous/site/selectors.rb +22 -3
  194. data/lib/spontaneous/storage/cloud.rb +13 -9
  195. data/lib/spontaneous/storage/local.rb +11 -6
  196. data/lib/spontaneous/style.rb +40 -23
  197. data/lib/spontaneous/utils/database/mysql_dumper.rb +1 -1
  198. data/lib/spontaneous/utils/smush_it.rb +1 -1
  199. data/lib/spontaneous/version.rb +1 -1
  200. data/lib/spontaneous.rb +35 -33
  201. data/spontaneous.gemspec +53 -787
  202. data/test/experimental/test_crypt.rb +56 -56
  203. data/test/experimental/test_features.rb +16 -27
  204. data/test/fixtures/assets/public1/css/data.css.scss +3 -0
  205. data/test/fixtures/assets/public1/css/image1.css.scss +4 -0
  206. data/test/fixtures/assets/public1/css/import.css.scss +1 -0
  207. data/test/fixtures/assets/public1/css/urlhash.css.scss +3 -0
  208. data/test/fixtures/assets/public1/js/a.js +1 -1
  209. data/test/fixtures/assets/public1/js/all.js +4 -0
  210. data/test/fixtures/assets/public1/js/{m.coffee → m.js.coffee} +1 -0
  211. data/test/fixtures/assets/public1/x.js +1 -0
  212. data/test/fixtures/assets/public2/css/all.css +4 -0
  213. data/test/fixtures/assets/public2/css/missing.css.scss +3 -0
  214. data/test/fixtures/assets/public2/i/y.png +0 -0
  215. data/test/fixtures/assets/public2/js/b.js +1 -1
  216. data/test/fixtures/assets/public2/js/c.js +1 -1
  217. data/test/fixtures/images/size.extended.webp +0 -0
  218. data/test/fixtures/images/size.lossless.webp +0 -0
  219. data/test/fixtures/images/size.lossy.webp +0 -0
  220. data/test/fixtures/schema/before.yml +4 -4
  221. data/test/fixtures/schema/schema.yml +1 -1
  222. data/test/fixtures/templates/aliases/aaa.html.cut +0 -0
  223. data/test/fixtures/templates/extended/partial_with_renderer.html.cut +1 -0
  224. data/test/fixtures/templates/extended/with_includes_and_renderer.html.cut +2 -0
  225. data/test/functional/test_application.rb +108 -106
  226. data/test/functional/test_back.rb +924 -930
  227. data/test/functional/test_front.rb +285 -238
  228. data/test/functional/test_user_manager.rb +75 -100
  229. data/test/integration/test_installation.rb +1 -1
  230. data/test/support/matchers.rb +12 -0
  231. data/test/support/minitest.rb +121 -0
  232. data/test/support/rack.rb +45 -0
  233. data/test/support/test_start_finish.rb +103 -0
  234. data/test/test_helper.rb +21 -68
  235. data/test/test_integration_helper.rb +1 -3
  236. data/test/unit/test_alias.rb +432 -408
  237. data/test/unit/test_asset_bundler.rb +58 -58
  238. data/test/unit/test_assets.rb +485 -155
  239. data/test/unit/test_async.rb +16 -37
  240. data/test/unit/test_authentication.rb +425 -457
  241. data/test/unit/test_boxes.rb +191 -191
  242. data/test/unit/test_changesets.rb +244 -254
  243. data/test/unit/test_config.rb +128 -142
  244. data/test/unit/test_content.rb +313 -359
  245. data/test/unit/test_content_inheritance.rb +29 -30
  246. data/test/unit/test_datamapper.rb +1205 -1080
  247. data/test/unit/test_datamapper_content.rb +49 -51
  248. data/test/unit/test_extensions.rb +23 -23
  249. data/test/unit/test_fields.rb +1488 -1180
  250. data/test/unit/test_formats.rb +158 -158
  251. data/test/unit/test_generators.rb +98 -40
  252. data/test/unit/test_helpers.rb +73 -76
  253. data/test/unit/test_image_size.rb +53 -22
  254. data/test/unit/test_images.rb +164 -165
  255. data/test/unit/test_layouts.rb +133 -122
  256. data/test/unit/test_logger.rb +14 -17
  257. data/test/unit/test_media.rb +69 -84
  258. data/test/unit/test_modifications.rb +513 -525
  259. data/test/unit/test_page.rb +462 -361
  260. data/test/unit/test_permissions.rb +379 -364
  261. data/test/unit/test_piece.rb +67 -75
  262. data/test/unit/test_plugins.rb +82 -89
  263. data/test/unit/test_prototype_set.rb +215 -216
  264. data/test/unit/test_prototypes.rb +114 -124
  265. data/test/unit/test_publishing.rb +252 -289
  266. data/test/unit/test_render.rb +167 -115
  267. data/test/unit/test_revisions.rb +436 -444
  268. data/test/unit/test_schema.rb +339 -309
  269. data/test/unit/test_search.rb +577 -574
  270. data/test/unit/test_serialisation.rb +136 -147
  271. data/test/unit/test_site.rb +252 -227
  272. data/test/unit/test_skeptick.rb +130 -0
  273. data/test/unit/test_storage.rb +46 -40
  274. data/test/unit/test_structure.rb +57 -66
  275. data/test/unit/test_styles.rb +104 -104
  276. data/test/unit/test_templates.rb +72 -57
  277. data/test/unit/test_type_hierarchy.rb +15 -16
  278. data/test/unit/test_visibility.rb +239 -257
  279. metadata +455 -326
  280. data/application/js/vendor/JS.Class-2.1.5/CHANGELOG +0 -283
  281. data/application/js/vendor/JS.Class-2.1.5/MIT-LICENSE +0 -30
  282. data/application/js/vendor/JS.Class-2.1.5/README +0 -30
  283. data/application/js/vendor/JS.Class-2.1.5/min/command.js +0 -1
  284. data/application/js/vendor/JS.Class-2.1.5/min/comparable.js +0 -1
  285. data/application/js/vendor/JS.Class-2.1.5/min/constant_scope.js +0 -1
  286. data/application/js/vendor/JS.Class-2.1.5/min/decorator.js +0 -1
  287. data/application/js/vendor/JS.Class-2.1.5/min/enumerable.js +0 -1
  288. data/application/js/vendor/JS.Class-2.1.5/min/forwardable.js +0 -1
  289. data/application/js/vendor/JS.Class-2.1.5/min/hash.js +0 -1
  290. data/application/js/vendor/JS.Class-2.1.5/min/linked_list.js +0 -1
  291. data/application/js/vendor/JS.Class-2.1.5/min/loader.js +0 -1
  292. data/application/js/vendor/JS.Class-2.1.5/min/method_chain.js +0 -1
  293. data/application/js/vendor/JS.Class-2.1.5/min/observable.js +0 -1
  294. data/application/js/vendor/JS.Class-2.1.5/min/package.js +0 -1
  295. data/application/js/vendor/JS.Class-2.1.5/min/proxy.js +0 -1
  296. data/application/js/vendor/JS.Class-2.1.5/min/ruby.js +0 -1
  297. data/application/js/vendor/JS.Class-2.1.5/min/set.js +0 -1
  298. data/application/js/vendor/JS.Class-2.1.5/min/stack_trace.js +0 -1
  299. data/application/js/vendor/JS.Class-2.1.5/min/state.js +0 -1
  300. data/application/js/vendor/JS.Class-2.1.5/min/stdlib.js +0 -16
  301. data/application/js/vendor/jquery-1.6.2.min.js +0 -18
  302. data/application/js/vendor/jquery-ui-1.8.16.custom.min.js +0 -791
  303. data/application/js/vendor/jquery-ui-1.8.9.custom.min.js +0 -415
  304. data/application/static/font/fontawesome-webfont-5c5c21100a346972a82c34c5e96ffcfe.ttf +0 -0
  305. data/application/static/select-arrow-6e7dd3745b00e934b0d7a3250c46558b.png +0 -0
  306. data/bin/limit-upload +0 -5
  307. data/bin/unlimit-upload +0 -3
  308. data/lib/spontaneous/asset/file.rb +0 -25
  309. data/lib/spontaneous/asset/source.rb +0 -28
  310. data/lib/spontaneous/image_size.rb +0 -123
  311. data/lib/spontaneous/output/assets/compression.rb +0 -58
  312. data/lib/spontaneous/output/assets.rb +0 -32
  313. data/lib/spontaneous/rack/around_back.rb +0 -20
  314. data/lib/spontaneous/rack/around_front.rb +0 -27
  315. data/lib/spontaneous/rack/around_preview.rb +0 -22
  316. data/lib/spontaneous/rack/assets.rb +0 -126
  317. data/lib/spontaneous/rack/authentication.rb +0 -20
  318. data/lib/spontaneous/rack/cookie_authentication.rb +0 -38
  319. data/lib/spontaneous/rack/helpers.rb +0 -52
  320. data/lib/spontaneous/rack/http.rb +0 -18
  321. data/lib/spontaneous/rack/media.rb +0 -30
  322. data/lib/spontaneous/rack/query_authentication.rb +0 -35
  323. data/lib/spontaneous/rack/reloader.rb +0 -45
  324. data/lib/spontaneous/rack/user_helpers.rb +0 -28
  325. /data/{README → application/js/field/markdown/text_command.js} +0 -0
  326. /data/application/js/vendor/{JS.Class-2.1.5/min/core.js → js.class-2.1.5.min.js} +0 -0
  327. /data/test/fixtures/assets/public1/css/{a.scss → a.css.scss} +0 -0
  328. /data/{lib/spontaneous/generators/site/public/css/site.scss → test/fixtures/assets/public1/x.css} +0 -0
  329. /data/{lib/spontaneous/generators/site/public/js/.empty_directory → test/fixtures/assets/public1/x.png} +0 -0
  330. /data/test/fixtures/assets/public2/css/{b.scss → b.css.scss} +0 -0
  331. /data/test/fixtures/assets/public2/js/{n.coffee → n.js.coffee} +0 -0
  332. /data/test/fixtures/back/{public → assets}/css/sass_include.scss +0 -0
  333. /data/test/fixtures/back/{public → assets}/css/sass_template.scss +0 -0
  334. /data/test/fixtures/back/{public → assets}/js/coffeescript.coffee +0 -0
  335. /data/{lib/spontaneous/generators/site/public/js/site.js → test/fixtures/templates/aliases/aa_alias.html.cut} +0 -0
@@ -3,646 +3,634 @@
3
3
  require File.expand_path('../../test_helper', __FILE__)
4
4
 
5
5
 
6
- class ModificationsTest < MiniTest::Spec
6
+ describe "Modifications" do
7
7
 
8
- def setup
8
+ before do
9
9
  @now = Time.now
10
10
  @site = setup_site
11
- end
12
-
13
- def teardown
14
- teardown_site
15
- end
11
+ stub_time(@now)
16
12
 
17
- context "modifications" do
18
- setup do
19
- stub_time(@now)
13
+ Content.delete
20
14
 
21
- # DB.logger = Logger.new($stdout)
22
- Content.delete
23
-
24
- class Page < ::Page
25
- field :title, :string, :default => "New Page"
26
- box :things
27
- end
28
- class Piece < ::Piece
29
- box :things
30
- end
15
+ class ::Page
16
+ field :title, :string, :default => "New Page"
17
+ box :things
18
+ end
19
+ class ::Piece
20
+ box :things
21
+ end
31
22
 
32
- @root = Page.create(:uid => "root")
33
- count = 0
34
- 2.times do |i|
35
- c = Page.new(:uid => i)
36
- @root.things << c
23
+ @root = Page.create(:uid => "root")
24
+ count = 0
25
+ 2.times do |i|
26
+ c = Page.new(:uid => i, :slug => "p-#{i}")
27
+ @root.things << c
28
+ count += 1
29
+ 2.times do |j|
30
+ d = Piece.new(:uid => "#{i}.#{j}", :slug => "p-#{i}-#{j}")
31
+ c.things << d
37
32
  count += 1
38
- 2.times do |j|
39
- d = Piece.new(:uid => "#{i}.#{j}")
40
- c.things << d
33
+ 2.times do |k|
34
+ d.things << Page.new(:uid => "#{i}.#{j}.#{k}", :slug => "p-#{i}-#{j}-#{k}")
35
+ d.save
41
36
  count += 1
42
- 2.times do |k|
43
- d.things << Page.new(:uid => "#{i}.#{j}.#{k}")
44
- d.save
45
- count += 1
46
- end
47
37
  end
48
- c.save
49
38
  end
50
- @root.save
39
+ c.save
51
40
  end
41
+ @root.save
42
+ end
52
43
 
53
- teardown do
54
- ModificationsTest.send(:remove_const, :Page) rescue nil
55
- ModificationsTest.send(:remove_const, :Piece) rescue nil
56
- Content.delete
57
- DB.logger = nil
58
- end
44
+ after do
45
+ Object.send(:remove_const, :Page) rescue nil
46
+ Object.send(:remove_const, :Piece) rescue nil
47
+ Content.delete
48
+ teardown_site
49
+ end
59
50
 
51
+ it "register creation date of all content" do
52
+ c = Content.create
53
+ c.created_at.to_i.must_equal @now.to_i
54
+ page = Page.create
55
+ page.created_at.to_i.must_equal @now.to_i
56
+ end
60
57
 
58
+ it "update modification date of page when page fields are updated" do
59
+ now = @now + 100
60
+ stub_time(now)
61
+ c = Content.first
62
+ (c.modified_at.to_i - @now.to_i).abs.must_be :<=, 1
63
+ c.label = "changed"
64
+ c.save
65
+ (c.modified_at - now).abs.must_be :<=, 1
66
+ end
61
67
 
62
- should "register creation date of all content" do
63
- c = Content.create
64
- c.created_at.to_i.should == @now.to_i
65
- page = Page.create
66
- page.created_at.to_i.should == @now.to_i
67
- end
68
+ it "update modification date of path when page visibility is changed" do
69
+ now = @now + 100
70
+ stub_time(now)
71
+ c = Page.uid("0")
72
+ (c.modified_at.to_i - @now.to_i).abs.must_be :<=, 1
73
+ c.toggle_visibility!
74
+ (c.modified_at - now).abs.must_be :<=, 1
75
+ end
68
76
 
69
- should "update modification date of page when page fields are updated" do
70
- now = @now + 100
71
- stub_time(now)
72
- c = Content.first
73
- (c.modified_at.to_i - @now.to_i).abs.should <= 1
74
- c.label = "changed"
75
- c.save
76
- (c.modified_at - now).abs.should <= 1
77
+ it "update page timestamps on modification of its box fields" do
78
+ Page.box :with_fields do
79
+ field :title
77
80
  end
78
81
 
79
- should "update modification date of path when page visibility is changed" do
80
- now = @now + 100
81
- stub_time(now)
82
- c = Page.uid("0")
83
- (c.modified_at.to_i - @now.to_i).abs.should <= 1
84
- c.toggle_visibility!
85
- (c.modified_at - now).abs.should <= 1
86
- end
82
+ stub_time(@now+3600)
83
+ page = Page.first :uid => "0"
84
+ (page.modified_at.to_i - @now.to_i).abs.must_be :<=, 1
85
+ page.with_fields.title.value = "updated"
86
+ page.save.reload
87
+ page.modified_at.to_i.must_equal @now.to_i + 3600
88
+ end
87
89
 
88
- should "update page timestamps on modification of its box fields" do
89
- Page.box :with_fields do
90
- field :title
91
- end
90
+ it "update page timestamps on modification of a piece" do
91
+ stub_time(@now+3600)
92
+ page = Page.first :uid => "0"
93
+ (page.modified_at.to_i - @now.to_i).abs.must_be :<=, 1
94
+ content = page.contents.first
95
+ content.page.must_equal page
96
+ content.label = "changed"
97
+ content.save
98
+ page.reload
99
+ page.modified_at.to_i.must_equal @now.to_i + 3600
100
+ end
92
101
 
93
- stub_time(@now+3600)
94
- page = Page.first :uid => "0"
95
- (page.modified_at.to_i - @now.to_i).abs.should <= 1
96
- page.with_fields.title.value = "updated"
97
- page.save.reload
98
- page.modified_at.to_i.should == @now.to_i + 3600
102
+ it "update page timestamps on modification of a piece's box fields" do
103
+ Piece.box :with_fields do
104
+ field :title
99
105
  end
106
+ stub_time(@now+3600)
107
+ page = Page.first :uid => "0"
108
+ (page.modified_at.to_i - @now.to_i).abs.must_be :<=, 1
109
+ content = page.contents.first
110
+
111
+ content.with_fields.title.value = "updated"
112
+ content.save
113
+ page.reload
114
+ page.modified_at.to_i.must_equal @now.to_i + 3600
115
+ end
100
116
 
101
- should "update page timestamps on modification of a piece" do
102
- stub_time(@now+3600)
103
- page = Page.first :uid => "0"
104
- (page.modified_at.to_i - @now.to_i).abs.should <= 1
105
- content = page.contents.first
106
- content.page.should == page
107
- content.label = "changed"
108
- content.save
109
- page.reload
110
- page.modified_at.to_i.should == @now.to_i + 3600
111
- end
117
+ it "update page timestamp on addition of piece" do
118
+ stub_time(@now+3600)
119
+ page = Page.first :uid => "0"
120
+ content = Content[page.contents.first.id]
121
+ content.things << Piece.new
122
+ content.save
123
+ content.modified_at.to_i.must_equal @now.to_i + 3600
124
+ page.reload
125
+ page.modified_at.to_i.must_equal @now.to_i + 3600
126
+ end
112
127
 
113
- should "update page timestamps on modification of a piece's box fields" do
114
- Piece.box :with_fields do
115
- field :title
116
- end
117
- stub_time(@now+3600)
118
- page = Page.first :uid => "0"
119
- (page.modified_at.to_i - @now.to_i).abs.should <= 1
120
- content = page.contents.first
121
-
122
- content.with_fields.title.value = "updated"
123
- content.save
124
- page.reload
125
- page.modified_at.to_i.should == @now.to_i + 3600
126
- end
128
+ it "not update the parent page's timestamp on addition of a child page yyyy" do
129
+ stub_time(@now+1000)
130
+ page = Page.first :uid => "0"
131
+ page.things << Page.new
132
+ page.save.reload
133
+ page.modified_at.to_i.must_equal @now.to_i
134
+ end
127
135
 
128
- should "update page timestamp on addition of piece" do
129
- stub_time(@now+3600)
130
- page = Page.first :uid => "0"
131
- content = Content[page.contents.first.id]
132
- content.things << Piece.new
133
- content.save
134
- content.modified_at.to_i.should == @now.to_i + 3600
135
- page.reload
136
- page.modified_at.to_i.should == @now.to_i + 3600
137
- end
136
+ it "update the parent page's modification time if child pages are re-ordered" do
137
+ page = Page.first :uid => "0.0.0"
138
+ page.things << Page.new(:uid => "0.0.0.0")
139
+ page.things << Page.new(:uid => "0.0.0.1")
140
+ page.save
141
+ page = Page.first :uid => "0.0.0"
142
+ stub_time(@now+1000)
143
+ child = page.things.first
144
+ child.update_position(1)
145
+ page.reload.modified_at.to_i.must_equal @now.to_i + 1000
146
+ end
138
147
 
139
- should "not update the parent page's timestamp on addition of a child page yyyy" do
140
- stub_time(@now+1000)
141
- page = Page.first :uid => "0"
142
- page.things << Page.new
143
- page.save.reload
144
- page.modified_at.to_i.should == @now.to_i
145
- end
148
+ it "update a page's timestamp on modification of its slug" do
149
+ stub_time(@now+1000)
150
+ page = Page.first :uid => "0"
151
+ page.slug = "changed"
152
+ page.save.reload
153
+ page.modified_at.to_i.must_equal @now.to_i + 1000
154
+ end
146
155
 
147
- should "update the parent page's modification time if child pages are re-ordered" do
148
- page = Page.first :uid => "0.0.0"
149
- page.things << Page.new(:uid => "0.0.0.0")
150
- page.things << Page.new(:uid => "0.0.0.1")
151
- page.save
152
- page = Page.first :uid => "0.0.0"
153
- stub_time(@now+1000)
154
- child = page.things.first
155
- child.update_position(1)
156
- page.reload.modified_at.to_i.should == @now.to_i + 1000
157
- end
156
+ it "not update child pages timestamps after changing their parent's slug" do
157
+ page = Page.first :uid => "0.0.0"
158
+ modified = page.modified_at.to_i
159
+ stub_time(@now+1000)
160
+ page = Page.first :uid => "0"
161
+ page.slug = "changed"
162
+ page.save.reload
163
+ page.modified_at.to_i.must_equal @now.to_i + 1000
164
+ page = Page.first :uid => "0.0.0"
165
+ page.modified_at.to_i.must_equal modified
166
+ end
158
167
 
159
- should "update a page's timestamp on modification of its slug" do
160
- stub_time(@now+1000)
161
- page = Page.first :uid => "0"
162
- page.slug = "changed"
163
- page.save.reload
164
- page.modified_at.to_i.should == @now.to_i + 1000
165
- end
168
+ it "update the pages timestamp if a boxes order is changed" do
169
+ stub_time(@now+3600)
170
+ page = Page.first :uid => "0"
171
+ content = Content[page.contents.first.id]
172
+ content.update_position(1)
173
+ page.reload.modified_at.to_i.must_equal @now.to_i + 3600
174
+ end
166
175
 
167
- should "not update child pages timestamps after changing their parent's slug" do
168
- page = Page.first :uid => "0.0.0"
169
- modified = page.modified_at.to_i
170
- stub_time(@now+1000)
171
- page = Page.first :uid => "0"
172
- page.slug = "changed"
173
- page.save.reload
174
- page.modified_at.to_i.should == @now.to_i + 1000
175
- page = Page.first :uid => "0.0.0"
176
- page.modified_at.to_i.should == modified
177
- end
176
+ it "update the parent page's modification time if the contents of a piece's box are re-ordered" do
177
+ stub_time(@now+3600)
178
+ page = Page.first :uid => "0"
179
+ content = page.things.first.things.first
180
+ content.update_position(1)
181
+ page.reload.modified_at.to_i.must_equal @now.to_i + 3600
182
+ end
178
183
 
179
- should "update the pages timestamp if a boxes order is changed" do
180
- stub_time(@now+3600)
181
- page = Page.first :uid => "0"
182
- content = Content[page.contents.first.id]
183
- content.update_position(1)
184
- page.reload.modified_at.to_i.should == @now.to_i + 3600
185
- end
184
+ it "update the parent page's modification date if a piece is deleted" do
185
+ stub_time(@now+3600)
186
+ page = Page.first :uid => "0"
187
+ content = Content[page.contents.first.id]
188
+ content.destroy
189
+ page.reload.modified_at.to_i.must_equal @now.to_i + 3600
190
+ end
186
191
 
187
- should "update the parent page's modification time if the contents of a piece's box are re-ordered" do
188
- stub_time(@now+3600)
189
- page = Page.first :uid => "0"
190
- content = page.things.first.things.first
191
- content.update_position(1)
192
- page.reload.modified_at.to_i.should == @now.to_i + 3600
193
- end
192
+ it "update the parent page's modification date if a page is deleted" do
193
+ stub_time(@now+3600)
194
+ page = Page.first :uid => "0"
195
+ content = Content[page.things.first.things.first.id]
196
+ content.destroy
197
+ page.reload.modified_at.to_i.must_equal @now.to_i + 3600
198
+ end
194
199
 
195
- should "update the parent page's modification date if a piece is deleted" do
196
- stub_time(@now+3600)
197
- page = Page.first :uid => "0"
198
- content = Content[page.contents.first.id]
199
- content.destroy
200
- page.reload.modified_at.to_i.should == @now.to_i + 3600
201
- end
200
+ it "add entry to the list of side effects for a visibility change" do
201
+ stub_time(@now+3600)
202
+ page = Page.first :uid => "1"
203
+ old_slug = page.slug
204
+ page.slug = "changed"
205
+ page.save
206
+ page.reload
207
+ page.pending_modifications.length.must_equal 1
208
+ mods = page.pending_modifications(:slug)
209
+ mods.length.must_equal 1
210
+ mod = mods.first
211
+ mod.must_be_instance_of Spontaneous::Model::Core::Modifications::SlugModification
212
+ mod.old_value.must_equal old_slug
213
+ mod.new_value.must_equal "changed"
214
+ mod.created_at.to_i.must_equal @now.to_i + 3600
215
+ end
202
216
 
203
- should "update the parent page's modification date if a page is deleted" do
204
- stub_time(@now+3600)
205
- page = Page.first :uid => "0"
206
- content = Content[page.things.first.things.first.id]
207
- content.destroy
208
- page.reload.modified_at.to_i.should == @now.to_i + 3600
209
- end
217
+ it "serialize page modifications" do
218
+ stub_time(@now+3600)
219
+ page = Page.first :uid => "1"
220
+ page.slug = "changed"
221
+ page.save
222
+ page.pending_modifications.length.must_equal 1
223
+ mod = page.pending_modifications(:slug).first
224
+ page = Page.first :id => page.id
225
+ page.pending_modifications.length.must_equal 1
226
+ page.pending_modifications(:slug).first.must_equal mod
227
+ page.pending_modifications(:slug).first.created_at.to_i.must_equal @now.to_i + 3600
228
+ end
210
229
 
211
- should "add entry to the list of side effects for a visibility change" do
212
- stub_time(@now+3600)
213
- page = Page.first :uid => "1"
214
- old_slug = page.slug
215
- page.slug = "changed"
216
- page.save
217
- page.reload
218
- page.pending_modifications.length.should == 1
219
- mods = page.pending_modifications(:slug)
220
- mods.length.should == 1
221
- mod = mods.first
222
- mod.must_be_instance_of Spontaneous::Model::Core::Modifications::SlugModification
223
- mod.old_value.should == old_slug
224
- mod.new_value.should == "changed"
225
- mod.created_at.to_i.should == @now.to_i + 3600
226
- end
230
+ it "concatenate multiple slug modifications together" do
231
+ stub_time(@now+3600)
232
+ page = Page.first :uid => "1"
233
+ old_slug = page.slug
234
+ page.slug = "changed"
235
+ page.save
236
+ page.pending_modifications.length.must_equal 1
237
+ page.slug = "changed-again"
238
+ page.save
239
+ mod = page.pending_modifications(:slug).first
240
+ mod.old_value.must_equal old_slug
241
+ mod.new_value.must_equal "changed-again"
242
+ end
227
243
 
228
- should "serialize page modifications" do
229
- stub_time(@now+3600)
230
- page = Page.first :uid => "1"
231
- page.slug = "changed"
232
- page.save
233
- page.pending_modifications.length.should == 1
234
- mod = page.pending_modifications(:slug).first
235
- page = Page.first :id => page.id
236
- page.pending_modifications.length.should == 1
237
- page.pending_modifications(:slug).first.should == mod
238
- page.pending_modifications(:slug).first.created_at.to_i.should == @now.to_i + 3600
239
- end
244
+ it "know the number of pages affected by slug modification" do
245
+ stub_time(@now+3600)
246
+ page = Page.first :uid => "1"
247
+ page.slug = "changed"
248
+ page.save
249
+ mod = page.pending_modifications(:slug).first
250
+ mod.count.must_equal 4
251
+ end
240
252
 
241
- should "concatenate multiple slug modifications together" do
242
- stub_time(@now+3600)
243
- page = Page.first :uid => "1"
244
- old_slug = page.slug
245
- page.slug = "changed"
246
- page.save
247
- page.pending_modifications.length.should == 1
248
- page.slug = "changed-again"
249
- page.save
250
- mod = page.pending_modifications(:slug).first
251
- mod.old_value.should == old_slug
252
- mod.new_value.should == "changed-again"
253
- end
253
+ it "show the number of pages whose visibility is affected in the case of a visibility change" do
254
+ stub_time(@now+3600)
255
+ page = Page.first :uid => "1"
256
+ page.hide!
257
+ page.reload
258
+ mods = page.pending_modifications(:visibility)
259
+ mods.length.must_equal 1
260
+ mod = mods.first
261
+ mod.count.must_equal 4
262
+ mod.owner.must_equal page
263
+ end
254
264
 
255
- should "know the number of pages affected by slug modification" do
256
- stub_time(@now+3600)
257
- page = Page.first :uid => "1"
258
- page.slug = "changed"
259
- page.save
260
- mod = page.pending_modifications(:slug).first
261
- mod.count.should == 4
262
- end
265
+ it "record visibility changes that originate from a content piece" do
266
+ stub_time(@now+3600)
267
+ page = Page.first :uid => "1"
268
+ page.things.first.hide!
269
+ page.reload
270
+ mods = page.pending_modifications(:visibility)
271
+ mods.length.must_equal 1
272
+ mod = mods.first
273
+ mod.count.must_equal 2
274
+ mod.owner.must_equal page.things.first
275
+ end
263
276
 
264
- should "show the number of pages whose visibility is affected in the case of a visibility change" do
265
- stub_time(@now+3600)
266
- page = Page.first :uid => "1"
267
- page.hide!
268
- page.reload
269
- mods = page.pending_modifications(:visibility)
270
- mods.length.should == 1
271
- mod = mods.first
272
- mod.count.should == 4
273
- mod.owner.should == page
274
- end
277
+ it "show number of pages that are to be deleted in the case of a deletion" do
278
+ stub_time(@now+3600)
279
+ page = Page.first(:uid => "1")
280
+ owner = page.owner
281
+ page.destroy
282
+ page = Page.first(:uid => "root")
283
+ mods = page.pending_modifications(:deletion)
284
+ mod = mods.first
285
+ # count is number of children of deleted page + 1 (for deleted page)
286
+ mod.count.must_equal 5
287
+ mod.owner.must_equal owner.reload
288
+ end
275
289
 
276
- should "record visibility changes that originate from a content piece" do
277
- stub_time(@now+3600)
278
- page = Page.first :uid => "1"
279
- page.things.first.hide!
280
- page.reload
281
- mods = page.pending_modifications(:visibility)
282
- mods.length.should == 1
283
- mod = mods.first
284
- mod.count.should == 2
285
- mod.owner.should == page.things.first
286
- end
290
+ it "show number of pages deleted if piece with pages is deleted" do
291
+ stub_time(@now+3600)
292
+ page = Page.first(:uid => "1")
293
+ piece = page.things.first
294
+ owner = piece.owner
295
+ piece.destroy
296
+ page = Page.first(:uid => "1")
297
+ mods = page.pending_modifications(:deletion)
298
+ mod = mods.first
299
+ mod.count.must_equal 2
300
+ mod.owner.must_equal owner.reload
301
+ end
287
302
 
288
- should "show number of pages that are to be deleted in the case of a deletion" do
289
- stub_time(@now+3600)
290
- page = Page.first(:uid => "1")
291
- owner = page.owner
292
- page.destroy
293
- page = Page.first(:uid => "root")
294
- mods = page.pending_modifications(:deletion)
295
- mod = mods.first
296
- # count is number of children of deleted page + 1 (for deleted page)
297
- mod.count.should == 5
298
- mod.owner.should == owner.reload
299
- end
303
+ it "show number of pages deleted if page belonging to piece is deleted" do
304
+ stub_time(@now+3600)
305
+ page = Page.first(:uid => "1")
306
+ child = page.things.first.things.first
307
+ owner = child.owner
308
+ child.destroy
309
+ page = Page.first(:uid => "1")
310
+ mods = page.pending_modifications(:deletion)
311
+ mod = mods.first
312
+ mod.count.must_equal 1
313
+ mod.owner.must_equal owner.reload
314
+ end
300
315
 
301
- should "show number of pages deleted if piece with pages is deleted" do
302
- stub_time(@now+3600)
303
- page = Page.first(:uid => "1")
304
- piece = page.things.first
305
- owner = piece.owner
306
- piece.destroy
307
- page = Page.first(:uid => "1")
308
- mods = page.pending_modifications(:deletion)
309
- mod = mods.first
310
- mod.count.should == 2
311
- mod.owner.should == owner.reload
316
+ it "have an empty modification if the slug has been reverted to original value" do
317
+ stub_time(@now+3600)
318
+ page = Page.first :uid => "1"
319
+ old_slug = page.slug
320
+ page.slug = "changed"
321
+ page.save
322
+ page.pending_modifications.length.must_equal 1
323
+ page.slug = "changed-again"
324
+ page.save
325
+ page.slug = old_slug
326
+ page.save
327
+ mods = page.reload.pending_modifications(:slug)
328
+ mods.length.must_equal 0
329
+ end
330
+
331
+ it "have an empty modification if the visibility has been reverted to original value" do
332
+ stub_time(@now+3600)
333
+ page = Page.first :uid => "1"
334
+ page.things.first.hide!
335
+ page.reload
336
+ page.things.first.show!
337
+ page.reload
338
+ mods = page.pending_modifications(:visibility)
339
+ mods.length.must_equal 0
340
+ end
341
+
342
+ describe "during publish" do
343
+ before do
344
+ @initial_revision = 1
345
+ @final_revision = 2
346
+ Content.delete_revision(@initial_revision) rescue nil
347
+ Content.delete_revision(@final_revision) rescue nil
348
+ ::Content.publish(@initial_revision)
312
349
  end
313
350
 
314
- should "show number of pages deleted if page belonging to piece is deleted" do
315
- stub_time(@now+3600)
316
- page = Page.first(:uid => "1")
317
- child = page.things.first.things.first
318
- owner = child.owner
319
- child.destroy
320
- page = Page.first(:uid => "1")
321
- mods = page.pending_modifications(:deletion)
322
- mod = mods.first
323
- mod.count.should == 1
324
- mod.owner.should == owner.reload
351
+ after do
352
+ Content.delete_revision(@initial_revision) rescue nil
353
+ Content.delete_revision(@final_revision) rescue nil
354
+ Content.delete_revision(@final_revision+1) rescue nil
325
355
  end
326
356
 
327
- should "have an empty modification if the slug has been reverted to original value" do
328
- stub_time(@now+3600)
357
+ it "act on path change modifications" do
329
358
  page = Page.first :uid => "1"
330
359
  old_slug = page.slug
331
360
  page.slug = "changed"
332
361
  page.save
333
- page.pending_modifications.length.should == 1
334
- page.slug = "changed-again"
335
- page.save
336
- page.slug = old_slug
337
- page.save
338
- mods = page.reload.pending_modifications(:slug)
339
- mods.length.should == 0
362
+ ::Content.publish(@final_revision, [page.id])
363
+ ::Content.with_revision(@final_revision) do
364
+ %w(1 1.1.1).each do |uid|
365
+ published_page = Page.first :uid => uid
366
+ ::Content.with_editable do
367
+ editable_page = Page.first :uid => uid
368
+ published_page.path.must_equal editable_page.path
369
+ end
370
+ end
371
+ end
340
372
  end
341
373
 
342
- should "have an empty modification if the visibility has been reverted to original value" do
343
- stub_time(@now+3600)
374
+ it "not publish slug changes on pages other than the one being published" do
375
+ #/bands/beatles -> /bands/beatles-changed
376
+ #/bands -> /bands-changed
377
+ # publish(bands)
378
+ # with_published { beatles.path.must_equal /bands-changed/beatles }
344
379
  page = Page.first :uid => "1"
345
- page.things.first.hide!
346
- page.reload
347
- page.things.first.show!
348
- page.reload
349
- mods = page.pending_modifications(:visibility)
350
- mods.length.should == 0
351
- end
380
+ page.slug = "changed"
381
+ page.save
352
382
 
353
- context "during publish" do
354
- setup do
355
- @initial_revision = 1
356
- @final_revision = 2
357
- Content.delete_revision(@initial_revision) rescue nil
358
- Content.delete_revision(@final_revision) rescue nil
359
- ::Content.publish(@initial_revision)
360
- end
383
+ child_page = Page.first :uid => "1.0.0"
384
+ old_slug = child_page.slug
385
+ child_page.slug = "changed-too"
386
+ child_page.save
361
387
 
362
- teardown do
363
- Content.delete_revision(@initial_revision) rescue nil
364
- Content.delete_revision(@final_revision) rescue nil
365
- Content.delete_revision(@final_revision+1) rescue nil
388
+ ::Content.publish(@final_revision, [page.id])
389
+ ::Content.with_revision(@final_revision) do
390
+ published = Page.first :uid => "1.0.0"
391
+ published.path.must_equal "/changed/#{old_slug}"
366
392
  end
393
+ end
367
394
 
368
- should "act on path change modifications" do
369
- page = Page.first :uid => "1"
370
- old_slug = page.slug
371
- page.slug = "changed"
372
- page.save
373
- ::Content.publish(@final_revision, [page.id])
374
- ::Content.with_revision(@final_revision) do
375
- %w(1 1.1.1).each do |uid|
376
- published_page = Page.first :uid => uid
377
- ::Content.with_editable do
378
- editable_page = Page.first :uid => uid
379
- published_page.path.should == editable_page.path
380
- end
381
- end
382
- end
383
- end
395
+ it "publish the correct path for new child pages with an un-published parent slug change" do
396
+ # add /bands/beatles
397
+ # /bands -> /bands-changed
398
+ # publish(beatles)
399
+ # with_published { beatles.path.must_equal /bands/beatles }
400
+ page = Page.first :uid => "1"
401
+ old_slug = page.slug
402
+ page.slug = "changed"
403
+ page.save
384
404
 
385
- should "not publish slug changes on pages other than the one being published" do
386
- #/bands/beatles -> /bands/beatles-changed
387
- #/bands -> /bands-changed
388
- # publish(bands)
389
- # with_published { beatles.path.should == /bands-changed/beatles }
390
- page = Page.first :uid => "1"
391
- page.slug = "changed"
392
- page.save
393
-
394
- child_page = Page.first :uid => "1.0.0"
395
- old_slug = child_page.slug
396
- child_page.slug = "changed-too"
397
- child_page.save
398
-
399
- ::Content.publish(@final_revision, [page.id])
400
- ::Content.with_revision(@final_revision) do
401
- published = Page.first :uid => "1.0.0"
402
- published.path.should == "/changed/#{old_slug}"
403
- end
404
- end
405
+ child_page = Page.first :uid => "1.0.0"
406
+ child_page.slug = "changed-too"
407
+ child_page.save
405
408
 
406
- should "publish the correct path for new child pages with an un-published parent slug change" do
407
- # add /bands/beatles
408
- # /bands -> /bands-changed
409
- # publish(beatles)
410
- # with_published { beatles.path.should == /bands/beatles }
411
- page = Page.first :uid => "1"
412
- old_slug = page.slug
413
- page.slug = "changed"
414
- page.save
415
-
416
- child_page = Page.first :uid => "1.0.0"
417
- child_page.slug = "changed-too"
418
- child_page.save
419
-
420
- ::Content.publish(@final_revision, [child_page.id])
421
- ::Content.with_revision(@final_revision) do
422
- published = Page.first :uid => "1.0.0"
423
- published.path.should == "/#{old_slug}/changed-too"
424
- end
409
+ ::Content.publish(@final_revision, [child_page.id])
410
+ ::Content.with_revision(@final_revision) do
411
+ published = Page.first :uid => "1.0.0"
412
+ published.path.must_equal "/#{old_slug}/changed-too"
425
413
  end
414
+ end
426
415
 
427
416
 
428
- should "act on visibility modifications" do
429
- page = Page.first :uid => "1"
430
- page.hide!
431
- ::Content.publish(@final_revision, [page.id])
432
- ::Content.with_revision(@final_revision) do
433
- %w(1 1.1.1).each do |uid|
434
- published_page = Page.first :uid => uid
435
- ::Content.with_editable do
436
- editable_page = Page.first :uid => uid
437
- published_page.hidden?.should == editable_page.hidden?
438
- end
417
+ it "act on visibility modifications" do
418
+ page = Page.first :uid => "1"
419
+ page.hide!
420
+ ::Content.publish(@final_revision, [page.id])
421
+ ::Content.with_revision(@final_revision) do
422
+ %w(1 1.1.1).each do |uid|
423
+ published_page = Page.first :uid => uid
424
+ ::Content.with_editable do
425
+ editable_page = Page.first :uid => uid
426
+ published_page.hidden?.must_equal editable_page.hidden?
439
427
  end
440
428
  end
441
429
  end
430
+ end
442
431
 
443
- should "publish the correct visibility for new child pages with un-published up-tree visibility changes" do
444
- page = Page.first :uid => "1"
445
- page.hide!
432
+ it "publish the correct visibility for new child pages with un-published up-tree visibility changes" do
433
+ page = Page.first :uid => "1"
434
+ page.hide!
446
435
 
447
- child_page = Page.new :uid => "child"
448
- page.things << child_page
449
- page.save
436
+ child_page = Page.new :uid => "child"
437
+ page.things << child_page
438
+ page.save
450
439
 
451
- ::Content.publish(@final_revision, [child_page.id])
440
+ ::Content.publish(@final_revision, [child_page.id])
452
441
 
453
- ::Content.with_revision(@final_revision) do
454
- published = Page.first :uid => "1.0.0"
455
- published.visible?.should be_true
456
- published = Page.first :uid => "child"
457
- published.visible?.should be_true
458
- end
442
+ ::Content.with_revision(@final_revision) do
443
+ published = Page.first :uid => "1.0.0"
444
+ assert published.visible?
445
+ published = Page.first :uid => "child"
446
+ assert published.visible?
459
447
  end
448
+ end
460
449
 
461
- should "publish the correct visibility for new child pages with published up-tree visibility changes" do
462
- page = Page.first :uid => "1"
463
- page.hide!
450
+ it "publish the correct visibility for new child pages with published up-tree visibility changes" do
451
+ page = Page.first :uid => "1"
452
+ page.hide!
464
453
 
465
- child_page = Page.new :uid => "child"
466
- page.things << child_page
467
- page.save
454
+ child_page = Page.new :uid => "child"
455
+ page.things << child_page
456
+ page.save
468
457
 
469
- ::Content.publish(@final_revision, [page.id, child_page.id])
458
+ ::Content.publish(@final_revision, [page.id, child_page.id])
470
459
 
471
- ::Content.with_revision(@final_revision) do
472
- published = Page.first :uid => "child"
473
- published.visible?.should be_false
474
- end
460
+ ::Content.with_revision(@final_revision) do
461
+ published = Page.first :uid => "child"
462
+ refute published.visible?
475
463
  end
464
+ end
476
465
 
477
- should "publish the correct visibility for child pages with un-published parent visibility changes" do
478
- # if we publish changes to a child page whose parent page is hidden but that visibility change
479
- # hasn't been published then the child page should be visible until the parent is published
480
- page = Page.first :uid => "1"
481
- page.hide!
466
+ it "publish the correct visibility for child pages with un-published parent visibility changes" do
467
+ # if we publish changes to a child page whose parent page is hidden but that visibility change
468
+ # hasn't been published then the child page it be visible until the parent is published
469
+ page = Page.first :uid => "1"
470
+ page.hide!
482
471
 
483
- child_page = Page.first :uid => "1.0.0"
484
- child_page.slug = "changed-too"
485
- child_page.save
472
+ child_page = Page.first :uid => "1.0.0"
473
+ child_page.slug = "changed-too"
474
+ child_page.save
486
475
 
487
- ::Content.publish(@final_revision, [child_page.id])
476
+ ::Content.publish(@final_revision, [child_page.id])
488
477
 
489
- ::Content.with_revision(@final_revision) do
490
- published = Page.first :uid => "1.0.0"
491
- published.visible?.should be_true
492
- end
478
+ ::Content.with_revision(@final_revision) do
479
+ published = Page.first :uid => "1.0.0"
480
+ assert published.visible?
493
481
  end
482
+ end
494
483
 
495
- should "publish the correct visibility for immediate child pages with published parent visibility changes" do
496
- page = Page.first :uid => "1"
484
+ it "publish the correct visibility for immediate child pages with published parent visibility changes" do
485
+ page = Page.first :uid => "1"
497
486
 
498
- child_page = Page.new :uid => "newpage"
499
- page.things << child_page
500
- page.save
487
+ child_page = Page.new :uid => "newpage"
488
+ page.things << child_page
489
+ page.save
501
490
 
502
- ::Content.publish(@final_revision, [page.id, child_page.id])
491
+ ::Content.publish(@final_revision, [page.id, child_page.id])
503
492
 
504
- child_page.hidden?.should be_false
493
+ refute child_page.hidden?
505
494
 
506
- page.hide!
495
+ page.hide!
507
496
 
508
- child_page.reload.hidden?.should be_true
497
+ assert child_page.reload.hidden?
509
498
 
510
- ::Content.publish(@final_revision + 1, [page.id])
499
+ ::Content.publish(@final_revision + 1, [page.id])
511
500
 
512
- ::Content.with_revision(@final_revision + 1) do
513
- published = Page.first :uid => "newpage"
514
- published.visible?.should be_false
515
- end
501
+ ::Content.with_revision(@final_revision + 1) do
502
+ published = Page.first :uid => "newpage"
503
+ refute published.visible?
516
504
  end
505
+ end
517
506
 
518
- should "publish the correct visibility for child pages with published parent visibility changes" do
519
- page = Page.first :uid => "1"
520
- child_page = Page.first :uid => "1.0.0"
521
- child_page.hidden?.should be_false
507
+ it "publish the correct visibility for child pages with published parent visibility changes" do
508
+ page = Page.first :uid => "1"
509
+ child_page = Page.first :uid => "1.0.0"
510
+ refute child_page.hidden?
522
511
 
523
- page.hide!
512
+ page.hide!
524
513
 
525
- child_page.reload.hidden?.should be_true
514
+ assert child_page.reload.hidden?
526
515
 
527
- ::Content.publish(@final_revision, [page.id])
516
+ ::Content.publish(@final_revision, [page.id])
528
517
 
529
- ::Content.with_revision(@final_revision) do
530
- published = Page.first :uid => "1.0.0"
531
- published.visible?.should be_false
532
- end
518
+ ::Content.with_revision(@final_revision) do
519
+ published = Page.first :uid => "1.0.0"
520
+ refute published.visible?
533
521
  end
522
+ end
534
523
 
535
- should "maintain correct published visibility for pieces" do
536
- page = Page.first :uid => "1"
537
- piece = page.things.first
538
- piece.hide!
539
- ::Content.publish(@final_revision, [page.id])
540
- ::Content.with_revision(@final_revision) do
541
- piece = Page.first(:uid => "1").things.first
542
- piece.visible?.should be_false
543
- end
524
+ it "maintain correct published visibility for pieces" do
525
+ page = Page.first :uid => "1"
526
+ piece = page.things.first
527
+ piece.hide!
528
+ ::Content.publish(@final_revision, [page.id])
529
+ ::Content.with_revision(@final_revision) do
530
+ piece = Page.first(:uid => "1").things.first
531
+ refute piece.visible?
532
+ end
544
533
 
545
- ::Content.publish(@final_revision+1, [page.id])
534
+ ::Content.publish(@final_revision+1, [page.id])
546
535
 
547
- ::Content.with_revision(@final_revision+1) do
548
- piece = Page.first(:uid => "1").things.first
549
- piece.visible?.should be_false
550
- end
536
+ ::Content.with_revision(@final_revision+1) do
537
+ piece = Page.first(:uid => "1").things.first
538
+ refute piece.visible?
551
539
  end
540
+ end
552
541
 
553
- should "maintain correct published visibility for pages" do
554
- page = Page.first :uid => "1.1.1"
555
- page.hide!
556
- ::Content.publish(@final_revision, [page.id])
557
- ::Content.with_revision(@final_revision) do
558
- page = Page.first(:uid => "1.1.1")
559
- page.visible?.should be_false
560
- end
542
+ it "maintain correct published visibility for pages" do
543
+ page = Page.first :uid => "1.1.1"
544
+ page.hide!
545
+ ::Content.publish(@final_revision, [page.id])
546
+ ::Content.with_revision(@final_revision) do
547
+ page = Page.first(:uid => "1.1.1")
548
+ refute page.visible?
549
+ end
561
550
 
562
- ::Content.publish(@final_revision+1, [page.id])
551
+ ::Content.publish(@final_revision+1, [page.id])
563
552
 
564
- ::Content.with_revision(@final_revision+1) do
565
- page = Page.first(:uid => "1.1.1")
566
- page.visible?.should be_false
567
- end
553
+ ::Content.with_revision(@final_revision+1) do
554
+ page = Page.first(:uid => "1.1.1")
555
+ refute page.visible?
568
556
  end
557
+ end
569
558
 
570
559
 
571
- should "act on multiple modifications" do
572
- page = Page.first :uid => "1"
573
- page.slug = "changed"
574
- page.slug = "changed-again"
575
- page.hide!
576
-
577
- ::Content.publish(@final_revision, [page.id])
578
- ::Content.with_revision(@final_revision) do
579
- %w(1 1.1.1).each do |uid|
580
- published_page = Page.first :uid => uid
581
- ::Content.with_editable do
582
- editable_page = Page.first :uid => uid
583
- published_page.hidden?.should == editable_page.hidden?
584
- published_page.slug.should == editable_page.slug
585
- published_page.path.should == editable_page.path
586
- end
560
+ it "act on multiple modifications" do
561
+ page = Page.first :uid => "1"
562
+ page.slug = "changed"
563
+ page.slug = "changed-again"
564
+ page.hide!
565
+
566
+ ::Content.publish(@final_revision, [page.id])
567
+ ::Content.with_revision(@final_revision) do
568
+ %w(1 1.1.1).each do |uid|
569
+ published_page = Page.first :uid => uid
570
+ ::Content.with_editable do
571
+ editable_page = Page.first :uid => uid
572
+ published_page.hidden?.must_equal editable_page.hidden?
573
+ published_page.slug.must_equal editable_page.slug
574
+ published_page.path.must_equal editable_page.path
587
575
  end
588
576
  end
589
577
  end
578
+ end
590
579
 
591
- should "ignore deletion modifications" do
592
- page = Page.first(:uid => "1")
593
- page.destroy
594
- page = Page.first(:uid => "root")
595
- ::Content.publish(@final_revision, [page.id])
596
- ::Content.with_revision(@final_revision) do
597
- %w(1 1.1.1).each do |uid|
598
- published_page = Page.first :uid => uid
599
- published_page.should be_nil
600
- end
601
- published_page = Page.first :uid => "0"
602
- published_page.should_not be_nil
580
+ it "ignore deletion modifications" do
581
+ page = Page.first(:uid => "1")
582
+ page.destroy
583
+ page = Page.first(:uid => "root")
584
+ ::Content.publish(@final_revision, [page.id])
585
+ ::Content.with_revision(@final_revision) do
586
+ %w(1 1.1.1).each do |uid|
587
+ published_page = Page.first :uid => uid
588
+ published_page.must_be_nil
603
589
  end
590
+ published_page = Page.first :uid => "0"
591
+ published_page.wont_be_nil
604
592
  end
593
+ end
605
594
 
606
- should "clear modifications after publish" do
607
- page = Page.first :uid => "1"
608
- page.slug = "changed"
609
- page.hide!
610
- ::Content.publish(@final_revision, [page.id])
611
- page = Page.first :id => page.id
612
- page.pending_modifications.length.should == 0
613
- end
595
+ it "clear modifications after publish" do
596
+ page = Page.first :uid => "1"
597
+ page.slug = "changed"
598
+ page.hide!
599
+ ::Content.publish(@final_revision, [page.id])
600
+ page = Page.first :id => page.id
601
+ page.pending_modifications.length.must_equal 0
614
602
  end
603
+ end
615
604
 
616
- context "with assigned editor" do
617
- setup do
618
- Spontaneous::Permissions::User.delete
619
- @user = Spontaneous::Permissions::User.create(:email => "root@example.com", :login => "root", :name => "root", :password => "rootpass")
620
- end
605
+ describe "with assigned editor" do
606
+ before do
607
+ Spontaneous::Permissions::User.delete
608
+ @user = Spontaneous::Permissions::User.create(:email => "root@example.com", :login => "root", :name => "root", :password => "rootpass")
609
+ end
621
610
 
622
- teardown do
623
- @user.destroy
624
- end
611
+ after do
612
+ @user.destroy
613
+ end
625
614
 
626
- should "add the editor to any modifications" do
627
- stub_time(@now+3600)
628
- page = Page.first :uid => "1"
629
- page.current_editor = @user
630
- page.slug = "changed"
631
- page.save
632
- mod = page.pending_modifications(:slug).first
633
- mod.user.should == @user
634
- end
615
+ it "add the editor to any modifications" do
616
+ stub_time(@now+3600)
617
+ page = Page.first :uid => "1"
618
+ page.current_editor = @user
619
+ page.slug = "changed"
620
+ page.save
621
+ mod = page.pending_modifications(:slug).first
622
+ mod.user.must_equal @user
623
+ end
635
624
 
636
- should "persist the user" do
637
- stub_time(@now+3600)
638
- page = Page.first :uid => "1"
639
- page.current_editor = @user
640
- page.slug = "changed"
641
- page.save
642
- page = Page.first :uid => "1"
643
- mod = page.pending_modifications(:slug).first
644
- mod.user.should == @user
645
- end
625
+ it "persist the user" do
626
+ stub_time(@now+3600)
627
+ page = Page.first :uid => "1"
628
+ page.current_editor = @user
629
+ page.slug = "changed"
630
+ page.save
631
+ page = Page.first :uid => "1"
632
+ mod = page.pending_modifications(:slug).first
633
+ mod.user.must_equal @user
646
634
  end
647
635
  end
648
636
  end