spontaneous 0.2.0.beta5 → 0.2.0.beta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +39 -0
- data/Gemfile +2 -0
- data/Readme.markdown +4 -4
- data/application/css/core.css.scss +144 -43
- data/application/css/definitions.css.scss +50 -16
- data/application/css/dialogue.css.scss +5 -2
- data/application/css/editing.css.scss +7 -7
- data/application/css/font.css.scss +1 -1
- data/application/css/meta.css.scss +6 -6
- data/application/css/popover.css.scss +6 -6
- data/application/css/top.css.scss +8 -1
- data/application/js/add_alias_dialogue.js +137 -36
- data/application/js/add_home_dialogue.js +10 -10
- data/application/js/ajax.js +26 -26
- data/application/js/authentication.js +2 -2
- data/application/js/box.js +21 -10
- data/application/js/box_container.js +13 -7
- data/application/js/compatibility.js +19 -17
- data/application/js/conflicted_field_dialogue.js +5 -5
- data/application/js/content.js +22 -16
- data/application/js/content_area.js +62 -33
- data/application/js/dialogue.js +16 -16
- data/application/js/dom.js +9 -10
- data/application/js/edit_panel.js +25 -20
- data/application/js/editing.js +21 -8
- data/application/js/entry.js +1 -1
- data/application/js/extensions.js +11 -11
- data/application/js/field/boolean.js +6 -6
- data/application/js/field/date.js +1 -1
- data/application/js/field/file.js +17 -17
- data/application/js/field/image.js +27 -27
- data/application/js/field/markdown.js +72 -71
- data/application/js/field/select.js +9 -9
- data/application/js/field/string.js +3 -3
- data/application/js/field/webvideo.js +2 -2
- data/application/js/field_preview.js +3 -0
- data/application/js/init.js +3 -2
- data/application/js/jquery-selection-position.js +13 -13
- data/application/js/location.js +17 -12
- data/application/js/login.js +2 -2
- data/application/js/meta_view/user_admin.js +101 -101
- data/application/js/metadata.js +1 -1
- data/application/js/page.js +2 -2
- data/application/js/page_browser.js +13 -13
- data/application/js/page_entry.js +1 -1
- data/application/js/panel/root_menu.js +10 -10
- data/application/js/popover.js +6 -5
- data/application/js/popover_view.js +5 -5
- data/application/js/preview.js +10 -4
- data/application/js/progress.js +6 -6
- data/application/js/properties.js +35 -6
- data/application/js/publish.js +43 -43
- data/application/js/require.js +14 -14
- data/application/js/services.js +3 -3
- data/application/js/sharded_upload.js +9 -8
- data/application/js/side_bar.js +5 -5
- data/application/js/state.js +2 -2
- data/application/js/status_bar.js +6 -6
- data/application/js/top_bar.js +97 -65
- data/application/js/types.js +9 -6
- data/application/js/upload.js +4 -4
- data/application/js/upload_manager.js +21 -21
- data/application/js/user.js +1 -1
- data/application/js/vendor/jquery.velocity.min.js +7 -0
- data/application/js/views.js +32 -8
- data/application/js/views/box_view.js +51 -31
- data/application/js/views/page_piece_view.js +17 -15
- data/application/js/views/page_view.js +54 -43
- data/application/js/views/piece_view.js +44 -37
- data/application/static/font/fontawesome-webfont-4f0022f25672c7f501c339cbf98d9117.ttf +0 -0
- data/application/views/index.erb +1 -0
- data/db/migrations/20130114120000_create_revision_tables.rb +2 -1
- data/db/migrations/20130813111009_increase_path_length.rb +11 -2
- data/db/migrations/20140506171823_add_index_to_target_id.rb +11 -0
- data/db/migrations/20140514090204_add_content_hash.rb +59 -0
- data/db/migrations/20140519150253_add_content_hash_timestamp.rb +20 -0
- data/lib/spontaneous.rb +0 -1
- data/lib/spontaneous/asset/environment.rb +77 -15
- data/lib/spontaneous/box.rb +21 -0
- data/lib/spontaneous/capistrano/deploy.rb +1 -1
- data/lib/spontaneous/capistrano/sync.rb +8 -7
- data/lib/spontaneous/change.rb +4 -2
- data/lib/spontaneous/cli/fields.rb +7 -3
- data/lib/spontaneous/cli/generate.rb +2 -0
- data/lib/spontaneous/cli/init.rb +24 -93
- data/lib/spontaneous/cli/init/db.rb +94 -0
- data/lib/spontaneous/cli/init/mysql.rb +17 -0
- data/lib/spontaneous/cli/init/postgresql.rb +33 -0
- data/lib/spontaneous/cli/init/sqlite.rb +14 -0
- data/lib/spontaneous/cli/site.rb +45 -20
- data/lib/spontaneous/collections/box_set.rb +3 -0
- data/lib/spontaneous/collections/entry_set.rb +43 -4
- data/lib/spontaneous/collections/field_set.rb +14 -2
- data/lib/spontaneous/data_mapper.rb +40 -7
- data/lib/spontaneous/data_mapper/content_model.rb +1 -1
- data/lib/spontaneous/data_mapper/content_model/associations.rb +63 -12
- data/lib/spontaneous/data_mapper/content_model/timestamps.rb +9 -14
- data/lib/spontaneous/data_mapper/content_table.rb +4 -2
- data/lib/spontaneous/data_mapper/dataset.rb +31 -2
- data/lib/spontaneous/data_mapper/scope.rb +37 -20
- data/lib/spontaneous/errors.rb +6 -0
- data/lib/spontaneous/facet.rb +20 -10
- data/lib/spontaneous/field/base.rb +8 -1
- data/lib/spontaneous/field/file.rb +28 -3
- data/lib/spontaneous/field/image.rb +2 -0
- data/lib/spontaneous/field/update.rb +6 -0
- data/lib/spontaneous/field/webvideo/vimeo.rb +6 -1
- data/lib/spontaneous/field/webvideo/vine.rb +1 -1
- data/lib/spontaneous/field/webvideo/youtube.rb +1 -1
- data/lib/spontaneous/generators/site.rb +6 -4
- data/lib/spontaneous/generators/site/.gitignore +1 -0
- data/lib/spontaneous/generators/site/Gemfile.tt +3 -3
- data/lib/spontaneous/generators/site/config/{indexes.rb.tt → initializers/indexes.rb.tt} +0 -0
- data/lib/spontaneous/generators/site/config/initializers/publishing.rb.tt +78 -0
- data/lib/spontaneous/generators/site/{config/database.yml.tt → db/mysql2.yml.tt} +7 -6
- data/lib/spontaneous/generators/site/db/postgres.yml.tt +25 -0
- data/lib/spontaneous/generators/site/db/sqlite3.yml.tt +18 -0
- data/lib/spontaneous/generators/site/public/humans.txt.tt +14 -0
- data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +51 -0
- data/lib/spontaneous/loader.rb +1 -1
- data/lib/spontaneous/logger.rb +1 -1
- data/lib/spontaneous/media/image/optimizer.rb +1 -1
- data/lib/spontaneous/media/image/processor.rb +11 -2
- data/lib/spontaneous/media/image/renderable.rb +2 -0
- data/lib/spontaneous/model.rb +3 -0
- data/lib/spontaneous/model/box/allowed_types.rb +17 -4
- data/lib/spontaneous/model/core.rb +36 -3
- data/lib/spontaneous/model/core/aliases.rb +5 -2
- data/lib/spontaneous/model/core/boxes.rb +6 -0
- data/lib/spontaneous/model/core/cascading_change.rb +38 -0
- data/lib/spontaneous/model/core/content_hash.rb +171 -0
- data/lib/spontaneous/model/core/entries.rb +0 -19
- data/lib/spontaneous/model/core/fields.rb +11 -0
- data/lib/spontaneous/model/core/modifications.rb +22 -21
- data/lib/spontaneous/model/core/render.rb +3 -0
- data/lib/spontaneous/model/core/serialisation.rb +18 -17
- data/lib/spontaneous/model/page.rb +35 -8
- data/lib/spontaneous/model/page/page_tree.rb +20 -8
- data/lib/spontaneous/model/page/paths.rb +79 -50
- data/lib/spontaneous/model/page/singleton.rb +71 -0
- data/lib/spontaneous/model/page/site_map.rb +2 -1
- data/lib/spontaneous/model/page/site_timestamps.rb +2 -2
- data/lib/spontaneous/model/piece.rb +10 -0
- data/lib/spontaneous/output/context.rb +13 -6
- data/lib/spontaneous/output/format.rb +30 -5
- data/lib/spontaneous/output/helpers/script_helper.rb +8 -0
- data/lib/spontaneous/output/helpers/stylesheet_helper.rb +7 -0
- data/lib/spontaneous/output/renderable.rb +16 -0
- data/lib/spontaneous/output/store.rb +1 -1
- data/lib/spontaneous/output/template/renderer.rb +2 -2
- data/lib/spontaneous/page_piece.rb +25 -1
- data/lib/spontaneous/prototypes/box_prototype.rb +13 -0
- data/lib/spontaneous/prototypes/field_prototype.rb +7 -4
- data/lib/spontaneous/publishing.rb +10 -5
- data/lib/spontaneous/publishing/immediate.rb +32 -349
- data/lib/spontaneous/publishing/pipeline.rb +43 -0
- data/lib/spontaneous/publishing/progress.rb +186 -0
- data/lib/spontaneous/publishing/publish.rb +107 -0
- data/lib/spontaneous/publishing/rerender.rb +17 -0
- data/lib/spontaneous/publishing/revision.rb +53 -18
- data/lib/spontaneous/publishing/simultaneous.rb +1 -1
- data/lib/spontaneous/publishing/steps.rb +154 -0
- data/lib/spontaneous/publishing/steps/activate_revision.rb +45 -0
- data/lib/spontaneous/publishing/steps/archive_old_revisions.rb +22 -0
- data/lib/spontaneous/publishing/steps/base_step.rb +49 -0
- data/lib/spontaneous/publishing/steps/copy_static_files.rb +74 -0
- data/lib/spontaneous/publishing/steps/create_revision_directory.rb +24 -0
- data/lib/spontaneous/publishing/steps/generate_rackup_file.rb +51 -0
- data/lib/spontaneous/publishing/steps/generate_search_indexes.rb +24 -0
- data/lib/spontaneous/publishing/steps/render_revision.rb +69 -0
- data/lib/spontaneous/publishing/steps/write_revision_file.rb +43 -0
- data/lib/spontaneous/rack/back.rb +3 -1
- data/lib/spontaneous/rack/back/alias.rb +9 -8
- data/lib/spontaneous/rack/front.rb +1 -1
- data/lib/spontaneous/rack/middleware.rb +7 -4
- data/lib/spontaneous/rack/middleware/transaction.rb +14 -0
- data/lib/spontaneous/rack/page_controller.rb +23 -8
- data/lib/spontaneous/revision.rb +5 -10
- data/lib/spontaneous/schema.rb +5 -0
- data/lib/spontaneous/server.rb +3 -1
- data/lib/spontaneous/site.rb +17 -10
- data/lib/spontaneous/site/publishing.rb +25 -3
- data/lib/spontaneous/site/state.rb +7 -3
- data/lib/spontaneous/tasks/database.rake +5 -10
- data/lib/spontaneous/utils/database/mysql_dumper.rb +5 -1
- data/lib/spontaneous/version.rb +1 -1
- data/spontaneous.gemspec +4 -3
- data/test/fixtures/example_application/config/initializers/initializer1.rb +1 -0
- data/test/fixtures/example_application/config/initializers/initializer2.rb +1 -0
- data/test/fixtures/example_application/config/initializers/publishing.rb +13 -0
- data/test/fixtures/search/config/{indexes.rb → initializers/indexes.rb} +0 -0
- data/test/fixtures/serialisation/root_hash.yaml.erb +10 -4
- data/test/functional/test_application.rb +10 -0
- data/test/functional/test_back.rb +23 -5
- data/test/functional/test_cli.rb +98 -34
- data/test/functional/test_front.rb +7 -3
- data/test/test_helper.rb +35 -28
- data/test/unit/test_alias.rb +20 -3
- data/test/unit/test_assets.rb +58 -30
- data/test/unit/test_changesets.rb +20 -12
- data/test/unit/test_content_hash.rb +496 -0
- data/test/unit/test_context.rb +28 -1
- data/test/unit/test_controllers.rb +96 -61
- data/test/unit/test_crypt.rb +1 -8
- data/test/unit/test_datamapper.rb +95 -19
- data/test/unit/test_features.rb +1 -4
- data/test/unit/test_fields.rb +61 -12
- data/test/unit/test_generators.rb +39 -2
- data/test/unit/test_images.rb +3 -1
- data/test/unit/test_modifications.rb +224 -219
- data/test/unit/test_output_store.rb +10 -0
- data/test/unit/{test_formats.rb → test_outputs.rb} +75 -6
- data/test/unit/test_page.rb +61 -15
- data/test/unit/test_plugins.rb +2 -42
- data/test/unit/test_publishing_pipeline.rb +1050 -0
- data/test/unit/test_render.rb +30 -0
- data/test/unit/test_revisions.rb +110 -2
- data/test/unit/test_schema.rb +4 -0
- data/test/unit/test_search.rb +1 -1
- data/test/unit/test_serialisation.rb +6 -1
- data/test/unit/test_singletons.rb +159 -0
- data/test/unit/test_site.rb +71 -44
- metadata +140 -86
- data/application/static/font/fontawesome-webfont-1c66a4738b40ef0f6b1abca0ba9a796d.ttf +0 -0
- data/test/unit/test_publishing.rb +0 -330
Binary file
|
@@ -1,330 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require File.expand_path('../../test_helper', __FILE__)
|
4
|
-
|
5
|
-
describe "Publishing" do
|
6
|
-
|
7
|
-
start do
|
8
|
-
site_root = Dir.mktmpdir
|
9
|
-
template_source = File.expand_path(File.dirname(__FILE__) / "../fixtures/templates/publishing/templates")
|
10
|
-
FileUtils.cp_r(template_source, site_root)
|
11
|
-
let(:site_root) { site_root }
|
12
|
-
end
|
13
|
-
|
14
|
-
finish do
|
15
|
-
::Content.delete_all_revisions! rescue nil
|
16
|
-
teardown_site(true)
|
17
|
-
end
|
18
|
-
|
19
|
-
before do
|
20
|
-
@now = Time.now
|
21
|
-
stub_time(@now)
|
22
|
-
|
23
|
-
@site = setup_site(site_root)
|
24
|
-
@site.background_mode = :immediate
|
25
|
-
@output_store = @site.output_store(:Memory)
|
26
|
-
|
27
|
-
Content.delete
|
28
|
-
|
29
|
-
class Page
|
30
|
-
field :title, :string, :default => "New Page"
|
31
|
-
box :things
|
32
|
-
end
|
33
|
-
class Piece
|
34
|
-
box :things
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
after do
|
39
|
-
Object.send(:remove_const, :Page) rescue nil
|
40
|
-
Object.send(:remove_const, :Piece) rescue nil
|
41
|
-
Content.delete
|
42
|
-
teardown_site(false)
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "site publishing" do
|
46
|
-
before do
|
47
|
-
Content.delete
|
48
|
-
@revision = 3
|
49
|
-
S::State.delete
|
50
|
-
S::State.create(:revision => @revision, :published_revision => 2)
|
51
|
-
S::State.revision.must_equal @revision
|
52
|
-
end
|
53
|
-
|
54
|
-
after do
|
55
|
-
Content.delete_revision(@revision)
|
56
|
-
S::PublishedRevision.delete
|
57
|
-
end
|
58
|
-
|
59
|
-
it "delete any conflicting revision tables" do
|
60
|
-
S::Publishing::Revision.create(Content, 3)
|
61
|
-
@site.publish_all
|
62
|
-
end
|
63
|
-
|
64
|
-
it "issue a publish_all if passed page id list including all pages (in any order)" do
|
65
|
-
skip "Implement after scheduled publishes"
|
66
|
-
end
|
67
|
-
|
68
|
-
it "publish all" do
|
69
|
-
Content.expects(:publish).with(@revision, nil)
|
70
|
-
@site.publish_all
|
71
|
-
end
|
72
|
-
|
73
|
-
it "record date and time of publish" do
|
74
|
-
Content.expects(:publish).with(@revision, nil)
|
75
|
-
S::PublishedRevision.expects(:create).with(:revision => @revision, :published_at => @now)
|
76
|
-
@site.publish_all
|
77
|
-
end
|
78
|
-
|
79
|
-
it "bump revision after a publish" do
|
80
|
-
@site.publish_all
|
81
|
-
@site.revision.must_equal @revision + 1
|
82
|
-
@site.published_revision.must_equal @revision
|
83
|
-
end
|
84
|
-
|
85
|
-
it "not delete scheduled changes after an exception during publish" do
|
86
|
-
skip "Implement after scheduled publishes"
|
87
|
-
end
|
88
|
-
|
89
|
-
it "set Site.pending_revision before publishing" do
|
90
|
-
Content.expects(:publish).with(@revision, nil) { @site.pending_revision == @revision }
|
91
|
-
@site.publish_all
|
92
|
-
end
|
93
|
-
|
94
|
-
it "reset Site.pending_revision after publishing" do
|
95
|
-
@site.publish_all
|
96
|
-
@site.pending_revision.must_be_nil
|
97
|
-
end
|
98
|
-
|
99
|
-
it "not update first_published or last_published if rendering fails" do
|
100
|
-
c = Content.create
|
101
|
-
c.first_published_at.must_be_nil
|
102
|
-
@site.expects(:pages).returns([c])
|
103
|
-
# c.expects(:render).raises(Exception)
|
104
|
-
begin
|
105
|
-
silence_logger { @site.publish_all }
|
106
|
-
rescue Exception; end
|
107
|
-
c.reload
|
108
|
-
Content.with_editable do
|
109
|
-
c.first_published_at.must_be_nil
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
it "clean up state on publishing failure" do
|
114
|
-
@site.pending_revision.must_be_nil
|
115
|
-
refute Content.revision_exists?(@revision)
|
116
|
-
# don't like peeking into implementation here but don't know how else
|
117
|
-
# to simulate the right error
|
118
|
-
root = Page.create()
|
119
|
-
@site.expects(:pages).returns([root])
|
120
|
-
output = root.output(:html)
|
121
|
-
output.expects(:render_using).raises(Exception)
|
122
|
-
root.expects(:outputs).at_least_once.returns([output])
|
123
|
-
revision_store = @output_store.revision(@revision)
|
124
|
-
@output_store.expects(:revision).with(@revision).at_least_once.returns(revision_store)
|
125
|
-
transaction = []
|
126
|
-
revision_store.expects(:delete)
|
127
|
-
revision_store.expects(:transaction).returns(transaction)
|
128
|
-
transaction.expects(:rollback)
|
129
|
-
begin
|
130
|
-
silence_logger { @site.publish_all }
|
131
|
-
rescue Exception; end
|
132
|
-
@site.pending_revision.must_be_nil
|
133
|
-
@output_store.revisions.must_equal []
|
134
|
-
refute Content.revision_exists?(@revision)
|
135
|
-
begin
|
136
|
-
silence_logger { @site.publish_pages([change1]) }
|
137
|
-
rescue Exception; end
|
138
|
-
@site.pending_revision.must_be_nil
|
139
|
-
refute Content.revision_exists?(@revision)
|
140
|
-
end
|
141
|
-
|
142
|
-
it "resets the must_publish_all flag after a successful publish" do
|
143
|
-
@site.must_publish_all!
|
144
|
-
@site.publish_all
|
145
|
-
@site.must_publish_all?.must_equal false
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
|
150
|
-
describe "rendering" do
|
151
|
-
before do
|
152
|
-
@revision = 2
|
153
|
-
Content.delete_revision(@revision)
|
154
|
-
Content.delete
|
155
|
-
S::State.delete
|
156
|
-
S::State.create(:revision => @revision, :published_revision => 2)
|
157
|
-
@site.revision.must_equal @revision
|
158
|
-
|
159
|
-
|
160
|
-
class ::PublishablePage < Page; end
|
161
|
-
class ::DynamicPublishablePage < Page; end
|
162
|
-
PublishablePage.box :box1
|
163
|
-
DynamicPublishablePage.box :box1
|
164
|
-
PublishablePage.layout :"static"
|
165
|
-
PublishablePage.layout :"dynamic"
|
166
|
-
|
167
|
-
DynamicPublishablePage.layout :"static"
|
168
|
-
DynamicPublishablePage.layout :"dynamic"
|
169
|
-
|
170
|
-
DynamicPublishablePage.controller do
|
171
|
-
get { show "/about" }
|
172
|
-
end
|
173
|
-
|
174
|
-
@home = PublishablePage.create(:title => 'Home')
|
175
|
-
@home.layout = :"dynamic"
|
176
|
-
@about = PublishablePage.create(:title => "About", :slug => "about")
|
177
|
-
@blog = PublishablePage.create(:title => "Blog", :slug => "blog")
|
178
|
-
@post1 = PublishablePage.create(:title => "Post 1", :slug => "post-1")
|
179
|
-
@post2 = PublishablePage.create(:title => "Post 2", :slug => "post-2")
|
180
|
-
@post3 = PublishablePage.create(:title => "Post 3", :slug => "post-3")
|
181
|
-
@news = DynamicPublishablePage.create(:title => "News", :slug => "news")
|
182
|
-
@contact = DynamicPublishablePage.create(:title => "Contact", :slug => "contact")
|
183
|
-
@contact.layout = :dynamic
|
184
|
-
@home.box1 << @about
|
185
|
-
@home.box1 << @blog
|
186
|
-
@home.box1 << @news
|
187
|
-
@home.box1 << @contact
|
188
|
-
@blog.box1 << @post1
|
189
|
-
@blog.box1 << @post2
|
190
|
-
@blog.box1 << @post3
|
191
|
-
@pages = [@home, @about, @blog, @news, @post1, @post2, @post3]
|
192
|
-
@pages.each { |p| p.save }
|
193
|
-
@site.publish_all
|
194
|
-
@template_revision = @output_store.revision(2)
|
195
|
-
end
|
196
|
-
|
197
|
-
after do
|
198
|
-
Content.delete_revision(@revision)
|
199
|
-
Content.delete_revision(@revision+1)
|
200
|
-
Content.delete
|
201
|
-
S::State.delete
|
202
|
-
Object.send(:remove_const, :PublishablePage) rescue nil
|
203
|
-
Object.send(:remove_const, :DynamicPublishablePage) rescue nil
|
204
|
-
end
|
205
|
-
|
206
|
-
it "symlink the latest revision to 'current'" do
|
207
|
-
revision_dir = @site.revision_root / "00002"
|
208
|
-
current_dir = @site.revision_root / "current"
|
209
|
-
assert File.exists?(current_dir)
|
210
|
-
assert File.symlink?(current_dir)
|
211
|
-
File.readlink(current_dir).must_equal revision_dir
|
212
|
-
end
|
213
|
-
|
214
|
-
it "have access to the current revision within the templates" do
|
215
|
-
@template_revision.static_template(@about.output(:html)).read.must_equal "Page: 'About' 2\n"
|
216
|
-
end
|
217
|
-
|
218
|
-
it "produce rendered versions of each page" do
|
219
|
-
revision_dir = @site.revision_root / "00002"
|
220
|
-
file = result = expected = nil
|
221
|
-
@pages.each do |page|
|
222
|
-
output = page.output(:html)
|
223
|
-
case page.slug
|
224
|
-
when "" # root is a dynamic page with no request handler
|
225
|
-
expected = "Page: '#{page.title}' {{Time.now.to_i}}\n"
|
226
|
-
result = @template_revision.dynamic_template(output)
|
227
|
-
when "news" # news produces a static template but has a request handler
|
228
|
-
expected = "Page: 'News' 2\n"
|
229
|
-
result = @template_revision.static_template(output)
|
230
|
-
when "contact" # contact is both dynamic and has a request handler
|
231
|
-
expected = "Page: 'Contact' {{Time.now.to_i}}\n"
|
232
|
-
result = @template_revision.dynamic_template(output)
|
233
|
-
else # the other pages are static
|
234
|
-
expected = "Page: '#{page.title}' 2\n"
|
235
|
-
result = @template_revision.static_template(output)
|
236
|
-
end
|
237
|
-
assert_equal expected, result.read
|
238
|
-
end
|
239
|
-
revision_dir = @site.revision_root / "00002"
|
240
|
-
Dir[S.root / "public/**/*"].each do |public_file|
|
241
|
-
site_file = public_file.gsub(%r(^#{S.root}/), '')
|
242
|
-
publish_file = revision_dir / site_file
|
243
|
-
assert File.exists?(publish_file)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
it "generate a config.ru file pointing to the current root" do
|
248
|
-
config_file = @site.revision_root / "00002/config.ru"
|
249
|
-
assert File.exists?(config_file)
|
250
|
-
File.read(config_file).must_match %r(#{Spontaneous.root})
|
251
|
-
end
|
252
|
-
|
253
|
-
it "generate a REVISION file containing the published revision number" do
|
254
|
-
rev_file = @site.revision_root / "REVISION"
|
255
|
-
result = File.read(rev_file)
|
256
|
-
result.must_equal Spontaneous::Media.pad_revision(@revision)
|
257
|
-
end
|
258
|
-
|
259
|
-
it "transparently support previously unknown formats by assuming a simple HTML like rendering model" do
|
260
|
-
PublishablePage.add_output :rtf
|
261
|
-
Content.delete_revision(@revision+1)
|
262
|
-
@site.publish_all
|
263
|
-
template_revision = @output_store.revision(@revision+1)
|
264
|
-
render = template_revision.static_template(@home.output(:rtf))
|
265
|
-
render.read.must_equal "RICH!\n"
|
266
|
-
end
|
267
|
-
|
268
|
-
it "respect a format's #dynamic? setting when deciding a rendered templates location" do
|
269
|
-
PublishablePage.add_output :rtf, :dynamic => true
|
270
|
-
Content.delete_revision(@revision+1)
|
271
|
-
@site.publish_all
|
272
|
-
@output_store.revision(@revision + 1).dynamic_template(@home.output(:rtf)).read.must_equal "RICH!\n"
|
273
|
-
end
|
274
|
-
|
275
|
-
it "run the content revision cleanup task after the revision is live" do
|
276
|
-
Content.expects(:cleanup_revisions).with(@revision+1, 8)
|
277
|
-
@site.publish_all
|
278
|
-
end
|
279
|
-
|
280
|
-
describe "hooks & triggers" do
|
281
|
-
it "after_publish hook should be fired after publish is complete" do
|
282
|
-
publish1 = mock
|
283
|
-
publish1.expects(:finished).with(@revision+1)
|
284
|
-
publish2 = mock
|
285
|
-
publish2.expects(:finished)
|
286
|
-
@site.after_publish do |revision|
|
287
|
-
publish1.finished(revision)
|
288
|
-
end
|
289
|
-
@site.after_publish do
|
290
|
-
publish2.finished
|
291
|
-
end
|
292
|
-
Content.delete_revision(@revision+1)
|
293
|
-
@site.publish_all
|
294
|
-
@site.published_revision.must_equal @revision+1
|
295
|
-
end
|
296
|
-
|
297
|
-
it "abort publish if hook raises error" do
|
298
|
-
published_revision = @revision+1
|
299
|
-
@site.pending_revision.must_be_nil
|
300
|
-
refute Content.revision_exists?(published_revision)
|
301
|
-
|
302
|
-
@site.after_publish do |revision|
|
303
|
-
raise "Boom"
|
304
|
-
end
|
305
|
-
|
306
|
-
begin
|
307
|
-
silence_logger { @site.publish_all }
|
308
|
-
rescue Exception; end
|
309
|
-
|
310
|
-
@site.pending_revision.must_be_nil
|
311
|
-
@site.published_revision.must_equal @revision
|
312
|
-
refute Content.revision_exists?(published_revision)
|
313
|
-
S::PublishedRevision.first(:revision => published_revision).must_be_nil
|
314
|
-
previous_root = Spontaneous.revision_dir(@revision)
|
315
|
-
published_root = Spontaneous.revision_dir(published_revision)
|
316
|
-
symlink = Pathname.new Spontaneous.revision_dir
|
317
|
-
# JRuby's Pathname#realpath doesn't work properly
|
318
|
-
# See: http://jira.codehaus.org/browse/JRUBY-6460
|
319
|
-
#
|
320
|
-
# This workaround tests that the symlink has been re-pointed
|
321
|
-
#
|
322
|
-
# File.read(symlink + "REVISION").realpath.to_s.must_equal Pathname.new(previous_root).realpath.to_s
|
323
|
-
File.open(Pathname.new(previous_root) + "REVISION", "w") do |file|
|
324
|
-
file.write(@revision)
|
325
|
-
end
|
326
|
-
File.read(symlink + "REVISION").must_equal @revision.to_s
|
327
|
-
end
|
328
|
-
end
|
329
|
-
end
|
330
|
-
end
|