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.
Files changed (247) hide show
  1. data/Gemfile +10 -4
  2. data/Readme.markdown +1 -1
  3. data/application/css/definitions.css.scss +5 -0
  4. data/application/css/dialogue.css.scss +62 -0
  5. data/application/js/content.js +1 -1
  6. data/application/js/dom.js +1 -1
  7. data/application/js/event_source.js +3 -0
  8. data/application/js/{field_types/date_field.js → field/date.js} +2 -2
  9. data/application/js/{field_types/file_field.js → field/file.js} +2 -2
  10. data/application/js/{field_types/image_field.js → field/image.js} +54 -20
  11. data/application/js/{field_types/long_string_field.js → field/long_string.js} +2 -2
  12. data/application/js/{field_types/markdown_field.js → field/markdown.js} +2 -2
  13. data/application/js/{field_types/select_field.js → field/select.js} +2 -2
  14. data/application/js/{field_types/string_field.js → field/string.js} +21 -7
  15. data/application/js/{field_types/webvideo_field.js → field/webvideo.js} +2 -2
  16. data/application/js/field.js +2 -2
  17. data/application/js/publish.js +99 -19
  18. data/application/js/spontaneous.js +8 -8
  19. data/application/js/top_bar.js +6 -4
  20. data/db/migrations/20130109125023_add_page_publish_lock.rb +17 -0
  21. data/db/migrations/20130111161934_convert_bcrypt_passwords.rb +22 -0
  22. data/db/migrations/20130114120000_create_revision_tables.rb +106 -0
  23. data/db/migrations/20130116220423_add_index_to_archive.rb +9 -0
  24. data/lib/spontaneous/box.rb +53 -18
  25. data/lib/spontaneous/box_style.rb +2 -3
  26. data/lib/spontaneous/change.rb +39 -13
  27. data/lib/spontaneous/cli/fields.rb +29 -0
  28. data/lib/spontaneous/cli/init.rb +2 -2
  29. data/lib/spontaneous/cli/migrate.rb +0 -1
  30. data/lib/spontaneous/cli/server.rb +14 -10
  31. data/lib/spontaneous/cli/site.rb +20 -9
  32. data/lib/spontaneous/cli.rb +8 -6
  33. data/lib/spontaneous/collections/box_set.rb +11 -0
  34. data/lib/spontaneous/collections/field_set.rb +24 -1
  35. data/lib/spontaneous/concern.rb +37 -0
  36. data/lib/spontaneous/config.rb +3 -4
  37. data/lib/spontaneous/crypt/version.rb +130 -0
  38. data/lib/spontaneous/crypt.rb +84 -0
  39. data/lib/spontaneous/data_mapper/content_model/associations.rb +199 -0
  40. data/lib/spontaneous/data_mapper/content_model/column_accessors.rb +52 -0
  41. data/lib/spontaneous/data_mapper/content_model/instance_hooks.rb +34 -0
  42. data/lib/spontaneous/data_mapper/content_model/serialization.rb +54 -0
  43. data/lib/spontaneous/data_mapper/content_model/timestamps.rb +39 -0
  44. data/lib/spontaneous/data_mapper/content_model.rb +343 -0
  45. data/lib/spontaneous/data_mapper/content_table.rb +103 -0
  46. data/lib/spontaneous/data_mapper/dataset.rb +194 -0
  47. data/lib/spontaneous/data_mapper/scope.rb +195 -0
  48. data/lib/spontaneous/data_mapper.rb +161 -0
  49. data/lib/spontaneous/facet.rb +2 -2
  50. data/lib/spontaneous/field/base.rb +418 -0
  51. data/lib/spontaneous/field/date.rb +54 -0
  52. data/lib/spontaneous/{field_version.rb → field/field_version.rb} +1 -1
  53. data/lib/spontaneous/field/file.rb +100 -0
  54. data/lib/spontaneous/{field_types/image_field.rb → field/image.rb} +33 -33
  55. data/lib/spontaneous/{field_types/location_field.rb → field/location.rb} +2 -2
  56. data/lib/spontaneous/{field_types/long_string_field.rb → field/long_string.rb} +3 -3
  57. data/lib/spontaneous/field/markdown.rb +36 -0
  58. data/lib/spontaneous/{field_types/select_field.rb → field/select.rb} +4 -5
  59. data/lib/spontaneous/field/string.rb +17 -0
  60. data/lib/spontaneous/field/update.rb +156 -0
  61. data/lib/spontaneous/field/webvideo.rb +310 -0
  62. data/lib/spontaneous/field.rb +80 -0
  63. data/lib/spontaneous/generators/site/Gemfile.tt +2 -2
  64. data/lib/spontaneous/generators/site/config/environments/development.rb.tt +1 -1
  65. data/lib/spontaneous/generators/site/config/environments/production.rb.tt +1 -1
  66. data/lib/spontaneous/generators/site/lib/content.rb.tt +6 -0
  67. data/lib/spontaneous/generators/site/schema/box.rb.tt +3 -2
  68. data/lib/spontaneous/generators/site/schema/page.rb.tt +3 -1
  69. data/lib/spontaneous/generators/site/schema/piece.rb.tt +3 -1
  70. data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +3 -1
  71. data/lib/spontaneous/generators/site.rb +4 -3
  72. data/lib/spontaneous/image_size.rb +8 -1
  73. data/lib/spontaneous/layout.rb +5 -1
  74. data/lib/spontaneous/loader.rb +2 -5
  75. data/lib/spontaneous/media/file.rb +11 -2
  76. data/lib/spontaneous/media/temp_file.rb +23 -0
  77. data/lib/spontaneous/media.rb +20 -39
  78. data/lib/spontaneous/{plugins → model/box}/allowed_types.rb +38 -17
  79. data/lib/spontaneous/model/box.rb +18 -0
  80. data/lib/spontaneous/{plugins → model/core}/aliases.rb +10 -14
  81. data/lib/spontaneous/{plugins → model/core}/boxes.rb +2 -2
  82. data/lib/spontaneous/{plugins → model/core}/content_groups.rb +2 -2
  83. data/lib/spontaneous/model/core/editor_class.rb +4 -0
  84. data/lib/spontaneous/{plugins → model/core}/entries.rb +19 -7
  85. data/lib/spontaneous/{plugins → model/core}/entry.rb +3 -3
  86. data/lib/spontaneous/{plugins → model/core}/fields.rb +38 -5
  87. data/lib/spontaneous/{plugins → model/core}/instance_code.rb +2 -2
  88. data/lib/spontaneous/{plugins → model/core}/media.rb +2 -12
  89. data/lib/spontaneous/{plugins → model/core}/modifications.rb +7 -6
  90. data/lib/spontaneous/model/core/page_search.rb +36 -0
  91. data/lib/spontaneous/{plugins → model/core}/permissions.rb +4 -4
  92. data/lib/spontaneous/{plugins → model/core}/prototypes.rb +4 -4
  93. data/lib/spontaneous/{plugins → model/core}/publishing.rb +93 -115
  94. data/lib/spontaneous/{plugins → model/core}/render.rb +2 -2
  95. data/lib/spontaneous/{plugins → model/core}/schema_hierarchy.rb +7 -11
  96. data/lib/spontaneous/model/core/schema_id.rb +65 -0
  97. data/lib/spontaneous/{plugins → model/core}/schema_title.rb +2 -2
  98. data/lib/spontaneous/{plugins → model/core}/serialisation.rb +2 -2
  99. data/lib/spontaneous/{plugins → model/core}/styles.rb +2 -2
  100. data/lib/spontaneous/{plugins → model/core}/supertype.rb +2 -2
  101. data/lib/spontaneous/{plugins → model/core}/visibility.rb +7 -48
  102. data/lib/spontaneous/model/core.rb +143 -0
  103. data/lib/spontaneous/{plugins → model/page}/controllers.rb +3 -3
  104. data/lib/spontaneous/{plugins → model}/page/formats.rb +2 -2
  105. data/lib/spontaneous/{plugins → model/page}/layouts.rb +2 -2
  106. data/lib/spontaneous/model/page/locks.rb +14 -0
  107. data/lib/spontaneous/{plugins → model/page}/page_tree.rb +3 -3
  108. data/lib/spontaneous/{plugins → model/page}/paths.rb +30 -12
  109. data/lib/spontaneous/{plugins → model}/page/request.rb +2 -2
  110. data/lib/spontaneous/{plugins → model/page}/site_map.rb +2 -2
  111. data/lib/spontaneous/model/page/site_timestamps.rb +44 -0
  112. data/lib/spontaneous/{page.rb → model/page.rb} +49 -28
  113. data/lib/spontaneous/{piece.rb → model/piece.rb} +7 -6
  114. data/lib/spontaneous/model.rb +97 -0
  115. data/lib/spontaneous/output/context.rb +1 -1
  116. data/lib/spontaneous/output/format.rb +4 -0
  117. data/lib/spontaneous/output/template/renderer.rb +2 -2
  118. data/lib/spontaneous/output.rb +2 -2
  119. data/lib/spontaneous/page_lock.rb +62 -0
  120. data/lib/spontaneous/page_piece.rb +1 -1
  121. data/lib/spontaneous/permissions/access_key.rb +9 -4
  122. data/lib/spontaneous/permissions/user.rb +19 -9
  123. data/lib/spontaneous/permissions.rb +2 -5
  124. data/lib/spontaneous/plugins/application/facets.rb +1 -2
  125. data/lib/spontaneous/plugins/application/features.rb +1 -1
  126. data/lib/spontaneous/plugins/application/paths.rb +1 -1
  127. data/lib/spontaneous/plugins/application/render.rb +1 -1
  128. data/lib/spontaneous/plugins/application/serialisation.rb +1 -1
  129. data/lib/spontaneous/plugins/application/state.rb +30 -1
  130. data/lib/spontaneous/plugins/application/system.rb +12 -12
  131. data/lib/spontaneous/prototypes/box_prototype.rb +1 -1
  132. data/lib/spontaneous/prototypes/field_prototype.rb +3 -6
  133. data/lib/spontaneous/prototypes/style_prototype.rb +1 -1
  134. data/lib/spontaneous/publishing/immediate.rb +77 -49
  135. data/lib/spontaneous/publishing/revision.rb +355 -0
  136. data/lib/spontaneous/publishing/simultaneous.rb +10 -49
  137. data/lib/spontaneous/publishing.rb +1 -0
  138. data/lib/spontaneous/rack/around_back.rb +1 -1
  139. data/lib/spontaneous/rack/around_front.rb +2 -4
  140. data/lib/spontaneous/rack/around_preview.rb +1 -1
  141. data/lib/spontaneous/rack/back.rb +80 -63
  142. data/lib/spontaneous/rack/cacheable_file.rb +2 -2
  143. data/lib/spontaneous/rack/cookie_authentication.rb +1 -1
  144. data/lib/spontaneous/rack/front.rb +1 -1
  145. data/lib/spontaneous/rack/helpers.rb +8 -9
  146. data/lib/spontaneous/{page_controller.rb → rack/page_controller.rb} +1 -1
  147. data/lib/spontaneous/rack/public.rb +3 -3
  148. data/lib/spontaneous/rack.rb +15 -15
  149. data/lib/spontaneous/schema/uid.rb +4 -1
  150. data/lib/spontaneous/schema.rb +57 -24
  151. data/lib/spontaneous/search/database.rb +12 -1
  152. data/lib/spontaneous/search/index.rb +34 -6
  153. data/lib/spontaneous/search/results.rb +1 -1
  154. data/lib/spontaneous/server.rb +3 -3
  155. data/lib/spontaneous/simultaneous.rb +53 -0
  156. data/lib/spontaneous/{plugins/site → site}/features.rb +2 -2
  157. data/lib/spontaneous/{plugins/site → site}/helpers.rb +2 -3
  158. data/lib/spontaneous/{plugins/site → site}/hooks.rb +2 -2
  159. data/lib/spontaneous/{plugins/site → site}/instance.rb +4 -6
  160. data/lib/spontaneous/{plugins/site → site}/level.rb +2 -2
  161. data/lib/spontaneous/{plugins/site → site}/map.rb +4 -4
  162. data/lib/spontaneous/{plugins/site → site}/paths.rb +2 -2
  163. data/lib/spontaneous/site/publishing.rb +89 -0
  164. data/lib/spontaneous/{plugins/site → site}/schema.rb +4 -4
  165. data/lib/spontaneous/{plugins/site → site}/search.rb +2 -2
  166. data/lib/spontaneous/{plugins/site → site}/selectors.rb +15 -7
  167. data/lib/spontaneous/{plugins/site → site}/state.rb +2 -2
  168. data/lib/spontaneous/{plugins/site → site}/storage.rb +2 -2
  169. data/lib/spontaneous/{plugins/site → site}/url.rb +2 -2
  170. data/lib/spontaneous/site.rb +31 -14
  171. data/lib/spontaneous/state.rb +5 -6
  172. data/lib/spontaneous/style.rb +3 -2
  173. data/lib/spontaneous/utils/database/mysql_dumper.rb +13 -0
  174. data/lib/spontaneous/utils/database/postgres_dumper.rb +5 -0
  175. data/lib/spontaneous/version.rb +1 -1
  176. data/lib/spontaneous.rb +34 -89
  177. data/spontaneous.gemspec +112 -114
  178. data/test/experimental/test_crypt.rb +158 -0
  179. data/test/experimental/test_features.rb +3 -3
  180. data/test/fixtures/example_application/config/environments/development.rb +1 -1
  181. data/test/fixtures/example_application/lib/content.rb +5 -0
  182. data/test/fixtures/example_application/schema/page.rb +2 -1
  183. data/test/fixtures/example_application/schema/piece.rb +3 -2
  184. data/test/fixtures/serialisation/class_hash.yaml.erb +5 -5
  185. data/test/fixtures/serialisation/root_hash.yaml.erb +8 -0
  186. data/test/functional/test_application.rb +12 -1
  187. data/test/functional/test_back.rb +80 -48
  188. data/test/functional/test_front.rb +39 -46
  189. data/test/functional/test_user_manager.rb +3 -9
  190. data/test/javascript/test_markdown.rb +2 -2
  191. data/test/test_helper.rb +78 -23
  192. data/test/unit/test_alias.rb +21 -15
  193. data/test/unit/test_asset_bundler.rb +3 -3
  194. data/test/unit/test_assets.rb +2 -2
  195. data/test/unit/test_async.rb +7 -6
  196. data/test/unit/test_authentication.rb +43 -37
  197. data/test/unit/test_boxes.rb +46 -21
  198. data/test/unit/test_changesets.rb +65 -20
  199. data/test/unit/test_config.rb +9 -9
  200. data/test/unit/test_content.rb +50 -51
  201. data/test/unit/test_content_inheritance.rb +6 -20
  202. data/test/unit/test_datamapper.rb +1330 -0
  203. data/test/unit/test_datamapper_content.rb +214 -0
  204. data/test/unit/test_fields.rb +543 -54
  205. data/test/unit/test_formats.rb +2 -3
  206. data/test/unit/test_generators.rb +6 -6
  207. data/test/unit/test_helpers.rb +1 -1
  208. data/test/unit/test_image_size.rb +10 -5
  209. data/test/unit/test_images.rb +17 -18
  210. data/test/unit/test_layouts.rb +18 -3
  211. data/test/unit/test_media.rb +74 -49
  212. data/test/unit/test_modifications.rb +43 -43
  213. data/test/unit/test_page.rb +7 -10
  214. data/test/unit/test_permissions.rb +3 -10
  215. data/test/unit/test_piece.rb +5 -6
  216. data/test/unit/test_plugins.rb +7 -14
  217. data/test/unit/test_prototypes.rb +3 -3
  218. data/test/unit/test_publishing.rb +49 -27
  219. data/test/unit/test_render.rb +46 -15
  220. data/test/unit/test_revisions.rb +124 -127
  221. data/test/unit/test_schema.rb +53 -58
  222. data/test/unit/test_search.rb +64 -16
  223. data/test/unit/test_serialisation.rb +4 -11
  224. data/test/unit/test_site.rb +11 -12
  225. data/test/unit/test_structure.rb +2 -5
  226. data/test/unit/test_styles.rb +22 -24
  227. data/test/unit/test_type_hierarchy.rb +7 -5
  228. data/test/unit/test_visibility.rb +79 -55
  229. metadata +128 -102
  230. data/lib/sequel/plugins/content_table_inheritance.rb +0 -203
  231. data/lib/sequel/plugins/scoped_table_name.rb +0 -54
  232. data/lib/spontaneous/content.rb +0 -129
  233. data/lib/spontaneous/field_types/date_field.rb +0 -56
  234. data/lib/spontaneous/field_types/field.rb +0 -302
  235. data/lib/spontaneous/field_types/file_field.rb +0 -68
  236. data/lib/spontaneous/field_types/markdown_field.rb +0 -38
  237. data/lib/spontaneous/field_types/string_field.rb +0 -19
  238. data/lib/spontaneous/field_types/webvideo_field.rb +0 -313
  239. data/lib/spontaneous/field_types.rb +0 -38
  240. data/lib/spontaneous/generators/site/lib/site.rb.tt +0 -4
  241. data/lib/spontaneous/plugins/field/editor_class.rb +0 -13
  242. data/lib/spontaneous/plugins/page/site_timestamps.rb +0 -28
  243. data/lib/spontaneous/plugins/page_search.rb +0 -63
  244. data/lib/spontaneous/plugins/schema_id.rb +0 -68
  245. data/lib/spontaneous/plugins/site/publishing.rb +0 -75
  246. data/lib/spontaneous/rack/fiber_pool.rb +0 -26
  247. data/test/unit/test_table_scoping.rb +0 -80
