spontaneous 0.2.0.beta1 → 0.2.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (335) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.locat +42 -0
  4. data/.travis/gemfiles/Gemfile.empty +7 -0
  5. data/.travis.yml +18 -0
  6. data/Gemfile +12 -8
  7. data/LICENSE +1 -1
  8. data/Rakefile +15 -157
  9. data/Readme.markdown +1 -1
  10. data/application/css/core.css.scss +22 -146
  11. data/application/css/definitions.css.scss +7 -3
  12. data/application/css/dialogue.css.scss +26 -1
  13. data/application/css/editing.css.scss +70 -28
  14. data/application/css/font.css.scss +1 -1
  15. data/application/css/popover.css.scss +2 -0
  16. data/application/css/top.css.scss +231 -0
  17. data/application/js/add_alias_dialogue.js +1 -1
  18. data/application/js/add_home_dialogue.js +1 -1
  19. data/application/js/ajax.js +61 -31
  20. data/application/js/box.js +4 -4
  21. data/application/js/conflicted_field_dialogue.js +1 -1
  22. data/application/js/content.js +5 -5
  23. data/application/js/dom.js +5 -0
  24. data/application/js/edit_panel.js +1 -0
  25. data/application/js/editing.js +1 -1
  26. data/application/js/extensions.js +8 -0
  27. data/application/js/field/boolean.js +31 -0
  28. data/application/js/field/file.js +32 -4
  29. data/application/js/field/image.js +24 -9
  30. data/application/js/field/markdown.js +87 -59
  31. data/application/js/field/select.js +1 -1
  32. data/application/js/field/webvideo.js +6 -1
  33. data/application/js/init.js +2 -2
  34. data/application/js/jquery-selection-position.js +130 -0
  35. data/application/js/location.js +4 -25
  36. data/application/js/meta_view/user_admin.js +2 -2
  37. data/application/js/metadata.js +2 -2
  38. data/application/js/page_browser.js +1 -1
  39. data/application/js/panel/root_menu.js +0 -1
  40. data/application/js/popover.js +27 -12
  41. data/application/js/popover_view.js +20 -4
  42. data/application/js/preview.js +31 -16
  43. data/application/js/progress.js +22 -21
  44. data/application/js/publish.js +18 -7
  45. data/application/js/sharded_upload.js +9 -6
  46. data/application/js/spontaneous.js +3 -1
  47. data/application/js/top_bar.js +264 -173
  48. data/application/js/upload.js +12 -5
  49. data/application/js/upload_manager.js +4 -3
  50. data/application/js/user.js +1 -2
  51. data/application/js/views/box_view.js +1 -1
  52. data/application/js/views/page_view.js +16 -5
  53. data/application/js/views/piece_view.js +5 -4
  54. data/application/static/font/fontawesome-webfont-1c66a4738b40ef0f6b1abca0ba9a796d.ttf +0 -0
  55. data/application/views/index.erb +6 -14
  56. data/application/views/login.erb +6 -25
  57. data/application/views/schema_modification_error.html.erb +3 -7
  58. data/db/migrations/20130114120000_create_revision_tables.rb +2 -2
  59. data/db/migrations/20130813111009_increase_path_length.rb +14 -0
  60. data/gem-public_cert.pem +20 -0
  61. data/lib/spontaneous/asset/app_compiler.rb +44 -0
  62. data/lib/spontaneous/asset/environment.rb +225 -0
  63. data/lib/spontaneous/asset.rb +2 -67
  64. data/lib/spontaneous/box.rb +0 -1
  65. data/lib/spontaneous/capistrano/deploy.rb +2 -2
  66. data/lib/spontaneous/capistrano/sync.rb +1 -1
  67. data/lib/spontaneous/cli/init.rb +36 -13
  68. data/lib/spontaneous/cli/server.rb +0 -1
  69. data/lib/spontaneous/cli/site.rb +2 -1
  70. data/lib/spontaneous/cli.rb +3 -1
  71. data/lib/spontaneous/collections/entry_set.rb +4 -12
  72. data/lib/spontaneous/collections/hash_with_fallback.rb +20 -0
  73. data/lib/spontaneous/collections/prototype_set.rb +6 -5
  74. data/lib/spontaneous/crypt.rb +2 -2
  75. data/lib/spontaneous/data_mapper/content_model/associations.rb +115 -63
  76. data/lib/spontaneous/data_mapper.rb +1 -1
  77. data/lib/spontaneous/errors.rb +6 -0
  78. data/lib/spontaneous/extensions/object_space.rb +6 -0
  79. data/lib/spontaneous/facet.rb +1 -0
  80. data/lib/spontaneous/field/base.rb +86 -13
  81. data/lib/spontaneous/field/boolean.rb +65 -0
  82. data/lib/spontaneous/field/file.rb +17 -6
  83. data/lib/spontaneous/field/html.rb +13 -0
  84. data/lib/spontaneous/field/image/size.rb +76 -0
  85. data/lib/spontaneous/field/image.rb +99 -414
  86. data/lib/spontaneous/field/tags.rb +36 -0
  87. data/lib/spontaneous/field/update.rb +1 -1
  88. data/lib/spontaneous/field/webvideo/fallback.rb +41 -0
  89. data/lib/spontaneous/field/webvideo/vimeo.rb +113 -0
  90. data/lib/spontaneous/field/webvideo/vine.rb +94 -0
  91. data/lib/spontaneous/field/webvideo/youtube.rb +133 -0
  92. data/lib/spontaneous/field/webvideo.rb +100 -250
  93. data/lib/spontaneous/field.rb +1 -1
  94. data/lib/spontaneous/generators/site/Gemfile.tt +5 -14
  95. data/lib/spontaneous/generators/site/assets/README.md +20 -0
  96. data/lib/spontaneous/generators/site/assets/css/site.scss +8 -0
  97. data/lib/spontaneous/generators/site/assets/js/site.js +6 -0
  98. data/lib/spontaneous/generators/site/config/deploy.rb.tt +9 -0
  99. data/lib/spontaneous/generators/site/config/user_levels.yml +14 -3
  100. data/lib/spontaneous/generators/site/public/README.md +12 -0
  101. data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +2 -2
  102. data/lib/spontaneous/generators/site.rb +77 -35
  103. data/lib/spontaneous/layout.rb +6 -7
  104. data/lib/spontaneous/loader.rb +21 -13
  105. data/lib/spontaneous/media/file.rb +22 -9
  106. data/lib/spontaneous/media/image/attributes.rb +33 -0
  107. data/lib/spontaneous/media/image/format/gif.rb +4 -0
  108. data/lib/spontaneous/media/image/format/jpg.rb +17 -0
  109. data/lib/spontaneous/media/image/format/png.rb +4 -0
  110. data/lib/spontaneous/media/image/format/webp.rb +26 -0
  111. data/lib/spontaneous/media/image/format.rb +79 -0
  112. data/lib/spontaneous/media/image/optimizer.rb +69 -0
  113. data/lib/spontaneous/media/image/processor.rb +17 -0
  114. data/lib/spontaneous/media/image/renderable.rb +52 -0
  115. data/lib/spontaneous/media/image/skeptick.rb +70 -0
  116. data/lib/spontaneous/media/image.rb +50 -0
  117. data/lib/spontaneous/media/temp_file.rb +4 -0
  118. data/lib/spontaneous/media.rb +1 -0
  119. data/lib/spontaneous/model/core/aliases.rb +14 -8
  120. data/lib/spontaneous/model/core/boxes.rb +5 -2
  121. data/lib/spontaneous/model/core/entries.rb +4 -0
  122. data/lib/spontaneous/model/core/entry.rb +1 -0
  123. data/lib/spontaneous/model/core/fields.rb +5 -2
  124. data/lib/spontaneous/model/core/locks.rb +16 -0
  125. data/lib/spontaneous/model/core/media.rb +1 -15
  126. data/lib/spontaneous/model/core.rb +31 -1
  127. data/lib/spontaneous/model/page/controllers.rb +2 -2
  128. data/lib/spontaneous/model/page/formats.rb +1 -4
  129. data/lib/spontaneous/model/page/layouts.rb +6 -2
  130. data/lib/spontaneous/model/page/locks.rb +8 -2
  131. data/lib/spontaneous/model/page/page_tree.rb +2 -2
  132. data/lib/spontaneous/model/page/paths.rb +74 -9
  133. data/lib/spontaneous/model/page.rb +11 -3
  134. data/lib/spontaneous/model.rb +6 -6
  135. data/lib/spontaneous/output/context/render_cache.rb +23 -0
  136. data/lib/spontaneous/output/context.rb +56 -30
  137. data/lib/spontaneous/output/helpers/script_helper.rb +9 -53
  138. data/lib/spontaneous/output/helpers/stylesheet_helper.rb +8 -40
  139. data/lib/spontaneous/output/template/renderer.rb +17 -5
  140. data/lib/spontaneous/output.rb +0 -1
  141. data/lib/spontaneous/paths.rb +6 -2
  142. data/lib/spontaneous/permissions/access_key.rb +18 -0
  143. data/lib/spontaneous/permissions/user.rb +1 -1
  144. data/lib/spontaneous/permissions.rb +4 -1
  145. data/lib/spontaneous/plugins/application/state.rb +19 -12
  146. data/lib/spontaneous/prototypes/field_prototype.rb +14 -8
  147. data/lib/spontaneous/published_revision.rb +7 -0
  148. data/lib/spontaneous/publishing/immediate.rb +43 -34
  149. data/lib/spontaneous/publishing/revision.rb +9 -6
  150. data/lib/spontaneous/rack/asset_server.rb +20 -0
  151. data/lib/spontaneous/rack/back/alias.rb +46 -0
  152. data/lib/spontaneous/rack/back/application_assets.rb +28 -0
  153. data/lib/spontaneous/rack/back/base.rb +34 -0
  154. data/lib/spontaneous/rack/back/changes.rb +19 -0
  155. data/lib/spontaneous/rack/back/content.rb +54 -0
  156. data/lib/spontaneous/rack/back/events.rb +38 -0
  157. data/lib/spontaneous/rack/back/field.rb +37 -0
  158. data/lib/spontaneous/rack/back/file.rb +118 -0
  159. data/lib/spontaneous/rack/back/helpers.rb +71 -0
  160. data/lib/spontaneous/rack/back/index.rb +16 -0
  161. data/lib/spontaneous/rack/back/login.rb +47 -0
  162. data/lib/spontaneous/rack/back/map.rb +24 -0
  163. data/lib/spontaneous/rack/back/page.rb +46 -0
  164. data/lib/spontaneous/rack/back/preview.rb +43 -0
  165. data/lib/spontaneous/rack/back/schema.rb +30 -0
  166. data/lib/spontaneous/rack/back/site.rb +25 -0
  167. data/lib/spontaneous/rack/back/site_assets.rb +13 -0
  168. data/lib/spontaneous/rack/back/unsupported_browser.rb +7 -0
  169. data/lib/spontaneous/rack/{user_admin.rb → back/user_admin.rb} +2 -5
  170. data/lib/spontaneous/rack/back.rb +85 -764
  171. data/lib/spontaneous/rack/cacheable_file.rb +3 -3
  172. data/lib/spontaneous/rack/front.rb +16 -9
  173. data/lib/spontaneous/rack/middleware/authenticate.rb +65 -0
  174. data/lib/spontaneous/rack/middleware/csrf.rb +66 -0
  175. data/lib/spontaneous/rack/middleware/reloader.rb +52 -0
  176. data/lib/spontaneous/rack/middleware/scope.rb +60 -0
  177. data/lib/spontaneous/rack/middleware.rb +6 -0
  178. data/lib/spontaneous/rack/page_controller.rb +18 -5
  179. data/lib/spontaneous/rack/public.rb +17 -11
  180. data/lib/spontaneous/rack.rb +34 -24
  181. data/lib/spontaneous/revision.rb +29 -2
  182. data/lib/spontaneous/schema/uid.rb +4 -3
  183. data/lib/spontaneous/schema/uid_map.rb +5 -24
  184. data/lib/spontaneous/schema.rb +1 -0
  185. data/lib/spontaneous/search/database.rb +8 -0
  186. data/lib/spontaneous/search/field.rb +1 -1
  187. data/lib/spontaneous/search/index.rb +3 -5
  188. data/lib/spontaneous/server.rb +1 -1
  189. data/lib/spontaneous/simultaneous.rb +1 -1
  190. data/lib/spontaneous/site/features.rb +4 -5
  191. data/lib/spontaneous/site/helpers.rb +22 -5
  192. data/lib/spontaneous/site/instance.rb +2 -2
  193. data/lib/spontaneous/site/selectors.rb +22 -3
  194. data/lib/spontaneous/storage/cloud.rb +13 -9
  195. data/lib/spontaneous/storage/local.rb +11 -6
  196. data/lib/spontaneous/style.rb +40 -23
  197. data/lib/spontaneous/utils/database/mysql_dumper.rb +1 -1
  198. data/lib/spontaneous/utils/smush_it.rb +1 -1
  199. data/lib/spontaneous/version.rb +1 -1
  200. data/lib/spontaneous.rb +35 -33
  201. data/spontaneous.gemspec +53 -787
  202. data/test/experimental/test_crypt.rb +56 -56
  203. data/test/experimental/test_features.rb +16 -27
  204. data/test/fixtures/assets/public1/css/data.css.scss +3 -0
  205. data/test/fixtures/assets/public1/css/image1.css.scss +4 -0
  206. data/test/fixtures/assets/public1/css/import.css.scss +1 -0
  207. data/test/fixtures/assets/public1/css/urlhash.css.scss +3 -0
  208. data/test/fixtures/assets/public1/js/a.js +1 -1
  209. data/test/fixtures/assets/public1/js/all.js +4 -0
  210. data/test/fixtures/assets/public1/js/{m.coffee → m.js.coffee} +1 -0
  211. data/test/fixtures/assets/public1/x.js +1 -0
  212. data/test/fixtures/assets/public2/css/all.css +4 -0
  213. data/test/fixtures/assets/public2/css/missing.css.scss +3 -0
  214. data/test/fixtures/assets/public2/i/y.png +0 -0
  215. data/test/fixtures/assets/public2/js/b.js +1 -1
  216. data/test/fixtures/assets/public2/js/c.js +1 -1
  217. data/test/fixtures/images/size.extended.webp +0 -0
  218. data/test/fixtures/images/size.lossless.webp +0 -0
  219. data/test/fixtures/images/size.lossy.webp +0 -0
  220. data/test/fixtures/schema/before.yml +4 -4
  221. data/test/fixtures/schema/schema.yml +1 -1
  222. data/test/fixtures/templates/aliases/aaa.html.cut +0 -0
  223. data/test/fixtures/templates/extended/partial_with_renderer.html.cut +1 -0
  224. data/test/fixtures/templates/extended/with_includes_and_renderer.html.cut +2 -0
  225. data/test/functional/test_application.rb +108 -106
  226. data/test/functional/test_back.rb +924 -930
  227. data/test/functional/test_front.rb +285 -238
  228. data/test/functional/test_user_manager.rb +75 -100
  229. data/test/integration/test_installation.rb +1 -1
  230. data/test/support/matchers.rb +12 -0
  231. data/test/support/minitest.rb +121 -0
  232. data/test/support/rack.rb +45 -0
  233. data/test/support/test_start_finish.rb +103 -0
  234. data/test/test_helper.rb +21 -68
  235. data/test/test_integration_helper.rb +1 -3
  236. data/test/unit/test_alias.rb +432 -408
  237. data/test/unit/test_asset_bundler.rb +58 -58
  238. data/test/unit/test_assets.rb +485 -155
  239. data/test/unit/test_async.rb +16 -37
  240. data/test/unit/test_authentication.rb +425 -457
  241. data/test/unit/test_boxes.rb +191 -191
  242. data/test/unit/test_changesets.rb +244 -254
  243. data/test/unit/test_config.rb +128 -142
  244. data/test/unit/test_content.rb +313 -359
  245. data/test/unit/test_content_inheritance.rb +29 -30
  246. data/test/unit/test_datamapper.rb +1205 -1080
  247. data/test/unit/test_datamapper_content.rb +49 -51
  248. data/test/unit/test_extensions.rb +23 -23
  249. data/test/unit/test_fields.rb +1488 -1180
  250. data/test/unit/test_formats.rb +158 -158
  251. data/test/unit/test_generators.rb +98 -40
  252. data/test/unit/test_helpers.rb +73 -76
  253. data/test/unit/test_image_size.rb +53 -22
  254. data/test/unit/test_images.rb +164 -165
  255. data/test/unit/test_layouts.rb +133 -122
  256. data/test/unit/test_logger.rb +14 -17
  257. data/test/unit/test_media.rb +69 -84
  258. data/test/unit/test_modifications.rb +513 -525
  259. data/test/unit/test_page.rb +462 -361
  260. data/test/unit/test_permissions.rb +379 -364
  261. data/test/unit/test_piece.rb +67 -75
  262. data/test/unit/test_plugins.rb +82 -89
  263. data/test/unit/test_prototype_set.rb +215 -216
  264. data/test/unit/test_prototypes.rb +114 -124
  265. data/test/unit/test_publishing.rb +252 -289
  266. data/test/unit/test_render.rb +167 -115
  267. data/test/unit/test_revisions.rb +436 -444
  268. data/test/unit/test_schema.rb +339 -309
  269. data/test/unit/test_search.rb +577 -574
  270. data/test/unit/test_serialisation.rb +136 -147
  271. data/test/unit/test_site.rb +252 -227
  272. data/test/unit/test_skeptick.rb +130 -0
  273. data/test/unit/test_storage.rb +46 -40
  274. data/test/unit/test_structure.rb +57 -66
  275. data/test/unit/test_styles.rb +104 -104
  276. data/test/unit/test_templates.rb +72 -57
  277. data/test/unit/test_type_hierarchy.rb +15 -16
  278. data/test/unit/test_visibility.rb +239 -257
  279. metadata +455 -326
  280. data/application/js/vendor/JS.Class-2.1.5/CHANGELOG +0 -283
  281. data/application/js/vendor/JS.Class-2.1.5/MIT-LICENSE +0 -30
  282. data/application/js/vendor/JS.Class-2.1.5/README +0 -30
  283. data/application/js/vendor/JS.Class-2.1.5/min/command.js +0 -1
  284. data/application/js/vendor/JS.Class-2.1.5/min/comparable.js +0 -1
  285. data/application/js/vendor/JS.Class-2.1.5/min/constant_scope.js +0 -1
  286. data/application/js/vendor/JS.Class-2.1.5/min/decorator.js +0 -1
  287. data/application/js/vendor/JS.Class-2.1.5/min/enumerable.js +0 -1
  288. data/application/js/vendor/JS.Class-2.1.5/min/forwardable.js +0 -1
  289. data/application/js/vendor/JS.Class-2.1.5/min/hash.js +0 -1
  290. data/application/js/vendor/JS.Class-2.1.5/min/linked_list.js +0 -1
  291. data/application/js/vendor/JS.Class-2.1.5/min/loader.js +0 -1
  292. data/application/js/vendor/JS.Class-2.1.5/min/method_chain.js +0 -1
  293. data/application/js/vendor/JS.Class-2.1.5/min/observable.js +0 -1
  294. data/application/js/vendor/JS.Class-2.1.5/min/package.js +0 -1
  295. data/application/js/vendor/JS.Class-2.1.5/min/proxy.js +0 -1
  296. data/application/js/vendor/JS.Class-2.1.5/min/ruby.js +0 -1
  297. data/application/js/vendor/JS.Class-2.1.5/min/set.js +0 -1
  298. data/application/js/vendor/JS.Class-2.1.5/min/stack_trace.js +0 -1
  299. data/application/js/vendor/JS.Class-2.1.5/min/state.js +0 -1
  300. data/application/js/vendor/JS.Class-2.1.5/min/stdlib.js +0 -16
  301. data/application/js/vendor/jquery-1.6.2.min.js +0 -18
  302. data/application/js/vendor/jquery-ui-1.8.16.custom.min.js +0 -791
  303. data/application/js/vendor/jquery-ui-1.8.9.custom.min.js +0 -415
  304. data/application/static/font/fontawesome-webfont-5c5c21100a346972a82c34c5e96ffcfe.ttf +0 -0
  305. data/application/static/select-arrow-6e7dd3745b00e934b0d7a3250c46558b.png +0 -0
  306. data/bin/limit-upload +0 -5
  307. data/bin/unlimit-upload +0 -3
  308. data/lib/spontaneous/asset/file.rb +0 -25
  309. data/lib/spontaneous/asset/source.rb +0 -28
  310. data/lib/spontaneous/image_size.rb +0 -123
  311. data/lib/spontaneous/output/assets/compression.rb +0 -58
  312. data/lib/spontaneous/output/assets.rb +0 -32
  313. data/lib/spontaneous/rack/around_back.rb +0 -20
  314. data/lib/spontaneous/rack/around_front.rb +0 -27
  315. data/lib/spontaneous/rack/around_preview.rb +0 -22
  316. data/lib/spontaneous/rack/assets.rb +0 -126
  317. data/lib/spontaneous/rack/authentication.rb +0 -20
  318. data/lib/spontaneous/rack/cookie_authentication.rb +0 -38
  319. data/lib/spontaneous/rack/helpers.rb +0 -52
  320. data/lib/spontaneous/rack/http.rb +0 -18
  321. data/lib/spontaneous/rack/media.rb +0 -30
  322. data/lib/spontaneous/rack/query_authentication.rb +0 -35
  323. data/lib/spontaneous/rack/reloader.rb +0 -45
  324. data/lib/spontaneous/rack/user_helpers.rb +0 -28
  325. /data/{README → application/js/field/markdown/text_command.js} +0 -0
  326. /data/application/js/vendor/{JS.Class-2.1.5/min/core.js → js.class-2.1.5.min.js} +0 -0
  327. /data/test/fixtures/assets/public1/css/{a.scss → a.css.scss} +0 -0
  328. /data/{lib/spontaneous/generators/site/public/css/site.scss → test/fixtures/assets/public1/x.css} +0 -0
  329. /data/{lib/spontaneous/generators/site/public/js/.empty_directory → test/fixtures/assets/public1/x.png} +0 -0
  330. /data/test/fixtures/assets/public2/css/{b.scss → b.css.scss} +0 -0
  331. /data/test/fixtures/assets/public2/js/{n.coffee → n.js.coffee} +0 -0
  332. /data/test/fixtures/back/{public → assets}/css/sass_include.scss +0 -0
  333. /data/test/fixtures/back/{public → assets}/css/sass_template.scss +0 -0
  334. /data/test/fixtures/back/{public → assets}/js/coffeescript.coffee +0 -0
  335. /data/{lib/spontaneous/generators/site/public/js/site.js → test/fixtures/templates/aliases/aa_alias.html.cut} +0 -0
