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_schema.rb
CHANGED
@@ -4,12 +4,11 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
4
4
|
|
5
5
|
|
6
6
|
class SchemaTest < MiniTest::Spec
|
7
|
-
include Spontaneous
|
8
|
-
|
9
|
-
|
10
7
|
def setup
|
11
8
|
@site = setup_site
|
12
9
|
@site.schema_loader_class = Spontaneous::Schema::PersistentMap
|
10
|
+
S::Permissions::UserLevel.reset!
|
11
|
+
S::Permissions::UserLevel.stubs(:level_file).returns(File.expand_path('../../fixtures/permissions', __FILE__) / 'config/user_levels.yml')
|
13
12
|
end
|
14
13
|
|
15
14
|
def teardown
|
@@ -18,9 +17,9 @@ class SchemaTest < MiniTest::Spec
|
|
18
17
|
|
19
18
|
context "Configurable names" do
|
20
19
|
setup do
|
21
|
-
class ::FunkyContent <
|
20
|
+
class ::FunkyContent < Piece; end
|
22
21
|
class ::MoreFunkyContent < FunkyContent; end
|
23
|
-
class ::ABCDifficultName <
|
22
|
+
class ::ABCDifficultName < Piece; end
|
24
23
|
|
25
24
|
class ::CustomName < ABCDifficultName
|
26
25
|
title "Some Name"
|
@@ -68,8 +67,10 @@ class SchemaTest < MiniTest::Spec
|
|
68
67
|
layout :clean
|
69
68
|
box :posts
|
70
69
|
end
|
70
|
+
# force loading of map
|
71
|
+
@site.schema.map
|
71
72
|
@instance = SchemaClass.new
|
72
|
-
@uids = @site.
|
73
|
+
@uids = @site.schema.uids
|
73
74
|
end
|
74
75
|
|
75
76
|
teardown do
|
@@ -81,7 +82,7 @@ class SchemaTest < MiniTest::Spec
|
|
81
82
|
# end
|
82
83
|
|
83
84
|
should "be unique" do
|
84
|
-
ids = (0..10000).map { Schema::UIDMap.generate }
|
85
|
+
ids = (0..10000).map { S::Schema::UIDMap.generate }
|
85
86
|
ids.uniq.length.should == ids.length
|
86
87
|
end
|
87
88
|
|
@@ -146,19 +147,19 @@ class SchemaTest < MiniTest::Spec
|
|
146
147
|
|
147
148
|
context "lookups" do
|
148
149
|
should "return classes" do
|
149
|
-
Site.schema
|
150
|
+
Site.schema.to_class("xxxxxxxxxxxx").should == SchemaClass
|
150
151
|
end
|
151
152
|
should "return fields" do
|
152
|
-
Site.schema
|
153
|
+
Site.schema.to_class("ffffffffffff").should == SchemaClass.field_prototypes[:description]
|
153
154
|
end
|
154
155
|
should "return boxes" do
|
155
|
-
Site.schema
|
156
|
+
Site.schema.to_class("bbbbbbbbbbbb").should == SchemaClass.box_prototypes[:posts]
|
156
157
|
end
|
157
158
|
should "return styles" do
|
158
|
-
Site.schema
|
159
|
+
Site.schema.to_class("ssssssssssss").should == SchemaClass.style_prototypes[:simple]
|
159
160
|
end
|
160
161
|
should "return layouts" do
|
161
|
-
Site.schema
|
162
|
+
Site.schema.to_class("llllllllllll").should == SchemaClass.layout_prototypes[:clean]
|
162
163
|
end
|
163
164
|
end
|
164
165
|
|
@@ -167,12 +168,10 @@ class SchemaTest < MiniTest::Spec
|
|
167
168
|
context "schema verification" do
|
168
169
|
setup do
|
169
170
|
@site.schema.schema_map_file = File.expand_path('../../fixtures/schema/before.yml', __FILE__)
|
170
|
-
|
171
|
-
field :title
|
172
|
-
end
|
171
|
+
Page.field :title
|
173
172
|
class B < ::Page; end
|
174
|
-
class C <
|
175
|
-
class D <
|
173
|
+
class C < Piece; end
|
174
|
+
class D < Piece; end
|
176
175
|
class O < Box; end
|
177
176
|
B.field :description
|
178
177
|
B.field :author
|
@@ -199,6 +198,7 @@ class SchemaTest < MiniTest::Spec
|
|
199
198
|
# between tests
|
200
199
|
# Schema.stubs(:classes).returns([B, C, D, O])
|
201
200
|
# Schema.classes.should == [B, C, D, O]
|
201
|
+
@site.schema.map
|
202
202
|
@uids = @site.schema.uids
|
203
203
|
::Page.schema_id.should == @uids["tttttttttttt"]
|
204
204
|
B.schema_id.should == @uids["bbbbbbbbbbbb"]
|
@@ -224,7 +224,7 @@ class SchemaTest < MiniTest::Spec
|
|
224
224
|
end
|
225
225
|
|
226
226
|
should "detect addition of classes" do
|
227
|
-
class E <
|
227
|
+
class E < ::Piece; end
|
228
228
|
@site.schema.stubs(:classes).returns([B, C, D, E])
|
229
229
|
exception = nil
|
230
230
|
begin
|
@@ -477,8 +477,8 @@ class SchemaTest < MiniTest::Spec
|
|
477
477
|
context "Transient (testing) maps" do
|
478
478
|
setup do
|
479
479
|
@site.schema.schema_loader_class = Spontaneous::Schema::TransientMap
|
480
|
-
class V <
|
481
|
-
class W <
|
480
|
+
class V < ::Piece; end
|
481
|
+
class W < ::Piece; end
|
482
482
|
end
|
483
483
|
teardown do
|
484
484
|
self.class.send(:remove_const, :V)
|
@@ -503,7 +503,7 @@ class SchemaTest < MiniTest::Spec
|
|
503
503
|
|
504
504
|
context "for inherited boxes" do
|
505
505
|
setup do
|
506
|
-
class ::A <
|
506
|
+
class ::A < ::Piece
|
507
507
|
box :a
|
508
508
|
end
|
509
509
|
class ::B < ::A
|
@@ -529,13 +529,13 @@ class SchemaTest < MiniTest::Spec
|
|
529
529
|
|
530
530
|
context "Schema groups" do
|
531
531
|
setup do
|
532
|
-
class ::A <
|
532
|
+
class ::A < ::Page
|
533
533
|
group :a, :b, :c
|
534
534
|
box :cgroup do
|
535
535
|
allow_group :c
|
536
536
|
end
|
537
537
|
end
|
538
|
-
class ::B <
|
538
|
+
class ::B < ::Piece
|
539
539
|
group :b, :c
|
540
540
|
style :fish
|
541
541
|
style :frog
|
@@ -544,7 +544,7 @@ class SchemaTest < MiniTest::Spec
|
|
544
544
|
allow_groups :a, :c
|
545
545
|
end
|
546
546
|
end
|
547
|
-
class ::C <
|
547
|
+
class ::C < ::Piece
|
548
548
|
group :c
|
549
549
|
|
550
550
|
box :bgroup do
|
@@ -571,10 +571,13 @@ class SchemaTest < MiniTest::Spec
|
|
571
571
|
|
572
572
|
should "apply the options to all the included classes" do
|
573
573
|
user = mock()
|
574
|
+
S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.editor).returns(true)
|
574
575
|
S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.root).returns(true)
|
575
|
-
|
576
|
+
C.boxes.cgroup.allowed_types(user).should == [A, B, C]
|
577
|
+
S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.editor).returns(true)
|
576
578
|
S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.root).returns(false)
|
577
|
-
|
579
|
+
C.boxes.cgroup.allowed_types(user).should == []
|
580
|
+
A.boxes.cgroup.allowed_types(user).should == [A, B, C]
|
578
581
|
end
|
579
582
|
|
580
583
|
should "allow for configuring styles" do
|
@@ -591,7 +594,7 @@ class SchemaTest < MiniTest::Spec
|
|
591
594
|
@site.schema.delete(::B)
|
592
595
|
Object.send(:remove_const, :B)
|
593
596
|
|
594
|
-
class ::B <
|
597
|
+
class ::B < ::Piece
|
595
598
|
group :b
|
596
599
|
style :fish
|
597
600
|
style :frog
|
@@ -612,7 +615,7 @@ class SchemaTest < MiniTest::Spec
|
|
612
615
|
context "Map writing" do
|
613
616
|
context "Non-existant maps" do
|
614
617
|
def expected_schema
|
615
|
-
classes = [ ::A, ::B]
|
618
|
+
classes = @site.schema.classes#[ Content::Page, Page, Content::Piece, Piece, ::A, ::B]
|
616
619
|
expected = Hash[ classes.map { |klass| [ klass.schema_id.to_s, klass.schema_name ] } ]
|
617
620
|
expected.merge!({
|
618
621
|
A.field_prototypes[:title].schema_id.to_s => A.field_prototypes[:title].schema_name,
|
@@ -632,7 +635,7 @@ class SchemaTest < MiniTest::Spec
|
|
632
635
|
::FileUtils.rm_f(@map_file) if ::File.exists?(@map_file)
|
633
636
|
|
634
637
|
@site.schema.schema_map_file = @map_file
|
635
|
-
class ::A <
|
638
|
+
class ::A < ::Page
|
636
639
|
field :title
|
637
640
|
field :introduction
|
638
641
|
layout :sparse
|
@@ -640,7 +643,7 @@ class SchemaTest < MiniTest::Spec
|
|
640
643
|
field :description
|
641
644
|
end
|
642
645
|
end
|
643
|
-
class ::B <
|
646
|
+
class ::B < ::Piece
|
644
647
|
field :location
|
645
648
|
style :daring
|
646
649
|
end
|
@@ -678,7 +681,7 @@ class SchemaTest < MiniTest::Spec
|
|
678
681
|
FileUtils.mkdir_p(File.dirname(@map_file))
|
679
682
|
FileUtils.cp(File.expand_path('../../fixtures/schema/resolvable.yml', __FILE__), @map_file)
|
680
683
|
@site.schema.schema_map_file = @map_file
|
681
|
-
class ::A <
|
684
|
+
class ::A < ::Page
|
682
685
|
field :title
|
683
686
|
field :introduction
|
684
687
|
layout :sparse
|
@@ -686,7 +689,7 @@ class SchemaTest < MiniTest::Spec
|
|
686
689
|
field :description
|
687
690
|
end
|
688
691
|
end
|
689
|
-
class ::B <
|
692
|
+
class ::B < ::Piece
|
690
693
|
field :location
|
691
694
|
field :duration
|
692
695
|
style :daring
|
@@ -700,26 +703,10 @@ class SchemaTest < MiniTest::Spec
|
|
700
703
|
Object.send(:remove_const, :B) rescue nil
|
701
704
|
Object.send(:remove_const, :X) rescue nil
|
702
705
|
Object.send(:remove_const, :Y) rescue nil
|
703
|
-
|
706
|
+
::Content.delete
|
704
707
|
FileUtils.rm(@map_file) if ::File.exists?(@map_file) rescue nil
|
705
708
|
end
|
706
709
|
|
707
|
-
should "update the STI map after addition of classes" do
|
708
|
-
::A.sti_subclasses_array.should == [::A.schema_id.to_s]
|
709
|
-
class ::X < ::A
|
710
|
-
field :wild
|
711
|
-
box :monkeys do
|
712
|
-
field :banana
|
713
|
-
end
|
714
|
-
layout :rich
|
715
|
-
end
|
716
|
-
S.schema.validate!
|
717
|
-
::X.schema_id.should_not be_nil
|
718
|
-
::X.sti_key_array.should == [::X.schema_id.to_s]
|
719
|
-
::A.sti_subclasses_array.should == [::A.schema_id.to_s, ::X.schema_id.to_s]
|
720
|
-
end
|
721
|
-
|
722
|
-
|
723
710
|
should "be done automatically if only additions are found" do
|
724
711
|
A.field :moose
|
725
712
|
class ::X < ::A
|
@@ -760,7 +747,12 @@ class SchemaTest < MiniTest::Spec
|
|
760
747
|
|
761
748
|
should "be done automatically if only boxes have been removed" do
|
762
749
|
uid = A.boxes[:posts].schema_id.to_s
|
763
|
-
|
750
|
+
Object.send :remove_const, :A
|
751
|
+
class ::A < ::Page
|
752
|
+
field :title
|
753
|
+
field :introduction
|
754
|
+
layout :sparse
|
755
|
+
end
|
764
756
|
S.schema.stubs(:classes).returns([A, B])
|
765
757
|
S.schema.reload!
|
766
758
|
S.schema.validate!
|
@@ -768,12 +760,15 @@ class SchemaTest < MiniTest::Spec
|
|
768
760
|
m.key?(uid).should be_false
|
769
761
|
end
|
770
762
|
|
771
|
-
should "be done automatically if only fields have been removed" do
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
A
|
776
|
-
|
763
|
+
should "be done automatically if only fields have been removed xxx" do
|
764
|
+
uid = A.fields[:title].schema_id.to_s
|
765
|
+
S.schema.delete(::A)
|
766
|
+
Object.send :remove_const, :A
|
767
|
+
class ::A < ::Page
|
768
|
+
field :introduction
|
769
|
+
layout :sparse
|
770
|
+
box(:posts) { field :description }
|
771
|
+
end
|
777
772
|
S.schema.reload!
|
778
773
|
S.schema.validate!
|
779
774
|
m = YAML.load_file(@map_file)
|
@@ -880,7 +875,7 @@ class SchemaTest < MiniTest::Spec
|
|
880
875
|
instance.posts << piece1
|
881
876
|
instance.posts << piece2
|
882
877
|
instance.save
|
883
|
-
instance =
|
878
|
+
instance = Content[instance.id]
|
884
879
|
instance.posts.contents.length.should == 2
|
885
880
|
Content.count.should == 3
|
886
881
|
uid = A.boxes[:posts].schema_id.to_s
|
@@ -889,7 +884,7 @@ class SchemaTest < MiniTest::Spec
|
|
889
884
|
S.schema.reload!
|
890
885
|
S.schema.validate!
|
891
886
|
Content.count.should == 1
|
892
|
-
|
887
|
+
Content[instance.id].should == instance
|
893
888
|
end
|
894
889
|
|
895
890
|
context "which isn't automatically resolvable" do
|
data/test/unit/test_search.rb
CHANGED
@@ -27,13 +27,13 @@ class SearchTest < MiniTest::Spec
|
|
27
27
|
|
28
28
|
def self.startup
|
29
29
|
# make sure that S::Piece & S::Page are removed from the schema
|
30
|
-
setup_site
|
31
|
-
*ids = S::Page.schema_id, S::Piece.schema_id
|
32
|
-
Object.const_set(:Site, Class.new(S::Site))
|
30
|
+
# setup_site
|
31
|
+
# *ids = S::Page.schema_id, S::Piece.schema_id
|
32
|
+
# Object.const_set(:Site, Class.new(S::Site))
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.shutdown
|
36
|
-
Object.send(:remove_const, :Site) rescue nil
|
36
|
+
# Object.send(:remove_const, :Site) rescue nil
|
37
37
|
end
|
38
38
|
|
39
39
|
def setup
|
@@ -49,8 +49,8 @@ class SearchTest < MiniTest::Spec
|
|
49
49
|
Content.delete
|
50
50
|
|
51
51
|
|
52
|
-
class ::Piece < S::Piece; end
|
53
|
-
class ::Page < S::Page; end
|
52
|
+
# class ::Piece < S::Piece; end
|
53
|
+
# class ::Page < S::Page; end
|
54
54
|
b = ::Page.box :pages
|
55
55
|
# instantiate box instance class to it gets added to schema
|
56
56
|
::Page.boxes.pages.instance_class.schema_id
|
@@ -68,7 +68,7 @@ class SearchTest < MiniTest::Spec
|
|
68
68
|
|
69
69
|
@all_page_classes = [::Page, ::PageClass1, ::PageClass2, ::PageClass3, ::PageClass4, ::PageClass5, ::PageClass6]
|
70
70
|
@all_piece_classes = [::Piece, ::PieceClass1, ::PieceClass2, ::PieceClass3]
|
71
|
-
@all_box_classes = [ ::Page::PagesBox ]
|
71
|
+
@all_box_classes = [ ::Box, ::Page::PagesBox ]
|
72
72
|
@all_classes = @all_page_classes + @all_piece_classes + @all_box_classes
|
73
73
|
|
74
74
|
@root0 = ::Page.create(:uid => "root")
|
@@ -401,7 +401,7 @@ class SearchTest < MiniTest::Spec
|
|
401
401
|
@l = ::PageClass1.boxes.pages.instance_class.field :l, :index => true
|
402
402
|
|
403
403
|
@page1.a = "a value 1"
|
404
|
-
|
404
|
+
@page1.pages.first.a = "a value 2"
|
405
405
|
@page1.pages.l = "l value 1"
|
406
406
|
|
407
407
|
@piece1 = PieceClass1.new(:g => "g value 1")
|
@@ -520,14 +520,14 @@ class SearchTest < MiniTest::Spec
|
|
520
520
|
xapian.expects(:search).with('"value 2"', {}).returns(XapianFu::ResultSet.new(:mset => mset))
|
521
521
|
xapian.expects(:flush)
|
522
522
|
|
523
|
-
XapianFu::XapianDb.expects(:new).with({
|
523
|
+
XapianFu::XapianDb.expects(:new).with(has_entries({
|
524
524
|
:dir => db_path,
|
525
525
|
:create => true,
|
526
526
|
:overwrite => true,
|
527
527
|
:language => :english,
|
528
528
|
:fields => @index1.fields,
|
529
529
|
:spelling => true
|
530
|
-
}).returns(xapian)
|
530
|
+
})).returns(xapian)
|
531
531
|
|
532
532
|
db = @index1.create_db(@revision)
|
533
533
|
assert File.directory?(db_path)
|
@@ -545,14 +545,14 @@ class SearchTest < MiniTest::Spec
|
|
545
545
|
language :italian
|
546
546
|
end
|
547
547
|
|
548
|
-
XapianFu::XapianDb.expects(:new).with({
|
548
|
+
XapianFu::XapianDb.expects(:new).with(has_entries({
|
549
549
|
:dir => db_path,
|
550
550
|
:create => true,
|
551
551
|
:overwrite => true,
|
552
552
|
:language => :italian,
|
553
553
|
:fields => index.fields,
|
554
554
|
:spelling => true
|
555
|
-
})
|
555
|
+
}))
|
556
556
|
|
557
557
|
db = index.create_db(@revision)
|
558
558
|
|
@@ -562,7 +562,7 @@ class SearchTest < MiniTest::Spec
|
|
562
562
|
stemmer false
|
563
563
|
end
|
564
564
|
|
565
|
-
XapianFu::XapianDb.expects(:new).with({
|
565
|
+
XapianFu::XapianDb.expects(:new).with(has_entries({
|
566
566
|
:dir => db_path,
|
567
567
|
:create => true,
|
568
568
|
:overwrite => true,
|
@@ -571,7 +571,7 @@ class SearchTest < MiniTest::Spec
|
|
571
571
|
:stopper => false,
|
572
572
|
:fields => index.fields,
|
573
573
|
:spelling => true
|
574
|
-
})
|
574
|
+
}))
|
575
575
|
|
576
576
|
db = index.create_db(@revision)
|
577
577
|
|
@@ -580,7 +580,7 @@ class SearchTest < MiniTest::Spec
|
|
580
580
|
|
581
581
|
should "return (reasonable) results to searches" do
|
582
582
|
db_path = @site.revision_dir(@revision) / 'indexes' / 'one'
|
583
|
-
Site.stubs(:published_revision).returns(@revision)
|
583
|
+
S::Site.stubs(:published_revision).returns(@revision)
|
584
584
|
db = @index1.create_db(@revision)
|
585
585
|
db << @page1
|
586
586
|
db << @page2
|
@@ -590,7 +590,7 @@ class SearchTest < MiniTest::Spec
|
|
590
590
|
results = @index1.search('+valeu', :limit => 1, :autocorrect => true)
|
591
591
|
results.must_be_instance_of S::Search::Results
|
592
592
|
results.each do |result|
|
593
|
-
result.class.should <
|
593
|
+
result.class.should < Content::Page
|
594
594
|
end
|
595
595
|
|
596
596
|
results.corrected_query.should == '+value'
|
@@ -613,6 +613,54 @@ class SearchTest < MiniTest::Spec
|
|
613
613
|
FileUtils.rm_r(db_path)
|
614
614
|
end
|
615
615
|
|
616
|
+
should "respect weighting factors given to fields" do
|
617
|
+
db_path = @site.revision_dir(@revision) / 'indexes' / 'one'
|
618
|
+
S::Site.stubs(:published_revision).returns(@revision)
|
619
|
+
db = @index1.create_db(@revision)
|
620
|
+
@w = PieceClass1.field :w, :index => { :weight => 100 }
|
621
|
+
@page1.pages << PieceClass1.new(:w => "findme")
|
622
|
+
@page2.pages << PieceClass2.new(:h => "findme findme")
|
623
|
+
@page2.pages << PieceClass2.new(:h => "findme findme")
|
624
|
+
@page5.pages << PieceClass2.new(:h => "findme")
|
625
|
+
@page5.pages << PieceClass2.new(:h => "findme")
|
626
|
+
|
627
|
+
@page1.save
|
628
|
+
@page2.save
|
629
|
+
@page5.save
|
630
|
+
db << @page1
|
631
|
+
db << @page2
|
632
|
+
db << @page5
|
633
|
+
db.close
|
634
|
+
results = @index1.search('findme', :limit => 5)
|
635
|
+
results.map(&:id).should == [@page1.id, @page2.id, @page5.id]
|
636
|
+
end
|
637
|
+
|
638
|
+
should "use the weighting specific to a subclass" do
|
639
|
+
db_path = @site.revision_dir(@revision) / 'indexes' / 'one'
|
640
|
+
S::Site.stubs(:published_revision).returns(@revision)
|
641
|
+
@w = PieceClass1.field :w, :index => { :weight => 100 }
|
642
|
+
WeightedPiece = Class.new(PieceClass1)
|
643
|
+
WeightedPiece.field :w, :index => { :weight => 1}
|
644
|
+
index = Site.index :weighted do
|
645
|
+
end
|
646
|
+
@page1.pages << WeightedPiece.new(:w => "findme")
|
647
|
+
@page2.pages << PieceClass2.new(:h => "findme findme")
|
648
|
+
@page2.pages << PieceClass2.new(:h => "findme findme")
|
649
|
+
@page5.pages << PieceClass2.new(:h => "findme")
|
650
|
+
@page5.pages << PieceClass2.new(:h => "findme")
|
651
|
+
|
652
|
+
@page1.save
|
653
|
+
@page2.save
|
654
|
+
@page5.save
|
655
|
+
db = index.create_db(@revision)
|
656
|
+
db << @page1
|
657
|
+
db << @page2
|
658
|
+
db << @page5
|
659
|
+
db.close
|
660
|
+
results = index.search('findme', :limit => 5)
|
661
|
+
results.map(&:id).should == [@page2.id, @page5.id, @page1.id]
|
662
|
+
end
|
663
|
+
|
616
664
|
should "provide a convenient way to add documents to multiple indexes" do
|
617
665
|
db1 = mock()
|
618
666
|
db2 = mock()
|
@@ -5,7 +5,6 @@ require 'erb'
|
|
5
5
|
|
6
6
|
|
7
7
|
class SerialisationTest < MiniTest::Spec
|
8
|
-
include Spontaneous
|
9
8
|
|
10
9
|
def setup
|
11
10
|
@site = setup_site
|
@@ -18,13 +17,9 @@ class SerialisationTest < MiniTest::Spec
|
|
18
17
|
context "Content" do
|
19
18
|
setup do
|
20
19
|
Content.delete
|
21
|
-
|
22
|
-
field :title, :string, :default => "New Page"
|
23
|
-
end
|
20
|
+
Page.field :title, :string, :default => "New Page"
|
24
21
|
|
25
|
-
|
26
|
-
style :tepid
|
27
|
-
end
|
22
|
+
Piece.style :tepid
|
28
23
|
|
29
24
|
class ::SerialisedPage < ::Page
|
30
25
|
field :direction, :title => "Pointing Direction", :comment => "NSEW" do
|
@@ -83,8 +78,6 @@ class SerialisationTest < MiniTest::Spec
|
|
83
78
|
end
|
84
79
|
|
85
80
|
teardown do
|
86
|
-
Object.send(:remove_const, :Page)
|
87
|
-
Object.send(:remove_const, :Piece)
|
88
81
|
Object.send(:remove_const, :SerialisedPiece)
|
89
82
|
Object.send(:remove_const, :SerialisedPage)
|
90
83
|
end
|
@@ -95,7 +88,7 @@ class SerialisationTest < MiniTest::Spec
|
|
95
88
|
pp SerialisedPiece.export; puts "="*60; pp @class_hash
|
96
89
|
end
|
97
90
|
# SerialisedPiece.export.should == @class_hash
|
98
|
-
assert_hashes_equal(SerialisedPiece.export
|
91
|
+
assert_hashes_equal(@class_hash, SerialisedPiece.export)
|
99
92
|
end
|
100
93
|
should "serialise to JSON" do
|
101
94
|
Spot::deserialise_http(SerialisedPiece.serialise_http).should == @class_hash
|
@@ -103,7 +96,7 @@ class SerialisationTest < MiniTest::Spec
|
|
103
96
|
should "include the title field name in the serialisation of page types" do
|
104
97
|
SerialisedPage.export(nil)[:title_field].should == 'title'
|
105
98
|
end
|
106
|
-
should "use JS friendly names for type keys" do
|
99
|
+
should "use JS friendly names for type keys xxx" do
|
107
100
|
class ::SerialisedPage
|
108
101
|
class InnerClass < Piece
|
109
102
|
end
|
data/test/unit/test_site.rb
CHANGED
@@ -4,7 +4,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
4
4
|
|
5
5
|
|
6
6
|
class SiteTest < MiniTest::Spec
|
7
|
-
include Spontaneous
|
8
7
|
|
9
8
|
def setup
|
10
9
|
@site = setup_site
|
@@ -17,16 +16,8 @@ class SiteTest < MiniTest::Spec
|
|
17
16
|
context "Site" do
|
18
17
|
setup do
|
19
18
|
Content.delete
|
20
|
-
|
21
|
-
|
22
|
-
box :subpages
|
23
|
-
end
|
24
|
-
class ::Piece < Spontaneous::Piece; end
|
25
|
-
end
|
26
|
-
|
27
|
-
teardown do
|
28
|
-
Object.send(:remove_const, :Page)
|
29
|
-
Object.send(:remove_const, :Piece)
|
19
|
+
Page.field :title
|
20
|
+
Page.box :subpages
|
30
21
|
end
|
31
22
|
|
32
23
|
context "contents" do
|
@@ -170,7 +161,7 @@ class SiteTest < MiniTest::Spec
|
|
170
161
|
|
171
162
|
context "Structure modification times" do
|
172
163
|
setup do
|
173
|
-
State.delete
|
164
|
+
S::State.delete
|
174
165
|
# remove microseconds from time value
|
175
166
|
@now = Time.at(Time.now.to_i)
|
176
167
|
end
|
@@ -197,6 +188,14 @@ class SiteTest < MiniTest::Spec
|
|
197
188
|
Site.modified_at.should == now
|
198
189
|
end
|
199
190
|
|
191
|
+
should "be updated when a page's slug changes" do
|
192
|
+
root = ::Page.create
|
193
|
+
now = @now + 98
|
194
|
+
Time.stubs(:now).returns(now)
|
195
|
+
root.update(:slug => "updated-slug")
|
196
|
+
Site.modified_at.should == now
|
197
|
+
end
|
198
|
+
|
200
199
|
should "not be updated when a piece is added" do
|
201
200
|
now1 = @now + 24
|
202
201
|
Time.stubs(:now).returns(now1)
|
data/test/unit/test_structure.rb
CHANGED
@@ -16,10 +16,7 @@ class StructureTest < MiniTest::Spec
|
|
16
16
|
context "content building" do
|
17
17
|
setup do
|
18
18
|
Content.delete
|
19
|
-
|
20
|
-
field :title
|
21
|
-
end
|
22
|
-
class Piece < Spot::Piece; end
|
19
|
+
Page.field :title
|
23
20
|
class ProjectPage < Page; end
|
24
21
|
class Image < Piece; end
|
25
22
|
class Project < Piece
|
@@ -53,7 +50,7 @@ class StructureTest < MiniTest::Spec
|
|
53
50
|
end
|
54
51
|
|
55
52
|
teardown do
|
56
|
-
[:
|
53
|
+
[:HomePage, :Project, :ProjectPage, :Image].each { |klass| StructureTest.send(:remove_const, klass) rescue nil }
|
57
54
|
end
|
58
55
|
|
59
56
|
context "site content" do
|