@@ -16,17 +16,16 @@ class ChangeTest < MiniTest::Spec
16
16
 
17
17
  context "Changes" do
18
18
  setup do
19
- @revision = 1
20
19
  stub_time(@now)
20
+ @revision = 1
21
21
 
22
- # DB.logger = Logger.new($stdout)
23
22
  Content.delete
24
23
 
25
- class Page < Spontaneous::Page
24
+ class Page < ::Page
26
25
  field :title, :string, :default => "New Page"
27
26
  box :things
28
27
  end
29
- class Piece < Spontaneous::Piece
28
+ class Piece < ::Piece
30
29
  box :things
31
30
  end
32
31
  end
@@ -41,6 +40,15 @@ class ChangeTest < MiniTest::Spec
41
40
  end
42
41
 
43
42
 
43
+ should "flag if the site has never been published" do
44
+ root = Page.create(:title => "root")
45
+ 5.times { |i| root.things << Page.create(:title => "Page #{i+1}") }
46
+ result = S::Change.outstanding
47
+ assert result.key?(:published_revision)
48
+ result[:published_revision].should == 0
49
+ result[:first_publish].should be_true
50
+ end
51
+
44
52
 
45
53
  should "list all newly created pages" do
46
54
  root = Page.create(:title => "root")
@@ -49,13 +57,16 @@ class ChangeTest < MiniTest::Spec
49
57
 
