spontaneous 0.2.0.alpha7 → 0.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -4
- data/Readme.markdown +1 -1
- data/application/css/definitions.css.scss +5 -0
- data/application/css/dialogue.css.scss +62 -0
- data/application/js/content.js +1 -1
- data/application/js/dom.js +1 -1
- data/application/js/event_source.js +3 -0
- data/application/js/{field_types/date_field.js → field/date.js} +2 -2
- data/application/js/{field_types/file_field.js → field/file.js} +2 -2
- data/application/js/{field_types/image_field.js → field/image.js} +54 -20
- data/application/js/{field_types/long_string_field.js → field/long_string.js} +2 -2
- data/application/js/{field_types/markdown_field.js → field/markdown.js} +2 -2
- data/application/js/{field_types/select_field.js → field/select.js} +2 -2
- data/application/js/{field_types/string_field.js → field/string.js} +21 -7
- data/application/js/{field_types/webvideo_field.js → field/webvideo.js} +2 -2
- data/application/js/field.js +2 -2
- data/application/js/publish.js +99 -19
- data/application/js/spontaneous.js +8 -8
- data/application/js/top_bar.js +6 -4
- data/db/migrations/20130109125023_add_page_publish_lock.rb +17 -0
- data/db/migrations/20130111161934_convert_bcrypt_passwords.rb +22 -0
- data/db/migrations/20130114120000_create_revision_tables.rb +106 -0
- data/db/migrations/20130116220423_add_index_to_archive.rb +9 -0
- data/lib/spontaneous/box.rb +53 -18
- data/lib/spontaneous/box_style.rb +2 -3
- data/lib/spontaneous/change.rb +39 -13
- data/lib/spontaneous/cli/fields.rb +29 -0
- data/lib/spontaneous/cli/init.rb +2 -2
- data/lib/spontaneous/cli/migrate.rb +0 -1
- data/lib/spontaneous/cli/server.rb +14 -10
- data/lib/spontaneous/cli/site.rb +20 -9
- data/lib/spontaneous/cli.rb +8 -6
- data/lib/spontaneous/collections/box_set.rb +11 -0
- data/lib/spontaneous/collections/field_set.rb +24 -1
- data/lib/spontaneous/concern.rb +37 -0
- data/lib/spontaneous/config.rb +3 -4
- data/lib/spontaneous/crypt/version.rb +130 -0
- data/lib/spontaneous/crypt.rb +84 -0
- data/lib/spontaneous/data_mapper/content_model/associations.rb +199 -0
- data/lib/spontaneous/data_mapper/content_model/column_accessors.rb +52 -0
- data/lib/spontaneous/data_mapper/content_model/instance_hooks.rb +34 -0
- data/lib/spontaneous/data_mapper/content_model/serialization.rb +54 -0
- data/lib/spontaneous/data_mapper/content_model/timestamps.rb +39 -0
- data/lib/spontaneous/data_mapper/content_model.rb +343 -0
- data/lib/spontaneous/data_mapper/content_table.rb +103 -0
- data/lib/spontaneous/data_mapper/dataset.rb +194 -0
- data/lib/spontaneous/data_mapper/scope.rb +195 -0
- data/lib/spontaneous/data_mapper.rb +161 -0
- data/lib/spontaneous/facet.rb +2 -2
- data/lib/spontaneous/field/base.rb +418 -0
- data/lib/spontaneous/field/date.rb +54 -0
- data/lib/spontaneous/{field_version.rb → field/field_version.rb} +1 -1
- data/lib/spontaneous/field/file.rb +100 -0
- data/lib/spontaneous/{field_types/image_field.rb → field/image.rb} +33 -33
- data/lib/spontaneous/{field_types/location_field.rb → field/location.rb} +2 -2
- data/lib/spontaneous/{field_types/long_string_field.rb → field/long_string.rb} +3 -3
- data/lib/spontaneous/field/markdown.rb +36 -0
- data/lib/spontaneous/{field_types/select_field.rb → field/select.rb} +4 -5
- data/lib/spontaneous/field/string.rb +17 -0
- data/lib/spontaneous/field/update.rb +156 -0
- data/lib/spontaneous/field/webvideo.rb +310 -0
- data/lib/spontaneous/field.rb +80 -0
- data/lib/spontaneous/generators/site/Gemfile.tt +2 -2
- data/lib/spontaneous/generators/site/config/environments/development.rb.tt +1 -1
- data/lib/spontaneous/generators/site/config/environments/production.rb.tt +1 -1
- data/lib/spontaneous/generators/site/lib/content.rb.tt +6 -0
- data/lib/spontaneous/generators/site/schema/box.rb.tt +3 -2
- data/lib/spontaneous/generators/site/schema/page.rb.tt +3 -1
- data/lib/spontaneous/generators/site/schema/piece.rb.tt +3 -1
- data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +3 -1
- data/lib/spontaneous/generators/site.rb +4 -3
- data/lib/spontaneous/image_size.rb +8 -1
- data/lib/spontaneous/layout.rb +5 -1
- data/lib/spontaneous/loader.rb +2 -5
- data/lib/spontaneous/media/file.rb +11 -2
- data/lib/spontaneous/media/temp_file.rb +23 -0
- data/lib/spontaneous/media.rb +20 -39
- data/lib/spontaneous/{plugins → model/box}/allowed_types.rb +38 -17
- data/lib/spontaneous/model/box.rb +18 -0
- data/lib/spontaneous/{plugins → model/core}/aliases.rb +10 -14
- data/lib/spontaneous/{plugins → model/core}/boxes.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/content_groups.rb +2 -2
- data/lib/spontaneous/model/core/editor_class.rb +4 -0
- data/lib/spontaneous/{plugins → model/core}/entries.rb +19 -7
- data/lib/spontaneous/{plugins → model/core}/entry.rb +3 -3
- data/lib/spontaneous/{plugins → model/core}/fields.rb +38 -5
- data/lib/spontaneous/{plugins → model/core}/instance_code.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/media.rb +2 -12
- data/lib/spontaneous/{plugins → model/core}/modifications.rb +7 -6
- data/lib/spontaneous/model/core/page_search.rb +36 -0
- data/lib/spontaneous/{plugins → model/core}/permissions.rb +4 -4
- data/lib/spontaneous/{plugins → model/core}/prototypes.rb +4 -4
- data/lib/spontaneous/{plugins → model/core}/publishing.rb +93 -115
- data/lib/spontaneous/{plugins → model/core}/render.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/schema_hierarchy.rb +7 -11
- data/lib/spontaneous/model/core/schema_id.rb +65 -0
- data/lib/spontaneous/{plugins → model/core}/schema_title.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/serialisation.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/styles.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/supertype.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/visibility.rb +7 -48
- data/lib/spontaneous/model/core.rb +143 -0
- data/lib/spontaneous/{plugins → model/page}/controllers.rb +3 -3
- data/lib/spontaneous/{plugins → model}/page/formats.rb +2 -2
- data/lib/spontaneous/{plugins → model/page}/layouts.rb +2 -2
- data/lib/spontaneous/model/page/locks.rb +14 -0
- data/lib/spontaneous/{plugins → model/page}/page_tree.rb +3 -3
- data/lib/spontaneous/{plugins → model/page}/paths.rb +30 -12
- data/lib/spontaneous/{plugins → model}/page/request.rb +2 -2
- data/lib/spontaneous/{plugins → model/page}/site_map.rb +2 -2
- data/lib/spontaneous/model/page/site_timestamps.rb +44 -0
- data/lib/spontaneous/{page.rb → model/page.rb} +49 -28
- data/lib/spontaneous/{piece.rb → model/piece.rb} +7 -6
- data/lib/spontaneous/model.rb +97 -0
- data/lib/spontaneous/output/context.rb +1 -1
- data/lib/spontaneous/output/format.rb +4 -0
- data/lib/spontaneous/output/template/renderer.rb +2 -2
- data/lib/spontaneous/output.rb +2 -2
- data/lib/spontaneous/page_lock.rb +62 -0
- data/lib/spontaneous/page_piece.rb +1 -1
- data/lib/spontaneous/permissions/access_key.rb +9 -4
- data/lib/spontaneous/permissions/user.rb +19 -9
- data/lib/spontaneous/permissions.rb +2 -5
- data/lib/spontaneous/plugins/application/facets.rb +1 -2
- data/lib/spontaneous/plugins/application/features.rb +1 -1
- data/lib/spontaneous/plugins/application/paths.rb +1 -1
- data/lib/spontaneous/plugins/application/render.rb +1 -1
- data/lib/spontaneous/plugins/application/serialisation.rb +1 -1
- data/lib/spontaneous/plugins/application/state.rb +30 -1
- data/lib/spontaneous/plugins/application/system.rb +12 -12
- data/lib/spontaneous/prototypes/box_prototype.rb +1 -1
- data/lib/spontaneous/prototypes/field_prototype.rb +3 -6
- data/lib/spontaneous/prototypes/style_prototype.rb +1 -1
- data/lib/spontaneous/publishing/immediate.rb +77 -49
- data/lib/spontaneous/publishing/revision.rb +355 -0
- data/lib/spontaneous/publishing/simultaneous.rb +10 -49
- data/lib/spontaneous/publishing.rb +1 -0
- data/lib/spontaneous/rack/around_back.rb +1 -1
- data/lib/spontaneous/rack/around_front.rb +2 -4
- data/lib/spontaneous/rack/around_preview.rb +1 -1
- data/lib/spontaneous/rack/back.rb +80 -63
- data/lib/spontaneous/rack/cacheable_file.rb +2 -2
- data/lib/spontaneous/rack/cookie_authentication.rb +1 -1
- data/lib/spontaneous/rack/front.rb +1 -1
- data/lib/spontaneous/rack/helpers.rb +8 -9
- data/lib/spontaneous/{page_controller.rb → rack/page_controller.rb} +1 -1
- data/lib/spontaneous/rack/public.rb +3 -3
- data/lib/spontaneous/rack.rb +15 -15
- data/lib/spontaneous/schema/uid.rb +4 -1
- data/lib/spontaneous/schema.rb +57 -24
- data/lib/spontaneous/search/database.rb +12 -1
- data/lib/spontaneous/search/index.rb +34 -6
- data/lib/spontaneous/search/results.rb +1 -1
- data/lib/spontaneous/server.rb +3 -3
- data/lib/spontaneous/simultaneous.rb +53 -0
- data/lib/spontaneous/{plugins/site → site}/features.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/helpers.rb +2 -3
- data/lib/spontaneous/{plugins/site → site}/hooks.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/instance.rb +4 -6
- data/lib/spontaneous/{plugins/site → site}/level.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/map.rb +4 -4
- data/lib/spontaneous/{plugins/site → site}/paths.rb +2 -2
- data/lib/spontaneous/site/publishing.rb +89 -0
- data/lib/spontaneous/{plugins/site → site}/schema.rb +4 -4
- data/lib/spontaneous/{plugins/site → site}/search.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/selectors.rb +15 -7
- data/lib/spontaneous/{plugins/site → site}/state.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/storage.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/url.rb +2 -2
- data/lib/spontaneous/site.rb +31 -14
- data/lib/spontaneous/state.rb +5 -6
- data/lib/spontaneous/style.rb +3 -2
- data/lib/spontaneous/utils/database/mysql_dumper.rb +13 -0
- data/lib/spontaneous/utils/database/postgres_dumper.rb +5 -0
- data/lib/spontaneous/version.rb +1 -1
- data/lib/spontaneous.rb +34 -89
- data/spontaneous.gemspec +112 -114
- data/test/experimental/test_crypt.rb +158 -0
- data/test/experimental/test_features.rb +3 -3
- data/test/fixtures/example_application/config/environments/development.rb +1 -1
- data/test/fixtures/example_application/lib/content.rb +5 -0
- data/test/fixtures/example_application/schema/page.rb +2 -1
- data/test/fixtures/example_application/schema/piece.rb +3 -2
- data/test/fixtures/serialisation/class_hash.yaml.erb +5 -5
- data/test/fixtures/serialisation/root_hash.yaml.erb +8 -0
- data/test/functional/test_application.rb +12 -1
- data/test/functional/test_back.rb +80 -48
- data/test/functional/test_front.rb +39 -46
- data/test/functional/test_user_manager.rb +3 -9
- data/test/javascript/test_markdown.rb +2 -2
- data/test/test_helper.rb +78 -23
- data/test/unit/test_alias.rb +21 -15
- data/test/unit/test_asset_bundler.rb +3 -3
- data/test/unit/test_assets.rb +2 -2
- data/test/unit/test_async.rb +7 -6
- data/test/unit/test_authentication.rb +43 -37
- data/test/unit/test_boxes.rb +46 -21
- data/test/unit/test_changesets.rb +65 -20
- data/test/unit/test_config.rb +9 -9
- data/test/unit/test_content.rb +50 -51
- data/test/unit/test_content_inheritance.rb +6 -20
- data/test/unit/test_datamapper.rb +1330 -0
- data/test/unit/test_datamapper_content.rb +214 -0
- data/test/unit/test_fields.rb +543 -54
- data/test/unit/test_formats.rb +2 -3
- data/test/unit/test_generators.rb +6 -6
- data/test/unit/test_helpers.rb +1 -1
- data/test/unit/test_image_size.rb +10 -5
- data/test/unit/test_images.rb +17 -18
- data/test/unit/test_layouts.rb +18 -3
- data/test/unit/test_media.rb +74 -49
- data/test/unit/test_modifications.rb +43 -43
- data/test/unit/test_page.rb +7 -10
- data/test/unit/test_permissions.rb +3 -10
- data/test/unit/test_piece.rb +5 -6
- data/test/unit/test_plugins.rb +7 -14
- data/test/unit/test_prototypes.rb +3 -3
- data/test/unit/test_publishing.rb +49 -27
- data/test/unit/test_render.rb +46 -15
- data/test/unit/test_revisions.rb +124 -127
- data/test/unit/test_schema.rb +53 -58
- data/test/unit/test_search.rb +64 -16
- data/test/unit/test_serialisation.rb +4 -11
- data/test/unit/test_site.rb +11 -12
- data/test/unit/test_structure.rb +2 -5
- data/test/unit/test_styles.rb +22 -24
- data/test/unit/test_type_hierarchy.rb +7 -5
- data/test/unit/test_visibility.rb +79 -55
- metadata +128 -102
- data/lib/sequel/plugins/content_table_inheritance.rb +0 -203
- data/lib/sequel/plugins/scoped_table_name.rb +0 -54
- data/lib/spontaneous/content.rb +0 -129
- data/lib/spontaneous/field_types/date_field.rb +0 -56
- data/lib/spontaneous/field_types/field.rb +0 -302
- data/lib/spontaneous/field_types/file_field.rb +0 -68
- data/lib/spontaneous/field_types/markdown_field.rb +0 -38
- data/lib/spontaneous/field_types/string_field.rb +0 -19
- data/lib/spontaneous/field_types/webvideo_field.rb +0 -313
- data/lib/spontaneous/field_types.rb +0 -38
- data/lib/spontaneous/generators/site/lib/site.rb.tt +0 -4
- data/lib/spontaneous/plugins/field/editor_class.rb +0 -13
- data/lib/spontaneous/plugins/page/site_timestamps.rb +0 -28
- data/lib/spontaneous/plugins/page_search.rb +0 -63
- data/lib/spontaneous/plugins/schema_id.rb +0 -68
- data/lib/spontaneous/plugins/site/publishing.rb +0 -75
- data/lib/spontaneous/rack/fiber_pool.rb +0 -26
- data/test/unit/test_table_scoping.rb +0 -80
data/test/unit/test_styles.rb
CHANGED
@@ -20,26 +20,24 @@ class StylesTest < MiniTest::Spec
|
|
20
20
|
context "styles for" do
|
21
21
|
|
22
22
|
setup do
|
23
|
-
|
24
|
-
class ::Page < Spontaneous::Page; end
|
25
|
-
class ::Piece < Spontaneous::Piece; end
|
26
|
-
class ::Box < Spontaneous::Box; end
|
23
|
+
::Content.delete
|
27
24
|
|
28
25
|
::Page.box :box1
|
29
26
|
|
30
|
-
class ::MissingClass < Piece; end
|
31
|
-
class ::TemplateClass < Piece; end
|
27
|
+
class ::MissingClass < ::Piece; end
|
28
|
+
class ::TemplateClass < ::Piece; end
|
32
29
|
class ::TemplateSubClass1 < TemplateClass; end
|
33
30
|
class ::TemplateSubClass2 < TemplateClass; end
|
34
|
-
class ::InvisibleClass < Piece; end
|
31
|
+
class ::InvisibleClass < ::Piece; end
|
35
32
|
end
|
36
33
|
|
37
34
|
teardown do
|
38
|
-
|
39
|
-
Object.send(:remove_const, :MissingClass)
|
40
|
-
Object.send(:remove_const, :TemplateClass)
|
41
|
-
Object.send(:remove_const, :TemplateSubClass1)
|
42
|
-
Object.send(:remove_const, :TemplateSubClass2)
|
35
|
+
::Content.delete
|
36
|
+
Object.send(:remove_const, :MissingClass) rescue nil
|
37
|
+
Object.send(:remove_const, :TemplateClass) rescue nil
|
38
|
+
Object.send(:remove_const, :TemplateSubClass1) rescue nil
|
39
|
+
Object.send(:remove_const, :TemplateSubClass2) rescue nil
|
40
|
+
Object.send(:remove_const, :InvisibleClass) rescue nil
|
43
41
|
end
|
44
42
|
|
45
43
|
context "pieces" do
|
@@ -286,14 +284,14 @@ class StylesTest < MiniTest::Spec
|
|
286
284
|
end
|
287
285
|
|
288
286
|
teardown do
|
289
|
-
Object.send(:remove_const, :InlineTemplateClass)
|
287
|
+
Object.send(:remove_const, :InlineTemplateClass) rescue nil
|
290
288
|
end
|
291
289
|
|
292
290
|
should "be used to render the content" do
|
293
291
|
@a.render.should == "html: Total Title"
|
294
292
|
end
|
295
293
|
|
296
|
-
should "be used to render the content with the right format
|
294
|
+
should "be used to render the content with the right format" do
|
297
295
|
@a.render(:pdf).should == "pdf: Total Title"
|
298
296
|
end
|
299
297
|
end
|
@@ -344,13 +342,13 @@ class StylesTest < MiniTest::Spec
|
|
344
342
|
|
345
343
|
context "boxes" do
|
346
344
|
setup do
|
347
|
-
class ::BoxA <
|
348
|
-
class ::BoxB <
|
345
|
+
class ::BoxA < ::Box; end
|
346
|
+
class ::BoxB < ::Box; end
|
349
347
|
end
|
350
348
|
|
351
349
|
teardown do
|
352
|
-
Object.send(:remove_const, :BoxA)
|
353
|
-
Object.send(:remove_const, :BoxB)
|
350
|
+
Object.send(:remove_const, :BoxA) rescue nil
|
351
|
+
Object.send(:remove_const, :BoxB) rescue nil
|
354
352
|
end
|
355
353
|
|
356
354
|
context "anonymous boxes" do
|
@@ -372,7 +370,7 @@ class StylesTest < MiniTest::Spec
|
|
372
370
|
@piece.entities << TemplateClass.new
|
373
371
|
@piece.entities << TemplateClass.new
|
374
372
|
@piece.entities.render.should == "template_class.html.cut\n\ntemplate_class.html.cut\n"
|
375
|
-
@piece.entities.style.template.call.should == '
|
373
|
+
@piece.entities.style.template.call.should == '${ render_content }'
|
376
374
|
end
|
377
375
|
|
378
376
|
|
@@ -394,7 +392,7 @@ class StylesTest < MiniTest::Spec
|
|
394
392
|
@piece.dongles.render.should == "named2.html.cut\n"
|
395
393
|
end
|
396
394
|
|
397
|
-
should "use styles assigned in a subclass" do
|
395
|
+
should "use styles assigned in a subclass xxx" do
|
398
396
|
::TemplateSubClass = Class.new(TemplateClass)
|
399
397
|
::TemplateSubSubClass = Class.new(TemplateSubClass)
|
400
398
|
|
@@ -432,8 +430,8 @@ class StylesTest < MiniTest::Spec
|
|
432
430
|
end
|
433
431
|
|
434
432
|
|
435
|
-
Object.send(:remove_const, :TemplateSubClass)
|
436
|
-
Object.send(:remove_const, :TemplateSubSubClass)
|
433
|
+
Object.send(:remove_const, :TemplateSubClass) rescue nil
|
434
|
+
Object.send(:remove_const, :TemplateSubSubClass) rescue nil
|
437
435
|
end
|
438
436
|
end
|
439
437
|
|
@@ -466,8 +464,8 @@ class StylesTest < MiniTest::Spec
|
|
466
464
|
piece = TemplateSubClass.new
|
467
465
|
@page.box1 << piece
|
468
466
|
assert_correct_template(piece.lastly, @template_root / 'box_a')
|
469
|
-
Object.send(:remove_const, :BoxASubclass)
|
470
|
-
Object.send(:remove_const, :TemplateSubClass)
|
467
|
+
Object.send(:remove_const, :BoxASubclass) rescue nil
|
468
|
+
Object.send(:remove_const, :TemplateSubClass) rescue nil
|
471
469
|
end
|
472
470
|
|
473
471
|
context "with configured styles" do
|
@@ -5,7 +5,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
5
5
|
|
6
6
|
class TypeHierarchyTest < MiniTest::Spec
|
7
7
|
|
8
|
-
|
9
8
|
def setup
|
10
9
|
@site = setup_site
|
11
10
|
end
|
@@ -16,17 +15,20 @@ class TypeHierarchyTest < MiniTest::Spec
|
|
16
15
|
|
17
16
|
context "Content" do
|
18
17
|
should "have an empty supertype" do
|
19
|
-
|
20
|
-
|
18
|
+
::Content.supertype.should be_nil
|
19
|
+
::Content.supertype?.should be_false
|
21
20
|
end
|
22
21
|
end
|
23
22
|
context "Schema classes" do
|
24
23
|
setup do
|
25
|
-
class SchemaClass <
|
24
|
+
class SchemaClass < ::Piece
|
26
25
|
end
|
27
26
|
end
|
27
|
+
teardown do
|
28
|
+
self.class.send :remove_const, :SchemaClass
|
29
|
+
end
|
28
30
|
should "have a reference to their super type" do
|
29
|
-
SchemaClass.supertype.should ==
|
31
|
+
SchemaClass.supertype.should == ::Piece
|
30
32
|
end
|
31
33
|
|
32
34
|
should "know what file they were defined in" do
|
@@ -6,52 +6,79 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
6
6
|
class VisibilityTest < MiniTest::Spec
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
|
10
|
+
def self.startup
|
10
11
|
@site = setup_site
|
12
|
+
Object.const_set :R, Class.new(Page)
|
13
|
+
Object.const_set :P, Class.new(Page)
|
14
|
+
Object.const_set :E, Class.new(Piece)
|
15
|
+
Object.const_set :MyAlias, Class.new(Piece)
|
16
|
+
::R.box :pages
|
17
|
+
# class ::R < Page; end
|
18
|
+
# class ::P < Page; end
|
19
|
+
P.box :things
|
20
|
+
# class ::E < Piece; end
|
21
|
+
E.box :pages
|
22
|
+
MyAlias.alias_of ::E
|
23
|
+
|
24
|
+
Content.delete
|
25
|
+
|
26
|
+
@root = R.new(:uid => 'root')
|
27
|
+
2.times do |i|
|
28
|
+
c = P.new(:uid => i, :slug => "#{i}")
|
29
|
+
@root.pages << c
|
30
|
+
4.times do |j|
|
31
|
+
d = E.new(:uid => "#{i}.#{j}")
|
32
|
+
c.things << d
|
33
|
+
2.times do |k|
|
34
|
+
e = P.new(:uid => "#{i}.#{j}.#{k}", :slug => "#{i}-#{j}-#{k}")
|
35
|
+
d.pages << e
|
36
|
+
2.times do |l|
|
37
|
+
e.things << E.new(:uid => "#{i}.#{j}.#{k}.#{l}")
|
38
|
+
end
|
39
|
+
e.save
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
@root.save
|
44
|
+
@root.reload
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.shutdown
|
48
|
+
Content.delete
|
49
|
+
Object.send(:remove_const, :R)
|
50
|
+
Object.send(:remove_const, :P)
|
51
|
+
Object.send(:remove_const, :E)
|
52
|
+
Object.send(:remove_const, :MyAlias)
|
53
|
+
teardown_site(true, true)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.site
|
57
|
+
@site
|
58
|
+
end
|
59
|
+
|
60
|
+
def setup
|
61
|
+
Content.count.should == 59
|
62
|
+
@site = self.class.site
|
63
|
+
@root = Content.root
|
64
|
+
@child = Page.uid("0")
|
11
65
|
end
|
12
66
|
|
13
67
|
def teardown
|
14
|
-
|
68
|
+
Content.update(:hidden => false, :hidden_origin => nil)
|
69
|
+
teardown_site(false, false)
|
15
70
|
end
|
16
71
|
|
17
72
|
context "Content" do
|
18
73
|
setup do
|
19
|
-
Content.delete
|
20
|
-
class ::R < Page; end
|
21
|
-
R.box :pages
|
22
|
-
class ::P < Page; end
|
23
|
-
P.box :things
|
24
|
-
class ::E < Piece; end
|
25
|
-
E.box :pages
|
26
|
-
|
27
|
-
@root = R.new(:uid => 'root')
|
28
|
-
2.times do |i|
|
29
|
-
c = P.new(:uid => i, :slug => "#{i}")
|
30
|
-
@root.pages << c
|
31
|
-
4.times do |j|
|
32
|
-
d = E.new(:uid => "#{i}.#{j}")
|
33
|
-
c.things << d
|
34
|
-
2.times do |k|
|
35
|
-
e = P.new(:uid => "#{i}.#{j}.#{k}", :slug => "#{i}-#{j}-#{k}")
|
36
|
-
d.pages << e
|
37
|
-
2.times do |l|
|
38
|
-
e.things << E.new(:uid => "#{i}.#{j}.#{k}.#{l}")
|
39
|
-
end
|
40
|
-
e.save
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
@root.save
|
45
|
-
@root.reload
|
46
|
-
@child = Page.uid("0")
|
47
74
|
end
|
48
75
|
|
49
76
|
teardown do
|
50
|
-
[:R, :P, :E].each do |k|
|
51
|
-
|
52
|
-
end
|
53
|
-
Spontaneous.database.logger = nil
|
54
|
-
Content.delete
|
77
|
+
# [:R, :P, :E].each do |k|
|
78
|
+
# Object.send(:remove_const, k)
|
79
|
+
# end
|
80
|
+
# Spontaneous.database.logger = nil
|
81
|
+
# Content.delete
|
55
82
|
end
|
56
83
|
|
57
84
|
should "be visible by default" do
|
@@ -83,10 +110,10 @@ class VisibilityTest < MiniTest::Spec
|
|
83
110
|
end
|
84
111
|
end
|
85
112
|
|
86
|
-
should "hide page content" do
|
113
|
+
should "hide page content xxx" do
|
87
114
|
@child.hide!
|
88
115
|
@child.reload
|
89
|
-
Piece.all.select { |f| f.visible? }.length.should == 20
|
116
|
+
Content::Piece.all.select { |f| f.visible? }.length.should == 20
|
90
117
|
Piece.all.select do |f|
|
91
118
|
f.page.ancestors.include?(@child) || f.page == @child
|
92
119
|
end.each do |f|
|
@@ -134,7 +161,7 @@ class VisibilityTest < MiniTest::Spec
|
|
134
161
|
c.hidden_origin.should be_nil
|
135
162
|
end
|
136
163
|
end
|
137
|
-
|
164
|
+
f.destroy
|
138
165
|
end
|
139
166
|
|
140
167
|
should "re-show all descendents of page content" do
|
@@ -198,6 +225,7 @@ class VisibilityTest < MiniTest::Spec
|
|
198
225
|
piece.hidden?.should be_true
|
199
226
|
page.show!
|
200
227
|
piece.reload.hidden?.should be_false
|
228
|
+
piece.destroy
|
201
229
|
end
|
202
230
|
|
203
231
|
context "root" do
|
@@ -216,20 +244,11 @@ class VisibilityTest < MiniTest::Spec
|
|
216
244
|
end
|
217
245
|
end
|
218
246
|
context "visibility scoping" do
|
219
|
-
setup do
|
220
|
-
# S.database.logger = ::Logger.new($stdout)
|
221
|
-
end
|
222
|
-
|
223
|
-
teardown do
|
224
|
-
# S.database.logger = nil
|
225
|
-
end
|
226
|
-
|
227
247
|
should "prevent inclusion of hidden content" do
|
228
248
|
@uid = '0'
|
229
249
|
@page = Page.uid(@uid)
|
230
250
|
@page.hide!
|
231
251
|
@page.reload
|
232
|
-
# Spontaneous.database.logger = ::Logger.new($stdout)
|
233
252
|
Page.path("/0").should == @page
|
234
253
|
Content.with_visible do
|
235
254
|
Content.visible_only?.should be_true
|
@@ -258,7 +277,9 @@ class VisibilityTest < MiniTest::Spec
|
|
258
277
|
Content.with_visible do
|
259
278
|
# would like to make sure we're raising a predictable error
|
260
279
|
# but 1.9 changes the typeerror to a runtime error
|
261
|
-
|
280
|
+
p = Piece.new
|
281
|
+
lambda { page.things << p }.must_raise(TypeError, RuntimeError)
|
282
|
+
p.destroy
|
262
283
|
end
|
263
284
|
end
|
264
285
|
|
@@ -283,16 +304,15 @@ class VisibilityTest < MiniTest::Spec
|
|
283
304
|
|
284
305
|
context "aliases" do
|
285
306
|
setup do
|
286
|
-
class ::MyAlias < Piece; end
|
287
|
-
MyAlias.alias_of ::E
|
288
307
|
end
|
289
308
|
|
290
309
|
teardown do
|
291
|
-
|
310
|
+
MyAlias.delete
|
292
311
|
end
|
293
312
|
|
294
313
|
should "be initalized as invisible if their target is invisible" do
|
295
|
-
target = E.
|
314
|
+
target = E.create(:uid => "X")
|
315
|
+
target.destroy
|
296
316
|
target.hide!
|
297
317
|
al = MyAlias.create(:target => target)
|
298
318
|
al.visible?.should be_false
|
@@ -300,7 +320,7 @@ class VisibilityTest < MiniTest::Spec
|
|
300
320
|
|
301
321
|
|
302
322
|
should "be made visible along with their target if added when target is hidden" do
|
303
|
-
target = E.
|
323
|
+
target = E.first(:uid => "1.1")
|
304
324
|
target.hide!
|
305
325
|
al = MyAlias.create(:target => target)
|
306
326
|
al.reload.visible?.should be_false
|
@@ -310,7 +330,7 @@ class VisibilityTest < MiniTest::Spec
|
|
310
330
|
|
311
331
|
should "be filtered by visibility when doing reverse lookup" do
|
312
332
|
page = P.first(:uid => "1")
|
313
|
-
target = E.
|
333
|
+
target = E.first(:uid => "1.1")
|
314
334
|
al1 = MyAlias.create(:target => target)
|
315
335
|
page.things << al1
|
316
336
|
al2 = MyAlias.create(:target => target).reload
|
@@ -318,6 +338,9 @@ class VisibilityTest < MiniTest::Spec
|
|
318
338
|
al1.hide!
|
319
339
|
al1.reload
|
320
340
|
al2.reload
|
341
|
+
target.reload
|
342
|
+
sort = proc { |e1, e2| e1.id <=> e2.id }
|
343
|
+
al = target.aliases.sort(&sort)
|
321
344
|
Set.new(target.aliases).should == Set.new([al1, al2])
|
322
345
|
target.reload
|
323
346
|
Content.with_visible do
|
@@ -326,13 +349,14 @@ class VisibilityTest < MiniTest::Spec
|
|
326
349
|
end
|
327
350
|
|
328
351
|
should "show as 'hidden' if their target is deleted" do
|
329
|
-
parent = E.
|
352
|
+
parent = E.first(:uid => "1.1")
|
330
353
|
target = P.new
|
331
354
|
parent.pages << target
|
332
355
|
parent.save
|
333
356
|
al1 = MyAlias.create(:target => target)
|
334
357
|
P.filter(:id => target.id).delete
|
335
358
|
al1.reload.visible?.should be_false
|
359
|
+
target.destroy
|
336
360
|
end
|
337
361
|
end
|
338
362
|
end
|