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
data/test/unit/test_schema.rb
CHANGED
@@ -3,20 +3,21 @@
|
|
3
3
|
require File.expand_path('../../test_helper', __FILE__)
|
4
4
|
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
describe "Schema" do
|
7
|
+
before do
|
8
8
|
@site = setup_site
|
9
9
|
@site.schema_loader_class = Spontaneous::Schema::PersistentMap
|
10
|
+
@user_levels_file = File.expand_path('../../fixtures/permissions', __FILE__) / 'config/user_levels.yml'
|
10
11
|
S::Permissions::UserLevel.reset!
|
11
|
-
S::Permissions::UserLevel.stubs(:level_file).returns(
|
12
|
+
S::Permissions::UserLevel.stubs(:level_file).returns(@user_levels_file)
|
12
13
|
end
|
13
14
|
|
14
|
-
|
15
|
+
after do
|
15
16
|
teardown_site
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
describe "Configurable names" do
|
20
|
+
before do
|
20
21
|
class ::FunkyContent < Piece; end
|
21
22
|
class ::MoreFunkyContent < FunkyContent; end
|
22
23
|
class ::ABCDifficultName < Piece; end
|
@@ -26,40 +27,40 @@ class SchemaTest < MiniTest::Spec
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
|
30
|
+
after do
|
30
31
|
[:FunkyContent, :MoreFunkyContent, :ABCDifficultName, :CustomName].each do |klass|
|
31
32
|
Object.send(:remove_const, klass)
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
|
-
|
36
|
-
FunkyContent.default_title.
|
37
|
-
FunkyContent.title.
|
38
|
-
MoreFunkyContent.title.
|
39
|
-
ABCDifficultName.default_title.
|
40
|
-
ABCDifficultName.title.
|
36
|
+
it "default to generated version" do
|
37
|
+
FunkyContent.default_title.must_equal "Funky Content"
|
38
|
+
FunkyContent.title.must_equal "Funky Content"
|
39
|
+
MoreFunkyContent.title.must_equal "More Funky Content"
|
40
|
+
ABCDifficultName.default_title.must_equal "ABC Difficult Name"
|
41
|
+
ABCDifficultName.title.must_equal "ABC Difficult Name"
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
-
CustomName.title.
|
44
|
+
it "be settable" do
|
45
|
+
CustomName.title.must_equal "Some Name"
|
45
46
|
FunkyContent.title "Content Class"
|
46
|
-
FunkyContent.title.
|
47
|
+
FunkyContent.title.must_equal "Content Class"
|
47
48
|
end
|
48
49
|
|
49
|
-
|
50
|
+
it "be settable using =" do
|
50
51
|
FunkyContent.title = "Content Class"
|
51
|
-
FunkyContent.title.
|
52
|
+
FunkyContent.title.must_equal "Content Class"
|
52
53
|
end
|
53
54
|
|
54
|
-
|
55
|
+
it "not inherit from superclass" do
|
55
56
|
FunkyContent.title = "Custom Name"
|
56
|
-
MoreFunkyContent.title.
|
57
|
+
MoreFunkyContent.title.must_equal "More Funky Content"
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
describe "Persistent maps" do
|
62
|
+
describe "Schema UIDs" do
|
63
|
+
before do
|
63
64
|
@site.schema.schema_map_file = File.expand_path('../../fixtures/schema/schema.yml', __FILE__)
|
64
65
|
class SchemaClass < Page
|
65
66
|
field :description
|
@@ -73,103 +74,101 @@ class SchemaTest < MiniTest::Spec
|
|
73
74
|
@uids = @site.schema.uids
|
74
75
|
end
|
75
76
|
|
76
|
-
|
77
|
-
|
77
|
+
after do
|
78
|
+
Object.send(:remove_const, :SchemaClass) rescue nil
|
78
79
|
end
|
79
80
|
|
80
|
-
|
81
|
-
# Schema::UID.generate.to_s.length.should == 12
|
82
|
-
# end
|
83
|
-
|
84
|
-
should "be unique" do
|
81
|
+
it "be unique" do
|
85
82
|
ids = (0..10000).map { S::Schema::UIDMap.generate }
|
86
|
-
ids.uniq.length.
|
83
|
+
ids.uniq.length.must_equal ids.length
|
87
84
|
end
|
88
85
|
|
89
86
|
|
90
|
-
|
87
|
+
it "be singletons" do
|
91
88
|
a = @uids["xxxxxxxxxxxx"]
|
92
89
|
b = @uids["xxxxxxxxxxxx"]
|
93
90
|
c = @uids["ffffffffffff"]
|
94
|
-
a.object_id.
|
95
|
-
a.
|
96
|
-
c.object_id.
|
97
|
-
c.
|
91
|
+
a.object_id.must_equal b.object_id
|
92
|
+
a.must_equal b
|
93
|
+
c.object_id.wont_equal b.object_id
|
94
|
+
c.wont_equal b
|
98
95
|
end
|
99
96
|
|
100
|
-
|
101
|
-
|
102
|
-
# end
|
103
|
-
|
104
|
-
should "return nil if passed nil" do
|
105
|
-
@uids[nil].should be_nil
|
97
|
+
it "return nil if passed nil" do
|
98
|
+
@uids[nil].must_be_nil
|
106
99
|
end
|
107
100
|
|
108
|
-
|
109
|
-
@uids[""].
|
101
|
+
it "return nil if passed an empty string" do
|
102
|
+
@uids[""].must_be_nil
|
110
103
|
end
|
111
104
|
|
112
|
-
|
105
|
+
it "return the same UID if passed one" do
|
113
106
|
a = @uids["xxxxxxxxxxxx"]
|
114
|
-
@uids[a].
|
107
|
+
@uids[a].must_be_same_as a
|
115
108
|
end
|
116
109
|
|
117
|
-
|
118
|
-
|
110
|
+
it "test as equal to its string representation" do
|
111
|
+
"llllllllllll".must_equal @uids["llllllllllll"]
|
119
112
|
end
|
120
113
|
|
121
|
-
|
114
|
+
it "test as eql? if they have the same id" do
|
122
115
|
a = @uids["llllllllllll"]
|
123
116
|
b = a.dup
|
124
117
|
assert a.eql?(b), "Identical IDs should pass eql? test"
|
125
118
|
end
|
126
119
|
|
127
|
-
should
|
128
|
-
SchemaClass.schema_id
|
120
|
+
it "should be serializable to JSON" do
|
121
|
+
a = SchemaClass.schema_id
|
122
|
+
json = Spontaneous::JSON.encode a
|
123
|
+
json.must_equal '"xxxxxxxxxxxx"'
|
129
124
|
end
|
130
125
|
|
131
|
-
|
132
|
-
|
126
|
+
it "be readable by content classes" do
|
127
|
+
SchemaClass.schema_id.must_equal @uids["xxxxxxxxxxxx"]
|
133
128
|
end
|
134
129
|
|
135
|
-
|
136
|
-
@instance.
|
130
|
+
it "be readable by fields" do
|
131
|
+
@instance.fields[:description].schema_id.must_equal @uids["ffffffffffff"]
|
137
132
|
end
|
138
133
|
|
139
|
-
|
140
|
-
@instance.
|
134
|
+
it "be readable by boxes" do
|
135
|
+
@instance.boxes[:posts].schema_id.must_equal @uids["bbbbbbbbbbbb"]
|
141
136
|
end
|
142
137
|
|
143
|
-
|
144
|
-
@instance.
|
145
|
-
@instance.layout.schema_id.should == @uids["llllllllllll"]
|
138
|
+
it "be readable by styles" do
|
139
|
+
@instance.styles[:simple].schema_id.must_equal @uids["ssssssssssss"]
|
146
140
|
end
|
147
141
|
|
148
|
-
|
149
|
-
|
150
|
-
|
142
|
+
it "be readable by layouts" do
|
143
|
+
@instance.layout.name.must_equal :clean
|
144
|
+
@instance.layout.schema_id.must_equal @uids["llllllllllll"]
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "lookups" do
|
148
|
+
it "return classes" do
|
149
|
+
Site.schema.to_class("xxxxxxxxxxxx").must_equal SchemaClass
|
151
150
|
end
|
152
|
-
|
153
|
-
Site.schema.to_class("ffffffffffff").
|
151
|
+
it "return fields" do
|
152
|
+
Site.schema.to_class("ffffffffffff").must_equal SchemaClass.field_prototypes[:description]
|
154
153
|
end
|
155
|
-
|
156
|
-
Site.schema.to_class("bbbbbbbbbbbb").
|
154
|
+
it "return boxes" do
|
155
|
+
Site.schema.to_class("bbbbbbbbbbbb").must_equal SchemaClass.box_prototypes[:posts]
|
157
156
|
end
|
158
|
-
|
159
|
-
Site.schema.to_class("ssssssssssss").
|
157
|
+
it "return styles" do
|
158
|
+
Site.schema.to_class("ssssssssssss").must_equal SchemaClass.style_prototypes[:simple]
|
160
159
|
end
|
161
|
-
|
162
|
-
Site.schema.to_class("llllllllllll").
|
160
|
+
it "return layouts" do
|
161
|
+
Site.schema.to_class("llllllllllll").must_equal SchemaClass.layout_prototypes[:clean]
|
163
162
|
end
|
164
163
|
end
|
165
164
|
|
166
165
|
end
|
167
166
|
|
168
|
-
|
169
|
-
|
167
|
+
describe "schema verification" do
|
168
|
+
before do
|
170
169
|
@site.schema.schema_map_file = File.expand_path('../../fixtures/schema/before.yml', __FILE__)
|
171
170
|
Page.field :title
|
172
|
-
class B <
|
171
|
+
class B < Page; end
|
173
172
|
class C < Piece; end
|
174
173
|
class D < Piece; end
|
175
174
|
class O < Box; end
|
@@ -192,38 +191,31 @@ class SchemaTest < MiniTest::Spec
|
|
192
191
|
O.style :ostyle1
|
193
192
|
O.style :ostyle2
|
194
193
|
|
195
|
-
# have to use mocking because schema class list is totally fecked up
|
196
|
-
# after running other tests
|
197
|
-
# TODO: look into reliable, non-harmful way of clearing out the schema state
|
198
|
-
# between tests
|
199
|
-
# Schema.stubs(:classes).returns([B, C, D, O])
|
200
|
-
# Schema.classes.should == [B, C, D, O]
|
201
194
|
@site.schema.map
|
202
195
|
@uids = @site.schema.uids
|
203
|
-
::Page.schema_id.
|
204
|
-
B.schema_id.
|
205
|
-
C.schema_id.
|
206
|
-
D.schema_id.
|
207
|
-
O.schema_id.
|
196
|
+
::Page.schema_id.must_equal @uids["tttttttttttt"]
|
197
|
+
B.schema_id.must_equal @uids["bbbbbbbbbbbb"]
|
198
|
+
C.schema_id.must_equal @uids["cccccccccccc"]
|
199
|
+
D.schema_id.must_equal @uids["dddddddddddd"]
|
200
|
+
O.schema_id.must_equal @uids["oooooooooooo"]
|
208
201
|
end
|
209
202
|
|
210
|
-
|
211
|
-
Object.send(:remove_const, :
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
SchemaTest.send(:remove_const, :O) rescue nil
|
203
|
+
after do
|
204
|
+
Object.send(:remove_const, :B) rescue nil
|
205
|
+
Object.send(:remove_const, :C) rescue nil
|
206
|
+
Object.send(:remove_const, :D) rescue nil
|
207
|
+
Object.send(:remove_const, :E) rescue nil
|
208
|
+
Object.send(:remove_const, :F) rescue nil
|
209
|
+
Object.send(:remove_const, :O) rescue nil
|
218
210
|
end
|
219
211
|
|
220
|
-
|
212
|
+
it "return the right schema anme for inherited box fields" do
|
221
213
|
f = B.boxes[:publishers].instance_class.field :newfield
|
222
|
-
B.boxes[:publishers].instance_class.fields.first.schema_name.
|
223
|
-
f.schema_name.
|
214
|
+
B.boxes[:publishers].instance_class.fields.first.schema_name.must_equal "field/oooooooooooo/ofield1"
|
215
|
+
f.schema_name.must_equal "field/publishers00/newfield"
|
224
216
|
end
|
225
217
|
|
226
|
-
|
218
|
+
it "detect addition of classes" do
|
227
219
|
class E < ::Piece; end
|
228
220
|
@site.schema.stubs(:classes).returns([B, C, D, E])
|
229
221
|
exception = nil
|
@@ -233,15 +225,15 @@ class SchemaTest < MiniTest::Spec
|
|
233
225
|
rescue Spontaneous::SchemaModificationError => e
|
234
226
|
exception = e
|
235
227
|
end
|
236
|
-
exception.added_classes.
|
228
|
+
exception.added_classes.must_equal [E]
|
237
229
|
# need to explicitly define solution to validation error
|
238
230
|
# Schema.expects(:generate).returns('dddddddddddd')
|
239
|
-
# D.schema_id.
|
231
|
+
# D.schema_id.must_equal 'dddddddddddd'
|
240
232
|
end
|
241
233
|
|
242
|
-
|
243
|
-
|
244
|
-
|
234
|
+
it "detect removal of classes" do
|
235
|
+
Object.send(:remove_const, :C) rescue nil
|
236
|
+
Object.send(:remove_const, :D) rescue nil
|
245
237
|
@site.schema.stubs(:classes).returns([::Page, B, O])
|
246
238
|
begin
|
247
239
|
@site.schema.validate_schema
|
@@ -249,12 +241,12 @@ class SchemaTest < MiniTest::Spec
|
|
249
241
|
rescue Spontaneous::SchemaModificationError => e
|
250
242
|
exception = e
|
251
243
|
end
|
252
|
-
exception.removed_classes.map { |c| c.name }.sort.
|
244
|
+
exception.removed_classes.map { |c| c.name }.sort.must_equal ["C", "D"]
|
253
245
|
end
|
254
246
|
|
255
|
-
|
256
|
-
|
257
|
-
|
247
|
+
it "detect multiple removals & additions of classes" do
|
248
|
+
Object.send(:remove_const, :C) rescue nil
|
249
|
+
Object.send(:remove_const, :D) rescue nil
|
258
250
|
class E < Content; end
|
259
251
|
class F < Content; end
|
260
252
|
@site.schema.stubs(:classes).returns([::Page, B, E, F, O])
|
@@ -264,11 +256,11 @@ class SchemaTest < MiniTest::Spec
|
|
264
256
|
rescue Spontaneous::SchemaModificationError => e
|
265
257
|
exception = e
|
266
258
|
end
|
267
|
-
exception.added_classes.
|
268
|
-
exception.removed_classes.map {|c| c.name}.sort.
|
259
|
+
exception.added_classes.must_equal [E, F]
|
260
|
+
exception.removed_classes.map {|c| c.name}.sort.must_equal ["C", "D"]
|
269
261
|
end
|
270
262
|
|
271
|
-
|
263
|
+
it "detect addition of fields" do
|
272
264
|
B.field :name
|
273
265
|
C.field :location
|
274
266
|
C.field :description
|
@@ -278,10 +270,10 @@ class SchemaTest < MiniTest::Spec
|
|
278
270
|
rescue Spontaneous::SchemaModificationError => e
|
279
271
|
exception = e
|
280
272
|
end
|
281
|
-
exception.added_fields.
|
273
|
+
exception.added_fields.must_equal [B.field_prototypes[:name], C.field_prototypes[:location], C.field_prototypes[:description]]
|
282
274
|
end
|
283
275
|
|
284
|
-
|
276
|
+
it "detect removal of fields" do
|
285
277
|
field = B.field_prototypes[:author]
|
286
278
|
B.stubs(:field_prototypes).returns({:author => field})
|
287
279
|
B.stubs(:fields).returns([field])
|
@@ -292,12 +284,12 @@ class SchemaTest < MiniTest::Spec
|
|
292
284
|
exception = e
|
293
285
|
end
|
294
286
|
exception.removed_fields.length == 1
|
295
|
-
exception.removed_fields[0].name.
|
296
|
-
exception.removed_fields[0].owner.
|
297
|
-
exception.removed_fields[0].category.
|
287
|
+
exception.removed_fields[0].name.must_equal "description"
|
288
|
+
exception.removed_fields[0].owner.must_equal B
|
289
|
+
exception.removed_fields[0].category.must_equal :field
|
298
290
|
end
|
299
291
|
|
300
|
-
|
292
|
+
it "detect addition of boxes" do
|
301
293
|
B.box :changes
|
302
294
|
B.box :updates
|
303
295
|
begin
|
@@ -306,10 +298,10 @@ class SchemaTest < MiniTest::Spec
|
|
306
298
|
rescue Spontaneous::SchemaModificationError => e
|
307
299
|
exception = e
|
308
300
|
end
|
309
|
-
exception.added_boxes.
|
301
|
+
exception.added_boxes.must_equal [B.boxes[:changes], B.boxes[:updates]]
|
310
302
|
end
|
311
303
|
|
312
|
-
|
304
|
+
it "detect removal of boxes" do
|
313
305
|
boxes = S::Collections::PrototypeSet.new
|
314
306
|
boxes[:promotions] = B.boxes[:promotions]
|
315
307
|
|
@@ -320,13 +312,13 @@ class SchemaTest < MiniTest::Spec
|
|
320
312
|
rescue Spontaneous::SchemaModificationError => e
|
321
313
|
exception = e
|
322
314
|
end
|
323
|
-
exception.removed_boxes.length.
|
324
|
-
exception.removed_boxes[0].name.
|
325
|
-
exception.removed_boxes[0].owner.
|
326
|
-
exception.removed_boxes[0].category.
|
315
|
+
exception.removed_boxes.length.must_equal 1
|
316
|
+
exception.removed_boxes[0].name.must_equal "publishers"
|
317
|
+
exception.removed_boxes[0].owner.must_equal B
|
318
|
+
exception.removed_boxes[0].category.must_equal :box
|
327
319
|
end
|
328
320
|
|
329
|
-
|
321
|
+
it "detect addition of styles" do
|
330
322
|
B.style :fancy
|
331
323
|
B.style :dirty
|
332
324
|
begin
|
@@ -335,10 +327,10 @@ class SchemaTest < MiniTest::Spec
|
|
335
327
|
rescue Spontaneous::SchemaModificationError => e
|
336
328
|
exception = e
|
337
329
|
end
|
338
|
-
exception.added_styles.
|
330
|
+
exception.added_styles.must_equal [B.styles.detect{ |s| s.name == :fancy }, B.styles.detect{ |s| s.name == :dirty }]
|
339
331
|
end
|
340
332
|
|
341
|
-
|
333
|
+
it "detect removal of styles" do
|
342
334
|
style = B.styles[:inline]
|
343
335
|
B.styles.expects(:order).returns([:inline])
|
344
336
|
B.styles.stubs(:[]).with(:inline).returns(style)
|
@@ -349,13 +341,13 @@ class SchemaTest < MiniTest::Spec
|
|
349
341
|
rescue Spontaneous::SchemaModificationError => e
|
350
342
|
exception = e
|
351
343
|
end
|
352
|
-
exception.removed_styles.length.
|
353
|
-
exception.removed_styles[0].name.
|
354
|
-
exception.removed_styles[0].owner.
|
355
|
-
exception.removed_styles[0].category.
|
344
|
+
exception.removed_styles.length.must_equal 1
|
345
|
+
exception.removed_styles[0].name.must_equal "outline"
|
346
|
+
exception.removed_styles[0].owner.must_equal B
|
347
|
+
exception.removed_styles[0].category.must_equal :style
|
356
348
|
end
|
357
349
|
|
358
|
-
|
350
|
+
it "detect addition of layouts" do
|
359
351
|
B.layout :fancy
|
360
352
|
B.layout :dirty
|
361
353
|
begin
|
@@ -364,10 +356,10 @@ class SchemaTest < MiniTest::Spec
|
|
364
356
|
rescue Spontaneous::SchemaModificationError => e
|
365
357
|
exception = e
|
366
358
|
end
|
367
|
-
exception.added_layouts.
|
359
|
+
exception.added_layouts.must_equal [B.layouts.detect{ |s| s.name == :fancy }, B.layouts.detect{ |s| s.name == :dirty }]
|
368
360
|
end
|
369
361
|
|
370
|
-
|
362
|
+
it "detect removal of layouts" do
|
371
363
|
layout = B.layouts[:thin]
|
372
364
|
B.layouts.expects(:order).returns([:thin])
|
373
365
|
B.layouts.stubs(:[]).with(:thin).returns(layout)
|
@@ -378,13 +370,13 @@ class SchemaTest < MiniTest::Spec
|
|
378
370
|
rescue Spontaneous::SchemaModificationError => e
|
379
371
|
exception = e
|
380
372
|
end
|
381
|
-
exception.removed_layouts.length.
|
382
|
-
exception.removed_layouts[0].name.
|
383
|
-
exception.removed_layouts[0].owner.
|
384
|
-
exception.removed_layouts[0].category.
|
373
|
+
exception.removed_layouts.length.must_equal 1
|
374
|
+
exception.removed_layouts[0].name.must_equal "fat"
|
375
|
+
exception.removed_layouts[0].owner.must_equal B
|
376
|
+
exception.removed_layouts[0].category.must_equal :layout
|
385
377
|
end
|
386
378
|
|
387
|
-
|
379
|
+
it "detect addition of fields to anonymous boxes" do
|
388
380
|
f1 = B.boxes[:publishers].instance_class.field :field3
|
389
381
|
f2 = B.boxes[:promotions].instance_class.field :field3
|
390
382
|
begin
|
@@ -393,10 +385,10 @@ class SchemaTest < MiniTest::Spec
|
|
393
385
|
rescue Spontaneous::SchemaModificationError => e
|
394
386
|
exception = e
|
395
387
|
end
|
396
|
-
|
388
|
+
assert_has_elements exception.added_fields, [f2, f1]
|
397
389
|
end
|
398
390
|
|
399
|
-
|
391
|
+
it "detect removal of fields from anonymous boxes" do
|
400
392
|
f2 = B.boxes[:promotions].instance_class.field_prototypes[:field2]
|
401
393
|
B.boxes[:promotions].instance_class.stubs(:field_prototypes).returns({:field2 => f2})
|
402
394
|
B.boxes[:promotions].instance_class.stubs(:fields).returns([f2])
|
@@ -406,13 +398,13 @@ class SchemaTest < MiniTest::Spec
|
|
406
398
|
rescue Spontaneous::SchemaModificationError => e
|
407
399
|
exception = e
|
408
400
|
end
|
409
|
-
exception.removed_fields.length.
|
410
|
-
exception.removed_fields[0].name.
|
411
|
-
exception.removed_fields[0].owner.instance_class.
|
412
|
-
exception.removed_fields[0].category.
|
401
|
+
exception.removed_fields.length.must_equal 1
|
402
|
+
exception.removed_fields[0].name.must_equal "field1"
|
403
|
+
exception.removed_fields[0].owner.instance_class.must_equal B.boxes[:promotions].instance_class
|
404
|
+
exception.removed_fields[0].category.must_equal :field
|
413
405
|
end
|
414
406
|
|
415
|
-
|
407
|
+
it "detect addition of fields to box types" do
|
416
408
|
O.field :name
|
417
409
|
begin
|
418
410
|
@site.schema.validate_schema
|
@@ -420,10 +412,10 @@ class SchemaTest < MiniTest::Spec
|
|
420
412
|
rescue Spontaneous::SchemaModificationError => e
|
421
413
|
exception = e
|
422
414
|
end
|
423
|
-
exception.added_fields.
|
415
|
+
exception.added_fields.must_equal [O.field_prototypes[:name]]
|
424
416
|
end
|
425
417
|
|
426
|
-
#
|
418
|
+
# it "detect removal of fields from box types" do
|
427
419
|
# skip "stubbing is messing up the field hierarchy in weird ways"
|
428
420
|
# fields = [O.field_prototypes[:ofield1]]
|
429
421
|
# O.stubs(:fields).returns(fields)
|
@@ -434,15 +426,15 @@ class SchemaTest < MiniTest::Spec
|
|
434
426
|
# exception = e
|
435
427
|
# end
|
436
428
|
# exception.removed_fields.length == 1
|
437
|
-
# exception.removed_fields[0].name.
|
438
|
-
# exception.removed_fields[0].owner.
|
439
|
-
# exception.removed_fields[0].category.
|
429
|
+
# exception.removed_fields[0].name.must_equal "ofield2"
|
430
|
+
# exception.removed_fields[0].owner.must_equal O
|
431
|
+
# exception.removed_fields[0].category.must_equal :field
|
440
432
|
# end
|
441
433
|
|
442
|
-
|
443
|
-
|
434
|
+
it "detect addition of styles to box types"
|
435
|
+
it "detect removal of styles from box types"
|
444
436
|
|
445
|
-
|
437
|
+
it "detect addition of styles to anonymous boxes" do
|
446
438
|
s1 = B.boxes[:publishers].instance_class.style :style3
|
447
439
|
s2 = B.boxes[:promotions].instance_class.style :style3
|
448
440
|
begin
|
@@ -451,10 +443,10 @@ class SchemaTest < MiniTest::Spec
|
|
451
443
|
rescue Spontaneous::SchemaModificationError => e
|
452
444
|
exception = e
|
453
445
|
end
|
454
|
-
|
446
|
+
assert_has_elements exception.added_styles, [s2, s1]
|
455
447
|
end
|
456
448
|
|
457
|
-
|
449
|
+
it "detect removal of styles from anonymous boxes" do
|
458
450
|
klass = B.boxes[:promotions].instance_class
|
459
451
|
style = klass.styles.first
|
460
452
|
klass.styles.expects(:order).returns([style.name])
|
@@ -466,43 +458,43 @@ class SchemaTest < MiniTest::Spec
|
|
466
458
|
rescue Spontaneous::SchemaModificationError => e
|
467
459
|
exception = e
|
468
460
|
end
|
469
|
-
exception.removed_styles.length.
|
470
|
-
exception.removed_styles[0].name.
|
471
|
-
exception.removed_styles[0].owner.instance_class.
|
472
|
-
exception.removed_styles[0].category.
|
461
|
+
exception.removed_styles.length.must_equal 1
|
462
|
+
exception.removed_styles[0].name.must_equal "style2"
|
463
|
+
exception.removed_styles[0].owner.instance_class.must_equal B.boxes[:promotions].instance_class
|
464
|
+
exception.removed_styles[0].category.must_equal :style
|
473
465
|
end
|
474
466
|
end
|
475
467
|
end
|
476
468
|
|
477
|
-
|
478
|
-
|
469
|
+
describe "Transient (testing) maps" do
|
470
|
+
before do
|
479
471
|
@site.schema.schema_loader_class = Spontaneous::Schema::TransientMap
|
480
472
|
class V < ::Piece; end
|
481
473
|
class W < ::Piece; end
|
482
474
|
end
|
483
|
-
|
484
|
-
|
485
|
-
|
475
|
+
after do
|
476
|
+
Object.send(:remove_const, :V)
|
477
|
+
Object.send(:remove_const, :W)
|
486
478
|
end
|
487
479
|
|
488
|
-
|
489
|
-
V.schema_id.
|
490
|
-
W.schema_id.
|
491
|
-
V.schema_id.
|
480
|
+
it "create uids on demand" do
|
481
|
+
V.schema_id.wont_be_nil
|
482
|
+
W.schema_id.wont_be_nil
|
483
|
+
V.schema_id.wont_equal W.schema_id
|
492
484
|
end
|
493
485
|
|
494
|
-
|
486
|
+
it "return consistent ids within a session" do
|
495
487
|
a = V.schema_id
|
496
488
|
b = V.schema_id
|
497
|
-
a.
|
489
|
+
a.must_be_same_as(b)
|
498
490
|
end
|
499
491
|
|
500
|
-
|
492
|
+
it "return UID objects" do
|
501
493
|
V.schema_id.must_be_instance_of(Spontaneous::Schema::UID)
|
502
494
|
end
|
503
495
|
|
504
|
-
|
505
|
-
|
496
|
+
describe "for inherited boxes" do
|
497
|
+
before do
|
506
498
|
class ::A < ::Piece
|
507
499
|
box :a
|
508
500
|
end
|
@@ -513,22 +505,22 @@ class SchemaTest < MiniTest::Spec
|
|
513
505
|
box :a
|
514
506
|
end
|
515
507
|
end
|
516
|
-
|
508
|
+
after do
|
517
509
|
Object.send(:remove_const, :A) rescue nil
|
518
510
|
Object.send(:remove_const, :B) rescue nil
|
519
511
|
Object.send(:remove_const, :C) rescue nil
|
520
512
|
end
|
521
|
-
|
522
|
-
B.boxes[:a].schema_id.
|
523
|
-
C.boxes[:a].schema_id.
|
524
|
-
B.boxes[:a].instance_class.schema_id.
|
525
|
-
C.boxes[:a].instance_class.schema_id.
|
513
|
+
it "be the same as the box in the supertype" do
|
514
|
+
B.boxes[:a].schema_id.must_equal A.boxes[:a].schema_id
|
515
|
+
C.boxes[:a].schema_id.must_equal A.boxes[:a].schema_id
|
516
|
+
B.boxes[:a].instance_class.schema_id.must_equal A.boxes[:a].instance_class.schema_id
|
517
|
+
C.boxes[:a].instance_class.schema_id.must_equal A.boxes[:a].instance_class.schema_id
|
526
518
|
end
|
527
519
|
end
|
528
520
|
end
|
529
521
|
|
530
|
-
|
531
|
-
|
522
|
+
describe "Schema groups" do
|
523
|
+
before do
|
532
524
|
class ::A < ::Page
|
533
525
|
group :a, :b, :c
|
534
526
|
box :cgroup do
|
@@ -556,39 +548,39 @@ class SchemaTest < MiniTest::Spec
|
|
556
548
|
end
|
557
549
|
end
|
558
550
|
|
559
|
-
|
551
|
+
after do
|
560
552
|
Object.send(:remove_const, :A) rescue nil
|
561
553
|
Object.send(:remove_const, :B) rescue nil
|
562
554
|
Object.send(:remove_const, :C) rescue nil
|
563
555
|
end
|
564
556
|
|
565
|
-
|
566
|
-
A.boxes.cgroup.allowed_types(nil).
|
567
|
-
C.boxes.bgroup.allowed_types(nil).
|
568
|
-
C.boxes.cgroup.allowed_types(nil).
|
569
|
-
B.boxes.agroup.allowed_types(nil).
|
557
|
+
it "let boxes allow a list of content types" do
|
558
|
+
A.boxes.cgroup.allowed_types(nil).must_equal [A, B, C]
|
559
|
+
C.boxes.bgroup.allowed_types(nil).must_equal [A, B]
|
560
|
+
C.boxes.cgroup.allowed_types(nil).must_equal [A, B, C]
|
561
|
+
B.boxes.agroup.allowed_types(nil).must_equal [A, B, C]
|
570
562
|
end
|
571
563
|
|
572
|
-
|
564
|
+
it "apply the options to all the included classes" do
|
573
565
|
user = mock()
|
574
566
|
S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.editor).returns(true)
|
575
567
|
S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.root).returns(true)
|
576
|
-
C.boxes.cgroup.allowed_types(user).
|
568
|
+
C.boxes.cgroup.allowed_types(user).must_equal [A, B, C]
|
577
569
|
S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.editor).returns(true)
|
578
570
|
S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.root).returns(false)
|
579
|
-
C.boxes.cgroup.allowed_types(user).
|
580
|
-
A.boxes.cgroup.allowed_types(user).
|
571
|
+
C.boxes.cgroup.allowed_types(user).must_equal []
|
572
|
+
A.boxes.cgroup.allowed_types(user).must_equal [A, B, C]
|
581
573
|
end
|
582
574
|
|
583
|
-
|
575
|
+
it "allow for configuring styles" do
|
584
576
|
c = C.new
|
585
577
|
b = B.new
|
586
578
|
styles = c.bgroup.available_styles(b)
|
587
|
-
styles.length.
|
588
|
-
styles.first.name.
|
579
|
+
styles.length.must_equal 1
|
580
|
+
styles.first.name.must_equal :fish
|
589
581
|
end
|
590
582
|
|
591
|
-
|
583
|
+
it "reload correctly" do
|
592
584
|
FileUtils.mkdir(@site.root / "config")
|
593
585
|
@site.schema.write_schema
|
594
586
|
@site.schema.delete(::B)
|
@@ -606,14 +598,14 @@ class SchemaTest < MiniTest::Spec
|
|
606
598
|
|
607
599
|
@site.schema.validate!
|
608
600
|
|
609
|
-
A.boxes.cgroup.allowed_types(nil).
|
610
|
-
C.boxes.bgroup.allowed_types(nil).
|
601
|
+
A.boxes.cgroup.allowed_types(nil).must_equal [A, C]
|
602
|
+
C.boxes.bgroup.allowed_types(nil).must_equal [A, B]
|
611
603
|
end
|
612
604
|
end
|
613
605
|
|
614
606
|
|
615
|
-
|
616
|
-
|
607
|
+
describe "Map writing" do
|
608
|
+
describe "Non-existant maps" do
|
617
609
|
def expected_schema
|
618
610
|
classes = @site.schema.classes#[ Content::Page, Page, Content::Piece, Piece, ::A, ::B]
|
619
611
|
expected = Hash[ classes.map { |klass| [ klass.schema_id.to_s, klass.schema_name ] } ]
|
@@ -629,7 +621,7 @@ class SchemaTest < MiniTest::Spec
|
|
629
621
|
expected
|
630
622
|
end
|
631
623
|
|
632
|
-
|
624
|
+
before do
|
633
625
|
@map_file = File.expand_path('../../../tmp/schema.yml', __FILE__)
|
634
626
|
|
635
627
|
::FileUtils.rm_f(@map_file) if ::File.exists?(@map_file)
|
@@ -649,34 +641,34 @@ class SchemaTest < MiniTest::Spec
|
|
649
641
|
end
|
650
642
|
end
|
651
643
|
|
652
|
-
|
644
|
+
after do
|
653
645
|
Object.send(:remove_const, :A) rescue nil
|
654
646
|
Object.send(:remove_const, :B) rescue nil
|
655
647
|
FileUtils.rm(@map_file) if ::File.exists?(@map_file)
|
656
648
|
end
|
657
649
|
|
658
|
-
|
650
|
+
it "get created with verification" do
|
659
651
|
S.schema.validate!
|
660
|
-
File.exists?(@map_file)
|
661
|
-
YAML.load_file(@map_file).
|
652
|
+
assert File.exists?(@map_file)
|
653
|
+
YAML.load_file(@map_file).must_equal expected_schema
|
662
654
|
end
|
663
655
|
|
664
656
|
# Having the generator create an empty config/schema.yml is a useful way of
|
665
657
|
# identifying a spontaneous site (for use by bin/spot)
|
666
|
-
|
658
|
+
it "get overwritten if invalid or empty" do
|
667
659
|
File.open(@map_file, "w") do |f|
|
668
660
|
f.write("# schema")
|
669
661
|
end
|
670
|
-
File.exists?(@map_file)
|
671
|
-
S.schema.map.valid
|
662
|
+
assert File.exists?(@map_file)
|
663
|
+
refute S.schema.map.valid?
|
672
664
|
S.schema.validate!
|
673
|
-
S.schema.map.valid
|
674
|
-
YAML.load_file(@map_file).
|
665
|
+
assert S.schema.map.valid?
|
666
|
+
YAML.load_file(@map_file).must_equal expected_schema
|
675
667
|
end
|
676
668
|
end
|
677
669
|
|
678
|
-
|
679
|
-
|
670
|
+
describe "change resolution" do
|
671
|
+
before do
|
680
672
|
@map_file = File.expand_path('../../../tmp/schema.yml', __FILE__)
|
681
673
|
FileUtils.mkdir_p(File.dirname(@map_file))
|
682
674
|
FileUtils.cp(File.expand_path('../../fixtures/schema/resolvable.yml', __FILE__), @map_file)
|
@@ -695,10 +687,48 @@ class SchemaTest < MiniTest::Spec
|
|
695
687
|
style :daring
|
696
688
|
end
|
697
689
|
@site.schema.validate!
|
698
|
-
A.schema_id.
|
690
|
+
A.schema_id.must_equal S.schema.uids["qLcxinA008"]
|
691
|
+
end
|
692
|
+
|
693
|
+
describe "renamed boxes" do
|
694
|
+
before do
|
695
|
+
S.schema.delete(::A)
|
696
|
+
Object.send :remove_const, :A
|
697
|
+
class ::A < ::Page
|
698
|
+
field :title
|
699
|
+
field :introduction
|
700
|
+
layout :sparse
|
701
|
+
box :renamed do
|
702
|
+
field :description
|
703
|
+
end
|
704
|
+
end
|
705
|
+
end
|
706
|
+
it "raise a validation exception" do
|
707
|
+
lambda { S.schema.validate! }.must_raise(Spontaneous::SchemaModificationError)
|
708
|
+
end
|
709
|
+
describe "modification exception" do
|
710
|
+
before do
|
711
|
+
begin
|
712
|
+
S.schema.validate!
|
713
|
+
rescue Spontaneous::SchemaModificationError => e
|
714
|
+
@exception = e
|
715
|
+
@modification = e.modification
|
716
|
+
end
|
717
|
+
end
|
718
|
+
|
719
|
+
it "not be resolvable" do
|
720
|
+
refute @modification.resolvable?
|
721
|
+
end
|
722
|
+
it "have one added & one removed box"do
|
723
|
+
@modification.added_boxes.length.must_equal 1
|
724
|
+
@modification.added_boxes.first.name.must_equal :renamed
|
725
|
+
@modification.removed_boxes.length.must_equal 1
|
726
|
+
@modification.removed_boxes.first.name.must_equal "posts"
|
727
|
+
end
|
728
|
+
end
|
699
729
|
end
|
700
730
|
|
701
|
-
|
731
|
+
after do
|
702
732
|
Object.send(:remove_const, :A) rescue nil
|
703
733
|
Object.send(:remove_const, :B) rescue nil
|
704
734
|
Object.send(:remove_const, :X) rescue nil
|
@@ -707,7 +737,7 @@ class SchemaTest < MiniTest::Spec
|
|
707
737
|
FileUtils.rm(@map_file) if ::File.exists?(@map_file) rescue nil
|
708
738
|
end
|
709
739
|
|
710
|
-
|
740
|
+
it "be done automatically if only additions are found" do
|
711
741
|
A.field :moose
|
712
742
|
class ::X < ::A
|
713
743
|
field :wild
|
@@ -720,32 +750,32 @@ class SchemaTest < MiniTest::Spec
|
|
720
750
|
style :risky
|
721
751
|
end
|
722
752
|
S.schema.validate!
|
723
|
-
::X.schema_id.
|
724
|
-
::Y.schema_id.
|
725
|
-
::A.field_prototypes[:moose].schema_id.
|
753
|
+
::X.schema_id.wont_be_nil
|
754
|
+
::Y.schema_id.wont_be_nil
|
755
|
+
::A.field_prototypes[:moose].schema_id.wont_be_nil
|
726
756
|
|
727
757
|
m = YAML.load_file(@map_file)
|
728
|
-
m[::A.field_prototypes[:moose].schema_id.to_s].
|
729
|
-
m[::X.schema_id.to_s].
|
730
|
-
m[::Y.schema_id.to_s].
|
731
|
-
m[::X.field_prototypes[:wild].schema_id.to_s].
|
732
|
-
m[::X.boxes[:monkeys].schema_id.to_s].
|
733
|
-
m[::X.boxes[:monkeys].field_prototypes[:banana].schema_id.to_s].
|
734
|
-
m[::X.layout_prototypes[:rich].schema_id.to_s].
|
758
|
+
m[::A.field_prototypes[:moose].schema_id.to_s].must_equal ::A.field_prototypes[:moose].schema_name
|
759
|
+
m[::X.schema_id.to_s].must_equal ::X.schema_name
|
760
|
+
m[::Y.schema_id.to_s].must_equal ::Y.schema_name
|
761
|
+
m[::X.field_prototypes[:wild].schema_id.to_s].must_equal ::X.field_prototypes[:wild].schema_name
|
762
|
+
m[::X.boxes[:monkeys].schema_id.to_s].must_equal ::X.boxes[:monkeys].schema_name
|
763
|
+
m[::X.boxes[:monkeys].field_prototypes[:banana].schema_id.to_s].must_equal ::X.boxes[:monkeys].field_prototypes[:banana].schema_name
|
764
|
+
m[::X.layout_prototypes[:rich].schema_id.to_s].must_equal ::X.layout_prototypes[:rich].schema_name
|
735
765
|
end
|
736
766
|
|
737
767
|
|
738
|
-
|
768
|
+
it "be done automatically if only classes have been removed" do
|
739
769
|
uid = B.schema_id.to_s
|
740
770
|
Object.send(:remove_const, :B)
|
741
771
|
S.schema.stubs(:classes).returns([::A])
|
742
772
|
S.schema.reload!
|
743
773
|
S.schema.validate!
|
744
774
|
m = YAML.load_file(@map_file)
|
745
|
-
m.key?(uid)
|
775
|
+
refute m.key?(uid)
|
746
776
|
end
|
747
777
|
|
748
|
-
|
778
|
+
it "be done automatically if only boxes have been removed" do
|
749
779
|
uid = A.boxes[:posts].schema_id.to_s
|
750
780
|
Object.send :remove_const, :A
|
751
781
|
class ::A < ::Page
|
@@ -757,10 +787,10 @@ class SchemaTest < MiniTest::Spec
|
|
757
787
|
S.schema.reload!
|
758
788
|
S.schema.validate!
|
759
789
|
m = YAML.load_file(@map_file)
|
760
|
-
m.key?(uid)
|
790
|
+
refute m.key?(uid)
|
761
791
|
end
|
762
792
|
|
763
|
-
|
793
|
+
it "be done automatically if only fields have been removed" do
|
764
794
|
uid = A.fields[:title].schema_id.to_s
|
765
795
|
S.schema.delete(::A)
|
766
796
|
Object.send :remove_const, :A
|
@@ -772,24 +802,24 @@ class SchemaTest < MiniTest::Spec
|
|
772
802
|
S.schema.reload!
|
773
803
|
S.schema.validate!
|
774
804
|
m = YAML.load_file(@map_file)
|
775
|
-
m.key?(uid)
|
805
|
+
refute m.key?(uid)
|
776
806
|
end
|
777
807
|
|
778
|
-
|
808
|
+
it "be done automatically in presence of independent addition inside type and of type" do
|
779
809
|
A.field :moose
|
780
810
|
uid = B.schema_id.to_s
|
781
811
|
Object.send(:remove_const, :B)
|
782
812
|
S.schema.stubs(:classes).returns([::A])
|
783
813
|
S.schema.reload!
|
784
814
|
S.schema.validate!
|
785
|
-
::A.field_prototypes[:moose].schema_id.
|
815
|
+
::A.field_prototypes[:moose].schema_id.wont_be_nil
|
786
816
|
|
787
817
|
m = YAML.load_file(@map_file)
|
788
|
-
m[::A.field_prototypes[:moose].schema_id.to_s].
|
789
|
-
m.key?(uid)
|
818
|
+
m[::A.field_prototypes[:moose].schema_id.to_s].must_equal ::A.field_prototypes[:moose].schema_name
|
819
|
+
refute m.key?(uid)
|
790
820
|
end
|
791
821
|
|
792
|
-
|
822
|
+
it "be done automatically in presence of independent addition & removal of fields" do
|
793
823
|
A.field :moose
|
794
824
|
f1 = B.field_prototypes[:location]
|
795
825
|
uid = f1.schema_id.to_s
|
@@ -799,14 +829,14 @@ class SchemaTest < MiniTest::Spec
|
|
799
829
|
S.schema.reload!
|
800
830
|
S.schema.validate!
|
801
831
|
|
802
|
-
::A.field_prototypes[:moose].schema_id.
|
832
|
+
::A.field_prototypes[:moose].schema_id.wont_be_nil
|
803
833
|
|
804
834
|
m = YAML.load_file(@map_file)
|
805
|
-
m[::A.field_prototypes[:moose].schema_id.to_s].
|
806
|
-
m.key?(uid)
|
835
|
+
m[::A.field_prototypes[:moose].schema_id.to_s].must_equal ::A.field_prototypes[:moose].schema_name
|
836
|
+
refute m.key?(uid)
|
807
837
|
end
|
808
838
|
|
809
|
-
|
839
|
+
it "be done automatically in presence of independent changes to boxes & fields" do
|
810
840
|
B.field :crisis
|
811
841
|
uid = A.boxes[:posts].schema_id.to_s
|
812
842
|
A.stubs(:box_prototypes).returns(S::Collections::PrototypeSet.new)
|
@@ -814,12 +844,12 @@ class SchemaTest < MiniTest::Spec
|
|
814
844
|
S.schema.reload!
|
815
845
|
S.schema.validate!
|
816
846
|
|
817
|
-
::B.field_prototypes[:crisis].schema_id.
|
847
|
+
::B.field_prototypes[:crisis].schema_id.wont_be_nil
|
818
848
|
m = YAML.load_file(@map_file)
|
819
|
-
m.key?(uid)
|
849
|
+
refute m.key?(uid)
|
820
850
|
end
|
821
851
|
|
822
|
-
|
852
|
+
it "be done automatically in presence of independent changes to classes, boxes & fields" do
|
823
853
|
class ::X < B; end
|
824
854
|
uid = A.boxes[:posts].schema_id.to_s
|
825
855
|
A.stubs(:box_prototypes).returns(S::Collections::PrototypeSet.new)
|
@@ -830,24 +860,24 @@ class SchemaTest < MiniTest::Spec
|
|
830
860
|
S.schema.reload!
|
831
861
|
S.schema.validate!
|
832
862
|
|
833
|
-
::A.field_prototypes[:crisis].schema_id.
|
863
|
+
::A.field_prototypes[:crisis].schema_id.wont_be_nil
|
834
864
|
m = YAML.load_file(@map_file)
|
835
865
|
|
836
866
|
box = ::B.boxes[:circus]
|
837
|
-
m[box.schema_id.to_s].
|
867
|
+
m[box.schema_id.to_s].must_equal box.schema_name
|
838
868
|
|
839
869
|
field = ::A.field_prototypes[:crisis]
|
840
|
-
m[field.schema_id.to_s].
|
870
|
+
m[field.schema_id.to_s].must_equal field.schema_name
|
841
871
|
|
842
872
|
field = ::B.field_prototypes[:crisis]
|
843
|
-
m[field.schema_id.to_s].
|
873
|
+
m[field.schema_id.to_s].must_equal field.schema_name
|
844
874
|
|
845
|
-
m.key?(uid)
|
875
|
+
refute m.key?(uid)
|
846
876
|
end
|
847
877
|
|
848
878
|
|
849
879
|
# sanity check
|
850
|
-
|
880
|
+
it "still raise error in case of addition & deletion" do
|
851
881
|
A.field :added
|
852
882
|
f1 = A.field_prototypes[:title]
|
853
883
|
f2 = A.field_prototypes[:added]
|
@@ -859,7 +889,7 @@ class SchemaTest < MiniTest::Spec
|
|
859
889
|
lambda { S.schema.validate! }.must_raise(Spontaneous::SchemaModificationError)
|
860
890
|
end
|
861
891
|
|
862
|
-
|
892
|
+
it "still raise error in case of addition & deletion of classes" do
|
863
893
|
class ::X < A; end
|
864
894
|
uid = B.schema_id.to_s
|
865
895
|
Object.send(:remove_const, :B)
|
@@ -868,7 +898,7 @@ class SchemaTest < MiniTest::Spec
|
|
868
898
|
lambda { S.schema.validate! }.must_raise(Spontaneous::SchemaModificationError)
|
869
899
|
end
|
870
900
|
|
871
|
-
|
901
|
+
it "delete box content when a box is removed" do
|
872
902
|
instance = A.new
|
873
903
|
piece1 = B.new
|
874
904
|
piece2 = B.new
|
@@ -876,20 +906,20 @@ class SchemaTest < MiniTest::Spec
|
|
876
906
|
instance.posts << piece2
|
877
907
|
instance.save
|
878
908
|
instance = Content[instance.id]
|
879
|
-
instance.posts.contents.length.
|
880
|
-
Content.count.
|
909
|
+
instance.posts.contents.length.must_equal 2
|
910
|
+
Content.count.must_equal 3
|
881
911
|
uid = A.boxes[:posts].schema_id.to_s
|
882
912
|
A.stubs(:box_prototypes).returns(S::Collections::PrototypeSet.new)
|
883
913
|
S.schema.stubs(:classes).returns([A, B])
|
884
914
|
S.schema.reload!
|
885
915
|
S.schema.validate!
|
886
|
-
Content.count.
|
887
|
-
Content[instance.id].
|
916
|
+
Content.count.must_equal 1
|
917
|
+
Content[instance.id].must_equal instance
|
888
918
|
end
|
889
919
|
|
890
|
-
|
891
|
-
|
892
|
-
|
920
|
+
describe "conflict" do
|
921
|
+
describe "-1 field" do
|
922
|
+
before do
|
893
923
|
A.field :a
|
894
924
|
A.field :b
|
895
925
|
@df1 = A.field_prototypes[:title]
|
@@ -907,27 +937,27 @@ class SchemaTest < MiniTest::Spec
|
|
907
937
|
@modification = e.modification
|
908
938
|
end
|
909
939
|
end
|
910
|
-
|
940
|
+
it "return list of solutions for removal of one field" do
|
911
941
|
# add :a, :b, delete :title
|
912
942
|
# add :b, rename :title => :a
|
913
943
|
# add :a, rename :title => :b
|
914
|
-
@modification.actions.description.
|
915
|
-
@modification.actions.length.
|
944
|
+
@modification.actions.description.must_match /field 'title'/
|
945
|
+
@modification.actions.length.must_equal 3
|
916
946
|
action = @modification.actions[0]
|
917
|
-
action.action.
|
918
|
-
action.source.
|
919
|
-
action.description.
|
947
|
+
action.action.must_equal :delete
|
948
|
+
action.source.must_equal @df1.schema_id
|
949
|
+
action.description.must_match /delete field 'title'/i
|
920
950
|
action = @modification.actions[1]
|
921
|
-
action.action.
|
922
|
-
action.source.
|
923
|
-
action.description.
|
951
|
+
action.action.must_equal :rename
|
952
|
+
action.source.must_equal @df1.schema_id
|
953
|
+
action.description.must_match /rename field 'title' to 'a'/i
|
924
954
|
action = @modification.actions[2]
|
925
|
-
action.action.
|
926
|
-
action.source.
|
927
|
-
action.description.
|
955
|
+
action.action.must_equal :rename
|
956
|
+
action.source.must_equal @df1.schema_id
|
957
|
+
action.description.must_match /rename field 'title' to 'b'/i
|
928
958
|
end
|
929
959
|
|
930
|
-
|
960
|
+
it "enable fixing the problem by deleting field from schema" do
|
931
961
|
action = @modification.actions[0]
|
932
962
|
begin
|
933
963
|
S.schema.apply(action)
|
@@ -936,10 +966,10 @@ class SchemaTest < MiniTest::Spec
|
|
936
966
|
end
|
937
967
|
|
938
968
|
m = YAML.load_file(@map_file)
|
939
|
-
m.key?(@uid)
|
969
|
+
refute m.key?(@uid)
|
940
970
|
end
|
941
971
|
|
942
|
-
|
972
|
+
it "enable fixing the problem by renaming field 'a'" do
|
943
973
|
action = @modification.actions[1]
|
944
974
|
begin
|
945
975
|
S.schema.apply(action)
|
@@ -947,10 +977,10 @@ class SchemaTest < MiniTest::Spec
|
|
947
977
|
flunk("Renaming of field should have resolved schema error")
|
948
978
|
end
|
949
979
|
m = YAML.load_file(@map_file)
|
950
|
-
m[@uid].
|
980
|
+
m[@uid].must_equal @af1.schema_name
|
951
981
|
end
|
952
982
|
|
953
|
-
|
983
|
+
it "enable fixing the problem by renaming field 'b'" do
|
954
984
|
action = @modification.actions[2]
|
955
985
|
begin
|
956
986
|
S.schema.apply(action)
|
@@ -958,12 +988,12 @@ class SchemaTest < MiniTest::Spec
|
|
958
988
|
flunk("Renaming of field should have resolved schema error")
|
959
989
|
end
|
960
990
|
m = YAML.load_file(@map_file)
|
961
|
-
m[@uid].
|
991
|
+
m[@uid].must_equal @af2.schema_name
|
962
992
|
end
|
963
993
|
end
|
964
994
|
|
965
|
-
|
966
|
-
|
995
|
+
describe "-2 fields" do
|
996
|
+
before do
|
967
997
|
A.field :a
|
968
998
|
A.field :b
|
969
999
|
A.field :c
|
@@ -984,7 +1014,7 @@ class SchemaTest < MiniTest::Spec
|
|
984
1014
|
@modification = e.modification
|
985
1015
|
end
|
986
1016
|
end
|
987
|
-
|
1017
|
+
it "return list of solutions" do
|
988
1018
|
# add :a, :b; delete :title, :introduction
|
989
1019
|
# rename :title => :a, :introduction => :b
|
990
1020
|
# rename :introduction => :a, :title => :b
|
@@ -992,27 +1022,27 @@ class SchemaTest < MiniTest::Spec
|
|
992
1022
|
# add :a; delete :title; rename :introduction => :b
|
993
1023
|
# add :b; delete :introduction; rename :title => :a
|
994
1024
|
# add :b; delete :title; rename :introduction => :a
|
995
|
-
@modification.actions.description.
|
996
|
-
@modification.actions.length.
|
1025
|
+
@modification.actions.description.must_match /field 'title'/
|
1026
|
+
@modification.actions.length.must_equal 4
|
997
1027
|
action = @modification.actions[0]
|
998
|
-
action.action.
|
999
|
-
action.source.
|
1000
|
-
action.description.
|
1028
|
+
action.action.must_equal :delete
|
1029
|
+
action.source.must_equal @df1.schema_id
|
1030
|
+
action.description.must_match /delete field 'title'/i
|
1001
1031
|
action = @modification.actions[1]
|
1002
|
-
action.action.
|
1003
|
-
action.source.
|
1004
|
-
action.description.
|
1032
|
+
action.action.must_equal :rename
|
1033
|
+
action.source.must_equal @df1.schema_id
|
1034
|
+
action.description.must_match /rename field 'title' to 'a'/i
|
1005
1035
|
action = @modification.actions[2]
|
1006
|
-
action.action.
|
1007
|
-
action.source.
|
1008
|
-
action.description.
|
1036
|
+
action.action.must_equal :rename
|
1037
|
+
action.source.must_equal @df1.schema_id
|
1038
|
+
action.description.must_match /rename field 'title' to 'b'/i
|
1009
1039
|
action = @modification.actions[3]
|
1010
|
-
action.action.
|
1011
|
-
action.source.
|
1012
|
-
action.description.
|
1040
|
+
action.action.must_equal :rename
|
1041
|
+
action.source.must_equal @df1.schema_id
|
1042
|
+
action.description.must_match /rename field 'title' to 'c'/i
|
1013
1043
|
end
|
1014
1044
|
|
1015
|
-
|
1045
|
+
it "enable fixing the problem by deleting both fields" do
|
1016
1046
|
action = @modification.actions[0]
|
1017
1047
|
begin
|
1018
1048
|
S.schema.apply(action)
|
@@ -1028,11 +1058,11 @@ class SchemaTest < MiniTest::Spec
|
|
1028
1058
|
flunk("Deletion of field should have resolved schema error")
|
1029
1059
|
end
|
1030
1060
|
m = YAML.load_file(@map_file)
|
1031
|
-
m.key?(@uid1)
|
1032
|
-
m.key?(@uid2)
|
1061
|
+
refute m.key?(@uid1)
|
1062
|
+
refute m.key?(@uid2)
|
1033
1063
|
end
|
1034
1064
|
|
1035
|
-
|
1065
|
+
it "enable fixing the problem by deleting one field and renaming other as 'a'" do
|
1036
1066
|
action = @modification.actions[0]
|
1037
1067
|
begin
|
1038
1068
|
S.schema.apply(action)
|
@@ -1048,12 +1078,12 @@ class SchemaTest < MiniTest::Spec
|
|
1048
1078
|
flunk("Deletion of field should have resolved schema error")
|
1049
1079
|
end
|
1050
1080
|
m = YAML.load_file(@map_file)
|
1051
|
-
m.key?(@uid1)
|
1052
|
-
m.key?(@uid2)
|
1053
|
-
m[@uid2].
|
1081
|
+
refute m.key?(@uid1)
|
1082
|
+
assert m.key?(@uid2)
|
1083
|
+
m[@uid2].must_equal @af1.schema_name
|
1054
1084
|
end
|
1055
1085
|
|
1056
|
-
|
1086
|
+
it "enable fixing the problem by renaming one field as 'c' and deleting other" do
|
1057
1087
|
action = @modification.actions[3]
|
1058
1088
|
begin
|
1059
1089
|
S.schema.apply(action)
|
@@ -1069,12 +1099,12 @@ class SchemaTest < MiniTest::Spec
|
|
1069
1099
|
flunk("Deletion of field should have resolved schema error")
|
1070
1100
|
end
|
1071
1101
|
m = YAML.load_file(@map_file)
|
1072
|
-
m.key?(@uid1)
|
1073
|
-
m.key?(@uid2)
|
1074
|
-
m[@uid1].
|
1102
|
+
assert m.key?(@uid1)
|
1103
|
+
refute m.key?(@uid2)
|
1104
|
+
m[@uid1].must_equal @af3.schema_name
|
1075
1105
|
end
|
1076
1106
|
|
1077
|
-
|
1107
|
+
it "enable fixing the problem by renaming one field as 'c' and renaming other as 'b'" do
|
1078
1108
|
action = @modification.actions[3]
|
1079
1109
|
begin
|
1080
1110
|
S.schema.apply(action)
|
@@ -1090,14 +1120,14 @@ class SchemaTest < MiniTest::Spec
|
|
1090
1120
|
flunk("Deletion of field should have resolved schema error")
|
1091
1121
|
end
|
1092
1122
|
m = YAML.load_file(@map_file)
|
1093
|
-
m.key?(@uid1)
|
1094
|
-
m.key?(@uid2)
|
1095
|
-
m[@uid1].
|
1096
|
-
m[@uid2].
|
1123
|
+
assert m.key?(@uid1)
|
1124
|
+
assert m.key?(@uid2)
|
1125
|
+
m[@uid1].must_equal @af3.schema_name
|
1126
|
+
m[@uid2].must_equal @af2.schema_name
|
1097
1127
|
end
|
1098
1128
|
|
1099
|
-
|
1100
|
-
|
1129
|
+
describe "-2 boxes" do
|
1130
|
+
before do
|
1101
1131
|
@db1 = A.boxes[:posts]
|
1102
1132
|
A.box :added1
|
1103
1133
|
A.box :added2
|
@@ -1118,7 +1148,7 @@ class SchemaTest < MiniTest::Spec
|
|
1118
1148
|
@modification = e.modification
|
1119
1149
|
end
|
1120
1150
|
end
|
1121
|
-
|
1151
|
+
it "enable fixing by deleting both fields and renaming a box" do
|
1122
1152
|
action = @modification.actions[0]
|
1123
1153
|
begin
|
1124
1154
|
S.schema.apply(action)
|