50
58
  5.times { |i| root.things << Page.create(:title => "Page #{i+1}") }
51
59
 
52
- result = Change.outstanding
53
- result.must_be_instance_of(Array)
54
- result.length.should == 5
60
+ result = S::Change.outstanding
61
+ result.must_be_instance_of(Hash)
62
+
63
+ pages = result[:changes]
64
+ pages.must_be_instance_of(Array)
65
+ pages.length.should == 5
55
66
 
56
- result.map(&:class).should == [Change]*5
67
+ pages.map(&:class).should == [S::Change]*5
57
68
 
58
- Set.new(result.map(&:page_id)).should == Set.new(root.things.map { |p| p.id })
69
+ Set.new(pages.map(&:page_id)).should == Set.new(root.things.map { |p| p.id })
59
70
  end
60
71
 
61
72
  should "not list new pieces as available for publish" do
@@ -66,7 +77,7 @@ class ChangeTest < MiniTest::Spec
66
77
  root[:first_published_at] = root[:last_published_at] = root.modified_at - 1000
67
78
  root.things << Piece.new
68
79
  root.save.reload
69
- result = Change.outstanding
80
+ result = S::Change.outstanding[:changes]
70
81
  result.length.should == 1
71
82
  result.first.page.should == root
72
83
  end