@@ -2,113 +2,116 @@
2
2
 
3
3
  require File.expand_path('../../test_helper', __FILE__)
4
4
 
5
+ describe "Permissions" do
5
6
 
6
- class PermissionsTest < MiniTest::Spec
7
+ Permissions = Spontaneous::Permissions unless defined?(Permissions)
7
8
 
8
- Permissions = Spontaneous::Permissions
9
-
10
- def setup
9
+ before do
11
10
  @site = setup_site
12
11
  ::Content.delete
13
12
  Permissions::UserLevel.reset!
14
- Permissions::UserLevel.stubs(:level_file).returns(File.expand_path('../../fixtures/permissions', __FILE__) / 'config/user_levels.yml')
13
+ @level_file = File.expand_path('../../fixtures/permissions/config/user_levels.yml', __FILE__)
14
+ Permissions::UserLevel.stubs(:level_file).returns(@level_file)
15
15
  end
16
16
 
17
- def teardown
17
+ after do
18
18
  teardown_site
19
+ begin
19
20
  Permissions::AccessGroup.delete
20
21
  Permissions::AccessKey.delete
21
22
  Permissions::User.delete
22
- end
23
-
24
- context "Permissions" do
25
- should "be able to generate random strings of any length" do
26
- (2..256).each do |length|
27
- s1 = Permissions.random_string(length)
28
- s2 = Permissions.random_string(length)
29
- s1.length.should == length
30
- s2.length.should == length
31
- s1.should_not == s2
23
+ rescue => e
24
+ # My uniqueness constraint test raises a db error which then causes
25
+ # a pg transaction error that I can safely ignore
26
+ unless e.class == Sequel::DatabaseError && e.message =~ /current transaction is aborted/
27
+ raise
32
28
  end
