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.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.locat +42 -0
- data/.travis/gemfiles/Gemfile.empty +7 -0
- data/.travis.yml +18 -0
- data/Gemfile +12 -8
- data/LICENSE +1 -1
- data/Rakefile +15 -157
- data/Readme.markdown +1 -1
- data/application/css/core.css.scss +22 -146
- data/application/css/definitions.css.scss +7 -3
- data/application/css/dialogue.css.scss +26 -1
- data/application/css/editing.css.scss +70 -28
- data/application/css/font.css.scss +1 -1
- data/application/css/popover.css.scss +2 -0
- data/application/css/top.css.scss +231 -0
- data/application/js/add_alias_dialogue.js +1 -1
- data/application/js/add_home_dialogue.js +1 -1
- data/application/js/ajax.js +61 -31
- data/application/js/box.js +4 -4
- data/application/js/conflicted_field_dialogue.js +1 -1
- data/application/js/content.js +5 -5
- data/application/js/dom.js +5 -0
- data/application/js/edit_panel.js +1 -0
- data/application/js/editing.js +1 -1
- data/application/js/extensions.js +8 -0
- data/application/js/field/boolean.js +31 -0
- data/application/js/field/file.js +32 -4
- data/application/js/field/image.js +24 -9
- data/application/js/field/markdown.js +87 -59
- data/application/js/field/select.js +1 -1
- data/application/js/field/webvideo.js +6 -1
- data/application/js/init.js +2 -2
- data/application/js/jquery-selection-position.js +130 -0
- data/application/js/location.js +4 -25
- data/application/js/meta_view/user_admin.js +2 -2
- data/application/js/metadata.js +2 -2
- data/application/js/page_browser.js +1 -1
- data/application/js/panel/root_menu.js +0 -1
- data/application/js/popover.js +27 -12
- data/application/js/popover_view.js +20 -4
- data/application/js/preview.js +31 -16
- data/application/js/progress.js +22 -21
- data/application/js/publish.js +18 -7
- data/application/js/sharded_upload.js +9 -6
- data/application/js/spontaneous.js +3 -1
- data/application/js/top_bar.js +264 -173
- data/application/js/upload.js +12 -5
- data/application/js/upload_manager.js +4 -3
- data/application/js/user.js +1 -2
- data/application/js/views/box_view.js +1 -1
- data/application/js/views/page_view.js +16 -5
- data/application/js/views/piece_view.js +5 -4
- data/application/static/font/fontawesome-webfont-1c66a4738b40ef0f6b1abca0ba9a796d.ttf +0 -0
- data/application/views/index.erb +6 -14
- data/application/views/login.erb +6 -25
- data/application/views/schema_modification_error.html.erb +3 -7
- data/db/migrations/20130114120000_create_revision_tables.rb +2 -2
- data/db/migrations/20130813111009_increase_path_length.rb +14 -0
- data/gem-public_cert.pem +20 -0
- data/lib/spontaneous/asset/app_compiler.rb +44 -0
- data/lib/spontaneous/asset/environment.rb +225 -0
- data/lib/spontaneous/asset.rb +2 -67
- data/lib/spontaneous/box.rb +0 -1
- data/lib/spontaneous/capistrano/deploy.rb +2 -2
- data/lib/spontaneous/capistrano/sync.rb +1 -1
- data/lib/spontaneous/cli/init.rb +36 -13
- data/lib/spontaneous/cli/server.rb +0 -1
- data/lib/spontaneous/cli/site.rb +2 -1
- data/lib/spontaneous/cli.rb +3 -1
- data/lib/spontaneous/collections/entry_set.rb +4 -12
- data/lib/spontaneous/collections/hash_with_fallback.rb +20 -0
- data/lib/spontaneous/collections/prototype_set.rb +6 -5
- data/lib/spontaneous/crypt.rb +2 -2
- data/lib/spontaneous/data_mapper/content_model/associations.rb +115 -63
- data/lib/spontaneous/data_mapper.rb +1 -1
- data/lib/spontaneous/errors.rb +6 -0
- data/lib/spontaneous/extensions/object_space.rb +6 -0
- data/lib/spontaneous/facet.rb +1 -0
- data/lib/spontaneous/field/base.rb +86 -13
- data/lib/spontaneous/field/boolean.rb +65 -0
- data/lib/spontaneous/field/file.rb +17 -6
- data/lib/spontaneous/field/html.rb +13 -0
- data/lib/spontaneous/field/image/size.rb +76 -0
- data/lib/spontaneous/field/image.rb +99 -414
- data/lib/spontaneous/field/tags.rb +36 -0
- data/lib/spontaneous/field/update.rb +1 -1
- data/lib/spontaneous/field/webvideo/fallback.rb +41 -0
- data/lib/spontaneous/field/webvideo/vimeo.rb +113 -0
- data/lib/spontaneous/field/webvideo/vine.rb +94 -0
- data/lib/spontaneous/field/webvideo/youtube.rb +133 -0
- data/lib/spontaneous/field/webvideo.rb +100 -250
- data/lib/spontaneous/field.rb +1 -1
- data/lib/spontaneous/generators/site/Gemfile.tt +5 -14
- data/lib/spontaneous/generators/site/assets/README.md +20 -0
- data/lib/spontaneous/generators/site/assets/css/site.scss +8 -0
- data/lib/spontaneous/generators/site/assets/js/site.js +6 -0
- data/lib/spontaneous/generators/site/config/deploy.rb.tt +9 -0
- data/lib/spontaneous/generators/site/config/user_levels.yml +14 -3
- data/lib/spontaneous/generators/site/public/README.md +12 -0
- data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +2 -2
- data/lib/spontaneous/generators/site.rb +77 -35
- data/lib/spontaneous/layout.rb +6 -7
- data/lib/spontaneous/loader.rb +21 -13
- data/lib/spontaneous/media/file.rb +22 -9
- data/lib/spontaneous/media/image/attributes.rb +33 -0
- data/lib/spontaneous/media/image/format/gif.rb +4 -0
- data/lib/spontaneous/media/image/format/jpg.rb +17 -0
- data/lib/spontaneous/media/image/format/png.rb +4 -0
- data/lib/spontaneous/media/image/format/webp.rb +26 -0
- data/lib/spontaneous/media/image/format.rb +79 -0
- data/lib/spontaneous/media/image/optimizer.rb +69 -0
- data/lib/spontaneous/media/image/processor.rb +17 -0
- data/lib/spontaneous/media/image/renderable.rb +52 -0
- data/lib/spontaneous/media/image/skeptick.rb +70 -0
- data/lib/spontaneous/media/image.rb +50 -0
- data/lib/spontaneous/media/temp_file.rb +4 -0
- data/lib/spontaneous/media.rb +1 -0
- data/lib/spontaneous/model/core/aliases.rb +14 -8
- data/lib/spontaneous/model/core/boxes.rb +5 -2
- data/lib/spontaneous/model/core/entries.rb +4 -0
- data/lib/spontaneous/model/core/entry.rb +1 -0
- data/lib/spontaneous/model/core/fields.rb +5 -2
- data/lib/spontaneous/model/core/locks.rb +16 -0
- data/lib/spontaneous/model/core/media.rb +1 -15
- data/lib/spontaneous/model/core.rb +31 -1
- data/lib/spontaneous/model/page/controllers.rb +2 -2
- data/lib/spontaneous/model/page/formats.rb +1 -4
- data/lib/spontaneous/model/page/layouts.rb +6 -2
- data/lib/spontaneous/model/page/locks.rb +8 -2
- data/lib/spontaneous/model/page/page_tree.rb +2 -2
- data/lib/spontaneous/model/page/paths.rb +74 -9
- data/lib/spontaneous/model/page.rb +11 -3
- data/lib/spontaneous/model.rb +6 -6
- data/lib/spontaneous/output/context/render_cache.rb +23 -0
- data/lib/spontaneous/output/context.rb +56 -30
- data/lib/spontaneous/output/helpers/script_helper.rb +9 -53
- data/lib/spontaneous/output/helpers/stylesheet_helper.rb +8 -40
- data/lib/spontaneous/output/template/renderer.rb +17 -5
- data/lib/spontaneous/output.rb +0 -1
- data/lib/spontaneous/paths.rb +6 -2
- data/lib/spontaneous/permissions/access_key.rb +18 -0
- data/lib/spontaneous/permissions/user.rb +1 -1
- data/lib/spontaneous/permissions.rb +4 -1
- data/lib/spontaneous/plugins/application/state.rb +19 -12
- data/lib/spontaneous/prototypes/field_prototype.rb +14 -8
- data/lib/spontaneous/published_revision.rb +7 -0
- data/lib/spontaneous/publishing/immediate.rb +43 -34
- data/lib/spontaneous/publishing/revision.rb +9 -6
- data/lib/spontaneous/rack/asset_server.rb +20 -0
- data/lib/spontaneous/rack/back/alias.rb +46 -0
- data/lib/spontaneous/rack/back/application_assets.rb +28 -0
- data/lib/spontaneous/rack/back/base.rb +34 -0
- data/lib/spontaneous/rack/back/changes.rb +19 -0
- data/lib/spontaneous/rack/back/content.rb +54 -0
- data/lib/spontaneous/rack/back/events.rb +38 -0
- data/lib/spontaneous/rack/back/field.rb +37 -0
- data/lib/spontaneous/rack/back/file.rb +118 -0
- data/lib/spontaneous/rack/back/helpers.rb +71 -0
- data/lib/spontaneous/rack/back/index.rb +16 -0
- data/lib/spontaneous/rack/back/login.rb +47 -0
- data/lib/spontaneous/rack/back/map.rb +24 -0
- data/lib/spontaneous/rack/back/page.rb +46 -0
- data/lib/spontaneous/rack/back/preview.rb +43 -0
- data/lib/spontaneous/rack/back/schema.rb +30 -0
- data/lib/spontaneous/rack/back/site.rb +25 -0
- data/lib/spontaneous/rack/back/site_assets.rb +13 -0
- data/lib/spontaneous/rack/back/unsupported_browser.rb +7 -0
- data/lib/spontaneous/rack/{user_admin.rb → back/user_admin.rb} +2 -5
- data/lib/spontaneous/rack/back.rb +85 -764
- data/lib/spontaneous/rack/cacheable_file.rb +3 -3
- data/lib/spontaneous/rack/front.rb +16 -9
- data/lib/spontaneous/rack/middleware/authenticate.rb +65 -0
- data/lib/spontaneous/rack/middleware/csrf.rb +66 -0
- data/lib/spontaneous/rack/middleware/reloader.rb +52 -0
- data/lib/spontaneous/rack/middleware/scope.rb +60 -0
- data/lib/spontaneous/rack/middleware.rb +6 -0
- data/lib/spontaneous/rack/page_controller.rb +18 -5
- data/lib/spontaneous/rack/public.rb +17 -11
- data/lib/spontaneous/rack.rb +34 -24
- data/lib/spontaneous/revision.rb +29 -2
- data/lib/spontaneous/schema/uid.rb +4 -3
- data/lib/spontaneous/schema/uid_map.rb +5 -24
- data/lib/spontaneous/schema.rb +1 -0
- data/lib/spontaneous/search/database.rb +8 -0
- data/lib/spontaneous/search/field.rb +1 -1
- data/lib/spontaneous/search/index.rb +3 -5
- data/lib/spontaneous/server.rb +1 -1
- data/lib/spontaneous/simultaneous.rb +1 -1
- data/lib/spontaneous/site/features.rb +4 -5
- data/lib/spontaneous/site/helpers.rb +22 -5
- data/lib/spontaneous/site/instance.rb +2 -2
- data/lib/spontaneous/site/selectors.rb +22 -3
- data/lib/spontaneous/storage/cloud.rb +13 -9
- data/lib/spontaneous/storage/local.rb +11 -6
- data/lib/spontaneous/style.rb +40 -23
- data/lib/spontaneous/utils/database/mysql_dumper.rb +1 -1
- data/lib/spontaneous/utils/smush_it.rb +1 -1
- data/lib/spontaneous/version.rb +1 -1
- data/lib/spontaneous.rb +35 -33
- data/spontaneous.gemspec +53 -787
- data/test/experimental/test_crypt.rb +56 -56
- data/test/experimental/test_features.rb +16 -27
- data/test/fixtures/assets/public1/css/data.css.scss +3 -0
- data/test/fixtures/assets/public1/css/image1.css.scss +4 -0
- data/test/fixtures/assets/public1/css/import.css.scss +1 -0
- data/test/fixtures/assets/public1/css/urlhash.css.scss +3 -0
- data/test/fixtures/assets/public1/js/a.js +1 -1
- data/test/fixtures/assets/public1/js/all.js +4 -0
- data/test/fixtures/assets/public1/js/{m.coffee → m.js.coffee} +1 -0
- data/test/fixtures/assets/public1/x.js +1 -0
- data/test/fixtures/assets/public2/css/all.css +4 -0
- data/test/fixtures/assets/public2/css/missing.css.scss +3 -0
- data/test/fixtures/assets/public2/i/y.png +0 -0
- data/test/fixtures/assets/public2/js/b.js +1 -1
- data/test/fixtures/assets/public2/js/c.js +1 -1
- data/test/fixtures/images/size.extended.webp +0 -0
- data/test/fixtures/images/size.lossless.webp +0 -0
- data/test/fixtures/images/size.lossy.webp +0 -0
- data/test/fixtures/schema/before.yml +4 -4
- data/test/fixtures/schema/schema.yml +1 -1
- data/test/fixtures/templates/aliases/aaa.html.cut +0 -0
- data/test/fixtures/templates/extended/partial_with_renderer.html.cut +1 -0
- data/test/fixtures/templates/extended/with_includes_and_renderer.html.cut +2 -0
- data/test/functional/test_application.rb +108 -106
- data/test/functional/test_back.rb +924 -930
- data/test/functional/test_front.rb +285 -238
- data/test/functional/test_user_manager.rb +75 -100
- data/test/integration/test_installation.rb +1 -1
- data/test/support/matchers.rb +12 -0
- data/test/support/minitest.rb +121 -0
- data/test/support/rack.rb +45 -0
- data/test/support/test_start_finish.rb +103 -0
- data/test/test_helper.rb +21 -68
- data/test/test_integration_helper.rb +1 -3
- data/test/unit/test_alias.rb +432 -408
- data/test/unit/test_asset_bundler.rb +58 -58
- data/test/unit/test_assets.rb +485 -155
- data/test/unit/test_async.rb +16 -37
- data/test/unit/test_authentication.rb +425 -457
- data/test/unit/test_boxes.rb +191 -191
- data/test/unit/test_changesets.rb +244 -254
- data/test/unit/test_config.rb +128 -142
- data/test/unit/test_content.rb +313 -359
- data/test/unit/test_content_inheritance.rb +29 -30
- data/test/unit/test_datamapper.rb +1205 -1080
- data/test/unit/test_datamapper_content.rb +49 -51
- data/test/unit/test_extensions.rb +23 -23
- data/test/unit/test_fields.rb +1488 -1180
- data/test/unit/test_formats.rb +158 -158
- data/test/unit/test_generators.rb +98 -40
- data/test/unit/test_helpers.rb +73 -76
- data/test/unit/test_image_size.rb +53 -22
- data/test/unit/test_images.rb +164 -165
- data/test/unit/test_layouts.rb +133 -122
- data/test/unit/test_logger.rb +14 -17
- data/test/unit/test_media.rb +69 -84
- data/test/unit/test_modifications.rb +513 -525
- data/test/unit/test_page.rb +462 -361
- data/test/unit/test_permissions.rb +379 -364
- data/test/unit/test_piece.rb +67 -75
- data/test/unit/test_plugins.rb +82 -89
- data/test/unit/test_prototype_set.rb +215 -216
- data/test/unit/test_prototypes.rb +114 -124
- data/test/unit/test_publishing.rb +252 -289
- data/test/unit/test_render.rb +167 -115
- data/test/unit/test_revisions.rb +436 -444
- data/test/unit/test_schema.rb +339 -309
- data/test/unit/test_search.rb +577 -574
- data/test/unit/test_serialisation.rb +136 -147
- data/test/unit/test_site.rb +252 -227
- data/test/unit/test_skeptick.rb +130 -0
- data/test/unit/test_storage.rb +46 -40
- data/test/unit/test_structure.rb +57 -66
- data/test/unit/test_styles.rb +104 -104
- data/test/unit/test_templates.rb +72 -57
- data/test/unit/test_type_hierarchy.rb +15 -16
- data/test/unit/test_visibility.rb +239 -257
- metadata +455 -326
- data/application/js/vendor/JS.Class-2.1.5/CHANGELOG +0 -283
- data/application/js/vendor/JS.Class-2.1.5/MIT-LICENSE +0 -30
- data/application/js/vendor/JS.Class-2.1.5/README +0 -30
- data/application/js/vendor/JS.Class-2.1.5/min/command.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/comparable.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/constant_scope.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/decorator.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/enumerable.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/forwardable.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/hash.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/linked_list.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/loader.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/method_chain.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/observable.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/package.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/proxy.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/ruby.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/set.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/stack_trace.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/state.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/stdlib.js +0 -16
- data/application/js/vendor/jquery-1.6.2.min.js +0 -18
- data/application/js/vendor/jquery-ui-1.8.16.custom.min.js +0 -791
- data/application/js/vendor/jquery-ui-1.8.9.custom.min.js +0 -415
- data/application/static/font/fontawesome-webfont-5c5c21100a346972a82c34c5e96ffcfe.ttf +0 -0
- data/application/static/select-arrow-6e7dd3745b00e934b0d7a3250c46558b.png +0 -0
- data/bin/limit-upload +0 -5
- data/bin/unlimit-upload +0 -3
- data/lib/spontaneous/asset/file.rb +0 -25
- data/lib/spontaneous/asset/source.rb +0 -28
- data/lib/spontaneous/image_size.rb +0 -123
- data/lib/spontaneous/output/assets/compression.rb +0 -58
- data/lib/spontaneous/output/assets.rb +0 -32
- data/lib/spontaneous/rack/around_back.rb +0 -20
- data/lib/spontaneous/rack/around_front.rb +0 -27
- data/lib/spontaneous/rack/around_preview.rb +0 -22
- data/lib/spontaneous/rack/assets.rb +0 -126
- data/lib/spontaneous/rack/authentication.rb +0 -20
- data/lib/spontaneous/rack/cookie_authentication.rb +0 -38
- data/lib/spontaneous/rack/helpers.rb +0 -52
- data/lib/spontaneous/rack/http.rb +0 -18
- data/lib/spontaneous/rack/media.rb +0 -30
- data/lib/spontaneous/rack/query_authentication.rb +0 -35
- data/lib/spontaneous/rack/reloader.rb +0 -45
- data/lib/spontaneous/rack/user_helpers.rb +0 -28
- /data/{README → application/js/field/markdown/text_command.js} +0 -0
- /data/application/js/vendor/{JS.Class-2.1.5/min/core.js → js.class-2.1.5.min.js} +0 -0
- /data/test/fixtures/assets/public1/css/{a.scss → a.css.scss} +0 -0
- /data/{lib/spontaneous/generators/site/public/css/site.scss → test/fixtures/assets/public1/x.css} +0 -0
- /data/{lib/spontaneous/generators/site/public/js/.empty_directory → test/fixtures/assets/public1/x.png} +0 -0
- /data/test/fixtures/assets/public2/css/{b.scss → b.css.scss} +0 -0
- /data/test/fixtures/assets/public2/js/{n.coffee → n.js.coffee} +0 -0
- /data/test/fixtures/back/{public → assets}/css/sass_include.scss +0 -0
- /data/test/fixtures/back/{public → assets}/css/sass_template.scss +0 -0
- /data/test/fixtures/back/{public → assets}/js/coffeescript.coffee +0 -0
- /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
|
-
|
6
|
+
describe "Modifications" do
|
7
7
|
|
8
|
-
|
8
|
+
before do
|
9
9
|
@now = Time.now
|
10
10
|
@site = setup_site
|
11
|
-
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
teardown_site
|
15
|
-
end
|
11
|
+
stub_time(@now)
|
16
12
|
|
17
|
-
|
18
|
-
setup do
|
19
|
-
stub_time(@now)
|
13
|
+
Content.delete
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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 |
|
39
|
-
d
|
40
|
-
|
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
|
-
|
39
|
+
c.save
|
51
40
|
end
|
41
|
+
@root.save
|
42
|
+
end
|
52
43
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
-
|
94
|
-
|
95
|
-
|
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
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
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
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
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
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
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
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
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
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
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
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
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
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
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
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
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
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
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
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
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
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
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
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
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
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
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
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
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
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
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
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
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
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
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
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
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
|
-
|
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.
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
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
|
-
|
343
|
-
|
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.
|
346
|
-
page.
|
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
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
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
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
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
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
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
|
-
|
386
|
-
|
387
|
-
|
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
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
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
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
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
|
-
|
444
|
-
|
445
|
-
|
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
|
-
|
448
|
-
|
449
|
-
|
436
|
+
child_page = Page.new :uid => "child"
|
437
|
+
page.things << child_page
|
438
|
+
page.save
|
450
439
|
|
451
|
-
|
440
|
+
::Content.publish(@final_revision, [child_page.id])
|
452
441
|
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
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
|
-
|
462
|
-
|
463
|
-
|
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
|
-
|
466
|
-
|
467
|
-
|
454
|
+
child_page = Page.new :uid => "child"
|
455
|
+
page.things << child_page
|
456
|
+
page.save
|
468
457
|
|
469
|
-
|
458
|
+
::Content.publish(@final_revision, [page.id, child_page.id])
|
470
459
|
|
471
|
-
|
472
|
-
|
473
|
-
|
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
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
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
|
-
|
484
|
-
|
485
|
-
|
472
|
+
child_page = Page.first :uid => "1.0.0"
|
473
|
+
child_page.slug = "changed-too"
|
474
|
+
child_page.save
|
486
475
|
|
487
|
-
|
476
|
+
::Content.publish(@final_revision, [child_page.id])
|
488
477
|
|
489
|
-
|
490
|
-
|
491
|
-
|
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
|
-
|
496
|
-
|
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
|
-
|
499
|
-
|
500
|
-
|
487
|
+
child_page = Page.new :uid => "newpage"
|
488
|
+
page.things << child_page
|
489
|
+
page.save
|
501
490
|
|
502
|
-
|
491
|
+
::Content.publish(@final_revision, [page.id, child_page.id])
|
503
492
|
|
504
|
-
|
493
|
+
refute child_page.hidden?
|
505
494
|
|
506
|
-
|
495
|
+
page.hide!
|
507
496
|
|
508
|
-
|
497
|
+
assert child_page.reload.hidden?
|
509
498
|
|
510
|
-
|
499
|
+
::Content.publish(@final_revision + 1, [page.id])
|
511
500
|
|
512
|
-
|
513
|
-
|
514
|
-
|
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
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
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
|
-
|
512
|
+
page.hide!
|
524
513
|
|
525
|
-
|
514
|
+
assert child_page.reload.hidden?
|
526
515
|
|
527
|
-
|
516
|
+
::Content.publish(@final_revision, [page.id])
|
528
517
|
|
529
|
-
|
530
|
-
|
531
|
-
|
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
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
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
|
-
|
534
|
+
::Content.publish(@final_revision+1, [page.id])
|
546
535
|
|
547
|
-
|
548
|
-
|
549
|
-
|
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
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
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
|
-
|
551
|
+
::Content.publish(@final_revision+1, [page.id])
|
563
552
|
|
564
|
-
|
565
|
-
|
566
|
-
|
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
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
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
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
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
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
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
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
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
|
-
|
623
|
-
|
624
|
-
|
611
|
+
after do
|
612
|
+
@user.destroy
|
613
|
+
end
|
625
614
|
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
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
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
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
|