@@ -81,7 +92,7 @@ class ChangeTest < MiniTest::Spec
81
92
 
82
93
  Content.publish(@revision+1, [root.id, root.things.first.id])
83
94
 
84
- result = Change.outstanding
95
+ result = S::Change.outstanding[:changes]
85
96
  result.length.should == 4
86
97
  Set.new(result.map(&:page_id).flatten).should == Set.new(root.things[1..-1].map(&:id))
87
98
  end
@@ -108,7 +119,7 @@ class ChangeTest < MiniTest::Spec
108
119
 
109
120
 
110
121
  Content.publish(@revision+1, [root.id])
111
- result = Change.outstanding
122
+ result = S::Change.outstanding[:changes]
112
123
 
113
124
  result.length.should == 5
114
125
 
@@ -146,7 +157,7 @@ class ChangeTest < MiniTest::Spec
146
157
 
147
158
 
148
159
  Content.publish(@revision+1, [root.id])
149
- result = Change.outstanding
160
+ result = S::Change.outstanding[:changes]
150
161
 
151
162
  e = nil
152
163
  begin
@@ -172,7 +183,7 @@ class ChangeTest < MiniTest::Spec
172
183
  root.save
173
184
 
174
185
  Content.publish(@revision+1, [root.id])
175
- result = Change.outstanding
186
+ result = S::Change.outstanding[:changes]
176
187
  change = result.detect { |change| change.page.id == new_child1.id }