33
29
  end
34
30
  end
35
- context "Levels" do
36
- setup do
37
- end
38
- teardown do
31
+
32
+ it "can generate random strings of any length" do
33
+ (2..256).each do |length|
34
+ s1 = Permissions.random_string(length)
35
+ s2 = Permissions.random_string(length)
36
+ s1.length.must_equal length
37
+ s2.length.must_equal length
38
+ s1.wont_equal s2
39
39
  end
40
+ end
40
41
 
41
- should "always have a level of :none/0" do
42
- Permissions::UserLevel.none.should == Permissions::UserLevel::None
43
- Permissions::UserLevel[:none].should == Permissions::UserLevel.none
44
- Permissions::UserLevel['none'].should == Permissions::UserLevel.none
42
+ describe "UserLevel" do
43
+ it "always has a level of :none/0" do
44
+ Permissions::UserLevel.none.must_equal Permissions::UserLevel::None
45
+ Permissions::UserLevel[:none].must_equal Permissions::UserLevel.none
46
+ Permissions::UserLevel['none'].must_equal Permissions::UserLevel.none
45
47
  end
46
48
 
47
- should "load from the config/user_levels.yml file" do
49
+ it "are loaded from the config/user_levels.yml file" do
48
50
  Permissions::UserLevel[:editor].must_be_instance_of(Permissions::UserLevel::Level)
49
51
  Permissions::UserLevel['editor'].must_be_instance_of(Permissions::UserLevel::Level)
50
52
  Permissions::UserLevel['admin'].must_be_instance_of(Permissions::UserLevel::Level)
51
53
  Permissions::UserLevel['designer'].must_be_instance_of(Permissions::UserLevel::Level)
52
54
  end
53
55
 
54
- should "provide a sorted list of all levels" do
55
- Permissions::UserLevel.all.map(&:to_sym).should == [:none, :editor, :admin, :designer, :root]
56
+ it "provides a sorted list of all levels" do
57
+ Permissions::UserLevel.all.map(&:to_sym).must_equal [:none, :editor, :admin, :designer, :root]
56
58
  end
57
59
 
58
- should "provide a list of all levels <= provided level" do
59
- Permissions::UserLevel.all(:editor).map(&:to_sym).should == [:none, :editor]
60
- Permissions::UserLevel.all(:designer).map(&:to_sym).should == [:none, :editor, :admin, :designer]
60
+ it "provides a list of all levels <= provided level" do
61
+ Permissions::UserLevel.all(:editor).map(&:to_sym).must_equal [:none, :editor]
62
+ Permissions::UserLevel.all(:designer).map(&:to_sym).must_equal [:none, :editor, :admin, :designer]
61
63
  end
62
64
 
63
- should "have a root level" do
64
- Permissions::UserLevel.root.should == Permissions::UserLevel::Root
65
+ it "has a root level" do
66
+ Permissions::UserLevel.root.must_equal Permissions::UserLevel::Root
65
67
  end
66
68
 
67
- should "have a root level that is always greater than other levels except root" do
68
- Permissions::UserLevel.root.should > Permissions::UserLevel['designer']
69
- Permissions::UserLevel.root.should >= Permissions::UserLevel['designer']
70
- Permissions::UserLevel.root.should_not > Permissions::UserLevel::Root
71
- Permissions::UserLevel.root.should >= Permissions::UserLevel::Root
72
- Permissions::UserLevel[:root].should == Permissions::UserLevel::Root
69
+ it "has a root level that is always greater than other levels except root" do
70
+ Permissions::UserLevel.root.must_be :>, Permissions::UserLevel['designer']
71
+ Permissions::UserLevel.root.must_be :>=, Permissions::UserLevel['designer']
72
+ Permissions::UserLevel.root.wont_be :>, Permissions::UserLevel::Root
73
+ Permissions::UserLevel.root.must_be :>=, Permissions::UserLevel::Root
74
+ Permissions::UserLevel[:root].must_equal Permissions::UserLevel::Root
73
75
  end
74
76
 
75
- should "work with > operator" do
76
- Permissions::UserLevel[:admin].should > Permissions::UserLevel[:editor]
77
- Permissions::UserLevel[:editor].should > Permissions::UserLevel[:none]
77
+ it "works with > operator" do
78
+ Permissions::UserLevel[:admin].must_be :>, Permissions::UserLevel[:editor]
79
+ Permissions::UserLevel[:editor].must_be :>, Permissions::UserLevel[:none]
78
80
  end
79
- should "work with >= operator" do
80
- Permissions::UserLevel[:admin].should >= Permissions::UserLevel[:admin]
81
- Permissions::UserLevel[:editor].should >= Permissions::UserLevel[:editor]
81
+ it "works with >= operator" do
82
+ Permissions::UserLevel[:admin].must_be :>=, Permissions::UserLevel[:admin]
83
+ Permissions::UserLevel[:editor].must_be :>=, Permissions::UserLevel[:editor]
82
84
  end
83
85
 
84
- should "return a minimum level > none" do
85
- Permissions::UserLevel.minimum.should == Permissions::UserLevel.editor
86
+ it "returns a minimum level > none" do
87
+ Permissions::UserLevel.minimum.must_equal Permissions::UserLevel.editor
86
88
  end
