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_boxes.rb
CHANGED
@@ -3,18 +3,18 @@
|
|
3
3
|
require File.expand_path('../../test_helper', __FILE__)
|
4
4
|
|
5
5
|
|
6
|
-
|
6
|
+
describe "Boxes" do
|
7
7
|
|
8
|
-
|
8
|
+
before do
|
9
9
|
@site = setup_site
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
after do
|
13
13
|
teardown_site
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
describe "Box definitions" do
|
17
|
+
before do
|
18
18
|
|
19
19
|
class ::MyBoxClass < Box; end
|
20
20
|
class ::MyContentClass < Piece; end
|
@@ -22,147 +22,147 @@ class BoxesTest < MiniTest::Spec
|
|
22
22
|
MyContentClass.field :description
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
after do
|
26
26
|
Object.send(:remove_const, :MyContentClass2) rescue nil
|
27
27
|
Object.send(:remove_const, :MyContentClass) rescue nil
|
28
28
|
Object.send(:remove_const, :MyBoxClass) rescue nil
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
MyContentClass.boxes.length.
|
31
|
+
it "start empty" do
|
32
|
+
MyContentClass.boxes.length.must_equal 0
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
MyContentClass.has_boxes
|
35
|
+
it "have a flag showing there are no defined boxes" do
|
36
|
+
refute MyContentClass.has_boxes?
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
it "be definable with a name" do
|
40
40
|
MyContentClass.box :images0
|
41
|
-
MyContentClass.boxes.length.
|
42
|
-
MyContentClass.boxes.first.name.
|
43
|
-
MyContentClass.has_boxes
|
41
|
+
MyContentClass.boxes.length.must_equal 1
|
42
|
+
MyContentClass.boxes.first.name.must_equal :images0
|
43
|
+
assert MyContentClass.has_boxes?
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
it "have a boolean test for emptiness" do
|
47
47
|
MyContentClass.box :images0
|
48
48
|
instance = MyContentClass.new
|
49
|
-
instance.images0.empty
|
49
|
+
assert instance.images0.empty?
|
50
50
|
instance.images0 << MyContentClass.new
|
51
|
-
instance.images0.empty
|
51
|
+
refute instance.images0.empty?
|
52
52
|
end
|
53
53
|
|
54
|
-
|
54
|
+
it "always return a symbol for the name" do
|
55
55
|
MyContentClass.box 'images0'
|
56
|
-
MyContentClass.boxes.first.name.
|
56
|
+
MyContentClass.boxes.first.name.must_equal :images0
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
it "create a method of the same name" do
|
60
60
|
MyContentClass.box :images1
|
61
61
|
MyContentClass.box :images2, :type => :MyBoxClass
|
62
62
|
instance = MyContentClass.new
|
63
|
-
instance.images1.class.superclass.
|
64
|
-
instance.images2.class.superclass.
|
63
|
+
instance.images1.class.superclass.must_equal Box
|
64
|
+
instance.images2.class.superclass.must_equal MyBoxClass
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
it "be available by name" do
|
68
68
|
MyContentClass.box :images1
|
69
69
|
MyContentClass.box :images2, :type => :MyBoxClass
|
70
|
-
MyContentClass.boxes[:images1].
|
71
|
-
MyContentClass.boxes[:images2].
|
70
|
+
MyContentClass.boxes[:images1].must_equal MyContentClass.boxes.first
|
71
|
+
MyContentClass.boxes[:images2].must_equal MyContentClass.boxes.last
|
72
72
|
instance = MyContentClass.new
|
73
|
-
instance.boxes[:images1].class.superclass.
|
74
|
-
instance.boxes[:images2].class.superclass.
|
73
|
+
instance.boxes[:images1].class.superclass.must_equal Box
|
74
|
+
instance.boxes[:images2].class.superclass.must_equal MyBoxClass
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
it "accept a custom instance class" do
|
78
78
|
MyContentClass.box :images1, :type => MyBoxClass
|
79
|
-
MyContentClass.boxes.first.instance_class.superclass.
|
79
|
+
MyContentClass.boxes.first.instance_class.superclass.must_equal MyBoxClass
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
it "accept a custom instance class as a string" do
|
83
83
|
MyContentClass.box :images1, :type => 'MyBoxClass'
|
84
|
-
MyContentClass.boxes.first.instance_class.superclass.
|
84
|
+
MyContentClass.boxes.first.instance_class.superclass.must_equal MyBoxClass
|
85
85
|
end
|
86
86
|
|
87
|
-
|
87
|
+
it "accept a custom instance class as a symbol" do
|
88
88
|
MyContentClass.box :images1, :type => :MyBoxClass
|
89
|
-
MyContentClass.boxes.first.instance_class.superclass.
|
89
|
+
MyContentClass.boxes.first.instance_class.superclass.must_equal MyBoxClass
|
90
90
|
end
|
91
91
|
|
92
|
-
|
92
|
+
it "Instantiate a box of the correct class" do
|
93
93
|
MyContentClass.box :images1
|
94
94
|
MyContentClass.box :images2, :type => :MyBoxClass
|
95
95
|
instance = MyContentClass.new
|
96
|
-
instance.boxes.first.class.superclass.
|
97
|
-
instance.boxes.last.class.superclass.
|
96
|
+
instance.boxes.first.class.superclass.must_equal Box
|
97
|
+
instance.boxes.last.class.superclass.must_equal MyBoxClass
|
98
98
|
end
|
99
99
|
|
100
|
-
|
100
|
+
it "give access to the prototype within the instance" do
|
101
101
|
MyContentClass.box :images1
|
102
102
|
instance = MyContentClass.new
|
103
|
-
instance.boxes[:images1]._prototype.
|
103
|
+
instance.boxes[:images1]._prototype.must_equal MyContentClass.boxes[:images1]
|
104
104
|
end
|
105
105
|
|
106
|
-
|
106
|
+
it "Use the name as the title by default" do
|
107
107
|
MyContentClass.box :band_and_band
|
108
108
|
MyContentClass.box :related_items
|
109
|
-
MyContentClass.boxes.first.title.
|
110
|
-
MyContentClass.boxes.last.title.
|
109
|
+
MyContentClass.boxes.first.title.must_equal "Band & Band"
|
110
|
+
MyContentClass.boxes.last.title.must_equal "Related Items"
|
111
111
|
end
|
112
112
|
|
113
|
-
|
113
|
+
it "have 'title' option" do
|
114
114
|
MyContentClass.box :images4, :title => "Custom Title"
|
115
|
-
MyContentClass.boxes.first.title.
|
115
|
+
MyContentClass.boxes.first.title.must_equal "Custom Title"
|
116
116
|
end
|
117
117
|
|
118
|
-
|
118
|
+
it "inherit boxes from superclass" do
|
119
119
|
MyContentClass.box :images1, :type => :MyBoxClass
|
120
120
|
MyContentClass2.box :images2
|
121
|
-
MyContentClass2.boxes.length.
|
121
|
+
MyContentClass2.boxes.length.must_equal 2
|
122
122
|
instance = MyContentClass2.new
|
123
|
-
instance.images1.class.superclass.
|
124
|
-
instance.images2.class.superclass.
|
125
|
-
instance.boxes.length.
|
123
|
+
instance.images1.class.superclass.must_equal MyBoxClass
|
124
|
+
instance.images2.class.superclass.must_equal Box
|
125
|
+
instance.boxes.length.must_equal 2
|
126
126
|
end
|
127
127
|
|
128
|
-
|
128
|
+
it "know their ordering in the container" do
|
129
129
|
MyContentClass.box :box1
|
130
130
|
MyContentClass.box :box2
|
131
131
|
MyContentClass.box :box3
|
132
132
|
MyContentClass.box_order :box3, :box2, :box1
|
133
|
-
MyContentClass.boxes.box3.position.
|
134
|
-
MyContentClass.boxes.box2.position.
|
135
|
-
MyContentClass.boxes.box1.position.
|
133
|
+
MyContentClass.boxes.box3.position.must_equal 0
|
134
|
+
MyContentClass.boxes.box2.position.must_equal 1
|
135
|
+
MyContentClass.boxes.box1.position.must_equal 2
|
136
136
|
instance = MyContentClass.new
|
137
|
-
instance.box3.position.
|
138
|
-
instance.box2.position.
|
139
|
-
instance.box1.position.
|
137
|
+
instance.box3.position.must_equal 0
|
138
|
+
instance.box2.position.must_equal 1
|
139
|
+
instance.box1.position.must_equal 2
|
140
140
|
end
|
141
141
|
|
142
|
-
|
143
|
-
|
142
|
+
describe "instances" do
|
143
|
+
it "have a connection to their owner" do
|
144
144
|
MyContentClass.box :box1
|
145
145
|
instance = MyContentClass.new
|
146
|
-
instance.box1.owner.
|
147
|
-
instance.box1.parent.
|
146
|
+
instance.box1.owner.must_equal instance
|
147
|
+
instance.box1.parent.must_equal instance
|
148
148
|
end
|
149
149
|
|
150
|
-
|
150
|
+
it "have a link to their container (which is their owner)" do
|
151
151
|
MyContentClass.box :box1
|
152
152
|
instance = MyContentClass.new
|
153
|
-
instance.box1.container.
|
154
|
-
instance.box1.container.
|
153
|
+
instance.box1.container.must_equal instance
|
154
|
+
instance.box1.container.must_equal instance
|
155
155
|
end
|
156
156
|
|
157
|
-
|
157
|
+
it "return their owner as content_instance" do
|
158
158
|
MyContentClass.box :box1
|
159
159
|
instance = MyContentClass.new
|
160
|
-
instance.box1.content_instance.
|
160
|
+
instance.box1.content_instance.must_equal instance
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
|
-
|
165
|
-
|
164
|
+
describe "ranges" do
|
165
|
+
before do
|
166
166
|
MyContentClass.box :images1
|
167
167
|
MyContentClass.box :images2
|
168
168
|
MyContentClass.box :images3
|
@@ -172,31 +172,23 @@ class BoxesTest < MiniTest::Spec
|
|
172
172
|
@instance = MyContentClass.new
|
173
173
|
@instance2 = MyContentClass2.new
|
174
174
|
end
|
175
|
-
|
176
|
-
@instance.boxes[1..-2].map { |b| b.box_name }.
|
177
|
-
@instance2.boxes[1..-2].map { |b| b.box_name }.
|
175
|
+
it "allow access to groups of boxes through ranges" do
|
176
|
+
@instance.boxes[1..-2].map { |b| b.box_name }.must_equal [:images2, :images3, :images4]
|
177
|
+
@instance2.boxes[1..-2].map { |b| b.box_name }.must_equal [:images2, :images3, :images4, :images5]
|
178
178
|
end
|
179
179
|
|
180
|
-
|
181
|
-
@instance.boxes[:images1, :images4].map { |b| b.box_name }.
|
182
|
-
@instance2.boxes[:images1, :images6].map { |b| b.box_name }.
|
180
|
+
it "allow you to pass a list of names" do
|
181
|
+
@instance.boxes[:images1, :images4].map { |b| b.box_name }.must_equal [:images1, :images4]
|
182
|
+
@instance2.boxes[:images1, :images6].map { |b| b.box_name }.must_equal [:images1, :images6]
|
183
183
|
end
|
184
184
|
|
185
|
-
|
186
|
-
@instance.boxes[0..2, :images5].map { |b| b.box_name }.
|
185
|
+
it "allow a mix of names and indexes" do
|
186
|
+
@instance.boxes[0..2, :images5].map { |b| b.box_name }.must_equal [:images1, :images2, :images3, :images5]
|
187
187
|
end
|
188
|
-
should "allow access to groups of boxes through tags"
|
189
|
-
# MyContentClass.box :images5, :tag => :main
|
190
|
-
# MyContentClass.box :posts, :tag => :main
|
191
|
-
# MyContentClass.box :comments
|
192
|
-
# MyContentClass.box :last, :tag => :main
|
193
|
-
# @instance = MyBoxClass.new
|
194
|
-
# @instance.boxes.tagged(:main).length.should == 3
|
195
|
-
# @instance.boxes.tagged('main').map {|e| e.name }.should == [:images5, :posts, :last]
|
196
|
-
# end
|
197
188
|
end
|
198
|
-
|
199
|
-
|
189
|
+
|
190
|
+
describe "with superclasses" do
|
191
|
+
before do
|
200
192
|
MyContentClass.box :images6, :tag => :main
|
201
193
|
|
202
194
|
@subclass1 = Class.new(MyContentClass) do
|
@@ -207,36 +199,34 @@ class BoxesTest < MiniTest::Spec
|
|
207
199
|
box :peanuts
|
208
200
|
end
|
209
201
|
end
|
210
|
-
|
211
|
-
@subclass2.boxes.length.
|
212
|
-
@subclass2.boxes.map { |s| s.name }.
|
213
|
-
# @subclass2.boxes.tagged(:main).length.
|
202
|
+
it "inherit boxes from its superclass" do
|
203
|
+
@subclass2.boxes.length.must_equal 4
|
204
|
+
@subclass2.boxes.map { |s| s.name }.must_equal [:images6, :monkeys, :apes, :peanuts]
|
205
|
+
# @subclass2.boxes.tagged(:main).length.must_equal 2
|
214
206
|
instance = @subclass2.new
|
215
|
-
instance.boxes.length.
|
207
|
+
instance.boxes.length.must_equal 4
|
216
208
|
end
|
217
209
|
|
218
|
-
|
210
|
+
it "allow customisation of the box order" do
|
219
211
|
new_order = [:peanuts, :apes, :images6, :monkeys]
|
220
212
|
@subclass2.box_order *new_order
|
221
|
-
@subclass2.boxes.map { |s| s.name }.
|
213
|
+
@subclass2.boxes.map { |s| s.name }.must_equal new_order
|
222
214
|
end
|
223
215
|
|
224
|
-
|
216
|
+
it "take order of instance boxes from class defn" do
|
225
217
|
new_order = [:peanuts, :apes, :images6, :monkeys]
|
226
218
|
@subclass2.box_order *new_order
|
227
219
|
instance = @subclass2.new
|
228
|
-
instance.boxes.map { |e| e.box_name.to_sym }.
|
220
|
+
instance.boxes.map { |e| e.box_name.to_sym }.must_equal new_order
|
229
221
|
end
|
230
222
|
end
|
231
223
|
|
232
|
-
|
233
|
-
|
234
|
-
should "accept values for the box's fields"
|
235
|
-
should "allow overwriting of class definitions using a block"
|
224
|
+
it "accept values for the box's fields"
|
225
|
+
it "allow overwriting of class definitions using a block"
|
236
226
|
end
|
237
227
|
|
238
|
-
|
239
|
-
|
228
|
+
describe "Box classes" do
|
229
|
+
before do
|
240
230
|
@site.stubs(:template_root).returns(File.expand_path('../../fixtures/templates/boxes', __FILE__))
|
241
231
|
class ::MyContentClass < ::Piece; end
|
242
232
|
class ::MyBoxClass < Box; end
|
@@ -249,35 +239,35 @@ class BoxesTest < MiniTest::Spec
|
|
249
239
|
@content = MyContentClass.new
|
250
240
|
end
|
251
241
|
|
252
|
-
|
242
|
+
after do
|
253
243
|
Object.send(:remove_const, :MyContentClass) rescue nil
|
254
244
|
Object.send(:remove_const, :MyBoxClass) rescue nil
|
255
245
|
end
|
256
246
|
|
257
|
-
|
258
|
-
MyBoxClass.fields.length.
|
247
|
+
it "have fields" do
|
248
|
+
MyBoxClass.fields.length.must_equal 2
|
259
249
|
MyBoxClass.field :another, :string
|
260
|
-
MyBoxClass.fields.length.
|
250
|
+
MyBoxClass.fields.length.must_equal 3
|
261
251
|
end
|
262
252
|
|
263
|
-
|
253
|
+
describe "with fields" do
|
264
254
|
|
265
|
-
|
255
|
+
it "save their field values" do
|
266
256
|
@content.images.title = "something"
|
267
257
|
@content.images.description = "description here"
|
268
258
|
@content.save
|
269
259
|
@content.reload
|
270
|
-
@content.images.title.value.
|
271
|
-
@content.images.description.value.
|
260
|
+
@content.images.title.value.must_equal "something"
|
261
|
+
@content.images.description.value.must_equal "description here"
|
272
262
|
end
|
273
263
|
|
274
|
-
|
275
|
-
@content.images.title.value.
|
276
|
-
@content.images.description.value.
|
264
|
+
it "take initial values from box definition" do
|
265
|
+
@content.images.title.value.must_equal "Default Title"
|
266
|
+
@content.images.description.value.must_equal "Default Description"
|
277
267
|
end
|
278
268
|
end
|
279
269
|
|
280
|
-
|
270
|
+
it "allow inline definition of fields" do
|
281
271
|
MyContentClass.box :partners do
|
282
272
|
field :name, :string
|
283
273
|
field :logo, :image
|
@@ -289,16 +279,16 @@ class BoxesTest < MiniTest::Spec
|
|
289
279
|
instance.partners.description = "Here is Howard"
|
290
280
|
instance.save
|
291
281
|
instance = Content[instance.id]
|
292
|
-
instance.partners.name.value.
|
293
|
-
instance.partners.description.value.
|
282
|
+
instance.partners.name.value.must_equal "Howard"
|
283
|
+
instance.partners.description.value.must_equal "Here is Howard"
|
294
284
|
end
|
295
285
|
|
296
286
|
# true?
|
297
|
-
|
287
|
+
it "default to template in root with the same name"
|
298
288
|
end
|
299
289
|
|
300
|
-
|
301
|
-
|
290
|
+
describe "Box content" do
|
291
|
+
before do
|
302
292
|
class ::BlankContent < ::Piece; end
|
303
293
|
class ::StyledContent < ::Piece; end
|
304
294
|
|
@@ -319,38 +309,38 @@ class BoxesTest < MiniTest::Spec
|
|
319
309
|
@parent = BlankContent.new
|
320
310
|
end
|
321
311
|
|
322
|
-
|
312
|
+
after do
|
323
313
|
Object.send(:remove_const, :BlankContent) rescue nil
|
324
314
|
Object.send(:remove_const, :StyledContent) rescue nil
|
325
315
|
end
|
326
316
|
|
327
|
-
|
317
|
+
it "be addable" do
|
328
318
|
child1 = BlankContent.new
|
329
319
|
child2 = BlankContent.new
|
330
320
|
child3 = BlankContent.new
|
331
321
|
@parent.images << child1
|
332
322
|
@parent.words << child2
|
333
|
-
child1.box.schema_id.
|
334
|
-
child2.box.schema_id.
|
323
|
+
child1.box.schema_id.must_equal @parent.images.schema_id
|
324
|
+
child2.box.schema_id.must_equal @parent.words.schema_id
|
335
325
|
@parent.save
|
336
326
|
child1.images << child3
|
337
327
|
child1.save
|
338
328
|
@parent = Content[@parent.id]
|
339
329
|
child1.reload; child2.reload; child3.reload
|
340
|
-
@parent.images.contents.
|
341
|
-
@parent.images.contents.
|
342
|
-
@parent.words.contents.
|
343
|
-
@parent.words.contents.
|
344
|
-
@parent.contents.
|
345
|
-
child1.images.contents.
|
346
|
-
child1.contents.
|
330
|
+
@parent.images.contents.must_equal [child1]
|
331
|
+
@parent.images.contents.must_equal [child1]
|
332
|
+
@parent.words.contents.must_equal [child2]
|
333
|
+
@parent.words.contents.must_equal [child2]
|
334
|
+
@parent.contents.to_a.must_equal [child1, child2]
|
335
|
+
child1.images.contents.must_equal [child3]
|
336
|
+
child1.contents.to_a.must_equal [child3]
|
347
337
|
|
348
|
-
@parent.images.contents.first.box.
|
349
|
-
@parent.words.contents.first.box.
|
350
|
-
@parent.contents.first.box.
|
338
|
+
@parent.images.contents.first.box.must_equal @parent.images
|
339
|
+
@parent.words.contents.first.box.must_equal @parent.words
|
340
|
+
@parent.contents.first.box.must_equal @parent.images
|
351
341
|
end
|
352
342
|
|
353
|
-
|
343
|
+
it "choose correct style" do
|
354
344
|
styled = StyledContent.new
|
355
345
|
child1 = BlankContent.new
|
356
346
|
child2 = BlankContent.new
|
@@ -360,11 +350,11 @@ class BoxesTest < MiniTest::Spec
|
|
360
350
|
styled.save
|
361
351
|
styled = Content.get styled.id
|
362
352
|
|
363
|
-
styled.one.contents.first.style.name.
|
364
|
-
styled.two.contents.first.style.name.
|
353
|
+
styled.one.contents.first.style.name.must_equal :blank2
|
354
|
+
styled.two.contents.first.style.name.must_equal :blank3
|
365
355
|
end
|
366
356
|
|
367
|
-
|
357
|
+
it "be insertable at any position" do
|
368
358
|
BlankContent.box :box3
|
369
359
|
BlankContent.box :box4
|
370
360
|
instance = BlankContent.new
|
@@ -373,18 +363,17 @@ class BoxesTest < MiniTest::Spec
|
|
373
363
|
count.times { |n| box << StyledContent.new(:label => n)}
|
374
364
|
end
|
375
365
|
instance.box4.insert(1, StyledContent.new(:label => "a"))
|
376
|
-
instance.box4.contents.map { |e| e.label }.
|
366
|
+
instance.box4.contents.map { |e| e.label }.must_equal ["0", "a", "1", "2", "3"]
|
377
367
|
instance.box4.insert(5, StyledContent.new(:label => "b"))
|
378
|
-
instance.box4.contents.map { |e| e.label }.
|
368
|
+
instance.box4.contents.map { |e| e.label }.must_equal ["0", "a", "1", "2", "3", "b"]
|
379
369
|
instance.box3.insert(2, StyledContent.new(:label => "c"))
|
380
|
-
instance.box3.contents.map { |e| e.label }.
|
370
|
+
instance.box3.contents.map { |e| e.label }.must_equal ["0", "1", "c", "2", "3"]
|
381
371
|
end
|
382
372
|
|
383
|
-
should "allow selection of subclasses"
|
384
373
|
end
|
385
374
|
|
386
|
-
|
387
|
-
|
375
|
+
describe "Allowed types" do
|
376
|
+
before do
|
388
377
|
class ::Allowed1 < Content
|
389
378
|
style :frank
|
390
379
|
style :freddy
|
@@ -424,59 +413,59 @@ class BoxesTest < MiniTest::Spec
|
|
424
413
|
|
425
414
|
end
|
426
415
|
|
427
|
-
|
416
|
+
after do
|
428
417
|
[:Parent, :Allowed1, :Allowed11, :Allowed111, :Allowed2, :Allowed3, :Allowed4, :ChildClass, :Allowable, :Mixed].each { |k| Object.send(:remove_const, k) } rescue nil
|
429
418
|
end
|
430
419
|
|
431
|
-
|
432
|
-
Parent.allowed.length.
|
420
|
+
it "have a list of allowed types" do
|
421
|
+
Parent.allowed.length.must_equal 3
|
433
422
|
end
|
434
423
|
|
435
|
-
|
436
|
-
Parent.allowed[0].instance_class.
|
437
|
-
Parent.allowed[1].instance_class.
|
438
|
-
Parent.allowed[2].instance_class.
|
424
|
+
it "have understood the type parameter" do
|
425
|
+
Parent.allowed[0].instance_class.must_equal Allowed1
|
426
|
+
Parent.allowed[1].instance_class.must_equal Allowed2
|
427
|
+
Parent.allowed[2].instance_class.must_equal Allowed3
|
439
428
|
end
|
440
429
|
|
441
430
|
# TODO: decide on whether testing class definitions is a good idea
|
442
|
-
#
|
431
|
+
# it "raise an error when given an invalid type name" do
|
443
432
|
# lambda { Parent.allow :WhatTheHellIsThis }.must_raise(NameError)
|
444
433
|
# end
|
445
434
|
|
446
|
-
|
447
|
-
Parent.allowed[2].styles(nil).
|
435
|
+
it "allow all styles by default" do
|
436
|
+
Parent.allowed[2].styles(nil).must_equal Allowed3.styles
|
448
437
|
end
|
449
438
|
|
450
|
-
|
451
|
-
Parent.allowed[1].styles(nil).length.
|
452
|
-
Parent.allowed[1].styles(nil).map { |s| s.name }.
|
439
|
+
it "have a list of allowable styles" do
|
440
|
+
Parent.allowed[1].styles(nil).length.must_equal 2
|
441
|
+
Parent.allowed[1].styles(nil).map { |s| s.name }.must_equal [:ringo, :george]
|
453
442
|
end
|
454
443
|
|
455
444
|
# TODO: decide on whether verifying style names is a good idea
|
456
|
-
#
|
445
|
+
# it "raise an error if we try to use an unknown style" do
|
457
446
|
# lambda { Parent.allow :Allowed3, :styles => [:merlin, :arthur] }.must_raise(Spontaneous::UnknownStyleException)
|
458
447
|
# end
|
459
448
|
|
460
|
-
|
449
|
+
it "use a configured style when adding a defined allowed type" do
|
461
450
|
a = Allowable.new
|
462
451
|
b = Allowed2.new
|
463
452
|
a.parents << b
|
464
|
-
a.parents.contents.first.style.prototype.
|
453
|
+
a.parents.contents.first.style.prototype.must_equal Allowed2.styles[:ringo]
|
465
454
|
end
|
466
455
|
|
467
|
-
|
456
|
+
it "know what the available styles are for an entry" do
|
468
457
|
a = Allowable.new
|
469
458
|
b = Allowed2.new
|
470
459
|
c = Allowed3.new
|
471
460
|
a.parents << b
|
472
461
|
a.parents << c
|
473
|
-
a.parents.available_styles(b).map { |s| s.name }.
|
474
|
-
a.parents.available_styles(c).map { |s| s.name }.
|
462
|
+
a.parents.available_styles(b).map { |s| s.name }.must_equal [:ringo, :george]
|
463
|
+
a.parents.available_styles(c).map { |s| s.name }.must_equal [:arthur, :lancelot]
|
475
464
|
end
|
476
465
|
|
477
|
-
|
478
|
-
ChildClass.allowed.
|
479
|
-
Allowable.boxes.parents.allowed_types(nil).
|
466
|
+
it "inherit allowed types from superclass" do
|
467
|
+
ChildClass.allowed.must_equal Parent.allowed
|
468
|
+
Allowable.boxes.parents.allowed_types(nil).must_equal [Allowed1, Allowed2, Allowed3]
|
480
469
|
class ::AChild < Allowable
|
481
470
|
box :parents do
|
482
471
|
allow :Allowed11
|
@@ -488,47 +477,47 @@ class BoxesTest < MiniTest::Spec
|
|
488
477
|
end
|
489
478
|
end
|
490
479
|
box = AChild.boxes.parents
|
491
|
-
box.allowed_types(nil).
|
480
|
+
box.allowed_types(nil).must_equal [Allowed1, Allowed2, Allowed3, Allowed11]
|
492
481
|
box = AChild2.boxes.parents
|
493
|
-
box.title.
|
494
|
-
box.allowed_types(nil).
|
482
|
+
box.title.must_equal "Things"
|
483
|
+
box.allowed_types(nil).must_equal [Allowed1, Allowed2, Allowed3, Allowed11, Allowed111]
|
495
484
|
Object.send(:remove_const, :AChild) rescue nil
|
496
485
|
Object.send(:remove_const, :AChild2) rescue nil
|
497
486
|
end
|
498
487
|
|
499
|
-
|
488
|
+
it "include a subtype's allowed list as well as the supertype's" do
|
500
489
|
ChildClass.allow :Allowed4
|
501
|
-
ChildClass.allowed.map {|a| a.instance_class }.
|
490
|
+
ChildClass.allowed.map {|a| a.instance_class }.must_equal (Parent.allowed.map {|a| a.instance_class } + [Allowed4])
|
502
491
|
end
|
503
492
|
|
504
|
-
|
493
|
+
it "propagate allowed types to slots" do
|
505
494
|
instance = Allowable.new
|
506
|
-
instance.parents.allowed_types.
|
495
|
+
instance.parents.allowed_types.must_equal Parent.allowed_types
|
507
496
|
end
|
508
497
|
|
509
|
-
|
510
|
-
Mixed.allowed_types.
|
498
|
+
it "correctly allow addition of subclasses" do
|
499
|
+
Mixed.allowed_types.must_equal [Allowed11, Allowed111]
|
511
500
|
end
|
512
501
|
|
513
|
-
|
502
|
+
it "create inline classes if passed a definition block" do
|
514
503
|
allowed = ChildClass.allow :InlineType do
|
515
504
|
field :title
|
516
505
|
end
|
517
506
|
inline_type = allowed.instance_class
|
518
|
-
inline_type.fields.length.
|
519
|
-
inline_type.fields.first.name.
|
520
|
-
inline_type.name.
|
507
|
+
inline_type.fields.length.must_equal 1
|
508
|
+
inline_type.fields.first.name.must_equal :title
|
509
|
+
inline_type.name.must_equal "ChildClass::InlineType"
|
521
510
|
end
|
522
511
|
|
523
|
-
|
512
|
+
it "use the given supertype for inline classes" do
|
524
513
|
allowed = ChildClass.allow :InlineType, :supertype => :Allowed1 do
|
525
514
|
field :title
|
526
515
|
end
|
527
516
|
inline_type = allowed.instance_class
|
528
|
-
inline_type.ancestors[0..1].
|
517
|
+
inline_type.ancestors[0..1].must_equal [ChildClass::InlineType, Allowed1]
|
529
518
|
end
|
530
519
|
|
531
|
-
|
520
|
+
it "add the created class to the schema immediately" do
|
532
521
|
allowed = ChildClass.allow :InlineType, :supertype => :Allowed1 do
|
533
522
|
field :title
|
534
523
|
end
|
@@ -536,8 +525,8 @@ class BoxesTest < MiniTest::Spec
|
|
536
525
|
end
|
537
526
|
end
|
538
527
|
|
539
|
-
|
540
|
-
|
528
|
+
describe "Box groups" do
|
529
|
+
before do
|
541
530
|
class ::A < ::Piece
|
542
531
|
box_group :inner do
|
543
532
|
box :a
|
@@ -573,25 +562,36 @@ class BoxesTest < MiniTest::Spec
|
|
573
562
|
@c.boxes[:f].stubs(:render).with(anything).returns("[f]")
|
574
563
|
end
|
575
564
|
|
576
|
-
|
565
|
+
after do
|
577
566
|
Object.send(:remove_const, :A) rescue nil
|
578
567
|
Object.send(:remove_const, :B) rescue nil
|
579
568
|
Object.send(:remove_const, :C) rescue nil
|
580
569
|
end
|
581
570
|
|
582
|
-
|
583
|
-
@a.boxes.inner.
|
584
|
-
@a.boxes.outer.
|
571
|
+
it "successfully allocate boxes" do
|
572
|
+
@a.boxes.inner.must_equal [@a.boxes[:a], @a.boxes[:b]]
|
573
|
+
@a.boxes.outer.must_equal [@a.boxes[:c], @a.boxes[:d]]
|
574
|
+
|
575
|
+
@b.boxes.inner.must_equal [@b.boxes[:a], @b.boxes[:b]]
|
576
|
+
@b.boxes.outer.must_equal [@b.boxes[:c], @b.boxes[:d], @b.boxes[:e]]
|
577
|
+
|
578
|
+
@c.boxes.inner.must_equal [@c.boxes[:a], @c.boxes[:b], @c.boxes[:f]]
|
579
|
+
@c.boxes.outer.must_equal [@c.boxes[:c], @c.boxes[:d], @c.boxes[:e]]
|
580
|
+
end
|
581
|
+
|
582
|
+
it "successfully render groups" do
|
583
|
+
@a.boxes.inner.render.must_equal "[a][b]"
|
584
|
+
@a.boxes.outer.render.must_equal "[c][d]"
|
585
585
|
|
586
|
-
@b.boxes.inner.render.
|
587
|
-
@b.boxes.outer.render.
|
586
|
+
@b.boxes.inner.render.must_equal "[a][b]"
|
587
|
+
@b.boxes.outer.render.must_equal "[c][d][e]"
|
588
588
|
|
589
|
-
@c.boxes.inner.render.
|
590
|
-
@c.boxes.outer.render.
|
589
|
+
@c.boxes.inner.render.must_equal "[a][b][f]"
|
590
|
+
@c.boxes.outer.render.must_equal "[c][d][e]"
|
591
591
|
end
|
592
592
|
|
593
|
-
|
594
|
-
@a.boxes.group(:nothing).
|
593
|
+
it "return an empty array when asking for an unknown box group" do
|
594
|
+
@a.boxes.group(:nothing).must_equal []
|
595
595
|
end
|
596
596
|
end
|
597
597
|
end
|