177
188
  change.export.should == {
178
189
  :id => new_child1.id,
@@ -183,12 +194,14 @@ class ChangeTest < MiniTest::Spec
183
194
  # :editor_login => "someone",
184
195
  :depth => new_child1.depth,
185
196
  :side_effects => {},
197
+ :update_locks => [],
186
198
  :dependent => [{
187
199
  :id => page1.id,
188
200
  :depth => page1.depth,
189
201
  :title => page1.title.value,
190
202
  :url => page1.path,
191
203
  :side_effects => {},
204
+ :update_locks => [],
192
205
  :published_at => nil,
193
206
  :modified_at => page1.modified_at.httpdate,
194
207
  }]
@@ -207,8 +220,8 @@ class ChangeTest < MiniTest::Spec
207
220
  page1.things << new_child1
208
221
  root.save
209
222
  last = Time.now + 100
210
- S::Content.filter(:id => new_child1.id).update(:modified_at => last)
211
- result = Change.outstanding
223
+ ::Content.filter(:id => new_child1.id).update(:modified_at => last)
224
+ result = S::Change.outstanding[:changes]
212
225
  assert result.first.modified_at > result.last.modified_at, "Change list in incorrect order"
213
226
  end
214
227
 
@@ -225,14 +238,17 @@ class ChangeTest < MiniTest::Spec
225
238
 
226
239
  Content.publish(@revision)
227
240
 
241
+ later = @now + 10
242
+ stub_time(later)
228
243
  old_slug = page1.slug
229
244
  page1.slug = "changed"
230
245
  page1.save
231
246
 
232
- result = Change.outstanding
247
+ result = S::Change.outstanding[:changes]
248
+
233
249
  change = result.detect { |change| change.page.id == page1.id }
234
250
  change.export[:side_effects].should == {
235
- :slug => [{ :count => 1, :created_at => @now.httpdate, :old_value => old_slug, :new_value => "changed"}]
251
+ :slug => [{ :count => 1, :created_at => later.httpdate, :old_value => old_slug, :new_value => "changed"}]
236
252
  }
237
253
  end
238
254
 
@@ -249,13 +265,42 @@ class ChangeTest < MiniTest::Spec
249
265
 
250
266
  Content.publish(@revision)
251
267
 
268
+ later = @now + 10
269
+ stub_time(later)
252
270
  page1.hide!
253
271
 
254
- result = Change.outstanding
272
+ page1.reload
273
+ result = S::Change.outstanding[:changes]
255
274
  change = result.detect { |change| change.page.id == page1.id }
256
275
  change.export[:side_effects].should == {
257
- :visibility => [{ :count => 1, :created_at => @now.httpdate, :old_value => false, :new_value => true}]
276
+ :visibility => [{ :count => 1, :created_at => later.httpdate, :old_value => false, :new_value => true}]
258
277
  }
259
278
  end
279
+
280
+ should "provide information about any update locks that exist on a page" do
281
+ Piece.field :async
282
+ page = Page.create(:title => "page")
283
+
284
+
285
+ piece = Piece.new
286
+
287
+ page.things << piece
288
+ page.save
289
+ piece.save
290
+
291
+ lock = Spontaneous::PageLock.create(:page_id => page.id, :content_id => piece.id, :field_id => piece.async.id, :description => "Update Lock")
292
+ page.locked_for_update?.should be_true
293
+ result = S::Change.outstanding[:changes]
294
+ change = result.detect { |change| change.page.id == page.id }
295
+ change.export[:update_locks].should == [{
296
+ id: lock.id,
297
+ content_id: piece.id,
298
+ field_id: piece.async.id,
299
+ field_name: :async,
300
+ location: "Field ‘async’ of entry 1 in box ‘things’",
301
+ description: "Update Lock",
302
+ created_at: @now.httpdate
303
+ }]
304
+ end
260
305
  end
261
306
  end
@@ -33,7 +33,7 @@ class ConfigTest < MiniTest::Spec
33
33
 
34
34
  context "Config" do
35
35
  setup do
36
- @config = Config.new(:development)
36
+ @config = Spontaneous::Config.new(:development)
37
37
  @config.load(@config_dir)
38
38
  end
39
39
  should "load the first time its accessed" do
@@ -44,7 +44,7 @@ class ConfigTest < MiniTest::Spec
44
44
  context "containing blocks" do
45
45
  setup do
46
46
  @settings = {}
47
- @config = Config::Loader.new(@settings)
47
+ @config = Spontaneous::Config::Loader.new(@settings)
48
48
  end
49
49
  should "add a hash to the settings under the defined key" do
50
50
  @config.storage :key1 do |config|
@@ -71,7 +71,7 @@ class ConfigTest < MiniTest::Spec
71
71
  # defined?(Spontaneous).should be_nil
72
72
  # require @lib_dir + '/spontaneous/config.rb'
73
73
  # Config.environment = :development
74
- @config = Config.new(:development)
74
+ @config = Spontaneous::Config.new(:development)
75
75
  @config.load(@config_dir)
76
76
  end
77
77
 
@@ -98,10 +98,10 @@ class ConfigTest < MiniTest::Spec
98
98
 
99
99
  should "overwrite values depending on environment" do
100
100
  @config.over_ridden.should == :development_value
101
- config = Config.new(:production)
101
+ config = Spontaneous::Config.new(:production)
102
102
  config.load(@config_dir)
103
103
  config.over_ridden.should == :production_value
104
- config = Config.new(:staging)
104
+ config = Spontaneous::Config.new(:staging)
105
105
  config.load(@config_dir)
106
106
  config.over_ridden.should == :environment_value
107
107
  end
@@ -120,10 +120,10 @@ class ConfigTest < MiniTest::Spec
120
120
 
121
121
  should "dynamically switch values according to the configured env" do
122
122
  @config.over_ridden.should == :development_value
123
- config = Config.new(:production)
123
+ config = Spontaneous::Config.new(:production)
124
124
  config.load(@config_dir)
125
125
  config.over_ridden.should == :production_value
126
- config = Config.new(:staging)
126
+ config = Spontaneous::Config.new(:staging)
127
127
  config.load(@config_dir)
128
128
  config.over_ridden.should == :environment_value
129
129
  end
@@ -157,7 +157,7 @@ class ConfigTest < MiniTest::Spec
157
157
 
158
158
  context "Spontaneous :back" do
159
159
  setup do
160
- @config = Config.new(:development, :back)
160
+ @config = Spontaneous::Config.new(:development, :back)
161
161
  @config.load(@config_dir)
162
162
  end
163
163
  should "read the correct configuration values" do
@@ -166,7 +166,7 @@ class ConfigTest < MiniTest::Spec
166
166
  end
167
167
  context "Spontaneous :front" do
168
168
  setup do
169
- @config = Config.new(:development, :front)
169
+ @config = Spontaneous::Config.new(:development, :front)
170
170
  @config.load(@config_dir)
171
171
  end
172
172
  should "read the correct configuration values" do
@@ -7,21 +7,19 @@ class ContentTest < MiniTest::Spec
7
7
  context "Content:" do
8
8
  setup do
9
9
  @site = setup_site
10
- class Piece < Spontaneous::Piece; end
11
- class Page < Spontaneous::Page; end
12
- class C < Piece; end
13
- class P < Page; end
10
+ # class Piece < Spontaneous::Piece; end
11
+ # class Page < Spontaneous::Page; end
12
+ class C < ::Piece; end
13
+ class P < ::Page; end
14
14
  C.box :things
15
15
  P.box :box1
16
16
  P.box :box2
17
17
  end
18
18
 
19
19
  teardown do
20
- teardown_site
21
- ContentTest.send(:remove_const, :Piece) rescue nil
22
- ContentTest.send(:remove_const, :Page) rescue nil
23
20
  ContentTest.send(:remove_const, :C) rescue nil
24
21
  ContentTest.send(:remove_const, :P) rescue nil
22
+ teardown_site
25
23
  end
26
24
 
27
25
  context "Content instances" do
@@ -31,7 +29,7 @@ class ContentTest < MiniTest::Spec
31
29
  })