87
- should "have a valid string representation" do
88
- Permissions::UserLevel[:editor].to_s.should == 'editor'
89
- Permissions::UserLevel[:none].to_s.should == 'none'
90
- Permissions::UserLevel[:root].to_s.should == 'root'
91
- Permissions::UserLevel[:designer].to_s.should == 'designer'
89
+ it "has a valid string representation" do
90
+ Permissions::UserLevel[:editor].to_s.must_equal 'editor'
91
+ Permissions::UserLevel[:none].to_s.must_equal 'none'
92
+ Permissions::UserLevel[:root].to_s.must_equal 'root'
93
+ Permissions::UserLevel[:designer].to_s.must_equal 'designer'
92
94
  end
93
95
 
94
- should "have configurable level above which you have access to the publishing mechanism" do
95
- Permissions::UserLevel[:none].can_publish?.should be_false
96
- Permissions::UserLevel[:editor].can_publish?.should be_false
97
- Permissions::UserLevel[:admin].can_publish?.should be_false
98
- Permissions::UserLevel[:designer].can_publish?.should be_true
99
- Permissions::UserLevel[:root].can_publish?.should be_true
96
+ it "has configurable level above which you have access to the publishing mechanism" do
97
+ refute Permissions::UserLevel[:none].can_publish?
98
+ refute Permissions::UserLevel[:editor].can_publish?
99
+ refute Permissions::UserLevel[:admin].can_publish?
100
+ assert Permissions::UserLevel[:designer].can_publish?
101
+ assert Permissions::UserLevel[:root].can_publish?
100
102
  end
101
- should "Have a developer flag" do
102
- Permissions::UserLevel[:none].developer?.should be_false
103
- Permissions::UserLevel[:editor].developer?.should be_false
104
- Permissions::UserLevel[:admin].developer?.should be_false
105
- Permissions::UserLevel[:designer].developer?.should be_true
106
- Permissions::UserLevel[:root].developer?.should be_true
103
+
104
+ it "has a developer flag" do
105
+ refute Permissions::UserLevel[:none].developer?
106
+ refute Permissions::UserLevel[:editor].developer?
107
+ refute Permissions::UserLevel[:admin].developer?
108
+ assert Permissions::UserLevel[:designer].developer?
109
+ assert Permissions::UserLevel[:root].developer?
107
110
  end
108
111
  end
109
112
 
110
- context "Users" do
111
- setup do
113
+ describe "User" do
114
+ before do
112
115
  @now = Time.now
113
116
  Time.stubs(:now).returns(@now)
114
117
  @valid = {
@@ -125,21 +128,18 @@ class PermissionsTest < MiniTest::Spec
125
128
  }
126
129
  end
127
130
 
128
- teardown do
129
- end
130
-
131
- should "be retrievable as a list" do
131
+ it "are retrievable as a list" do
132
132
  user1 = Permissions::User.create(@valid.merge(:level => S::Permissions[:editor]))
133
133
  user2 = Permissions::User.create(@valid2.merge(:level => S::Permissions[:admin]))
134
134
  user1.logged_in!("196.168.1.11")
135
135
  exported = Permissions::User.export(nil)
