kiteditor 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/POST_INSTALL +21 -0
- data/{vendor → app}/assets/images/mercury/button.png +0 -0
- data/{vendor → app}/assets/images/mercury/close.png +0 -0
- data/app/assets/images/mercury/default-snippet.png +0 -0
- data/{vendor → app}/assets/images/mercury/loading-dark.gif +0 -0
- data/{vendor → app}/assets/images/mercury/loading-light.gif +0 -0
- data/{vendor → app}/assets/images/mercury/missing-image.png +0 -0
- data/{vendor → app}/assets/images/mercury/search-icon.png +0 -0
- data/{vendor → app}/assets/images/mercury/temp-logo.png +0 -0
- data/app/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/action.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/tools.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/user.png +0 -0
- data/app/assets/images/mercury/toolbar/snippets/buttons.png +0 -0
- data/{vendor/assets/javascripts/mercury/dependencies → app/assets/javascripts}/jquery-1.7.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury.js +60 -87
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.additions.js +103 -13
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/liquidmetal.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/showdown.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialog.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +1 -1
- data/{vendor → app}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +1 -1
- data/{vendor → app}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/finalize.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/lightview.js.coffee +38 -17
- data/app/assets/javascripts/mercury/locales/ar.locale.js.coffee +201 -0
- data/app/assets/javascripts/mercury/locales/da.locale.js.coffee +208 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/de.locale.js.coffee +4 -10
- data/{vendor → app}/assets/javascripts/mercury/locales/es.locale.js.coffee +3 -9
- data/{vendor → app}/assets/javascripts/mercury/locales/example.local.js.coffee +3 -5
- data/{vendor → app}/assets/javascripts/mercury/locales/fr.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/hu.locale.js.coffee +209 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/it.locale.js.coffee +3 -9
- data/{vendor → app}/assets/javascripts/mercury/locales/ko.local.js.coffee +4 -10
- data/{vendor → app}/assets/javascripts/mercury/locales/nl.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/pl.locale.js.coffee +213 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/pt.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/ru.locale.js.coffee +200 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/sv.local.js.coffee +3 -9
- data/{vendor → app}/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/uk.locale.js.coffee +200 -0
- data/app/assets/javascripts/mercury/locales/zh.local.js.coffee +203 -0
- data/app/assets/javascripts/mercury/mercury-compiled.js +10720 -0
- data/{vendor → app}/assets/javascripts/mercury/mercury.js.coffee +10 -1
- data/{vendor → app}/assets/javascripts/mercury/modal.js.coffee +62 -40
- data/{vendor → app}/assets/javascripts/mercury/modals/htmleditor.js.coffee +1 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +1 -0
- data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +152 -0
- data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +132 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +2 -0
- data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +68 -0
- data/{vendor → app}/assets/javascripts/mercury/native_extensions.js.coffee +0 -6
- data/{vendor → app}/assets/javascripts/mercury/page_editor.js.coffee +84 -50
- data/{vendor → app}/assets/javascripts/mercury/palette.js.coffee +1 -1
- data/{vendor → app}/assets/javascripts/mercury/panel.js.coffee +3 -2
- data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +2 -2
- data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/region.js.coffee +18 -17
- data/{vendor/assets/javascripts/mercury/regions/editable.js.coffee → app/assets/javascripts/mercury/regions/full.js.coffee} +41 -31
- data/app/assets/javascripts/mercury/regions/image.js.coffee +93 -0
- data/{vendor/assets/javascripts/mercury/regions/markupable.js.coffee → app/assets/javascripts/mercury/regions/markdown.js.coffee} +29 -24
- data/{vendor → app}/assets/javascripts/mercury/regions/simple.js.coffee +11 -54
- data/{vendor/assets/javascripts/mercury/regions/snippetable.js.coffee → app/assets/javascripts/mercury/regions/snippets.js.coffee} +10 -9
- data/{vendor → app}/assets/javascripts/mercury/select.js.coffee +1 -1
- data/app/assets/javascripts/mercury/snippet.js.coffee +136 -0
- data/{vendor → app}/assets/javascripts/mercury/snippet_toolbar.js.coffee +19 -6
- data/{vendor → app}/assets/javascripts/mercury/statusbar.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/support/history.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/table_editor.js.coffee +16 -0
- data/{vendor → app}/assets/javascripts/mercury/toolbar.button.js.coffee +45 -30
- data/{vendor → app}/assets/javascripts/mercury/toolbar.button_group.js.coffee +2 -2
- data/{vendor → app}/assets/javascripts/mercury/toolbar.expander.js.coffee +4 -4
- data/{vendor → app}/assets/javascripts/mercury/toolbar.js.coffee +10 -6
- data/{vendor → app}/assets/javascripts/mercury/tooltip.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/uploader.js.coffee +37 -19
- data/app/assets/stylesheets/_mercury-bootstrap-overrides.scss +61 -0
- data/app/assets/stylesheets/_mercury-sass.scss +33 -0
- data/{vendor → app}/assets/stylesheets/mercury.css +1 -5
- data/{vendor → app}/assets/stylesheets/mercury/all_images.css.erb +6 -2
- data/app/assets/stylesheets/mercury/bootstrap-ish.css +1367 -0
- data/app/assets/stylesheets/mercury/bootstrap-overrides.css +61 -0
- data/{vendor → app}/assets/stylesheets/mercury/dialog.css +21 -8
- data/{vendor → app}/assets/stylesheets/mercury/lightview.css +6 -56
- data/app/assets/stylesheets/mercury/mercury.css +43 -0
- data/{vendor → app}/assets/stylesheets/mercury/modal.css +15 -32
- data/{vendor → app}/assets/stylesheets/mercury/statusbar.css +0 -0
- data/{vendor → app}/assets/stylesheets/mercury/toolbar.css +4 -1
- data/{vendor → app}/assets/stylesheets/mercury/tooltip.css +0 -0
- data/{vendor → app}/assets/stylesheets/mercury/uploader.css +4 -4
- data/app/helpers/mercury_helper.rb +7 -0
- data/app/views/layouts/mercury.html.erb +10 -20
- data/app/views/layouts/mercury.html.haml +19 -0
- data/app/views/layouts/mercury.html.slim +19 -0
- data/app/views/mercury/modals/character.html +1 -1
- data/app/views/mercury/modals/htmleditor.html +3 -7
- data/app/views/mercury/modals/link.html +37 -51
- data/app/views/mercury/modals/media.html +102 -0
- data/app/views/mercury/modals/table.html +79 -73
- data/app/views/mercury/panels/snippets.html +6 -1
- data/app/views/mercury/snippets/example/options.html.erb +23 -27
- data/app/views/mercury/snippets/no_options/preview.html.erb +1 -0
- data/config/routes.rb +9 -0
- data/features/generators/authentication.feature +10 -0
- data/features/generators/images.feature +41 -0
- data/features/generators/install.feature +21 -0
- data/features/loading/loading.feature +5 -2
- data/features/loading/user_interface.feature +9 -7
- data/features/regions/{editable → full}/advanced_editing.feature +0 -0
- data/features/regions/full/basic_editing.feature +198 -0
- data/features/regions/{editable → full}/inserting_links.feature +20 -19
- data/features/regions/{editable → full}/inserting_media.feature +36 -18
- data/features/regions/{editable → full}/inserting_snippets.feature +28 -18
- data/features/regions/{editable → full}/inserting_special_characters.feature +2 -2
- data/features/regions/full/inserting_tables.feature +109 -0
- data/features/regions/{editable → full}/pasting.feature +0 -0
- data/features/regions/{editable → full}/uploading_images.feature +0 -0
- data/features/regions/{markupable → image}/uploading_images.feature +0 -0
- data/features/regions/{markupable → markdown}/advanced_editing.feature +0 -0
- data/features/regions/{markupable → markdown}/basic_editing.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_links.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_media.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_snippets.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_special_characters.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_tables.feature +0 -0
- data/features/regions/{snippetable/advanced_editing.feature → markdown/uploading_images.feature} +0 -0
- data/features/regions/simple/basic_editing.feature +5 -0
- data/features/regions/{snippetable/basic_editing.feature → snippets/advanced_editing.feature} +0 -0
- data/features/regions/{snippetable/inserting_snippets.feature → snippets/basic_editing.feature} +0 -0
- data/{vendor/assets/javascripts/mercury/locales/da.locale.js.coffee → features/regions/snippets/inserting_snippets.feature} +0 -0
- data/features/saving/saving.feature +8 -8
- data/features/step_definitions/custom_web_steps.rb +22 -0
- data/features/step_definitions/generator_steps.rb +23 -0
- data/features/step_definitions/mercury_steps.rb +1 -438
- data/features/support/aruba.rb +28 -0
- data/features/support/env.rb +11 -1
- data/features/support/selectors.rb +23 -0
- data/lib/generators/mercury/install/authentication/authentication_generator.rb +17 -0
- data/lib/generators/mercury/install/images/images_generator.rb +47 -0
- data/{app/models/mercury/image.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image.rb} +7 -0
- data/{db/migrate/20110526035601_create_mercury_images.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image_migration.rb} +0 -0
- data/{app/controllers/mercury → lib/generators/mercury/install/images/templates}/images_controller.rb +0 -0
- data/lib/generators/mercury/install/{templates → images/templates}/mongoid_paperclip_image.rb +0 -0
- data/lib/generators/mercury/install/install_generator.rb +12 -23
- data/lib/mercury-rails.rb +1 -2
- data/lib/mercury/authentication.rb +1 -0
- data/lib/mercury/cucumber/step_definitions.rb +13 -0
- data/lib/mercury/cucumber/step_definitions/mercury_steps.rb +408 -0
- data/{features → lib/mercury/cucumber}/support/mercury_contents.rb +3 -3
- data/{features → lib/mercury/cucumber}/support/mercury_selectors.rb +0 -20
- data/lib/mercury/engine.rb +19 -0
- data/lib/mercury/rails.rb +5 -0
- data/lib/mercury/version.rb +3 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -0
- data/spec/dummy/app/assets/javascripts/prototype.js +6082 -0
- data/spec/dummy/app/assets/stylesheets/application.css.scss +110 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/mercury.html.erb +28 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +58 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/teabag.rb +9 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/db/.gitkeep +0 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/blank.html +1 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/images/bunny.gif +0 -0
- data/spec/dummy/public/images/bunny2.jpg +0 -0
- data/spec/dummy/public/index.html +279 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialog.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/backcolor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/forecolor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/formatblock.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/snippetpanel.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/style.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/lightview.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modal.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modals/htmleditor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modals/insertcharacter.html +0 -0
- data/spec/javascripts/fixtures/mercury/modals/insertlink.html +67 -0
- data/spec/javascripts/fixtures/mercury/modals/insertmedia.html +87 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modals/insertsnippet.html +0 -0
- data/spec/javascripts/fixtures/mercury/modals/inserttable.html +73 -0
- data/spec/javascripts/{templates → fixtures}/mercury/page_editor.html +4 -4
- data/spec/javascripts/{templates → fixtures}/mercury/palette.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/panel.html +0 -0
- data/spec/javascripts/fixtures/mercury/region.html +6 -0
- data/spec/javascripts/fixtures/mercury/regions/full.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/image.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/markdown.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/simple.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/snippets.html +4 -0
- data/spec/javascripts/{templates → fixtures}/mercury/select.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/snippet.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/snippet_toolbar.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/statusbar.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/table_editor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.button.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.button_group.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.expander.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/tooltip.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/uploader.html +0 -0
- data/spec/javascripts/mercury/{dialog_spec.js.coffee → dialog_spec.coffee} +11 -12
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +3 -4
- data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/lightview_spec.js.coffee +180 -142
- data/spec/javascripts/mercury/mercury_spec.js.coffee +19 -13
- data/spec/javascripts/mercury/modal_spec.js.coffee +192 -148
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +4 -5
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +107 -34
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +106 -26
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +50 -40
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +124 -80
- data/spec/javascripts/mercury/palette_spec.js.coffee +4 -5
- data/spec/javascripts/mercury/panel_spec.js.coffee +9 -12
- data/spec/javascripts/mercury/region_spec.js.coffee +22 -17
- data/spec/javascripts/mercury/regions/{editable_spec.js.coffee → full_spec.js.coffee} +26 -28
- data/spec/javascripts/mercury/regions/image_spec.js.coffee +33 -0
- data/spec/javascripts/mercury/regions/{markupable_spec.js.coffee → markdown_spec.js.coffee} +32 -34
- data/spec/javascripts/mercury/regions/simple_spec.js.coffee +32 -0
- data/spec/javascripts/mercury/regions/{snippetable_spec.js.coffee → snippets_spec.js.coffee} +54 -55
- data/spec/javascripts/mercury/select_spec.js.coffee +4 -5
- data/spec/javascripts/mercury/snippet_spec.js.coffee +92 -16
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +31 -16
- data/spec/javascripts/mercury/statusbar_spec.js.coffee +9 -10
- data/spec/javascripts/mercury/table_editor_spec.js.coffee +1 -2
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +7 -9
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +55 -26
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +13 -13
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +43 -14
- data/spec/javascripts/mercury/tooltip_spec.js.coffee +1 -2
- data/spec/javascripts/mercury/uploader_spec.js.coffee +47 -33
- data/spec/javascripts/spec_helper.coffee +4 -0
- data/spec/javascripts/{spec_helper.js → support/event_simulation.js} +0 -2
- data/spec/teabag_env.rb +32 -0
- metadata +366 -196
- data/features/regions/editable/basic_editing.feature +0 -195
- data/features/regions/editable/inserting_tables.feature +0 -109
- data/spec/javascripts/templates/mercury/modals/insertlink.html +0 -30
- data/spec/javascripts/templates/mercury/modals/insertmedia.html +0 -35
- data/spec/javascripts/templates/mercury/modals/inserttable.html +0 -27
- data/spec/javascripts/templates/mercury/region.html +0 -2
- data/spec/javascripts/templates/mercury/regions/editable.html +0 -3
- data/spec/javascripts/templates/mercury/regions/snippetable.html +0 -4
- data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +0 -54
- data/vendor/assets/javascripts/mercury_loader.js +0 -193
- data/vendor/assets/javascripts/mercury_overrides.js +0 -6
- data/vendor/assets/stylesheets/mercury/mercury.css +0 -151
- data/vendor/assets/stylesheets/mercury_overrides.css +0 -17
data/spec/javascripts/mercury/regions/{snippetable_spec.js.coffee → snippets_spec.js.coffee}
RENAMED
@@ -1,9 +1,8 @@
|
|
1
|
-
describe "Mercury.Regions.
|
2
|
-
|
3
|
-
template 'mercury/regions/snippetable.html'
|
1
|
+
describe "Mercury.Regions.Snippets", ->
|
4
2
|
|
5
3
|
beforeEach ->
|
6
|
-
|
4
|
+
fixture.load('mercury/regions/snippets.html')
|
5
|
+
@regionElement = $('#snippets_region1')
|
7
6
|
|
8
7
|
afterEach ->
|
9
8
|
@region = null
|
@@ -12,50 +11,50 @@ describe "Mercury.Regions.Snippetable", ->
|
|
12
11
|
describe "constructor", ->
|
13
12
|
|
14
13
|
beforeEach ->
|
15
|
-
@buildSpy = spyOn(Mercury.Regions.
|
16
|
-
@bindEventsSpy = spyOn(Mercury.Regions.
|
17
|
-
@makeSortableSpy = spyOn(Mercury.Regions.
|
14
|
+
@buildSpy = spyOn(Mercury.Regions.Snippets.prototype, 'build').andCallFake(=>)
|
15
|
+
@bindEventsSpy = spyOn(Mercury.Regions.Snippets.prototype, 'bindEvents').andCallFake(=>)
|
16
|
+
@makeSortableSpy = spyOn(Mercury.Regions.Snippets.prototype, 'makeSortable').andCallFake(=>)
|
18
17
|
|
19
18
|
it "expects an element and window", ->
|
20
|
-
@region = new Mercury.Regions.
|
21
|
-
expect(@region.element.get(0)).toEqual($('#
|
19
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window)
|
20
|
+
expect(@region.element.get(0)).toEqual($('#snippets_region1').get(0))
|
22
21
|
expect(@region.window).toEqual(window)
|
23
22
|
|
24
23
|
it "accepts options", ->
|
25
|
-
@region = new Mercury.Regions.
|
24
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window, {foo: 'something'})
|
26
25
|
expect(@region.options).toEqual({foo: 'something'})
|
27
26
|
|
28
27
|
it "sets it's type", ->
|
29
|
-
@region = new Mercury.Regions.
|
30
|
-
expect(@region.type).toEqual('
|
28
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window)
|
29
|
+
expect(@region.type()).toEqual('snippets')
|
31
30
|
|
32
31
|
it "calls build", ->
|
33
|
-
@region = new Mercury.Regions.
|
32
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window)
|
34
33
|
expect(@buildSpy.callCount).toEqual(1)
|
35
34
|
|
36
35
|
it "calls bindEvents", ->
|
37
|
-
@region = new Mercury.Regions.
|
36
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window)
|
38
37
|
expect(@bindEventsSpy.callCount).toEqual(1)
|
39
38
|
|
40
39
|
it "makes the snippets sortable", ->
|
41
|
-
@region = new Mercury.Regions.
|
40
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window)
|
42
41
|
expect(@makeSortableSpy.callCount).toEqual(1)
|
43
42
|
|
44
43
|
|
45
44
|
describe "#build", ->
|
46
45
|
|
47
46
|
beforeEach ->
|
48
|
-
spyOn(Mercury.Regions.
|
47
|
+
spyOn(Mercury.Regions.Snippets.prototype, 'bindEvents').andCallFake(=>)
|
49
48
|
|
50
49
|
it "sets the element min-height to 20 if it's min-height is 0 (or not set)", ->
|
51
|
-
@region = new Mercury.Regions.
|
52
|
-
expect($('#
|
50
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window)
|
51
|
+
expect($('#snippets_region1').css('minHeight')).toEqual('20px')
|
53
52
|
|
54
53
|
|
55
54
|
describe "observed events", ->
|
56
55
|
|
57
56
|
beforeEach ->
|
58
|
-
@region = new Mercury.Regions.
|
57
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window)
|
59
58
|
Mercury.region = @region
|
60
59
|
|
61
60
|
describe "custom event: unfocus:regions", ->
|
@@ -121,33 +120,33 @@ describe "Mercury.Regions.Snippetable", ->
|
|
121
120
|
describe "keydown on document (for undo / redo)", ->
|
122
121
|
|
123
122
|
it "calls execCommand with undo on meta+z", ->
|
124
|
-
spy = spyOn(Mercury.Regions.
|
123
|
+
spy = spyOn(Mercury.Regions.Snippets.prototype, 'execCommand')
|
125
124
|
jasmine.simulate.keydown(document, {shiftKey: false, metaKey: true, keyCode: 90})
|
126
125
|
expect(spy.callCount).toEqual(1)
|
127
126
|
expect(spy.argsForCall[0]).toEqual(['undo'])
|
128
127
|
|
129
128
|
it "calls execCommand with redo on shift+meta+z", ->
|
130
|
-
spy = spyOn(Mercury.Regions.
|
129
|
+
spy = spyOn(Mercury.Regions.Snippets.prototype, 'execCommand')
|
131
130
|
jasmine.simulate.keydown(document, {shiftKey: true, metaKey: true, keyCode: 90})
|
132
131
|
expect(spy.callCount).toEqual(1)
|
133
132
|
expect(spy.argsForCall[0]).toEqual(['redo'])
|
134
133
|
|
135
134
|
it "does nothing if previewing", ->
|
136
135
|
@region.previewing = true
|
137
|
-
spy = spyOn(Mercury.Regions.
|
136
|
+
spy = spyOn(Mercury.Regions.Snippets.prototype, 'execCommand')
|
138
137
|
jasmine.simulate.keydown(document, {shiftKey: true, metaKey: true, keyCode: 90})
|
139
138
|
expect(spy.callCount).toEqual(0)
|
140
139
|
|
141
140
|
it "does nothing if it's not the active region", ->
|
142
141
|
Mercury.region = null
|
143
|
-
spy = spyOn(Mercury.Regions.
|
142
|
+
spy = spyOn(Mercury.Regions.Snippets.prototype, 'execCommand')
|
144
143
|
jasmine.simulate.keydown(document, {shiftKey: true, metaKey: true, keyCode: 90})
|
145
144
|
expect(spy.callCount).toEqual(0)
|
146
145
|
|
147
146
|
describe "mouseup", ->
|
148
147
|
|
149
148
|
it "calls focus", ->
|
150
|
-
spy = spyOn(Mercury.Regions.
|
149
|
+
spy = spyOn(Mercury.Regions.Snippets.prototype, 'focus')
|
151
150
|
jasmine.simulate.mouseup(@region.element.get(0))
|
152
151
|
expect(spy.callCount).toEqual(1)
|
153
152
|
|
@@ -158,7 +157,7 @@ describe "Mercury.Regions.Snippetable", ->
|
|
158
157
|
|
159
158
|
it "does nothing if previewing", ->
|
160
159
|
@region.previewing = true
|
161
|
-
spy = spyOn(Mercury.Regions.
|
160
|
+
spy = spyOn(Mercury.Regions.Snippets.prototype, 'focus')
|
162
161
|
jasmine.simulate.mouseup(@region.element.get(0))
|
163
162
|
expect(spy.callCount).toEqual(0)
|
164
163
|
|
@@ -181,7 +180,7 @@ describe "Mercury.Regions.Snippetable", ->
|
|
181
180
|
describe "#focus", ->
|
182
181
|
|
183
182
|
beforeEach ->
|
184
|
-
@region = new Mercury.Regions.
|
183
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window)
|
185
184
|
|
186
185
|
it "sets the active mercury region", ->
|
187
186
|
Mercury.region = null
|
@@ -189,19 +188,19 @@ describe "Mercury.Regions.Snippetable", ->
|
|
189
188
|
expect(Mercury.region).toEqual(@region)
|
190
189
|
|
191
190
|
it "makes the snippets sortable again", ->
|
192
|
-
spy = spyOn(Mercury.Regions.
|
191
|
+
spy = spyOn(Mercury.Regions.Snippets.prototype, 'makeSortable')
|
193
192
|
@region.focus()
|
194
193
|
expect(spy.callCount).toEqual(1)
|
195
194
|
|
196
195
|
it "adds the focus class to the element", ->
|
197
196
|
@region.focus()
|
198
|
-
expect($('#
|
197
|
+
expect($('#snippets_region1').hasClass('focus')).toEqual(true)
|
199
198
|
|
200
199
|
|
201
200
|
describe "#togglePreview", ->
|
202
201
|
|
203
202
|
beforeEach ->
|
204
|
-
@region = new Mercury.Regions.
|
203
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window)
|
205
204
|
|
206
205
|
describe "when not previewing", ->
|
207
206
|
|
@@ -214,7 +213,7 @@ describe "Mercury.Regions.Snippetable", ->
|
|
214
213
|
it "removes the focus class", ->
|
215
214
|
@regionElement.addClass('focus')
|
216
215
|
@region.togglePreview()
|
217
|
-
expect($('#
|
216
|
+
expect($('#snippets_region1').hasClass('focus')).toEqual(false)
|
218
217
|
|
219
218
|
describe "when previewing", ->
|
220
219
|
|
@@ -222,7 +221,7 @@ describe "Mercury.Regions.Snippetable", ->
|
|
222
221
|
@region.previewing = true
|
223
222
|
|
224
223
|
it "makes the snippets sortable again", ->
|
225
|
-
spy = spyOn(Mercury.Regions.
|
224
|
+
spy = spyOn(Mercury.Regions.Snippets.prototype, 'makeSortable')
|
226
225
|
@region.togglePreview()
|
227
226
|
expect(spy.callCount).toEqual(1)
|
228
227
|
|
@@ -230,9 +229,9 @@ describe "Mercury.Regions.Snippetable", ->
|
|
230
229
|
describe "#execCommand", ->
|
231
230
|
|
232
231
|
beforeEach ->
|
233
|
-
@region = new Mercury.Regions.
|
234
|
-
Mercury.Regions.
|
235
|
-
@handlerSpy = spyOn(Mercury.Regions.
|
232
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window)
|
233
|
+
Mercury.Regions.Snippets.actions['foo'] = ->
|
234
|
+
@handlerSpy = spyOn(Mercury.Regions.Snippets.actions, 'foo')
|
236
235
|
|
237
236
|
it "calls a handler (from the actions) if one exists", ->
|
238
237
|
@region.execCommand('foo', {value: 'something'})
|
@@ -243,7 +242,7 @@ describe "Mercury.Regions.Snippetable", ->
|
|
243
242
|
describe "#makeSortable", ->
|
244
243
|
|
245
244
|
beforeEach ->
|
246
|
-
@region = new Mercury.Regions.
|
245
|
+
@region = new Mercury.Regions.Snippets(@regionElement, window)
|
247
246
|
@sortableSpy = spyOn($.fn, 'sortable')
|
248
247
|
|
249
248
|
it "makes the snippets sortable", ->
|
@@ -261,26 +260,25 @@ describe "Mercury.Regions.Snippetable", ->
|
|
261
260
|
expect(spy.argsForCall[0]).toEqual(['hide:toolbar', {type: 'snippet', immediately: true}])
|
262
261
|
|
263
262
|
it "pushes to the history after dragging", ->
|
264
|
-
spy = spyOn(Mercury.Regions.
|
265
|
-
spyOn(window, 'setTimeout').andCallFake((
|
263
|
+
spy = spyOn(Mercury.Regions.Snippets.prototype, 'pushHistory').andCallFake(=>)
|
264
|
+
spyOn(window, 'setTimeout').andCallFake((callback, timeout)=> callback())
|
266
265
|
@sortableSpy.andCallFake((arg) => if arg == 'destroy' then return @region.element else arg.stop())
|
267
266
|
@region.makeSortable()
|
268
267
|
expect(spy.callCount).toEqual(1)
|
269
268
|
|
270
269
|
|
271
270
|
|
272
|
-
describe "Mercury.Regions.
|
273
|
-
|
274
|
-
template 'mercury/regions/snippetable.html'
|
271
|
+
describe "Mercury.Regions.Snippets.actions", ->
|
275
272
|
|
276
273
|
beforeEach ->
|
277
|
-
|
278
|
-
@
|
274
|
+
fixture.load('mercury/regions/snippets.html')
|
275
|
+
@region = new Mercury.Regions.Snippets($('#snippets_region2'), window)
|
276
|
+
@actions = Mercury.Regions.Snippets.actions
|
279
277
|
|
280
278
|
describe ".undo", ->
|
281
279
|
|
282
280
|
it "calls undo on the history buffer and sets the content", ->
|
283
|
-
htmlSpy = spyOn(Mercury.Regions.
|
281
|
+
htmlSpy = spyOn(Mercury.Regions.Snippets.prototype, 'content').andCallFake(=>)
|
284
282
|
historySpy = spyOn(@region.history, 'undo').andCallFake(=> 'history -1')
|
285
283
|
@actions['undo'].call(@region)
|
286
284
|
expect(historySpy.callCount).toEqual(1)
|
@@ -291,7 +289,7 @@ describe "Mercury.Regions.Snippetable.actions", ->
|
|
291
289
|
describe ".redo", ->
|
292
290
|
|
293
291
|
it "calls redo on the history buffer and sets the content", ->
|
294
|
-
htmlSpy = spyOn(Mercury.Regions.
|
292
|
+
htmlSpy = spyOn(Mercury.Regions.Snippets.prototype, 'content').andCallFake(=>)
|
295
293
|
historySpy = spyOn(@region.history, 'redo').andCallFake(=> 'history +1')
|
296
294
|
@actions['redo'].call(@region)
|
297
295
|
expect(historySpy.callCount).toEqual(1)
|
@@ -302,6 +300,7 @@ describe "Mercury.Regions.Snippetable.actions", ->
|
|
302
300
|
describe ".insertSnippet", ->
|
303
301
|
|
304
302
|
beforeEach ->
|
303
|
+
Mercury.Snippet.all = []
|
305
304
|
Mercury.Snippet.load({
|
306
305
|
'snippet_1': {name: 'example', options: {'foo': 'bar'}},
|
307
306
|
'snippet_2': {name: 'example', options: {'foo': 'bar'}},
|
@@ -312,15 +311,15 @@ describe "Mercury.Regions.Snippetable.actions", ->
|
|
312
311
|
|
313
312
|
it "finds the snippet by it's identity and replaces it with the new snippet", ->
|
314
313
|
@actions['insertSnippet'].call(@region, {value: Mercury.Snippet.find('snippet_1')})
|
315
|
-
expect($('#
|
316
|
-
expect($('#
|
317
|
-
expect($('#
|
318
|
-
expect($('#
|
319
|
-
expect($('#
|
314
|
+
expect($('#snippets_region2').html()).toContain('class="example-snippet"')
|
315
|
+
expect($('#snippets_region2').html()).toContain('contenteditable="false"')
|
316
|
+
expect($('#snippets_region2').html()).toContain('data-version="1"')
|
317
|
+
expect($('#snippets_region2').html()).toContain('data-snippet="snippet_1"')
|
318
|
+
expect($('#snippets_region2').html()).toContain('[snippet_1]')
|
320
319
|
|
321
320
|
it "pushes to the history after it's been rendered", ->
|
322
321
|
spyOn(Mercury.Snippet.prototype, 'getHTML').andCallFake((x, callback) => callback() if callback)
|
323
|
-
spy = spyOn(Mercury.Regions.
|
322
|
+
spy = spyOn(Mercury.Regions.Snippets.prototype, 'pushHistory').andCallFake(=>)
|
324
323
|
@actions['insertSnippet'].call(@region, {value: Mercury.Snippet.find('snippet_1')})
|
325
324
|
expect(spy.callCount).toEqual(1)
|
326
325
|
|
@@ -328,11 +327,11 @@ describe "Mercury.Regions.Snippetable.actions", ->
|
|
328
327
|
|
329
328
|
it "appends the new snippet html to the element", ->
|
330
329
|
@actions['insertSnippet'].call(@region, {value: Mercury.Snippet.find('snippet_2')})
|
331
|
-
expect($('#
|
330
|
+
expect($('#snippets_region2 [data-snippet]').length).toEqual(2)
|
332
331
|
|
333
332
|
it "pushes to the history after it's been rendered", ->
|
334
333
|
spyOn(Mercury.Snippet.prototype, 'getHTML').andCallFake((x, callback) => callback() if callback)
|
335
|
-
spy = spyOn(Mercury.Regions.
|
334
|
+
spy = spyOn(Mercury.Regions.Snippets.prototype, 'pushHistory').andCallFake(=>)
|
336
335
|
@actions['insertSnippet'].call(@region, {value: Mercury.Snippet.find('snippet_2')})
|
337
336
|
expect(spy.callCount).toEqual(1)
|
338
337
|
|
@@ -340,7 +339,7 @@ describe "Mercury.Regions.Snippetable.actions", ->
|
|
340
339
|
describe ".editSnippet", ->
|
341
340
|
|
342
341
|
beforeEach ->
|
343
|
-
@region.snippet = $('#
|
342
|
+
@region.snippet = $('#snippets_region2 [data-snippet]')
|
344
343
|
|
345
344
|
it "finds and displays the options for the given snippet", ->
|
346
345
|
spy = spyOn(Mercury.Snippet.prototype, 'displayOptions')
|
@@ -357,11 +356,11 @@ describe "Mercury.Regions.Snippetable.actions", ->
|
|
357
356
|
describe ".removeSnippet", ->
|
358
357
|
|
359
358
|
beforeEach ->
|
360
|
-
@region.snippet = $('#
|
359
|
+
@region.snippet = $('#snippets_region2 .mercury-snippet')
|
361
360
|
|
362
361
|
it "removes the snippet if there's an active one", ->
|
363
362
|
@actions['removeSnippet'].call(@region)
|
364
|
-
expect($('#
|
363
|
+
expect($('#snippets_region2 .mercury-snippet').length).toEqual(0)
|
365
364
|
|
366
365
|
it "triggers the hide:toolbar event", ->
|
367
366
|
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
@@ -1,8 +1,7 @@
|
|
1
1
|
describe "Mercury.Select", ->
|
2
2
|
|
3
|
-
template 'mercury/select.html'
|
4
|
-
|
5
3
|
beforeEach ->
|
4
|
+
fixture.load('mercury/select.html')
|
6
5
|
$.fx.off = true
|
7
6
|
|
8
7
|
afterEach ->
|
@@ -12,7 +11,7 @@ describe "Mercury.Select", ->
|
|
12
11
|
describe "#build", ->
|
13
12
|
|
14
13
|
it "builds an element", ->
|
15
|
-
@select = new Mercury.Select('/blank.html', 'foo', {appendTo:
|
14
|
+
@select = new Mercury.Select('/blank.html', 'foo', {appendTo: fixture.el, for: $('#button')})
|
16
15
|
html = $('<div>').html(@select.element).html()
|
17
16
|
expect(html).toContain('class="mercury-select mercury-foo-select loading"')
|
18
17
|
expect(html).toContain('style="display:none"')
|
@@ -25,7 +24,7 @@ describe "Mercury.Select", ->
|
|
25
24
|
describe "observed events", ->
|
26
25
|
|
27
26
|
beforeEach ->
|
28
|
-
@select = new Mercury.Select('/blank.html', 'foo', {appendTo:
|
27
|
+
@select = new Mercury.Select('/blank.html', 'foo', {appendTo: fixture.el, for: $('#button')})
|
29
28
|
|
30
29
|
it "hides", ->
|
31
30
|
@select.element.css({display: 'block'})
|
@@ -41,7 +40,7 @@ describe "Mercury.Select", ->
|
|
41
40
|
describe "#position", ->
|
42
41
|
|
43
42
|
beforeEach ->
|
44
|
-
@select = new Mercury.Select('/blank.html', 'foo', {appendTo:
|
43
|
+
@select = new Mercury.Select('/blank.html', 'foo', {appendTo: fixture.el, for: $('#button')})
|
45
44
|
|
46
45
|
it "positions based on it's button", ->
|
47
46
|
@select.element.css({display: 'block'})
|
@@ -1,6 +1,7 @@
|
|
1
1
|
describe "Mercury.Snippet", ->
|
2
2
|
|
3
|
-
|
3
|
+
beforeEach ->
|
4
|
+
fixture.load('mercury/snippet.html')
|
4
5
|
|
5
6
|
afterEach ->
|
6
7
|
Mercury.Snippet.all = []
|
@@ -35,7 +36,7 @@ describe "Mercury.Snippet", ->
|
|
35
36
|
it "builds an element (in whatever context is provided", ->
|
36
37
|
ret = @snippet.getHTML($(document))
|
37
38
|
html = $('<div>').html(ret).html()
|
38
|
-
expect(html).toContain('class="
|
39
|
+
expect(html).toContain('class="foo-snippet"')
|
39
40
|
expect(html).toContain('contenteditable="false"')
|
40
41
|
expect(html).toContain('data-snippet="identity"')
|
41
42
|
expect(html).toContain('data-version="1"')
|
@@ -53,6 +54,19 @@ describe "Mercury.Snippet", ->
|
|
53
54
|
@snippet.getHTML($(document), callback)
|
54
55
|
expect(@loadPreviewSpy.argsForCall[0][1]).toEqual(callback)
|
55
56
|
|
57
|
+
it "wraps the snippet in the specified wrapperTag", ->
|
58
|
+
@snippet.wrapperTag = 'li'
|
59
|
+
ret = @snippet.getHTML($(document))
|
60
|
+
container = $('<div>')
|
61
|
+
container.html(ret)
|
62
|
+
expect($(container.children()[0]).is('li')).toEqual(true)
|
63
|
+
|
64
|
+
it "adds the specified wrapperClass to the wrapperTag", ->
|
65
|
+
@snippet.wrapperClass = 'something'
|
66
|
+
ret = @snippet.getHTML($(document))
|
67
|
+
container = $('<div>')
|
68
|
+
container.html(ret)
|
69
|
+
expect($(container.children()[0]).hasClass('something')).toEqual(true)
|
56
70
|
|
57
71
|
describe "#getText", ->
|
58
72
|
|
@@ -142,6 +156,11 @@ describe "Mercury.Snippet", ->
|
|
142
156
|
@snippet.setOptions({foo: 'baz'})
|
143
157
|
expect(@snippet.history.stack.length).toEqual(2)
|
144
158
|
|
159
|
+
it "can set the wrapperTag attribute from options", ->
|
160
|
+
expect(@snippet.wrapperTag).toEqual('div')
|
161
|
+
@snippet.setOptions({wrapperTag: 'li'})
|
162
|
+
expect(@snippet.wrapperTag).toEqual('li')
|
163
|
+
|
145
164
|
|
146
165
|
describe "#setVersion", ->
|
147
166
|
|
@@ -151,11 +170,11 @@ describe "Mercury.Snippet", ->
|
|
151
170
|
|
152
171
|
it "sets the version", ->
|
153
172
|
@snippet.setVersion(5)
|
154
|
-
expect(@snippet.version).toEqual(
|
173
|
+
expect(@snippet.version).toEqual(5)
|
155
174
|
|
156
175
|
it "accepts a version (can be a string)", ->
|
157
176
|
@snippet.setVersion('2')
|
158
|
-
expect(@snippet.version).toEqual(
|
177
|
+
expect(@snippet.version).toEqual(2)
|
159
178
|
|
160
179
|
it "pulls the version out of the history buffer", ->
|
161
180
|
@snippet.setVersion(3)
|
@@ -177,7 +196,7 @@ describe "Mercury.Snippet", ->
|
|
177
196
|
|
178
197
|
it "returns an object with name and options", ->
|
179
198
|
ret = @snippet.serialize()
|
180
|
-
expect(ret).toEqual({name: 'foo',
|
199
|
+
expect(ret).toEqual({name: 'foo', foo: 'bar'})
|
181
200
|
|
182
201
|
|
183
202
|
|
@@ -190,16 +209,45 @@ describe "Mercury.Snippet class methods", ->
|
|
190
209
|
|
191
210
|
beforeEach ->
|
192
211
|
@modalSpy = spyOn(Mercury, 'modal').andCallFake(=>)
|
212
|
+
@triggerSpy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
193
213
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
214
|
+
describe "with options", ->
|
215
|
+
|
216
|
+
it "opens a modal with the name in the url", ->
|
217
|
+
Mercury.Snippet.displayOptionsFor('foo')
|
218
|
+
expect(@modalSpy.callCount).toEqual(1)
|
219
|
+
expect(@modalSpy.argsForCall[0]).toEqual(["/mercury/snippets/foo/options.html", {title: 'Snippet Options', handler: 'insertSnippet', snippetName: 'foo', loadType : 'POST'}])
|
220
|
+
|
221
|
+
it "sets the snippet back to nothing", ->
|
222
|
+
Mercury.snippet = 'foo'
|
223
|
+
Mercury.Snippet.displayOptionsFor('foo')
|
224
|
+
expect(Mercury.snippet).toEqual(null)
|
225
|
+
|
226
|
+
it "can pass options to the modal", ->
|
227
|
+
Mercury.Snippet.displayOptionsFor('foo', {option1: 'option1'})
|
228
|
+
expect(@modalSpy.callCount).toEqual(1)
|
229
|
+
expect(@modalSpy.argsForCall[0]).toEqual(["/mercury/snippets/foo/options.html", {title: 'Snippet Options', handler: 'insertSnippet', snippetName: 'foo', loadType: 'POST', option1: 'option1'}])
|
198
230
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
231
|
+
it "doesn't trigger an event to insert the snippet", ->
|
232
|
+
Mercury.Snippet.displayOptionsFor('foo')
|
233
|
+
expect(@triggerSpy.callCount).toEqual(0)
|
234
|
+
|
235
|
+
describe "without options", ->
|
236
|
+
|
237
|
+
it "triggers an event to insert the snippet", ->
|
238
|
+
Mercury.Snippet.displayOptionsFor('foo', {}, false)
|
239
|
+
expect(@triggerSpy.callCount).toEqual(1)
|
240
|
+
expect(@triggerSpy.argsForCall[0][0]).toEqual('action')
|
241
|
+
expect(@triggerSpy.argsForCall[0][1]['action']).toEqual('insertSnippet')
|
242
|
+
|
243
|
+
it "doesn't open a modal", ->
|
244
|
+
Mercury.Snippet.displayOptionsFor('foo', {}, false)
|
245
|
+
expect(@modalSpy.callCount).toEqual(0)
|
246
|
+
|
247
|
+
it "sets the snippet back to nothing", ->
|
248
|
+
Mercury.snippet = 'foo'
|
249
|
+
Mercury.Snippet.displayOptionsFor('foo', {}, false)
|
250
|
+
expect(Mercury.snippet).toEqual(null)
|
203
251
|
|
204
252
|
|
205
253
|
describe ".create", ->
|
@@ -219,6 +267,30 @@ describe "Mercury.Snippet class methods", ->
|
|
219
267
|
Mercury.Snippet.create('foo', {foo: 'bar'})
|
220
268
|
expect(Mercury.Snippet.all.length).toEqual(1)
|
221
269
|
|
270
|
+
describe "when a snippet exist with an identical identity", ->
|
271
|
+
it "generates a unique identity", ->
|
272
|
+
Mercury.Snippet.load
|
273
|
+
snippet_0: {name: 'foo0', options: {foo: 'bar'}}
|
274
|
+
snippet_1: {name: 'foo1', options: {foo: 'bar'}}
|
275
|
+
snippet_3: {name: 'bar3', options: {baz: 'pizza'}}
|
276
|
+
|
277
|
+
ret = Mercury.Snippet.create('noobie', {noobie: 'one'})
|
278
|
+
expect(ret.identity).toEqual('snippet_2')
|
279
|
+
|
280
|
+
it "generates a unique identity with an un-ordered snippet list", ->
|
281
|
+
Mercury.Snippet.load
|
282
|
+
snippet_0: {name: 'foo0', options: {foo: 'bar'}}
|
283
|
+
snippet_1: {name: 'foo1', options: {foo: 'bar'}}
|
284
|
+
snippet_2: {name: 'foo2', options: {foo: 'bar'}}
|
285
|
+
snippet_12: {name: 'bar12', options: {baz: 'pizza'}}
|
286
|
+
snippet_6: {name: 'bar6', options: {baz: 'pizza'}}
|
287
|
+
snippet_7: {name: 'bar7', options: {baz: 'pizza'}}
|
288
|
+
snippet_3: {name: 'foo3', options: {foo: 'bar'}}
|
289
|
+
snippet_4: {name: 'foo4', options: {foo: 'bar'}}
|
290
|
+
snippet_5: {name: 'foo5', options: {foo: 'bar'}}
|
291
|
+
|
292
|
+
ret = Mercury.Snippet.create('noobie', {noobie: 'one'})
|
293
|
+
expect(ret.identity).toEqual('snippet_8')
|
222
294
|
|
223
295
|
describe ".find", ->
|
224
296
|
|
@@ -236,10 +308,14 @@ describe "Mercury.Snippet class methods", ->
|
|
236
308
|
|
237
309
|
beforeEach ->
|
238
310
|
@snippets = {
|
239
|
-
snippet_1: {name: 'foo',
|
240
|
-
snippet_2: {name: 'bar',
|
311
|
+
snippet_1: {name: 'foo', something: {foo: 'bar'}}
|
312
|
+
snippet_2: {name: 'bar', something: {baz: 'pizza'}}
|
241
313
|
}
|
314
|
+
Mercury.Snippet.load(@snippets)
|
242
315
|
|
243
316
|
it "creates a new instance for each item in the collection", ->
|
244
|
-
Mercury.Snippet.load(@snippets)
|
245
317
|
expect(Mercury.Snippet.all.length).toEqual(2)
|
318
|
+
|
319
|
+
it 'sets the options', ->
|
320
|
+
expect(Mercury.Snippet.find('snippet_1').options.something.foo).toEqual('bar')
|
321
|
+
|