32
30
  @instance.monkey.should == 'magic'
33
31
  id = @instance.id
34
- @instance = Content[id]
32
+ @instance = ::Content[id]
35
33
  @instance.monkey.should == 'magic'
36
34
  end
37
35
  end
@@ -41,8 +39,9 @@ class ContentTest < MiniTest::Spec
41
39
  end
42
40
 
43
41
  teardown do
44
- Content.delete
42
+ ::Content.delete rescue nil
45
43
  end
44
+
46
45
  should "be initialised empty" do
47
46
  @instance.contents.should == []
48
47
  end
@@ -330,51 +329,51 @@ class ContentTest < MiniTest::Spec
330
329
  end
331
330
 
332
331
  should "ensure that child pages have their visibility paths updated" do
333
- flunk "Implement this"
332
+ skip "Implement this"
334
333
  end
335
334
  end
336
335
 
337
336
 
338
- context "identity map" do
339
- setup do
340
-
341
- Content.delete
342
- Content.delete_all_revisions!
343
- class ::IdentitySubclass < C; end
344
- @c1 = C.create
345
- @c2 = C.create
346
- @i1 = IdentitySubclass.create
347
- @i2 = IdentitySubclass.create
348
- end
349
- teardown do
350
- Object.send(:remove_const, :IdentitySubclass) rescue nil
351
- # Content.delete
352
- # Content.delete_all_revisions!
353
- end
354
- should "work for Content" do
355
- Content.with_identity_map do
356
- Content[@c1.id].object_id.should == Content[@c1.id].object_id
357
- end
358
- end
359
-
360
- should "work for subclasses" do
361
- Content.with_identity_map do
362
- IdentitySubclass[@i1.id].object_id.should == IdentitySubclass[@i1.id].object_id
363
- end
364
- end
365
-
366
- should "return different objects for different revisions" do
367
- revision = 2
368
- a = b = nil
369
- Content.publish(revision)
370
- Content.with_identity_map do
371
- a = Content[@c1.id]
372
- Content.with_revision(revision) do
373
- b = Content[@c1.id]
374
- end
375
- a.object_id.should_not == b.object_id
376
- end
377
- end
378
- end
337
+ # context "identity map" do
338
+ # setup do
339
+
340
+ # ::Content.delete
341
+ # ::Content.delete_all_revisions!
342
+ # class ::IdentitySubclass < C; end
343
+ # @c1 = C.create
344
+ # @c2 = C.create
345
+ # @i1 = IdentitySubclass.create
346
+ # @i2 = IdentitySubclass.create
347
+ # end
348
+ # teardown do
349
+ # Object.send(:remove_const, :IdentitySubclass) rescue nil
350
+ # # Content.delete
351
+ # # Content.delete_all_revisions!
352
+ # end
353
+ # should "work for Content" do
354
+ # Content.with_identity_map do
355
+ # Content[@c1.id].object_id.should == Content[@c1.id].object_id
356
+ # end
357
+ # end
358
+
359
+ # should "work for subclasses" do
360
+ # Content.with_identity_map do
361
+ # IdentitySubclass[@i1.id].object_id.should == IdentitySubclass[@i1.id].object_id
362
+ # end
363
+ # end
364
+
365
+ # should "return different objects for different revisions" do
366
+ # revision = 2
367
+ # a = b = nil
368
+ # Content.publish(revision)
369
+ # Content.with_identity_map do
370
+ # a = Content[@c1.id]
371
+ # Content.with_revision(revision) do
372
+ # b = Content[@c1.id]
373
+ # end
374
+ # a.object_id.should_not == b.object_id
375
+ # end
376
+ # end
377
+ # end
379
378
  end