136
- exported[:users].should == [
136
+ exported[:users].must_equal [
137
137
  { :id => user1.id, :name => "A Person", :email => "person@example.org", :login => "person", :level => "editor",
138
138
  :keys => [:last_access_at => @now.httpdate, :last_access_ip => "196.168.1.11"], :disabled => false },
139
139
  { :id => user2.id, :name => "Another Person", :email => "person2@example.org", :login => "person2", :level => "admin", :disabled => false,
140
140
  :keys => [] }
141
141
  ]
142
- exported[:levels].should == [
142
+ exported[:levels].must_equal [
143
143
  { :level => "none", :can_publish => false, :is_admin => false },
144
144
  { :level => "editor", :can_publish => false, :is_admin => false },
145
145
  { :level => "admin", :can_publish => false, :is_admin => true },
@@ -148,226 +148,226 @@ class PermissionsTest < MiniTest::Spec
148
148
  ]
149
149
  end
150
150
 
151
- should "filter exported user list to remove users with a higher level" do
151
+ it "filters exported user list to remove users with a higher level" do
152
152
  user1 = Permissions::User.create(@valid.merge(:level => S::Permissions[:editor]))
153
153
  user2 = Permissions::User.create(@valid2.merge(:level => S::Permissions[:admin]))
154
154
  user3 = Permissions::User.create(@valid.merge(:login => "person3", :email => "person3@example.com", :level => S::Permissions[:root]))
155
155
  user1.logged_in!("196.168.1.11")
156
156
  exported = Permissions::User.export(user2)
157
- exported[:users].should == [
157
+ exported[:users].must_equal [
158
158
  { :id => user1.id, :name => "A Person", :email => "person@example.org", :login => "person", :level => "editor", :disabled => false,
159
159
  :keys => [:last_access_at => @now.httpdate, :last_access_ip => "196.168.1.11"] },
160
160
  { :id => user2.id, :name => "Another Person", :email => "person2@example.org", :login => "person2", :level => "admin", :disabled => false,
161
161
  :keys => [] }
162
162
  ]
163
- exported[:levels].should == [
163
+ exported[:levels].must_equal [
164
164
  { :level => "none", :can_publish => false, :is_admin => false },
165
165
  { :level => "editor", :can_publish => false, :is_admin => false },
166
166
  { :level => "admin", :can_publish => false, :is_admin => true },
167
167
  ]
168
168
  end
169
169
 
170
- should "be creatable with valid params" do
170
+ it "is creatable with valid params" do
171
171
  user = Permissions::User.new(@valid)
172
172
  user.save.must_be_instance_of(Permissions::User)
173
- user.valid?.should be_true
173
+ assert user.valid?
174
174
  end
175
175
 
176
- should "validate name" do
176
+ it "validates names" do
177
177
  user = Permissions::User.new(@valid.merge(:name => ""))
178
- user.save.should be_nil
179
- user.valid?.should be_false
180
- user.errors[:name].should_not be_blank
178
+ user.save.must_be_nil
179
+ refute user.valid?
180
+ user.errors[:name].wont_be_empty
181
181
  end
182
182
 
183
- should "validate presence of email address" do
183
+ it "validates presence of email addresses" do
184
184
  user = Permissions::User.new(@valid.merge(:email => ""))
185
185
  user.save
186
- user.valid?.should be_false
187
- user.errors[:email].should_not be_blank
186
+ refute user.valid?
187
+ user.errors[:email].wont_be_empty
188
188
  end
189
189
 
190
- should "validate format of email address" do
190
+ it "validates format of email addresses" do
191
191
  user = Permissions::User.new(@valid.merge(:email => "invalid.email.address"))
192
192
  user.save
193
- user.valid?.should be_false
194
- user.errors[:email].should_not be_blank
193
+ refute user.valid?
194
+ user.errors[:email].wont_be_empty
195
195
  end
196
196
 
197
- should "validate presence of login" do
197
+ it "validates presence of logins" do
198
198
  user = Permissions::User.new(@valid.merge(:login => ""))
199
199
  user.save
200
- user.valid?.should be_false
201
- user.errors[:login].should_not be_blank
200
+ refute user.valid?
201
+ user.errors[:login].wont_be_empty
202
202
  end
203
203
 
204
- should "validate length of login" do
204
+ it "validates length of logins" do
205
205
  user = Permissions::User.new(@valid.merge(:login => "xx"))
206
206
  user.save
207
- user.valid?.should be_false
208
- user.errors[:login].should_not be_blank
207
+ refute user.valid?
208
+ user.errors[:login].wont_be_empty
209
209
  end
210
210
 
211
- should "reject duplicate logins on creation" do
211
+ it "rejects duplicate logins on creation" do
212
212
  user1 = Permissions::User.create(@valid)
213
213
  user2 = Permissions::User.new(@valid)
214
214
  user2.save
215
- user2.valid?.should be_false
216
- user2.errors[:login].should_not be_blank
215
+ refute user2.valid?
216
+ user2.errors[:login].wont_be_empty
217
217
  end
218
218
 
219
- should "reject duplicate logins" do
219
+ it "rejects duplicate logins on update" do
220
220
  user1 = Permissions::User.create(@valid)
221
221
  user2 = Permissions::User.create(@valid.merge(:login => "other"))
222
222
  user2.update_fields({:login => @valid[:login]}, [:login])
223
- user2.valid?.should be_false
224
- user2.errors[:login].should_not be_blank
223
+ refute user2.valid?
224
+ user2.errors[:login].wont_be_empty
225
225
  end
226
226
 
227
- should "require a non-blank password" do
227
+ it "requires non-blank passwords" do
228
228
  user = Permissions::User.new(@valid.merge(:password => ""))
229
229
  user.save
230
- user.valid?.should be_false
231
- user.errors[:password].should_not be_blank
230
+ refute user.valid?
231
+ user.errors[:password].wont_be_empty
232
232
  end
233
233
 
234
- should "require passwords to be at least 8 characters" do
234
+ it "requires passwords to be at least 8 characters" do
235
235
  user = Permissions::User.new(@valid.merge(:password => "1234567"))
236
236
  user.save
237
- user.valid?.should be_false
238
- user.errors[:password].should_not be_blank
237
+ refute user.valid?
238
+ user.errors[:password].wont_be_empty
239
239
  end
240
240
 
241
- context "who are valid" do
242
- setup do
241
+ describe "Valid" do
242
+ before do
243
243
  @user = Permissions::User.create(@valid)
244
244
  @user.reload
245
245
  end
246
246
 
247
- should "have a created_at date" do
248
- @user.created_at.to_i.should == @now.to_i
247
+ it "have a created_at date" do
248
+ @user.created_at.to_i.must_equal @now.to_i
249
249
  end
250
250
 
251
- should "have an associated 'invisible' group" do
251
+ it "have an associated 'invisible' group" do
252
252
  @user.group.must_be_instance_of(Permissions::AccessGroup)
253
- @user.group.invisible?.should be_true
254
- @user.group.level.should == Permissions::UserLevel::None
253
+ assert @user.group.invisible?
254
+ @user.group.level.must_equal Permissions::UserLevel::None
255
255
  end
256
256
 
257
257
  # the following actually works on the associated silent group
258
- should "default to a user level of Permissions::UserLevel.minimum" do
259
- @user.level.should == Permissions::UserLevel.none
258
+ it "default to a user level of Permissions::UserLevel.minimum" do
259
+ @user.level.must_equal Permissions::UserLevel.none
260
260
  end
261
261
 
262
- should "have a settable user level" do
262
+ it "have a settable user level" do
263
263
  @user.update(:level => Permissions::UserLevel[:root])
264
- @user.reload.level.should == Permissions::UserLevel.root
264
+ @user.reload.level.must_equal Permissions::UserLevel.root
265
265
  end
266
266
 
267
- should "have a list of groups it belongs to" do
268
- @user.memberships.should == [@user.group]
267
+ it "have a list of groups it belongs to" do
268
+ @user.memberships.must_equal [@user.group]
269
269
  end
270
270
 
271
- should "be able to login with right login/password combination" do
271
+ it "be able to login with right login/password combination" do
272
272
  key = Permissions::User.authenticate(@user.login, @user.password)
273
- key.user.id.should == @user.id
273
+ key.user.id.must_equal @user.id
274
274
  key = Permissions::User.authenticate(@user.login, "wrong password")
275
- key.should be_nil
275
+ key.must_be_nil
276
276
  end
277
277
 
278
- should "have a last login date" do
279
- @user.last_login_at.should be_nil
278
+ it "have a last login date" do
279
+ @user.last_login_at.must_be_nil
280
280
  key = Permissions::User.authenticate(@user.login, @user.password)
281
- @user.reload.last_login_at.to_i.should == @now.to_i
281
+ @user.reload.last_login_at.to_i.must_equal @now.to_i
282
282
  end
283
283
 
284
- should "generate a new access key on successful login" do
285
- @user.access_keys.should be_blank
284
+ it "generate a new access key on successful login" do
285
+ @user.access_keys.must_be_empty
286
286
  key = Permissions::User.authenticate(@user.login, @user.password)
287
- @user.reload.access_keys.length.should == 1
288
- @user.access_keys.first.created_at.to_i.should == @now.to_i
289
- @user.access_keys.first.last_access_at.to_i.should == @now.to_i
287
+ @user.reload.access_keys.length.must_equal 1
288
+ @user.access_keys.first.created_at.to_i.must_equal @now.to_i
289
+ @user.access_keys.first.last_access_at.to_i.must_equal @now.to_i
290
290
  end
291
291
 
292
- should "have a list of access keys" do
292
+ it "have a list of access keys" do
293
293
  @user.access_keys.must_be_instance_of(Array)
294
294
  end
295
295
 
296
- should "be blockable" do
296
+ it "be blockable" do
297
297
  @user.update(:disabled => true)
298
298
  key = Permissions::User.authenticate(@user.login, @user.password)
299
- key.should be_nil
299
+ key.must_be_nil
300
300
  end
301
301
 
302
- should "be able to belong to more than one group" do
302
+ it "be able to belong to more than one group" do
303
303
  group1 = Permissions::AccessGroup.create(:name => "Group 1")
304
304
  group2 = Permissions::AccessGroup.create(:name => "Group 2")
305
305
  @user.add_group(group1)
306
306
  @user.add_group(group2)
307
- @user.groups.length.should == 2
308
- group1.members.should == [@user]
309
- group2.members.should == [@user]
307
+ @user.groups.length.must_equal 2
308
+ group1.members.must_equal [@user]
309
+ group2.members.must_equal [@user]
310
310
  end
311
311
 
312
- should "return the right user level for a piece of content" do
312
+ it "return the right user level for a piece of content" do
313
313
  page = Page.create
314
314
  @user.update(:level => Permissions::UserLevel.admin)
315
- @user.access_selector.should == "*"
316
- @user.level_for(page).should == Permissions::UserLevel.admin
315
+ @user.access_selector.must_equal "*"
316
+ @user.level_for(page).must_equal Permissions::UserLevel.admin
317
317
  end
318
318
 
319
- should "return the highest access level when multiple exist" do
319
+ it "return the highest access level when multiple exist" do
320
320
  page = Page.create
321
321
  @user.update(:level => Permissions::UserLevel.none)
322
322
  group1 = Permissions::AccessGroup.create(:name => "Group 1", :level => Permissions::UserLevel.admin)
323
323
  group2 = Permissions::AccessGroup.create(:name => "Group 1", :level => Permissions::UserLevel.editor)
324
324
  group1.add_member(@user)
325
325
  group2.add_member(@user)
326
- @user.level_for(page).should == Permissions::UserLevel.admin
326
+ @user.level_for(page).must_equal Permissions::UserLevel.admin
327
327
  end
328
328
 
329
- should "have a test for developer status" do
329
+ it "have a test for developer status" do
330
330
  @user.update(:level => Permissions::UserLevel.editor)
331
- @user.developer?.should be_false
331
+ refute @user.developer?
332
332
  @user.update(:level => Permissions::UserLevel.designer)
333
- @user.developer?.should be_true
333
+ assert @user.developer?
334
334
  end
335
335
 
336
- should "be testable for ability to publish depending on their user level" do
336
+ it "be testable for ability to publish depending on their user level" do
337
337
  @user.update(:level => Permissions::UserLevel.editor)
338
- @user.can_publish?.should be_false
338
+ refute @user.can_publish?
339
339
  @user.update(:level => Permissions::UserLevel.designer)
340
- @user.can_publish?.should be_true
340
+ assert @user.can_publish?
341
341
  end
342
342
 
343
- should "be testable for admin privileges" do
343
+ it "be testable for admin privileges" do
344
344
  @user.update(:level => Permissions::UserLevel.none)
345
- @user.admin?.should be_false
345
+ refute @user.admin?
346
346
  @user.update(:level => Permissions::UserLevel.editor)
347
- @user.admin?.should be_false
347
+ refute @user.admin?
348
348
  @user.update(:level => Permissions::UserLevel.designer)
349
- @user.admin?.should be_false
349
+ refute @user.admin?
350
350
  @user.update(:level => Permissions::UserLevel.admin)
351
- @user.admin?.should be_true
351
+ assert @user.admin?
352
352
  @user.update(:level => Permissions::UserLevel.root)
353
- @user.admin?.should be_true
353
+ assert @user.admin?
354
354
  end
355
355
 
356
- should "serialise to JSON" do
357
- @user.export.should == {
356
+ it "serialise to JSON" do
357
+ @user.export.must_equal({
358
358
  :name => "A Person",
359
359
  :email => "person@example.org",
360
360
  :login => "person",
361
361
  :can_publish => false,
362
362
  :admin => false,
363
363
  :developer => false
364
- }
364
+ })
365
365
  end
366
366
  end
367
367
  end
368
368
 
369
- context "access keys" do
370
- setup do
369
+ describe "access keys" do
370
+ before do
371
371
  @now = Time.now
372
372
  Time.stubs(:now).returns(@now)
373
373
  @valid = {
@@ -378,113 +378,128 @@ class PermissionsTest < MiniTest::Spec
378
378
  }
379
379
  end
380
380
 
381
- teardown do
381
+ after do
382
382
  end
383
383
 
384
- should "have a generated key_id" do
384
+ it "have a generated key_id" do
385
385
  key1 = Permissions::AccessKey.create
386
- key1.key_id.length.should == 44
386
+ key1.key_id.length.must_equal 44
387
387
  key2 = Permissions::AccessKey.create
388
- key2.key_id.length.should == 44
389
- key1.key_id.should_not == key2.key_id
388
+ key2.key_id.length.must_equal 44
389
+ key1.key_id.wont_equal key2.key_id
390
390
  end
391
391
 
392
- should "allow authentication of a user" do
392
+ it "allow authentication of a user" do
393
393
  key1 = Permissions::AccessKey.create
394
394
  key2 = Permissions::AccessKey.authenticate(key1.key_id)
395
- key1.id.should == key2.id
395
+ key1.id.must_equal key2.id
396
396
  end
397
397
 
398
- should "update timestamps when authenticated" do
398
+ it "update timestamps when authenticated" do
399
399
  user = Permissions::User.create(@valid)
400
400
  key1 = Permissions::AccessKey.create(:user_id => user.id)
401
401
  Time.stubs(:now).returns(@now + 1000)
402
402
  key2 = Permissions::AccessKey.create(:user_id => user.id)
403
403
  key3 = Permissions::AccessKey.authenticate(key2.key_id)
404
- key2.id.should == key3.id
405
- key2.reload.last_access_at.to_i.should == (@now+1000).to_i
406
- key2.user.last_access_at.to_i.should == (@now+1000).to_i
404
+ key2.id.must_equal key3.id
405
+ key2.reload.last_access_at.to_i.must_equal (@now+1000).to_i
406
+ key2.user.last_access_at.to_i.must_equal (@now+1000).to_i
407
407
  end
408
408
 
409
- should "be guaranteed unique" do
409
+ it "be guaranteed unique" do
410
410
  Permissions.stubs(:random_string).returns("xxxx")
411
411
  key1 = Permissions::AccessKey.create()
412
412
  lambda { Permissions::AccessKey.create() }.must_raise(Sequel::DatabaseError)
413
413
  end
414
414
 
415
- should "have a creation date" do
415
+ it "have a creation date" do
416
416
  key1 = Permissions::AccessKey.create
417
- key1.created_at.to_i.should == @now.to_i
417
+ key1.created_at.to_i.must_equal @now.to_i
418
418
  end
419
419
 
420
- should "have a source IP address"
421
-
422
- should "retrieve their associated user" do
420
+ it "retrieve their associated user" do
423
421
  user = Permissions::User.create(@valid)
424
422
  key1 = Permissions::AccessKey.create(:user_id => user.id)
425
- key1.reload.user.should == user
423
+ key1.reload.user.must_equal user
426
424
  end
427
425
 
428
- should "be disabled when user blocked" do
426
+ it "be disabled when user blocked" do
429
427
  user = Permissions::User.create(@valid)
430
428
  key1 = Permissions::AccessKey.create(:user_id => user.id)
431
429
  user.update(:disabled => true)
432
430
  key3 = Permissions::AccessKey.authenticate(key1.key_id)
433
- key3.should be_nil
431
+ key3.must_be_nil
434
432
  end
435
- end
436
433
 
434
+ describe "csrf tokens" do
435
+ before do
436
+ user = Permissions::User.create(@valid)
437
+ @key1 = Permissions::AccessKey.create(:user_id => user.id)
438
+ @key2 = Permissions::AccessKey.create(:user_id => user.id)
439
+ end
437
440
 
441
+ it "be validatable" do
442
+ token = @key1.generate_csrf_token
443
+ assert @key1.csrf_token_valid?(token)
444
+ end
438
445
 
439
- context "Groups" do
440
- setup do
441
- @valid_group = {
442
- :name => "Some People"
443
- }
446
+ it "only be valid for the same token" do
447
+ token = @key1.generate_csrf_token
448
+ refute @key2.csrf_token_valid?(token)
449
+ end
450
+
451
+ it "recognises nil tokens as invalid" do
452
+ refute @key2.csrf_token_valid?(nil)
453
+ end
444
454
  end
455
+ end
456
+
457
+
445
458
 
446
- teardown do
459
+ describe "Groups" do
460
+ before do
461
+ @valid_group = { :name => "Some People" }
447
462
  end
448
463
 
449
- should "always have a name" do
464
+ it "always have a name" do
450
465
  group = Permissions::AccessGroup.new(@valid_group.merge(:name => ""))
451
- group.valid?.should be_false
452
- group.errors[:name].should_not be_blank
466
+ refute group.valid?
467
+ group.errors[:name].wont_be_empty
453
468
  end
454
469
 
455
- should "default to a user level of :none" do
470
+ it "default to a user level of :none" do
456
471
  group = Permissions::AccessGroup.create(@valid_group)
457
472
  group.reload
458
- group.level.should == Permissions::UserLevel::None
473
+ group.level.must_equal Permissions::UserLevel::None
459
474
  end
460
475
 
461
476
  # disabling a user and blocking a group are different
462
477
  # if you disable a user you disable their login
463
478
  # if you block a group they belong to you remove the permissions
464
479
  # granted by that group but you aren't stopping them from logging in
465
- should "be blockable" do
480
+ it "be blockable" do
466
481
  group = Permissions::AccessGroup.create(@valid_group.merge(:level => Permissions::UserLevel.admin))
467
- group.level.should == Permissions::UserLevel.admin
482
+ group.level.must_equal Permissions::UserLevel.admin
468
483
  group.update(:disabled => true)
469
- group.level.should == Permissions::UserLevel.none
484
+ group.level.must_equal Permissions::UserLevel.none
470
485
  end
471
486
 
472
- should "default to applying to the whole site" do
487
+ it "default to applying to the whole site" do
473
488
  group = Permissions::AccessGroup.create(@valid_group)
474
- group.access_selector.should == "*"
489
+ group.access_selector.must_equal "*"
475
490
  end
476
491
 
477
- should "return the right user level for a piece of content" do
492
+ it "return the right user level for a piece of content" do
478
493
  group = Permissions::AccessGroup.create(@valid_group)
479
494
  page = Page.create
480
495
  group.update(:level => Permissions::UserLevel.admin)
481
- group.access_selector.should == "*"
482
- group.level_for(page).should == Permissions::UserLevel.admin
496
+ group.access_selector.must_equal "*"
497
+ group.level_for(page).must_equal Permissions::UserLevel.admin
483
498
  end
484
499
  end
485
500
 
486
- context "Guards" do
487
- setup do
501
+ describe "Guards" do
502
+ before do
488
503
  Permissions::User.delete
489
504
  @visitor = Permissions::User.create(:email => "visitor@example.com", :login => "visitor", :name => "visitor", :password => "visitorpass")
490
505
  @editor = Permissions::User.create(:email => "editor@example.com", :login => "editor", :name => "editor", :password => "editorpass")
@@ -557,144 +572,144 @@ class PermissionsTest < MiniTest::Spec
557
572
  @i = C.new
558
573
  end
559
574
 
560
- teardown do
575
+ after do
561
576
  Object.send(:remove_const, :C) rescue nil
562
577
  Object.send(:remove_const, :D) rescue nil
563
578
  end
564
579
 
565
- should "protect field reads" do
580
+ it "protect field reads" do
566
581
  # without user (e.g. terminal/console access) everything is always
567
582
  # possible
568
- @i.field_readable?(nil, :editor_level).should be_true
569
- @i.field_readable?(nil, :admin_level).should be_true
570
- @i.field_readable?(nil, :root_level).should be_true
571
- @i.field_readable?(nil, :mixed_level).should be_true
572
- @i.field_readable?(nil, :default_level).should be_true
573
-
574
- @i.field_readable?(@visitor, :editor_level).should be_false
575
- @i.field_readable?(@visitor, :admin_level).should be_false
576
- @i.field_readable?(@visitor, :root_level).should be_false
577
- @i.field_readable?(@visitor, :mixed_level).should be_false
578
- @i.field_readable?(@visitor, :default_level).should be_true
579
-
580
- @i.field_readable?(@editor, :editor_level).should be_true
581
- @i.field_readable?(@editor, :admin_level).should be_false
582
- @i.field_readable?(@editor, :root_level).should be_false
583
- @i.field_readable?(@editor, :mixed_level).should be_true
584
- @i.field_readable?(@editor, :default_level).should be_true
585
-
586
- @i.field_readable?(@admin, :editor_level).should be_true
587
- @i.field_readable?(@admin, :admin_level).should be_true
588
- @i.field_readable?(@admin, :root_level).should be_false
589
- @i.field_readable?(@admin, :mixed_level).should be_true
590
- @i.field_readable?(@admin, :default_level).should be_true
591
-
592
- @i.field_readable?(@root, :editor_level).should be_true
593
- @i.field_readable?(@root, :admin_level).should be_true
594
- @i.field_readable?(@root, :root_level).should be_true
595
- @i.field_readable?(@root, :mixed_level).should be_true
596
- @i.field_readable?(@root, :default_level).should be_true
597
- end
598
-
599
- should "protect field writes" do
583
+ assert @i.field_readable?(nil, :editor_level)
584
+ assert @i.field_readable?(nil, :admin_level)
585
+ assert @i.field_readable?(nil, :root_level)
586
+ assert @i.field_readable?(nil, :mixed_level)
587
+ assert @i.field_readable?(nil, :default_level)
588
+
589
+ refute @i.field_readable?(@visitor, :editor_level)
590
+ refute @i.field_readable?(@visitor, :admin_level)
591
+ refute @i.field_readable?(@visitor, :root_level)
592
+ refute @i.field_readable?(@visitor, :mixed_level)
593
+ assert @i.field_readable?(@visitor, :default_level)
594
+
595
+ assert @i.field_readable?(@editor, :editor_level)
596
+ refute @i.field_readable?(@editor, :admin_level)
597
+ refute @i.field_readable?(@editor, :root_level)
598
+ assert @i.field_readable?(@editor, :mixed_level)
599
+ assert @i.field_readable?(@editor, :default_level)
600
+
601
+ assert @i.field_readable?(@admin, :editor_level)
602
+ assert @i.field_readable?(@admin, :admin_level)
603
+ refute @i.field_readable?(@admin, :root_level)
604
+ assert @i.field_readable?(@admin, :mixed_level)
605
+ assert @i.field_readable?(@admin, :default_level)
606
+
607
+ assert @i.field_readable?(@root, :editor_level)
608
+ assert @i.field_readable?(@root, :admin_level)
609
+ assert @i.field_readable?(@root, :root_level)
610
+ assert @i.field_readable?(@root, :mixed_level)
611
+ assert @i.field_readable?(@root, :default_level)
612
+ end
613
+
614
+ it "protect field writes" do
600
615
  # without user (e.g. terminal/console access) everything is always
601
616
  # possible
602
- @i.field_writable?(nil, :editor_level).should be_true
603
- @i.field_writable?(nil, :admin_level).should be_true
604
- @i.field_writable?(nil, :root_level).should be_true
605
- @i.field_writable?(nil, :mixed_level).should be_true
606
- @i.field_writable?(nil, :default_level).should be_true
607
-
608
- @i.field_writable?(@visitor, :editor_level).should be_false
609
- @i.field_writable?(@visitor, :admin_level).should be_false
610
- @i.field_writable?(@visitor, :root_level).should be_false
611
- @i.field_writable?(@visitor, :mixed_level).should be_false
612
- @i.field_writable?(@visitor, :default_level).should be_false
613
-
614
- @i.field_writable?(@editor, :editor_level).should be_true
615
- @i.field_writable?(@editor, :admin_level).should be_false
616
- @i.field_writable?(@editor, :root_level).should be_false
617
- @i.field_writable?(@editor, :mixed_level).should be_false
618
- @i.field_writable?(@editor, :default_level).should be_true
619
-
620
- @i.field_writable?(@admin, :editor_level).should be_true
621
- @i.field_writable?(@admin, :admin_level).should be_true
622
- @i.field_writable?(@admin, :root_level).should be_false
623
- @i.field_writable?(@admin, :mixed_level).should be_false
624
- @i.field_writable?(@admin, :default_level).should be_true
625
-
626
- @i.field_writable?(@root, :editor_level).should be_true
627
- @i.field_writable?(@root, :admin_level).should be_true
628
- @i.field_writable?(@root, :root_level).should be_true
629
- @i.field_writable?(@root, :mixed_level).should be_true
630
- @i.field_writable?(@root, :default_level).should be_true
631
- end
632
-
633
- should "protect box reads" do
634
- @i.box_readable?(nil, :editor_level).should be_true
635
- @i.box_readable?(nil, :admin_level).should be_true
636
- @i.box_readable?(nil, :root_level).should be_true
637
- @i.box_readable?(nil, :mixed_level).should be_true
638
- @i.box_readable?(nil, :default_level).should be_true
639
-
640
- @i.box_readable?(@visitor, :editor_level).should be_false
641
- @i.box_readable?(@visitor, :admin_level).should be_false
642
- @i.box_readable?(@visitor, :root_level).should be_false
643
- @i.box_readable?(@visitor, :mixed_level).should be_false
644
- @i.box_readable?(@visitor, :default_level).should be_true
645
-
646
- @i.box_readable?(@editor, :editor_level).should be_true
647
- @i.box_readable?(@editor, :admin_level).should be_false
648
- @i.box_readable?(@editor, :root_level).should be_false
649
- @i.box_readable?(@editor, :mixed_level).should be_true
650
- @i.box_readable?(@editor, :default_level).should be_true
651
-
652
- @i.box_readable?(@admin, :editor_level).should be_true
653
- @i.box_readable?(@admin, :admin_level).should be_true
654
- @i.box_readable?(@admin, :root_level).should be_false
655
- @i.box_readable?(@admin, :mixed_level).should be_true
656
- @i.box_readable?(@admin, :default_level).should be_true
657
-
658
- @i.box_readable?(@root, :editor_level).should be_true
659
- @i.box_readable?(@root, :admin_level).should be_true
660
- @i.box_readable?(@root, :root_level).should be_true
661
- @i.box_readable?(@root, :mixed_level).should be_true
662
- @i.box_readable?(@root, :default_level).should be_true
663
- end
664
- should "protect box writes" do
665
- @i.box_writable?(nil, :editor_level).should be_true
666
- @i.box_writable?(nil, :admin_level).should be_true
667
- @i.box_writable?(nil, :root_level).should be_true
668
- @i.box_writable?(nil, :mixed_level).should be_true
669
- @i.box_writable?(nil, :default_level).should be_true
670
-
671
- @i.box_writable?(@visitor, :editor_level).should be_false
672
- @i.box_writable?(@visitor, :admin_level).should be_false
673
- @i.box_writable?(@visitor, :root_level).should be_false
674
- @i.box_writable?(@visitor, :mixed_level).should be_false
675
- @i.box_writable?(@visitor, :default_level).should be_false
676
-
677
- @i.box_writable?(@editor, :editor_level).should be_true
678
- @i.box_writable?(@editor, :admin_level).should be_false
679
- @i.box_writable?(@editor, :root_level).should be_false
680
- @i.box_writable?(@editor, :mixed_level).should be_false
681
- @i.box_writable?(@editor, :default_level).should be_true
682
-
683
- @i.box_writable?(@admin, :editor_level).should be_true
684
- @i.box_writable?(@admin, :admin_level).should be_true
685
- @i.box_writable?(@admin, :root_level).should be_false
686
- @i.box_writable?(@admin, :mixed_level).should be_false
687
- @i.box_writable?(@admin, :default_level).should be_true
688
-
689
-
690
- @i.box_writable?(@root, :editor_level).should be_true
691
- @i.box_writable?(@root, :admin_level).should be_true
692
- @i.box_writable?(@root, :root_level).should be_true
693
- @i.box_writable?(@root, :mixed_level).should be_true
694
- @i.box_writable?(@root, :default_level).should be_true
695
- end
696
-
697
- should "serialise only things in class viewable by the current user" do
617
+ assert @i.field_writable?(nil, :editor_level)
618
+ assert @i.field_writable?(nil, :admin_level)
619
+ assert @i.field_writable?(nil, :root_level)
620
+ assert @i.field_writable?(nil, :mixed_level)
621
+ assert @i.field_writable?(nil, :default_level)
622
+
623
+ refute @i.field_writable?(@visitor, :editor_level)
624
+ refute @i.field_writable?(@visitor, :admin_level)
625
+ refute @i.field_writable?(@visitor, :root_level)
626
+ refute @i.field_writable?(@visitor, :mixed_level)
627
+ refute @i.field_writable?(@visitor, :default_level)
628
+
629
+ assert @i.field_writable?(@editor, :editor_level)
630
+ refute @i.field_writable?(@editor, :admin_level)
631
+ refute @i.field_writable?(@editor, :root_level)
632
+ refute @i.field_writable?(@editor, :mixed_level)
633
+ assert @i.field_writable?(@editor, :default_level)
634
+
635
+ assert @i.field_writable?(@admin, :editor_level)
636
+ assert @i.field_writable?(@admin, :admin_level)
637
+ refute @i.field_writable?(@admin, :root_level)
638
+ refute @i.field_writable?(@admin, :mixed_level)
639
+ assert @i.field_writable?(@admin, :default_level)
640
+
641
+ assert @i.field_writable?(@root, :editor_level)
642
+ assert @i.field_writable?(@root, :admin_level)
643
+ assert @i.field_writable?(@root, :root_level)
644
+ assert @i.field_writable?(@root, :mixed_level)
645
+ assert @i.field_writable?(@root, :default_level)
646
+ end
647
+
648
+ it "protect box reads" do
649
+ assert @i.box_readable?(nil, :editor_level)
650
+ assert @i.box_readable?(nil, :admin_level)
651
+ assert @i.box_readable?(nil, :root_level)
652
+ assert @i.box_readable?(nil, :mixed_level)
653
+ assert @i.box_readable?(nil, :default_level)
654
+
655
+ refute @i.box_readable?(@visitor, :editor_level)
656
+ refute @i.box_readable?(@visitor, :admin_level)
657
+ refute @i.box_readable?(@visitor, :root_level)
658
+ refute @i.box_readable?(@visitor, :mixed_level)
659
+ assert @i.box_readable?(@visitor, :default_level)
660
+
661
+ assert @i.box_readable?(@editor, :editor_level)
662
+ refute @i.box_readable?(@editor, :admin_level)
663
+ refute @i.box_readable?(@editor, :root_level)
664
+ assert @i.box_readable?(@editor, :mixed_level)
665
+ assert @i.box_readable?(@editor, :default_level)
666
+
667
+ assert @i.box_readable?(@admin, :editor_level)
668
+ assert @i.box_readable?(@admin, :admin_level)
669
+ refute @i.box_readable?(@admin, :root_level)
670
+ assert @i.box_readable?(@admin, :mixed_level)
671
+ assert @i.box_readable?(@admin, :default_level)
672
+
673
+ assert @i.box_readable?(@root, :editor_level)
674
+ assert @i.box_readable?(@root, :admin_level)
675
+ assert @i.box_readable?(@root, :root_level)
676
+ assert @i.box_readable?(@root, :mixed_level)
677
+ assert @i.box_readable?(@root, :default_level)
678
+ end
679
+ it "protect box writes" do
680
+ assert @i.box_writable?(nil, :editor_level)
681
+ assert @i.box_writable?(nil, :admin_level)
682
+ assert @i.box_writable?(nil, :root_level)
683
+ assert @i.box_writable?(nil, :mixed_level)
684
+ assert @i.box_writable?(nil, :default_level)
685
+
686
+ refute @i.box_writable?(@visitor, :editor_level)
687
+ refute @i.box_writable?(@visitor, :admin_level)
688
+ refute @i.box_writable?(@visitor, :root_level)
689
+ refute @i.box_writable?(@visitor, :mixed_level)
690
+ refute @i.box_writable?(@visitor, :default_level)
691
+
692
+ assert @i.box_writable?(@editor, :editor_level)
693
+ refute @i.box_writable?(@editor, :admin_level)
694
+ refute @i.box_writable?(@editor, :root_level)
695
+ refute @i.box_writable?(@editor, :mixed_level)
696
+ assert @i.box_writable?(@editor, :default_level)
697
+
698
+ assert @i.box_writable?(@admin, :editor_level)
699
+ assert @i.box_writable?(@admin, :admin_level)
700
+ refute @i.box_writable?(@admin, :root_level)
701
+ refute @i.box_writable?(@admin, :mixed_level)
702
+ assert @i.box_writable?(@admin, :default_level)
703
+
704
+
705
+ assert @i.box_writable?(@root, :editor_level)
706
+ assert @i.box_writable?(@root, :admin_level)
707
+ assert @i.box_writable?(@root, :root_level)
708
+ assert @i.box_writable?(@root, :mixed_level)
709
+ assert @i.box_writable?(@root, :default_level)
710
+ end
711
+
712
+ it "serialise only things in class viewable by the current user" do
698
713
  expected = [
699
714
  ["editor_level", true],
700
715
  ["admin_level", true],
@@ -702,9 +717,9 @@ class PermissionsTest < MiniTest::Spec
702
717
  ["mixed_level", true],
703
718
  ["default_level", true]
704
719
  ]
705
- C.export[:fields].map { |f| [f[:name], f[:writable]] }.should == expected
706
- C.export[:boxes].map { |f| [f[:name], f[:writable]] }.should == expected
707
- C.export[:boxes].map { |b| [b[:name], b[:fields].map {|f| [f[:name], f[:writable]]}] }.should == [
720
+ C.export[:fields].map { |f| [f[:name], f[:writable]] }.must_equal expected
721
+ C.export[:boxes].map { |f| [f[:name], f[:writable]] }.must_equal expected
722
+ C.export[:boxes].map { |b| [b[:name], b[:fields].map {|f| [f[:name], f[:writable]]}] }.must_equal [
708
723
  ["editor_level", expected],
709
724
  ["admin_level", expected],
710
725
  ["root_level", expected],
@@ -713,9 +728,9 @@ class PermissionsTest < MiniTest::Spec
713
728
  ]
714
729
 
715
730
  # Permissions.with_user(@root) do
716
- C.export(@root)[:fields].map { |f| [f[:name], f[:writable]] }.should == expected
717
- C.export(@root)[:boxes].map { |f| [f[:name], f[:writable]] }.should == expected
718
- C.export(@root)[:boxes].map { |b| [b[:name], b[:fields].map {|f| [f[:name], f[:writable]]}] }.should == [
731
+ C.export(@root)[:fields].map { |f| [f[:name], f[:writable]] }.must_equal expected
732
+ C.export(@root)[:boxes].map { |f| [f[:name], f[:writable]] }.must_equal expected
733
+ C.export(@root)[:boxes].map { |b| [b[:name], b[:fields].map {|f| [f[:name], f[:writable]]}] }.must_equal [
719
734
  ["editor_level", expected],
720
735
  ["admin_level", expected],
721
736
  ["root_level", expected],
@@ -728,9 +743,9 @@ class PermissionsTest < MiniTest::Spec
728
743
  expected = [
729
744
  ["default_level", false]
730
745
  ]
731
- C.export(@visitor)[:fields].map { |f| [f[:name], f[:writable]] }.should == expected
732
- C.export(@visitor)[:boxes].map { |f| [f[:name], f[:writable]] }.should == expected
733
- C.export(@visitor)[:boxes].map { |b| [b[:name], b[:fields].map {|f| [f[:name], f[:writable]]}] }.should == [
746
+ C.export(@visitor)[:fields].map { |f| [f[:name], f[:writable]] }.must_equal expected
747
+ C.export(@visitor)[:boxes].map { |f| [f[:name], f[:writable]] }.must_equal expected
748
+ C.export(@visitor)[:boxes].map { |b| [b[:name], b[:fields].map {|f| [f[:name], f[:writable]]}] }.must_equal [
734
749
  ["default_level", expected ]
735
750
  ]
736
751
  # end
@@ -741,9 +756,9 @@ class PermissionsTest < MiniTest::Spec
741
756
  ["mixed_level", false],
742
757
  ["default_level", true]
743
758
  ]
744
- C.export(@editor)[:fields].map { |f| [f[:name], f[:writable]] }.should == expected
745
- C.export(@editor)[:boxes].map { |f| [f[:name], f[:writable]] }.should == expected
746
- C.export(@editor)[:boxes].map { |b| [b[:name], b[:fields].map {|f| [f[:name], f[:writable]]}] }.should == [
759
+ C.export(@editor)[:fields].map { |f| [f[:name], f[:writable]] }.must_equal expected
760
+ C.export(@editor)[:boxes].map { |f| [f[:name], f[:writable]] }.must_equal expected
761
+ C.export(@editor)[:boxes].map { |b| [b[:name], b[:fields].map {|f| [f[:name], f[:writable]]}] }.must_equal [
747
762
  ["editor_level", expected],
748
763
  ["mixed_level", expected],
749
764
  ["default_level", expected]
@@ -757,9 +772,9 @@ class PermissionsTest < MiniTest::Spec
757
772
  ["mixed_level", false],
758
773
  ["default_level", true]
759
774
  ]
760
- C.export(@admin)[:fields].map { |f| [f[:name], f[:writable]] }.should == expected
761
- C.export(@admin)[:boxes].map { |f| [f[:name], f[:writable]] }.should == expected
762
- C.export(@admin)[:boxes].map { |b| [b[:name], b[:fields].map {|f| [f[:name], f[:writable]]}] }.should == [
775
+ C.export(@admin)[:fields].map { |f| [f[:name], f[:writable]] }.must_equal expected
776
+ C.export(@admin)[:boxes].map { |f| [f[:name], f[:writable]] }.must_equal expected
777
+ C.export(@admin)[:boxes].map { |b| [b[:name], b[:fields].map {|f| [f[:name], f[:writable]]}] }.must_equal [
763
778
  ["editor_level", expected],
764
779
  ["admin_level", expected],
765
780
  ["mixed_level", expected],
@@ -768,7 +783,7 @@ class PermissionsTest < MiniTest::Spec
768
783
  # end
769
784
  end
770
785
 
771
- should "only list allowed types addable by the user" do
786
+ it "only list allowed types addable by the user" do
772
787
  expected = [
773
788
  ["editor_level", ["D", "C"]],
774
789
  ["admin_level", ["C"]],
@@ -776,16 +791,16 @@ class PermissionsTest < MiniTest::Spec
776
791
  ["mixed_level", ["C"]],
777
792
  ["default_level", ["C"]]
778
793
  ]
779
- C.export[:boxes].map { |b| [b[:name], b[:allowed_types]] }.should == expected
794
+ C.export[:boxes].map { |b| [b[:name], b[:allowed_types]] }.must_equal expected
780
795
 
781
796
  # Permissions.with_user(@root) do
782
- C.export(@root)[:boxes].map { |b| [b[:name], b[:allowed_types]] }.should == expected
797
+ C.export(@root)[:boxes].map { |b| [b[:name], b[:allowed_types]] }.must_equal expected
783
798
  # end
784
799
  # Permissions.with_user(@visitor) do
785
800
  expected = [
786
801
  ["default_level", []]
787
802
  ]
788
- C.export(@visitor)[:boxes].map { |b| [b[:name], b[:allowed_types]] }.should == expected
803
+ C.export(@visitor)[:boxes].map { |b| [b[:name], b[:allowed_types]] }.must_equal expected
789
804
  # end
790
805
  # Permissions.with_user(@editor) do
791
806
  expected = [
@@ -793,7 +808,7 @@ class PermissionsTest < MiniTest::Spec
793
808
  ["mixed_level", []],
794
809
  ["default_level", ["C"]]
795
810
  ]
796
- C.export(@editor)[:boxes].map { |b| [b[:name], b[:allowed_types]] }.should == expected
811
+ C.export(@editor)[:boxes].map { |b| [b[:name], b[:allowed_types]] }.must_equal expected
797
812
  # end
798
813
  # Permissions.with_user(@admin) do
799
814
  expected = [
@@ -802,11 +817,11 @@ class PermissionsTest < MiniTest::Spec
802
817
  ["mixed_level", []],
803
818
  ["default_level", ["C"]]
804
819
  ]
805
- C.export(@admin)[:boxes].map { |b| [b[:name], b[:allowed_types]] }.should == expected
820
+ C.export(@admin)[:boxes].map { |b| [b[:name], b[:allowed_types]] }.must_equal expected
806
821
  # end
807
822
  end
808
823
 
809
- should "serialise only things in instance viewable by the current user" do
824
+ it "serialise only things in instance viewable by the current user" do
810
825
  expected = [
811
826
  "editor_level",
812
827
  "admin_level",
@@ -814,8 +829,8 @@ class PermissionsTest < MiniTest::Spec
814
829
  "mixed_level",
815
830
  "default_level"
816
831
  ]
817
- @i.export[:boxes].map { |f| f[:name] }.should == expected
818
- @i.export[:boxes].map { |b| [b[:name], b[:fields].map {|f| f[:name]}] }.should == [
832
+ @i.export[:boxes].map { |f| f[:name] }.must_equal expected
833
+ @i.export[:boxes].map { |b| [b[:name], b[:fields].map {|f| f[:name]}] }.must_equal [
819
834
  ["editor_level", expected],
820
835
  ["admin_level", expected],
821
836
  ["root_level", expected],
@@ -823,8 +838,8 @@ class PermissionsTest < MiniTest::Spec
823
838
  ["default_level", expected]
824
839
  ]
825
840
  # Permissions.with_user(@root) do
826
- @i.export(@root)[:boxes].map { |f| f[:name] }.should == expected
827
- @i.export(@root)[:boxes].map { |b| [b[:name], b[:fields].map {|f| f[:name]}] }.should == [
841
+ @i.export(@root)[:boxes].map { |f| f[:name] }.must_equal expected
842
+ @i.export(@root)[:boxes].map { |b| [b[:name], b[:fields].map {|f| f[:name]}] }.must_equal [
828
843
  ["editor_level", expected],
829
844
  ["admin_level", expected],
830
845
  ["root_level", expected],
@@ -834,10 +849,10 @@ class PermissionsTest < MiniTest::Spec
834
849
  # end
835
850
 
836
851
  # Permissions.with_user(@visitor) do
837
- @i.export(@visitor)[:boxes].map { |f| f[:name] }.should == [
852
+ @i.export(@visitor)[:boxes].map { |f| f[:name] }.must_equal [
838
853
  "default_level"
839
854
  ]
840
- @i.export(@visitor)[:boxes].map { |b| [b[:name], b[:fields].map {|f| f[:name]}] }.should == [
855
+ @i.export(@visitor)[:boxes].map { |b| [b[:name], b[:fields].map {|f| f[:name]}] }.must_equal [
841
856
  ["default_level", ["default_level"]]
842
857
  ]
843
858
  # end
@@ -848,8 +863,8 @@ class PermissionsTest < MiniTest::Spec
848
863
  "mixed_level",
849
864
  "default_level"
850
865
  ]
851
- @i.export(@editor)[:boxes].map { |f| f[:name] }.should == expected
852
- @i.export(@editor)[:boxes].map { |b| [b[:name], b[:fields].map {|f| f[:name]}] }.should == [
866
+ @i.export(@editor)[:boxes].map { |f| f[:name] }.must_equal expected
867
+ @i.export(@editor)[:boxes].map { |b| [b[:name], b[:fields].map {|f| f[:name]}] }.must_equal [
853
868
  ["editor_level", expected],
854
869
  ["mixed_level", expected],
855
870
  ["default_level", expected]
@@ -863,8 +878,8 @@ class PermissionsTest < MiniTest::Spec
863
878
  "mixed_level",
864
879
  "default_level"
865
880
  ]
866
- @i.export(@admin)[:boxes].map { |f| f[:name] }.should == expected
867
- @i.export(@admin)[:boxes].map { |b| [b[:name], b[:fields].map {|f| f[:name]}] }.should == [
881
+ @i.export(@admin)[:boxes].map { |f| f[:name] }.must_equal expected
882
+ @i.export(@admin)[:boxes].map { |b| [b[:name], b[:fields].map {|f| f[:name]}] }.must_equal [
868
883
  ["editor_level", expected],
869
884
  ["admin_level", expected],
870
885
  ["mixed_level", expected],
@@ -874,11 +889,11 @@ class PermissionsTest < MiniTest::Spec
874
889
 
875
890
  end
876
891
 
877
- should "determine what fields are visible in the exoported schema" do
892
+ it "determine what fields are visible in the exoported schema" do
878
893
  schema = Site.schema.export(@editor)
879
894
  c_schema = schema["C"]
880
- c_schema[:fields].map { |f| f[:name] }.should == %w(editor_level mixed_level default_level)
881
- c_schema[:boxes].map { |b| b[:name] }.should == %w(editor_level mixed_level default_level)
895
+ c_schema[:fields].map { |f| f[:name] }.must_equal %w(editor_level mixed_level default_level)
896
+ c_schema[:boxes].map { |b| b[:name] }.must_equal %w(editor_level mixed_level default_level)
882
897
  end
883
898
  end
884
899
  end