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_page.rb
CHANGED
@@ -4,7 +4,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
4
4
|
|
5
5
|
|
6
6
|
class PageTest < MiniTest::Spec
|
7
|
-
include Spontaneous
|
8
7
|
|
9
8
|
def setup
|
10
9
|
@site = setup_site
|
@@ -14,21 +13,14 @@ class PageTest < MiniTest::Spec
|
|
14
13
|
teardown_site
|
15
14
|
end
|
16
15
|
|
17
|
-
context "All pages" do
|
18
|
-
# should "have a pre-defined 'title' field" do
|
19
|
-
# p = Page.new
|
20
|
-
# p.field?(:title).should be_true
|
21
|
-
# p.title.value.should == "New Page"
|
22
|
-
# end
|
23
|
-
end
|
24
16
|
context "Pages:" do
|
25
17
|
setup do
|
26
18
|
Content.delete
|
27
|
-
class Page <
|
19
|
+
class Page < ::Page
|
28
20
|
field :title, :string
|
29
21
|
box :sub
|
30
22
|
end
|
31
|
-
class Piece <
|
23
|
+
class Piece < ::Piece; end
|
32
24
|
end
|
33
25
|
teardown do
|
34
26
|
PageTest.send(:remove_const, :Page)
|
@@ -184,6 +176,11 @@ class PageTest < MiniTest::Spec
|
|
184
176
|
@s.page.should == @s
|
185
177
|
@t.page.should == @t
|
186
178
|
end
|
179
|
+
|
180
|
+
should "have a reference to themselves as content_instance" do
|
181
|
+
@p.content_instance.should == @p
|
182
|
+
end
|
183
|
+
|
187
184
|
should "keep track of their depth" do
|
188
185
|
@p.depth.should == 0
|
189
186
|
@q.depth.should == 1
|
@@ -5,9 +5,11 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
5
5
|
|
6
6
|
class PermissionsTest < MiniTest::Spec
|
7
7
|
|
8
|
+
Permissions = Spontaneous::Permissions
|
9
|
+
|
8
10
|
def setup
|
9
11
|
@site = setup_site
|
10
|
-
|
12
|
+
::Content.delete
|
11
13
|
Permissions::UserLevel.reset!
|
12
14
|
Permissions::UserLevel.stubs(:level_file).returns(File.expand_path('../../fixtures/permissions', __FILE__) / 'config/user_levels.yml')
|
13
15
|
end
|
@@ -236,15 +238,6 @@ class PermissionsTest < MiniTest::Spec
|
|
236
238
|
user.errors[:password].should_not be_blank
|
237
239
|
end
|
238
240
|
|
239
|
-
|
240
|
-
should "have a random salt" do
|
241
|
-
user1 = Permissions::User.create(@valid)
|
242
|
-
user2 = Permissions::User.create(@valid.merge(:login => "person2"))
|
243
|
-
user1.salt.should_not be_blank
|
244
|
-
user2.salt.should_not be_blank
|
245
|
-
user1.salt.should_not == user2.salt
|
246
|
-
end
|
247
|
-
|
248
241
|
context "who are valid" do
|
249
242
|
setup do
|
250
243
|
@user = Permissions::User.create(@valid)
|
data/test/unit/test_piece.rb
CHANGED
@@ -4,7 +4,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
4
4
|
|
5
5
|
|
6
6
|
class PieceTest < MiniTest::Spec
|
7
|
-
include Spontaneous
|
8
7
|
|
9
8
|
def setup
|
10
9
|
@site = setup_site
|
@@ -17,15 +16,11 @@ class PieceTest < MiniTest::Spec
|
|
17
16
|
context "Pieces" do
|
18
17
|
setup do
|
19
18
|
Content.delete
|
20
|
-
class ::Piece < Spot::Piece; end
|
21
|
-
class ::Page < Spot::Page; end
|
22
19
|
class ::Fridge < ::Piece; end
|
23
20
|
end
|
24
21
|
|
25
22
|
teardown do
|
26
|
-
Object.send(:remove_const, :
|
27
|
-
Object.send(:remove_const, :Piece)
|
28
|
-
Object.send(:remove_const, :Fridge)
|
23
|
+
Object.send(:remove_const, :Fridge) rescue nil
|
29
24
|
end
|
30
25
|
|
31
26
|
should "not be pages" do
|
@@ -76,6 +71,10 @@ class PieceTest < MiniTest::Spec
|
|
76
71
|
@f3.parent.should == @f2
|
77
72
|
end
|
78
73
|
|
74
|
+
should "return themselves as content_instance" do
|
75
|
+
@f2.content_instance.should == @f2
|
76
|
+
end
|
77
|
+
|
79
78
|
should "know their depth in the piece tree" do
|
80
79
|
@f1.depth.should == 1
|
81
80
|
@f2.depth.should == 2
|
data/test/unit/test_plugins.rb
CHANGED
@@ -13,11 +13,7 @@ class PluginsTest < MiniTest::Spec
|
|
13
13
|
@site = setup_site
|
14
14
|
|
15
15
|
|
16
|
-
|
17
|
-
klass.box :box1
|
18
|
-
Object.send(:const_set, :Page, klass)
|
19
|
-
klass = Class.new(Spontaneous::Piece)
|
20
|
-
Object.send(:const_set, :Piece, klass)
|
16
|
+
::Page.box :box1
|
21
17
|
klass = Class.new(::Page) do
|
22
18
|
layout :from_plugin
|
23
19
|
end
|
@@ -35,11 +31,9 @@ class PluginsTest < MiniTest::Spec
|
|
35
31
|
end
|
36
32
|
|
37
33
|
def self.shutdown
|
38
|
-
teardown_site
|
39
|
-
Object.send(:remove_const, :Page) rescue nil
|
40
|
-
Object.send(:remove_const, :Piece) rescue nil
|
41
34
|
Object.send(:remove_const, :LocalPage) rescue nil
|
42
35
|
Object.send(:remove_const, :LocalPiece) rescue nil
|
36
|
+
teardown_site
|
43
37
|
end
|
44
38
|
|
45
39
|
def app
|
@@ -49,8 +43,8 @@ class PluginsTest < MiniTest::Spec
|
|
49
43
|
context "Plugins:" do
|
50
44
|
|
51
45
|
setup do
|
52
|
-
Site.
|
53
|
-
State.delete
|
46
|
+
S::Site.background_mode = :immediate
|
47
|
+
S::State.delete
|
54
48
|
Content.delete
|
55
49
|
@site = Spontaneous.instance
|
56
50
|
page = ::Page.new
|
@@ -59,7 +53,7 @@ class PluginsTest < MiniTest::Spec
|
|
59
53
|
end
|
60
54
|
|
61
55
|
teardown do
|
62
|
-
State.delete
|
56
|
+
S::State.delete
|
63
57
|
Content.delete
|
64
58
|
end
|
65
59
|
|
@@ -100,18 +94,17 @@ class PluginsTest < MiniTest::Spec
|
|
100
94
|
|
101
95
|
context "during publishing" do
|
102
96
|
setup do
|
103
|
-
|
104
97
|
Content.delete_revision(1) rescue nil
|
105
98
|
|
106
99
|
Spontaneous.logger.silent! {
|
107
|
-
Site.publish_all
|
100
|
+
S::Site.publish_all
|
108
101
|
}
|
109
102
|
end
|
110
103
|
|
111
104
|
teardown do
|
112
105
|
FileUtils.rm_rf(@revision_root) rescue nil
|
113
106
|
Content.delete
|
114
|
-
State.delete
|
107
|
+
S::State.delete
|
115
108
|
Content.delete_revision(1)
|
116
109
|
end
|
117
110
|
|
@@ -13,7 +13,7 @@ class PrototypesTest < MiniTest::Spec
|
|
13
13
|
|
14
14
|
context "Prototypes" do
|
15
15
|
setup do
|
16
|
-
class ::ImageClass <
|
16
|
+
class ::ImageClass < ::Piece
|
17
17
|
field :image
|
18
18
|
field :description
|
19
19
|
|
@@ -26,7 +26,7 @@ class PrototypesTest < MiniTest::Spec
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
class ::PrototypeClass <
|
29
|
+
class ::PrototypeClass < ::Piece
|
30
30
|
field :title, :string
|
31
31
|
field :date, :string
|
32
32
|
field :something, :string, :default => "Here"
|
@@ -149,7 +149,7 @@ class PrototypesTest < MiniTest::Spec
|
|
149
149
|
|
150
150
|
should "raise error if definition does not accept exactly 1 argument" do
|
151
151
|
begin
|
152
|
-
class ::Prototype3Class < ::
|
152
|
+
class ::Prototype3Class < ::Piece
|
153
153
|
prototype {}
|
154
154
|
end
|
155
155
|
flunk("Defining prototypes with no arguments should raise error")
|
@@ -16,7 +16,8 @@ class PublishingTest < MiniTest::Spec
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.shutdown
|
19
|
-
|
19
|
+
::Content.delete_all_revisions! rescue nil
|
20
|
+
teardown_site(true)
|
20
21
|
end
|
21
22
|
|
22
23
|
@@now = Time.now
|
@@ -24,7 +25,11 @@ class PublishingTest < MiniTest::Spec
|
|
24
25
|
def setup
|
25
26
|
@site = setup_site(self.class.site_root)
|
26
27
|
@now = @@now
|
27
|
-
Site.
|
28
|
+
Site.background_mode = :immediate
|
29
|
+
end
|
30
|
+
|
31
|
+
def teardown
|
32
|
+
teardown_site(false)
|
28
33
|
end
|
29
34
|
|
30
35
|
context "publishing" do
|
@@ -32,14 +37,13 @@ class PublishingTest < MiniTest::Spec
|
|
32
37
|
setup do
|
33
38
|
stub_time(@@now)
|
34
39
|
|
35
|
-
# DB.logger = Logger.new($stdout)
|
36
40
|
Content.delete
|
37
41
|
|
38
|
-
class Page <
|
42
|
+
class Page < ::Page
|
39
43
|
field :title, :string, :default => "New Page"
|
40
44
|
box :things
|
41
45
|
end
|
42
|
-
class Piece <
|
46
|
+
class Piece < ::Piece
|
43
47
|
box :things
|
44
48
|
end
|
45
49
|
|
@@ -65,7 +69,6 @@ class PublishingTest < MiniTest::Spec
|
|
65
69
|
PublishingTest.send(:remove_const, :Page) rescue nil
|
66
70
|
PublishingTest.send(:remove_const, :Piece) rescue nil
|
67
71
|
Content.delete
|
68
|
-
DB.logger = nil
|
69
72
|
end
|
70
73
|
|
71
74
|
|
@@ -75,41 +78,40 @@ class PublishingTest < MiniTest::Spec
|
|
75
78
|
setup do
|
76
79
|
Content.delete
|
77
80
|
@revision = 3
|
78
|
-
State.delete
|
79
|
-
State.create(:revision => @revision, :published_revision => 2)
|
80
|
-
State.revision.should == @revision
|
81
|
+
S::State.delete
|
82
|
+
S::State.create(:revision => @revision, :published_revision => 2)
|
83
|
+
S::State.revision.should == @revision
|
81
84
|
end
|
82
85
|
|
83
86
|
teardown do
|
84
87
|
Content.delete_revision(@revision)
|
85
|
-
Revision.delete
|
88
|
+
S::Revision.delete
|
86
89
|
end
|
87
90
|
|
88
91
|
should "delete any conflicting revision tables" do
|
89
|
-
S::
|
90
|
-
Site.publish_all
|
92
|
+
S::Publishing::Revision.create(Content, 3)
|
93
|
+
S::Site.publish_all
|
91
94
|
end
|
92
95
|
|
93
|
-
|
94
96
|
should "issue a publish_all if passed page id list including all pages (in any order)" do
|
95
97
|
skip "Implement after scheduled publishes"
|
96
98
|
end
|
97
99
|
|
98
100
|
should "publish all" do
|
99
101
|
Content.expects(:publish).with(@revision, nil)
|
100
|
-
Site.publish_all
|
102
|
+
S::Site.publish_all
|
101
103
|
end
|
102
104
|
|
103
105
|
should "record date and time of publish" do
|
104
106
|
Content.expects(:publish).with(@revision, nil)
|
105
|
-
Revision.expects(:create).with(:revision => @revision, :published_at => @now)
|
106
|
-
Site.publish_all
|
107
|
+
S::Revision.expects(:create).with(:revision => @revision, :published_at => @now)
|
108
|
+
S::Site.publish_all
|
107
109
|
end
|
108
110
|
|
109
111
|
should "bump revision after a publish" do
|
110
|
-
Site.publish_all
|
111
|
-
Site.revision.should == @revision + 1
|
112
|
-
Site.published_revision.should == @revision
|
112
|
+
S::Site.publish_all
|
113
|
+
S::Site.revision.should == @revision + 1
|
114
|
+
S::Site.published_revision.should == @revision
|
113
115
|
end
|
114
116
|
|
115
117
|
should "not delete scheduled changes after an exception during publish" do
|
@@ -129,7 +131,7 @@ class PublishingTest < MiniTest::Spec
|
|
129
131
|
should "not update first_published or last_published if rendering fails" do
|
130
132
|
c = Content.create
|
131
133
|
c.first_published_at.should be_nil
|
132
|
-
Spontaneous::
|
134
|
+
Spontaneous::Site.expects(:pages).returns([c])
|
133
135
|
# c.expects(:render).raises(Exception)
|
134
136
|
begin
|
135
137
|
silence_logger { Site.publish_all }
|
@@ -147,7 +149,7 @@ class PublishingTest < MiniTest::Spec
|
|
147
149
|
# don't like peeking into implementation here but don't know how else
|
148
150
|
# to simulate the right error
|
149
151
|
root = Page.create()
|
150
|
-
Spontaneous::
|
152
|
+
Spontaneous::Site.expects(:pages).returns([root])
|
151
153
|
output = root.output(:html)
|
152
154
|
output.expects(:render_using).raises(Exception)
|
153
155
|
root.expects(:outputs).at_least_once.returns([output])
|
@@ -170,9 +172,9 @@ class PublishingTest < MiniTest::Spec
|
|
170
172
|
@revision = 2
|
171
173
|
Content.delete_revision(@revision)
|
172
174
|
Content.delete
|
173
|
-
State.delete
|
174
|
-
State.create(:revision => @revision, :published_revision => 2)
|
175
|
-
Site.revision.should == @revision
|
175
|
+
S::State.delete
|
176
|
+
S::State.create(:revision => @revision, :published_revision => 2)
|
177
|
+
S::Site.revision.should == @revision
|
176
178
|
|
177
179
|
|
178
180
|
class ::PublishablePage < Page; end
|
@@ -213,7 +215,7 @@ class PublishingTest < MiniTest::Spec
|
|
213
215
|
Content.delete_revision(@revision)
|
214
216
|
Content.delete_revision(@revision+1)
|
215
217
|
Content.delete
|
216
|
-
State.delete
|
218
|
+
S::State.delete
|
217
219
|
Object.send(:remove_const, :PublishablePage) rescue nil
|
218
220
|
Object.send(:remove_const, :DynamicPublishablePage) rescue nil
|
219
221
|
end
|
@@ -270,6 +272,12 @@ class PublishingTest < MiniTest::Spec
|
|
270
272
|
File.read(config_file).should =~ %r(#{Spontaneous.root})
|
271
273
|
end
|
272
274
|
|
275
|
+
should "generate a REVISION file containing the published revision number" do
|
276
|
+
rev_file = @site.revision_root / "REVISION"
|
277
|
+
result = File.read(rev_file)
|
278
|
+
result.should == Spontaneous::Media.pad_revision(@revision)
|
279
|
+
end
|
280
|
+
|
273
281
|
should "transparently support previously unknown formats by assuming a simple HTML like rendering model" do
|
274
282
|
PublishablePage.add_output :rtf
|
275
283
|
Content.delete_revision(@revision+1)
|
@@ -277,13 +285,18 @@ class PublishingTest < MiniTest::Spec
|
|
277
285
|
File.read("#{@site.revision_root}/00003/static/index.rtf").should == "RICH!\n"
|
278
286
|
end
|
279
287
|
|
280
|
-
should "respect a format's #dynamic? setting when deciding a rendered templates location
|
288
|
+
should "respect a format's #dynamic? setting when deciding a rendered templates location" do
|
281
289
|
PublishablePage.add_output :rtf, :dynamic => true
|
282
290
|
Content.delete_revision(@revision+1)
|
283
291
|
Site.publish_all
|
284
292
|
File.read("#{@site.revision_root}/00003/dynamic/index.rtf.cut").should == "RICH!\n"
|
285
293
|
end
|
286
294
|
|
295
|
+
should "run the content revision cleanup task after the revision is live xxx" do
|
296
|
+
Content.expects(:cleanup_revisions).with(@revision+1, 8)
|
297
|
+
Site.publish_all
|
298
|
+
end
|
299
|
+
|
287
300
|
context "hooks & triggers" do
|
288
301
|
setup do
|
289
302
|
end
|
@@ -324,7 +337,16 @@ class PublishingTest < MiniTest::Spec
|
|
324
337
|
previous_root = Spontaneous.revision_dir(@revision)
|
325
338
|
published_root = Spontaneous.revision_dir(published_revision)
|
326
339
|
symlink = Pathname.new Spontaneous.revision_dir
|
327
|
-
|
340
|
+
# JRuby's Pathname#realpath doesn't work properly
|
341
|
+
# See: http://jira.codehaus.org/browse/JRUBY-6460
|
342
|
+
#
|
343
|
+
# This workaround tests that the symlink has been re-pointed
|
344
|
+
#
|
345
|
+
# File.read(symlink + "REVISION").realpath.to_s.should == Pathname.new(previous_root).realpath.to_s
|
346
|
+
File.open(Pathname.new(previous_root) + "REVISION", "w") do |file|
|
347
|
+
file.write(@revision)
|
348
|
+
end
|
349
|
+
File.read(symlink + "REVISION").should == @revision.to_s
|
328
350
|
end
|
329
351
|
end
|
330
352
|
end
|
data/test/unit/test_render.rb
CHANGED
@@ -5,10 +5,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
5
5
|
require 'sinatra/base'
|
6
6
|
|
7
7
|
class RenderTest < MiniTest::Spec
|
8
|
-
include Spontaneous
|
9
8
|
|
10
9
|
def setup
|
11
10
|
@site = setup_site
|
11
|
+
Content.delete
|
12
12
|
end
|
13
13
|
|
14
14
|
def teardown
|
@@ -22,15 +22,13 @@ class RenderTest < MiniTest::Spec
|
|
22
22
|
|
23
23
|
context "Publish rendering step" do
|
24
24
|
setup do
|
25
|
-
Content.delete
|
26
25
|
@site.paths.add(:templates, template_root)
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
class ::TemplateClass < Spontaneous::Piece
|
27
|
+
Page.field :title
|
28
|
+
Page.box :sections1
|
29
|
+
Page.box :sections2
|
30
|
+
|
31
|
+
class ::TemplateClass < ::Piece
|
34
32
|
field :title do
|
35
33
|
def to_epub
|
36
34
|
to_html
|
@@ -103,19 +101,19 @@ class RenderTest < MiniTest::Spec
|
|
103
101
|
a = b = c = nil
|
104
102
|
template = '%{ navigation do |section, active| }${section.object_id} %{ end }'
|
105
103
|
renderer = Spontaneous::Output::Template::PreviewRenderer.new
|
106
|
-
a = renderer.render_string(template,
|
107
|
-
b = renderer.render_string(template,
|
104
|
+
a = renderer.render_string(template, ::Content[@section1.id].output(:html), {}).strip
|
105
|
+
b = renderer.render_string(template, ::Content[@section1.id].output(:html), {}).strip
|
108
106
|
a.should_not == b
|
109
107
|
|
110
108
|
renderer = Spontaneous::Output::Template::PublishRenderer.new
|
111
109
|
template = '%{ navigation do |section, active| }${section.object_id} %{ end }'
|
112
|
-
a = renderer.render_string(template,
|
113
|
-
b = renderer.render_string(template,
|
110
|
+
a = renderer.render_string(template, ::Content[@section1.id].output(:html), {}).strip
|
111
|
+
b = renderer.render_string(template, ::Content[@section1.id].output(:html), {}).strip
|
114
112
|
a.should == b
|
115
113
|
|
116
114
|
renderer = Spontaneous::Output::Template::PublishRenderer.new
|
117
115
|
template = '%{ navigation do |section, active| }${section.object_id} %{ end }'
|
118
|
-
c = renderer.render_string(template,
|
116
|
+
c = renderer.render_string(template, ::Content[@section1.id].output(:html), {}).strip
|
119
117
|
a.should_not == c
|
120
118
|
end
|
121
119
|
|
@@ -170,10 +168,28 @@ class RenderTest < MiniTest::Spec
|
|
170
168
|
@content.bits << child
|
171
169
|
@content.bits.last.style = TemplateClass.get_style(:this_template)
|
172
170
|
@content.bits.last.hide!
|
173
|
-
|
171
|
+
|
172
|
+
expected = "<complex>\nThe Title\n<piece><html><title>Child Title</title><body>Child Description</body></html>\n</piece>\n</complex>\n"
|
173
|
+
@content.render.should == expected
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
|
+
context "fields" do
|
178
|
+
should "render a joined list of field values" do
|
179
|
+
Page.field :description, :markdown
|
180
|
+
Page.field :image
|
181
|
+
::Page.layout do
|
182
|
+
%(${ fields })
|
183
|
+
end
|
184
|
+
@page.title = "Title & Things"
|
185
|
+
@page.image = "/photo.jpg"
|
186
|
+
@page.description = "Description & Stuff"
|
187
|
+
lines = @page.render.split(/\n(?=<div)/)
|
188
|
+
@page.fields.each_with_index do |field, i|
|
189
|
+
lines[i].should =~ /<div.+?>#{field.render(:html)}<\/div>/
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
177
193
|
context "boxes" do
|
178
194
|
setup do
|
179
195
|
TemplateClass.style :slots_template, :default => true
|
@@ -190,9 +206,24 @@ class RenderTest < MiniTest::Spec
|
|
190
206
|
@content.images.first.style = TemplateClass.get_style(:this_template)
|
191
207
|
end
|
192
208
|
|
209
|
+
should "render box sets as a joined list of each box's output" do
|
210
|
+
::Page.layout do
|
211
|
+
%(${ content })
|
212
|
+
end
|
213
|
+
@page.render.should == @page.boxes.map(&:render).join("\n")
|
214
|
+
end
|
215
|
+
|
216
|
+
should "render 'boxes' as a joined list of each box's output" do
|
217
|
+
::Page.layout do
|
218
|
+
%(${ boxes })
|
219
|
+
end
|
220
|
+
@page.render.should == @page.boxes.map(&:render).join("\n")
|
221
|
+
end
|
222
|
+
|
193
223
|
should "render boxes" do
|
194
224
|
@content.render.should == "<boxes>\n <img><html><title>Child Title</title><body>Child Description</body></html>\n</img>\n</boxes>\n"
|
195
225
|
end
|
226
|
+
|
196
227
|
should "render boxes to alternate formats" do
|
197
228
|
::Page.add_output :pdf
|
198
229
|
@content.render(:pdf).should == "<boxes-pdf>\n <img><PDF><title>Child Title</title><body>{Child Description}</body></PDF>\n</img>\n</boxes-pdf>\n"
|
@@ -325,7 +356,7 @@ class RenderTest < MiniTest::Spec
|
|
325
356
|
end
|
326
357
|
|
327
358
|
should "persist sub-page style settings" do
|
328
|
-
@parent =
|
359
|
+
@parent = Content[@parent.id]
|
329
360
|
@parent.contents.first.style.should == PageClass.default_style
|
330
361
|
end
|
331
362
|
|