380
379
  end
@@ -10,7 +10,6 @@ class ContentInheritanceTest < MiniTest::Spec
10
10
  @site = setup_site
11
11
 
12
12
  Content.delete
13
- class ::Page < Spontaneous::Page; end
14
13
  class ::PageClass1 < ::Page; end
15
14
  class ::PageClass11 < ::PageClass1; end
16
15
  class ::PageClass111 < ::PageClass1; end
@@ -23,7 +22,6 @@ class ContentInheritanceTest < MiniTest::Spec
23
22
  @page2 = PageClass2.create.reload
24
23
  @page22 = PageClass22.create.reload
25
24
 
26
- class ::Piece < Spontaneous::Piece; end
27
25
  class ::PieceClass1 < ::Piece; end
28
26
  class ::PieceClass11 < PieceClass1; end
29
27
  class ::PieceClass111 < PieceClass11; end
@@ -39,7 +37,6 @@ class ContentInheritanceTest < MiniTest::Spec
39
37
 
40
38
  teardown do
41
39
  [
42
- :Page, :Piece,
43
40
  :PageClass1, :PageClass11, :PageClass111, :PageClass2, :PageClass22,
44
41
  :PieceClass1, :PieceClass11, :PieceClass111, :PieceClass2, :PieceClass22
45
42
  ].each do |klass|
@@ -48,7 +45,7 @@ class ContentInheritanceTest < MiniTest::Spec
48
45
  teardown_site
49
46
  end
50
47
 
51
- should "aaa correctly type subclasses found via Content" do
48
+ should "correctly type subclasses found via Content" do
52
49
  Set.new(Content.all.map { |c| c.class }).should == \
53
50
  Set.new([PageClass1, PageClass11, PageClass111, PageClass2, PageClass22,
54
51
  PieceClass1, PieceClass11, PieceClass111, PieceClass2, PieceClass22])
@@ -59,16 +56,10 @@ class ContentInheritanceTest < MiniTest::Spec
59
56
 
60
57
  context "Pages" do
61
58
 
62
- should "type subclasses found via Page" do
63
- Set.new(::Page.all.map { |c| c.class }).should == \
59
+ should "type subclasses found via Content::Page" do
60
+ Set.new(Content::Page.all.map { |c| c.class }).should == \
64
61
  Set.new([PageClass1, PageClass11, PageClass111, PageClass2, PageClass22])
65
- Set.new(::Page.all).should == Set.new([@page1, @page11, @page111, @page2, @page22])
66
- end
67
-
68
- should "type subclasses found via Spontaneous::Page" do
69
- Set.new(Spontaneous::Page.all.map { |c| c.class }).should == \
70
- Set.new([PageClass1, PageClass11, PageClass111, PageClass2, PageClass22])
71
- Set.new(Spontaneous::Page.all).should == Set.new([@page1, @page11, @page111, @page2, @page22])
62
+ Set.new(Content::Page.all).should == Set.new([@page1, @page11, @page111, @page2, @page22])
72
63
  end
73
64
 
74
65
  should "only find instances of a single class when searching via that subclass" do
@@ -82,14 +73,9 @@ class ContentInheritanceTest < MiniTest::Spec
82
73
 
83
74
  context "Pieces" do
84
75
  should "type subclasses found via Spontaneous::Piece" do
85
- Set.new(Spontaneous::Piece.all.map { |c| c.class }).should == \
86
- Set.new([PieceClass1, PieceClass11, PieceClass111, PieceClass2, PieceClass22])
87
- Set.new(Spontaneous::Piece.all).should == Set.new([@piece1, @piece11, @piece111, @piece2, @piece22])
88
- end
89
- should "type subclasses found via Piece" do
90
- Set.new(::Piece.all.map { |c| c.class }).should == \
76
+ Set.new(Content::Piece.all.map { |c| c.class }).should == \
91
77
  Set.new([PieceClass1, PieceClass11, PieceClass111, PieceClass2, PieceClass22])
92
- Set.new(::Piece.all).should == Set.new([@piece1, @piece11, @piece111, @piece2, @piece22])
78
+ Set.new(Content::Piece.all).should == Set.new([@piece1, @piece11, @piece111, @piece2, @piece22])
93
79
  end
94
80
 
95
81
  should "only find instances of a single class when searching via that subclass" do