lanes 0.1.2 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -0
- data/client/lanes/access/Extension.coffee +19 -0
- data/client/lanes/access/LoginDialog.coffee +47 -0
- data/client/lanes/access/Roles.coffee +88 -0
- data/client/lanes/access/User.coffee +72 -0
- data/client/lanes/access/index.js +5 -0
- data/client/lanes/access/login-dialog.html +16 -0
- data/client/lanes/access/screens/user-management/GridUserEditor.coffee +25 -0
- data/client/lanes/access/screens/user-management/UserManagement.coffee +24 -0
- data/client/lanes/access/screens/user-management/grid-popover-editor.html +33 -0
- data/client/lanes/access/screens/user-management/index.js +3 -0
- data/client/lanes/access/screens/user-management/index.scss +7 -0
- data/client/lanes/access/screens/user-management/screen.html +7 -0
- data/client/lanes/{components/enabled.scss.erb → access/styles.scss} +0 -0
- data/{lib/lanes/command/templates/client/components → client/lanes/access/views}/.gitkeep +0 -0
- data/client/lanes/components/Base.coffee +3 -4
- data/client/lanes/components/enabled.js.erb +2 -0
- data/client/lanes/components/grid/Editor.coffee +1 -1
- data/client/lanes/components/grid/Grid.coffee +26 -27
- data/client/lanes/components/grid/{_index.scss → styles.scss} +0 -0
- data/client/lanes/components/grid/template.html +1 -1
- data/client/lanes/components/grid/vendor/dataTables.scroller.js +119 -42
- data/client/lanes/components/grid/vendor/jquery.dataTables.js +984 -526
- data/client/lanes/components/modal/ModalDialog.coffee +25 -4
- data/client/lanes/components/modal/styles.scss +19 -0
- data/client/lanes/components/modal/template.html +2 -2
- data/client/lanes/components/multi-select/MultiSelect.coffee +46 -0
- data/client/lanes/components/popover/PopOver.coffee +1 -1
- data/client/lanes/components/popover/styles.scss +2 -0
- data/client/lanes/components/{radio_group → radio-group}/RadioGroup.coffee +12 -23
- data/client/lanes/components/radio-group/index.js +1 -0
- data/client/lanes/components/radio-group/styles.scss +1 -0
- data/client/lanes/components/record-finder/Clause.coffee +38 -0
- data/client/lanes/components/record-finder/Dialog.coffee +45 -0
- data/client/lanes/components/record-finder/RecordFinder.coffee +55 -0
- data/client/lanes/components/{record_finder/clause.skr → record-finder/clause.html} +7 -5
- data/client/lanes/components/record-finder/config.json +3 -0
- data/client/lanes/components/{record_finder/dialog.skr → record-finder/dialog.html} +0 -0
- data/client/lanes/components/{record_finder/field.skr → record-finder/field.html} +1 -1
- data/client/lanes/components/record-finder/index.js +4 -0
- data/client/lanes/{styles/components/record-finder.scss → components/record-finder/styles.scss} +22 -20
- data/client/lanes/components/select-field/SelectField.coffee +62 -0
- data/client/lanes/components/{select_field → select-field}/index.js +0 -0
- data/client/lanes/components/{select_field/_index.scss → select-field/styles.scss} +0 -0
- data/client/lanes/extension/EarlyExtensions.js.erb +3 -3
- data/client/lanes/extension/Extensions.coffee +4 -1
- data/client/lanes/extension/LateLoaded.js.erb +3 -3
- data/client/lanes/index.js +2 -2
- data/client/lanes/index.scss.erb +30 -0
- data/client/lanes/lib/MakeBaseClass.coffee +20 -19
- data/client/lanes/lib/ModuleSupport.coffee +1 -1
- data/client/lanes/lib/results.coffee +1 -9
- data/client/lanes/lib/utilFunctions.coffee +56 -10
- data/client/lanes/models/Base.coffee +57 -116
- data/client/lanes/models/ChangeMonitor.coffee +29 -0
- data/client/lanes/models/ChangeSet.coffee +3 -3
- data/client/lanes/models/Collection.coffee +36 -4
- data/client/lanes/models/ModelAssociations.coffee +118 -0
- data/client/lanes/models/PubSub.coffee +5 -5
- data/client/lanes/models/Query.coffee +37 -27
- data/client/lanes/models/Sync.coffee +1 -1
- data/client/lanes/models/index.js +1 -0
- data/client/lanes/screens/Base.coffee +5 -8
- data/client/lanes/screens/ChangeListener.coffee +6 -3
- data/client/lanes/{models/Screens.coffee → screens/Definitions.coffee} +22 -9
- data/client/lanes/screens/Instance.coffee +22 -22
- data/client/lanes/screens/Router.coffee +1 -3
- data/client/lanes/screens/all.js.erb +3 -0
- data/client/lanes/screens/index.js +6 -1
- data/client/lanes/screens/{screen-definitions.js.erb → register.js.erb} +3 -3
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_alerts.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_badges.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_breadcrumbs.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_button-groups.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_buttons.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_carousel.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_close.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_code.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_component-animations.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_dropdowns.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_forms.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_glyphicons.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_grid.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_input-groups.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_jumbotron.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_labels.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_list-group.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_media.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_mixins.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_modals.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_navbar.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_navs.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_normalize.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_pager.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_pagination.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_panels.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_popovers.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_print.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_progress-bars.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_responsive-embed.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_responsive-utilities.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_scaffolding.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_tables.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_theme.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_thumbnails.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_tooltip.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_type.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_utilities.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_variables.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/_wells.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_alerts.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_background-variant.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_border-radius.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_buttons.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_center-block.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_clearfix.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_forms.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_gradients.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_grid-framework.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_grid.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_hide-text.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_image.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_labels.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_list-group.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_nav-divider.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_nav-vertical-align.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_opacity.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_pagination.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_panels.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_progress-bar.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_reset-filter.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_resize.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_responsive-visibility.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_size.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_tab-focus.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_table-row.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_text-emphasis.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_text-overflow.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/mixins/_vendor-prefixes.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_alerts.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_badges.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_breadcrumbs.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_button-groups.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_buttons.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_carousel.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_close.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_code.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_component-animations.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_dropdowns.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_forms.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_glyphicons.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_grid.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_input-groups.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_jumbotron.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_labels.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_list-group.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_media.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_mixins.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_modals.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_navbar.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_navs.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_normalize.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_pager.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_pagination.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_panels.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_popovers.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_print.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_progress-bars.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_responsive-embed.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_responsive-utilities.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_scaffolding.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_tables.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_theme.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_thumbnails.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_tooltip.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_type.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_utilities.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_variables.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/_wells.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/bootstrap.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_alerts.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_background-variant.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_border-radius.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_buttons.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_center-block.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_clearfix.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_forms.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_gradients.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_grid-framework.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_grid.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_hide-text.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_image.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_labels.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_list-group.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_nav-divider.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_nav-vertical-align.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_opacity.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_pagination.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_panels.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_progress-bar.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_reset-filter.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_resize.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_responsive-visibility.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_size.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_tab-focus.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_table-row.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_text-emphasis.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_text-overflow.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap → bootstrap}/old/mixins/_vendor-prefixes.scss +0 -0
- data/client/lanes/styles/{vendor/bootstrap-custom-grid.scss → bootstrap-custom-grid.scss} +0 -0
- data/client/lanes/styles/{vendor/bootstrap-custom-modals.scss → bootstrap-custom-modals.scss} +0 -0
- data/client/lanes/styles/bootstrap.scss +71 -0
- data/client/lanes/styles/{vendor/dataTables.scss → dataTables.scss} +0 -0
- data/client/lanes/styles/fonts.scss +9 -20
- data/client/lanes/vendor/packaged.js +27 -25
- data/client/lanes/views/Base.coffee +47 -34
- data/client/lanes/views/FormBindings.coffee +10 -9
- data/client/lanes/views/Helpers.coffee +14 -16
- data/client/lanes/views/ModelObserver.coffee +4 -4
- data/client/lanes/views/ModelUpdate.coffee +5 -2
- data/client/lanes/views/PubSub.coffee +1 -1
- data/client/lanes/views/Viewport.coffee +8 -78
- data/client/lanes/views/_button.html +1 -1
- data/client/lanes/views/_toolbar.html +21 -25
- data/client/lanes/views/model-update.html +7 -5
- data/client/lanes/workspace/ActiveScreensSwitcher.coffee +6 -12
- data/client/lanes/workspace/Extension.coffee +3 -0
- data/client/lanes/workspace/Layout.coffee +13 -9
- data/client/lanes/workspace/Navbar.coffee +2 -18
- data/client/lanes/workspace/Pages.coffee +13 -14
- data/client/lanes/workspace/ScreensMenu.coffee +9 -18
- data/client/lanes/workspace/UIState.coffee +78 -0
- data/client/lanes/workspace/WorkspaceView.coffee +4 -1
- data/client/lanes/workspace/index.js +0 -3
- data/client/lanes/workspace/navbar.html +0 -4
- data/client/lanes/workspace/pages.html +1 -1
- data/client/lanes/workspace/styles/changes-notification.scss +57 -0
- data/client/lanes/{styles → workspace/styles}/forms.scss +0 -0
- data/client/lanes/workspace/styles/header.scss +42 -0
- data/client/lanes/{styles → workspace/styles}/keybindings.scss +0 -0
- data/client/lanes/workspace/styles/layout.scss +209 -0
- data/client/lanes/workspace/styles/screens.scss +67 -0
- data/client/lanes/workspace/styles/tabs.scss +147 -0
- data/client/lanes/workspace/styles/toolbar.scss +4 -0
- data/client/lanes/workspace/styles.scss +20 -0
- data/docs/model.md +39 -7
- data/docs/todo-example-part-1.md +7 -7
- data/docs/view.md +57 -40
- data/lib/lanes/access/authentication_provider.rb +59 -0
- data/lib/lanes/access/config/routes.rb +26 -0
- data/lib/lanes/access/config/screens.rb +16 -0
- data/lib/lanes/access/db/migrate/20140615031600_create_lanes_users.rb +12 -0
- data/lib/lanes/access/extension.rb +40 -0
- data/lib/lanes/access/locked_fields.rb +43 -0
- data/lib/lanes/access/role.rb +60 -0
- data/lib/lanes/access/role_collection.rb +76 -0
- data/lib/lanes/access/roles/administrator.rb +39 -0
- data/lib/lanes/access/roles/support.rb +15 -0
- data/lib/lanes/access/track_modifications.rb +48 -0
- data/lib/lanes/access/user.rb +128 -0
- data/lib/lanes/access/version.rb +5 -0
- data/lib/lanes/access.rb +51 -0
- data/lib/lanes/api/helper_methods.rb +2 -2
- data/lib/lanes/api/javascript_processor.rb +3 -3
- data/lib/lanes/api/null_authentication_provider.rb +1 -1
- data/lib/lanes/api/pub_sub.rb +3 -3
- data/lib/lanes/api/request_wrapper.rb +1 -1
- data/lib/lanes/api/root.rb +1 -2
- data/lib/lanes/api/sprockets_extension.rb +6 -4
- data/lib/lanes/api/test_specs.rb +2 -8
- data/lib/lanes/command/app.rb +30 -12
- data/lib/lanes/command/db.rb +3 -0
- data/lib/lanes/command/generate_model.rb +4 -4
- data/lib/lanes/command/generate_screen.rb +12 -10
- data/lib/lanes/command/generate_view.rb +12 -9
- data/lib/lanes/command/named_command.rb +7 -5
- data/lib/lanes/command/server.rb +1 -1
- data/lib/lanes/command.rb +2 -5
- data/lib/lanes/components.rb +1 -1
- data/lib/lanes/concerns/queries.rb +1 -1
- data/lib/lanes/concerns/set_attribute_data.rb +5 -7
- data/lib/lanes/db.rb +5 -4
- data/lib/lanes/extension/definition.rb +95 -0
- data/lib/lanes/extension.rb +34 -69
- data/lib/lanes/guard_tasks.rb +2 -2
- data/lib/lanes/screen.rb +8 -0
- data/lib/lanes/spec_helper.rb +1 -37
- data/lib/lanes/version.rb +1 -1
- data/lib/lanes/workspace/extension.rb +28 -0
- data/lib/lanes/workspace.rb +7 -0
- data/npm-build/package.json +2 -2
- data/spec/api/javascript_processor_spec.rb +1 -1
- data/spec/lanes/components/grid/GridSpec.coffee +31 -0
- data/{lib/lanes/command/templates/client/views → spec/lanes/helpers}/.gitkeep +0 -0
- data/spec/{helpers → lanes/helpers}/jasmine-matchers.js +0 -0
- data/spec/{helpers → lanes/helpers}/lanes-helpers.coffee +2 -4
- data/spec/lanes/helpers/mock-ajax.js +576 -0
- data/spec/lanes/models/BaseSpec.coffee +24 -37
- data/spec/lanes/models/CollectionSpec.coffee +15 -2
- data/spec/lanes/models/ModelAssociationsSpec.coffee +51 -0
- data/spec/lanes/views/BaseSpec.coffee +14 -14
- data/spec/server/command_spec.rb +39 -0
- data/spec/{concerns → server/concerns}/api_path_spec.rb +1 -1
- data/spec/{concerns → server/concerns}/association_extensions_spec.rb +1 -2
- data/spec/{concerns → server/concerns}/attr_accessor_with_default_spec.rb +0 -0
- data/spec/{concerns → server/concerns}/export_associations_spec.rb +1 -2
- data/spec/{concerns → server/concerns}/export_methods_spec.rb +1 -3
- data/spec/{concerns → server/concerns}/export_scope_spec.rb +2 -2
- data/spec/{concerns → server/concerns}/exported_limits_spec.rb +1 -2
- data/spec/{concerns → server/concerns}/pub_sub_spec.rb +1 -1
- data/spec/{concerns → server/concerns}/set_attribute_data_spec.rb +1 -1
- data/spec/{configuration_spec.rb → server/configuration_spec.rb} +1 -1
- data/spec/{helpers → server}/minitest_assertions.rb +1 -1
- data/spec/{numbers_spec.rb → server/numbers_spec.rb} +1 -2
- data/{lib/lanes/testing_models.rb → spec/server/spec_helper.rb} +17 -3
- data/spec/{strings_spec.rb → server/strings_spec.rb} +1 -1
- data/templates/Gemfile +6 -0
- data/{lib/lanes/command/templates → templates}/Guardfile +0 -0
- data/templates/Rakefile +2 -0
- data/templates/client/Extension.coffee +7 -0
- data/templates/client/Router.coffee +4 -0
- data/{lib/lanes/command/templates/public → templates/client/components}/.gitkeep +0 -0
- data/templates/client/components/Component.coffee +1 -0
- data/{lib/lanes/command/templates → templates}/client/index.js +1 -0
- data/templates/client/models/BaseModel.coffee +5 -0
- data/{lib/lanes/command/templates → templates}/client/models/Model.coffee +2 -3
- data/{lib/lanes/command/templates → templates}/client/screens/Screen.coffee +6 -1
- data/{lib/lanes/command/templates → templates}/client/screens/index.js +0 -0
- data/{lib/lanes/command/templates → templates}/client/screens/layout.html +0 -0
- data/{lib/lanes/command/templates → templates}/client/screens/styles.scss +1 -2
- data/{lib/lanes/command/templates → templates}/client/styles.scss +0 -0
- data/{spec/helpers → templates/client/views}/.gitkeep +0 -0
- data/templates/client/views/BaseView.coffee +5 -0
- data/templates/client/views/View.coffee +10 -0
- data/{lib/lanes/command/templates → templates}/client/views/template.html +0 -0
- data/{lib/lanes/command/templates → templates}/config/database.yml +0 -0
- data/{lib/lanes/command/templates → templates}/config/lanes.rb +0 -0
- data/{lib/lanes/command/templates → templates}/config/routes.rb +0 -0
- data/templates/config/screen.rb +12 -0
- data/{lib/lanes/command/templates → templates}/config.ru +1 -1
- data/{lib/lanes/command/templates → templates}/db/create_table_migration.rb +1 -1
- data/{lib/lanes/command/templates → templates}/gitignore +1 -0
- data/templates/lib/namespace/base_model.rb +11 -0
- data/{lib/lanes/command/templates → templates}/lib/namespace/extension.rb +3 -3
- data/{lib/lanes/command/templates → templates}/lib/namespace/model.rb +1 -1
- data/templates/lib/namespace/version.rb +3 -0
- data/templates/lib/namespace.rb +14 -0
- data/templates/public/.gitkeep +0 -0
- data/templates/spec/client/Screen.coffee +5 -0
- data/templates/spec/client/helpers/ClientHelpers.coffee +5 -0
- data/templates/spec/client/models/ModelSpec.coffee +5 -0
- data/templates/spec/client/views/ViewSpec.coffee +5 -0
- data/{lib/lanes/command/templates → templates}/spec/fixtures/namespace/model.yml +0 -0
- data/{lib/lanes/command/templates/spec/namespace → templates/spec/server}/model_spec.rb +2 -2
- data/{lib/lanes/command/templates/spec/spec_helper.rb → templates/spec/server/spec_helpers.rb} +3 -2
- data/views/index.erb +5 -4
- data/views/specs.erb +2 -1
- metadata +273 -238
- data/client/lanes/components/grid/vendor/dataTables.bootstrap.js +0 -156
- data/client/lanes/components/grid/vendor/datatables.responsive.js +0 -666
- data/client/lanes/components/modal/_index.scss +0 -20
- data/client/lanes/components/popover/_index.scss +0 -1
- data/client/lanes/components/record_finder/RecordFinder.coffee +0 -143
- data/client/lanes/components/select_field/SelectField.coffee +0 -87
- data/client/lanes/extension/GlAccounts.coffee +0 -9
- data/client/lanes/minimal.js +0 -11
- data/client/lanes/minimal.scss.erb +0 -12
- data/client/lanes/styles/components/all.scss +0 -6
- data/client/lanes/styles/components/changes-notification.scss +0 -44
- data/client/lanes/styles/components/suggest.scss +0 -266
- data/client/lanes/styles/index.css +0 -4
- data/client/lanes/styles/layout.scss +0 -272
- data/client/lanes/styles/screens.scss +0 -66
- data/client/lanes/styles/tabs.scss +0 -148
- data/client/lanes/styles/vendor/bootstrap.scss +0 -74
- data/client/lanes/workspace.scss.erb +0 -29
- data/client/lanes-complete.js +0 -3
- data/client/lanes-workspace.scss.erb +0 -21
- data/db/migrate/20140615031600_create_hip_users.rb +0 -17
- data/lib/lanes/command/templates/Gemfile +0 -9
- data/lib/lanes/command/templates/Rakefile +0 -2
- data/lib/lanes/command/templates/client/Extension.coffee +0 -5
- data/lib/lanes/command/templates/client/components/Component.coffee +0 -1
- data/lib/lanes/command/templates/client/models/BaseModel.coffee +0 -5
- data/lib/lanes/command/templates/client/views/BaseView.coffee +0 -5
- data/lib/lanes/command/templates/client/views/View.coffee +0 -7
- data/lib/lanes/command/templates/config/screen.rb +0 -8
- data/lib/lanes/command/templates/lib/namespace/base_model.rb +0 -9
- data/lib/lanes/command/templates/lib/namespace/version.rb +0 -3
- data/lib/lanes/command/templates/lib/namespace.rb +0 -12
- data/lib/lanes/command/templates/spec/client/Screen.coffee +0 -7
- data/lib/lanes/command/templates/spec/client/models/ModelSpec.coffee +0 -5
- data/lib/lanes/command/templates/spec/client/views/ViewSpec.coffee +0 -5
- data/lib/lanes/db/migration_helpers.rb +0 -178
- data/public/javascripts/jasmine_examples/Player.js +0 -22
- data/public/javascripts/jasmine_examples/Song.js +0 -7
- data/spec/command_spec.rb +0 -49
- data/spec/helpers/jasmine-jquery.js +0 -813
@@ -0,0 +1,31 @@
|
|
1
|
+
#= require lanes/components/grid
|
2
|
+
#= require lanes/access/User
|
3
|
+
|
4
|
+
describe "Lanes.Components.Grid", ->
|
5
|
+
|
6
|
+
DATA = {total:1,success:true,message:"Retrieve succeeded",data:[
|
7
|
+
[1,"TEST","Nathan Stitt",null,"0.0"]
|
8
|
+
]}
|
9
|
+
RESPONSE = {
|
10
|
+
status:200,
|
11
|
+
contentType: "application/json"
|
12
|
+
responseText: JSON.stringify(DATA)
|
13
|
+
}
|
14
|
+
|
15
|
+
beforeEach ->
|
16
|
+
jasmine.Ajax.install()
|
17
|
+
afterEach ->
|
18
|
+
jasmine.Ajax.uninstall()
|
19
|
+
|
20
|
+
it "loads", ->
|
21
|
+
query = new Lanes.Models.Query(
|
22
|
+
fields: [ 'code', 'name', 'notes' ]
|
23
|
+
modelClass: Lanes.Models.User
|
24
|
+
)
|
25
|
+
grid = new Lanes.Components.Grid(recordQuery:query)
|
26
|
+
expect( grid.render() ).toBe( grid )
|
27
|
+
request = jasmine.Ajax.requests.mostRecent()
|
28
|
+
expect(request.url).toMatch(/^\/users.json/)
|
29
|
+
|
30
|
+
request.respondWith(RESPONSE)
|
31
|
+
expect( grid.dt_api.rows().length ).toEqual(1)
|
File without changes
|
File without changes
|
@@ -10,7 +10,7 @@ class Lanes.Test.DummyView extends Lanes.Views.Base
|
|
10
10
|
onClick: Lanes.emptyFn
|
11
11
|
|
12
12
|
class Lanes.Test.DummyModel extends Lanes.Models.Base
|
13
|
-
api_path: "test"
|
13
|
+
api_path: -> "test"
|
14
14
|
props:
|
15
15
|
id: 'number',
|
16
16
|
name: ['string', true],
|
@@ -76,11 +76,9 @@ beforeEach ->
|
|
76
76
|
message: ''
|
77
77
|
data: {}
|
78
78
|
}
|
79
|
-
|
79
|
+
|
80
80
|
Lanes.Test.syncSpy = jasmine.createSpy('sync').and.callFake(syncResponse)
|
81
81
|
Lanes.Test.syncSpy.lastOptions = ->
|
82
82
|
this.calls.mostRecent().args[2]
|
83
83
|
Lanes.Models.Base::sync = Lanes.Test.syncSpy
|
84
84
|
Lanes.Models.Collection::sync = Lanes.Test.syncSpy
|
85
|
-
|
86
|
-
|
@@ -0,0 +1,576 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Jasmine-Ajax : a set of helpers for testing AJAX requests under the Jasmine
|
4
|
+
BDD framework for JavaScript.
|
5
|
+
|
6
|
+
http://github.com/pivotal/jasmine-ajax
|
7
|
+
|
8
|
+
Jasmine Home page: http://pivotal.github.com/jasmine
|
9
|
+
|
10
|
+
Copyright (c) 2008-2013 Pivotal Labs
|
11
|
+
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
13
|
+
a copy of this software and associated documentation files (the
|
14
|
+
"Software"), to deal in the Software without restriction, including
|
15
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
16
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
17
|
+
permit persons to whom the Software is furnished to do so, subject to
|
18
|
+
the following conditions:
|
19
|
+
|
20
|
+
The above copyright notice and this permission notice shall be
|
21
|
+
included in all copies or substantial portions of the Software.
|
22
|
+
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
26
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
27
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
28
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
29
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
30
|
+
|
31
|
+
*/
|
32
|
+
|
33
|
+
getJasmineRequireObj().ajax = function(jRequire) {
|
34
|
+
var $ajax = {};
|
35
|
+
|
36
|
+
$ajax.RequestStub = jRequire.AjaxRequestStub();
|
37
|
+
$ajax.RequestTracker = jRequire.AjaxRequestTracker();
|
38
|
+
$ajax.StubTracker = jRequire.AjaxStubTracker();
|
39
|
+
$ajax.ParamParser = jRequire.AjaxParamParser();
|
40
|
+
$ajax.fakeRequest = jRequire.AjaxFakeRequest();
|
41
|
+
$ajax.MockAjax = jRequire.MockAjax($ajax);
|
42
|
+
|
43
|
+
return $ajax.MockAjax;
|
44
|
+
};
|
45
|
+
|
46
|
+
getJasmineRequireObj().AjaxFakeRequest = function() {
|
47
|
+
function extend(destination, source, propertiesToSkip) {
|
48
|
+
propertiesToSkip = propertiesToSkip || [];
|
49
|
+
for (var property in source) {
|
50
|
+
if (!arrayContains(propertiesToSkip, property)) {
|
51
|
+
destination[property] = source[property];
|
52
|
+
}
|
53
|
+
}
|
54
|
+
return destination;
|
55
|
+
}
|
56
|
+
|
57
|
+
function arrayContains(arr, item) {
|
58
|
+
for (var i = 0; i < arr.length; i++) {
|
59
|
+
if (arr[i] === item) {
|
60
|
+
return true;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
return false;
|
64
|
+
}
|
65
|
+
|
66
|
+
function wrapProgressEvent(xhr, eventName) {
|
67
|
+
return function() {
|
68
|
+
if (xhr[eventName]) {
|
69
|
+
xhr[eventName]();
|
70
|
+
}
|
71
|
+
};
|
72
|
+
}
|
73
|
+
|
74
|
+
function initializeEvents(xhr) {
|
75
|
+
return {
|
76
|
+
'loadstart': wrapProgressEvent(xhr, 'onloadstart'),
|
77
|
+
'load': wrapProgressEvent(xhr, 'onload'),
|
78
|
+
'loadend': wrapProgressEvent(xhr, 'onloadend'),
|
79
|
+
'progress': wrapProgressEvent(xhr, 'onprogress'),
|
80
|
+
'error': wrapProgressEvent(xhr, 'onerror'),
|
81
|
+
'abort': wrapProgressEvent(xhr, 'onabort'),
|
82
|
+
'timeout': wrapProgressEvent(xhr, 'ontimeout')
|
83
|
+
};
|
84
|
+
}
|
85
|
+
|
86
|
+
function unconvertibleResponseTypeMessage(type) {
|
87
|
+
var msg = [
|
88
|
+
"Can't build XHR.response for XHR.responseType of '",
|
89
|
+
type,
|
90
|
+
"'.",
|
91
|
+
"XHR.response must be explicitly stubbed"
|
92
|
+
];
|
93
|
+
return msg.join(' ');
|
94
|
+
}
|
95
|
+
|
96
|
+
function fakeRequest(global, requestTracker, stubTracker, paramParser) {
|
97
|
+
function FakeXMLHttpRequest() {
|
98
|
+
requestTracker.track(this);
|
99
|
+
this.events = initializeEvents(this);
|
100
|
+
this.requestHeaders = {};
|
101
|
+
this.overriddenMimeType = null;
|
102
|
+
}
|
103
|
+
|
104
|
+
function findHeader(name, headers) {
|
105
|
+
name = name.toLowerCase();
|
106
|
+
for (var header in headers) {
|
107
|
+
if (header.toLowerCase() === name) {
|
108
|
+
return headers[header];
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
function normalizeHeaders(rawHeaders, contentType) {
|
114
|
+
var headers = [];
|
115
|
+
|
116
|
+
if (rawHeaders) {
|
117
|
+
if (rawHeaders instanceof Array) {
|
118
|
+
headers = rawHeaders;
|
119
|
+
} else {
|
120
|
+
for (var headerName in rawHeaders) {
|
121
|
+
if (rawHeaders.hasOwnProperty(headerName)) {
|
122
|
+
headers.push({ name: headerName, value: rawHeaders[headerName] });
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
} else {
|
127
|
+
headers.push({ name: "Content-Type", value: contentType || "application/json" });
|
128
|
+
}
|
129
|
+
|
130
|
+
return headers;
|
131
|
+
}
|
132
|
+
|
133
|
+
function parseXml(xmlText, contentType) {
|
134
|
+
if (global.DOMParser) {
|
135
|
+
return (new global.DOMParser()).parseFromString(xmlText, 'text/xml');
|
136
|
+
} else {
|
137
|
+
var xml = new global.ActiveXObject("Microsoft.XMLDOM");
|
138
|
+
xml.async = "false";
|
139
|
+
xml.loadXML(xmlText);
|
140
|
+
return xml;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
var xmlParsables = ['text/xml', 'application/xml'];
|
145
|
+
|
146
|
+
function getResponseXml(responseText, contentType) {
|
147
|
+
if (arrayContains(xmlParsables, contentType.toLowerCase())) {
|
148
|
+
return parseXml(responseText, contentType);
|
149
|
+
} else if (contentType.match(/\+xml$/)) {
|
150
|
+
return parseXml(responseText, 'text/xml');
|
151
|
+
}
|
152
|
+
return null;
|
153
|
+
}
|
154
|
+
|
155
|
+
var iePropertiesThatCannotBeCopied = ['responseBody', 'responseText', 'responseXML', 'status', 'statusText', 'responseTimeout'];
|
156
|
+
extend(FakeXMLHttpRequest.prototype, new global.XMLHttpRequest(), iePropertiesThatCannotBeCopied);
|
157
|
+
extend(FakeXMLHttpRequest.prototype, {
|
158
|
+
open: function() {
|
159
|
+
this.method = arguments[0];
|
160
|
+
this.url = arguments[1];
|
161
|
+
this.username = arguments[3];
|
162
|
+
this.password = arguments[4];
|
163
|
+
this.readyState = 1;
|
164
|
+
this.onreadystatechange();
|
165
|
+
},
|
166
|
+
|
167
|
+
setRequestHeader: function(header, value) {
|
168
|
+
if(this.requestHeaders.hasOwnProperty(header)) {
|
169
|
+
this.requestHeaders[header] = [this.requestHeaders[header], value].join(', ');
|
170
|
+
} else {
|
171
|
+
this.requestHeaders[header] = value;
|
172
|
+
}
|
173
|
+
},
|
174
|
+
|
175
|
+
overrideMimeType: function(mime) {
|
176
|
+
this.overriddenMimeType = mime;
|
177
|
+
},
|
178
|
+
|
179
|
+
abort: function() {
|
180
|
+
this.readyState = 0;
|
181
|
+
this.status = 0;
|
182
|
+
this.statusText = "abort";
|
183
|
+
this.onreadystatechange();
|
184
|
+
this.events.progress();
|
185
|
+
this.events.abort();
|
186
|
+
this.events.loadend();
|
187
|
+
},
|
188
|
+
|
189
|
+
readyState: 0,
|
190
|
+
|
191
|
+
onloadstart: null,
|
192
|
+
onprogress: null,
|
193
|
+
onabort: null,
|
194
|
+
onerror: null,
|
195
|
+
onload: null,
|
196
|
+
ontimeout: null,
|
197
|
+
onloadend: null,
|
198
|
+
|
199
|
+
onreadystatechange: function(isTimeout) {
|
200
|
+
},
|
201
|
+
|
202
|
+
addEventListener: function(event, callback) {
|
203
|
+
var existingCallback = this.events[event],
|
204
|
+
self = this;
|
205
|
+
|
206
|
+
this.events[event] = function() {
|
207
|
+
callback.apply(self);
|
208
|
+
existingCallback();
|
209
|
+
};
|
210
|
+
},
|
211
|
+
|
212
|
+
status: null,
|
213
|
+
|
214
|
+
send: function(data) {
|
215
|
+
this.params = data;
|
216
|
+
this.readyState = 2;
|
217
|
+
this.events.loadstart();
|
218
|
+
this.onreadystatechange();
|
219
|
+
|
220
|
+
var stub = stubTracker.findStub(this.url, data, this.method);
|
221
|
+
if (stub) {
|
222
|
+
this.respondWith(stub);
|
223
|
+
}
|
224
|
+
},
|
225
|
+
|
226
|
+
contentType: function() {
|
227
|
+
return findHeader('content-type', this.requestHeaders);
|
228
|
+
},
|
229
|
+
|
230
|
+
data: function() {
|
231
|
+
if (!this.params) {
|
232
|
+
return {};
|
233
|
+
}
|
234
|
+
|
235
|
+
return paramParser.findParser(this).parse(this.params);
|
236
|
+
},
|
237
|
+
|
238
|
+
getResponseHeader: function(name) {
|
239
|
+
name = name.toLowerCase();
|
240
|
+
var resultHeader;
|
241
|
+
for(var i = 0; i < this.responseHeaders.length; i++) {
|
242
|
+
var header = this.responseHeaders[i];
|
243
|
+
if (name === header.name.toLowerCase()) {
|
244
|
+
if (resultHeader) {
|
245
|
+
resultHeader = [resultHeader, header.value].join(', ');
|
246
|
+
} else {
|
247
|
+
resultHeader = header.value;
|
248
|
+
}
|
249
|
+
}
|
250
|
+
}
|
251
|
+
return resultHeader;
|
252
|
+
},
|
253
|
+
|
254
|
+
getAllResponseHeaders: function() {
|
255
|
+
var responseHeaders = [];
|
256
|
+
for (var i = 0; i < this.responseHeaders.length; i++) {
|
257
|
+
responseHeaders.push(this.responseHeaders[i].name + ': ' +
|
258
|
+
this.responseHeaders[i].value);
|
259
|
+
}
|
260
|
+
return responseHeaders.join('\r\n') + '\r\n';
|
261
|
+
},
|
262
|
+
|
263
|
+
responseText: null,
|
264
|
+
response: null,
|
265
|
+
responseType: null,
|
266
|
+
|
267
|
+
responseValue: function() {
|
268
|
+
switch(this.responseType) {
|
269
|
+
case null:
|
270
|
+
case "":
|
271
|
+
case "text":
|
272
|
+
return this.readyState >= 3 ? this.responseText : "";
|
273
|
+
case "json":
|
274
|
+
return JSON.parse(this.responseText);
|
275
|
+
case "arraybuffer":
|
276
|
+
throw unconvertibleResponseTypeMessage('arraybuffer');
|
277
|
+
case "blob":
|
278
|
+
throw unconvertibleResponseTypeMessage('blob');
|
279
|
+
case "document":
|
280
|
+
return this.responseXML;
|
281
|
+
}
|
282
|
+
},
|
283
|
+
|
284
|
+
|
285
|
+
respondWith: function(response) {
|
286
|
+
if (this.readyState === 4) {
|
287
|
+
throw new Error("FakeXMLHttpRequest already completed");
|
288
|
+
}
|
289
|
+
this.status = response.status;
|
290
|
+
this.statusText = response.statusText || "";
|
291
|
+
this.responseText = response.responseText || "";
|
292
|
+
this.responseType = response.responseType || "";
|
293
|
+
this.readyState = 4;
|
294
|
+
this.responseHeaders = normalizeHeaders(response.responseHeaders, response.contentType);
|
295
|
+
this.responseXML = getResponseXml(response.responseText, this.getResponseHeader('content-type') || '');
|
296
|
+
if (this.responseXML) {
|
297
|
+
this.responseType = 'document';
|
298
|
+
}
|
299
|
+
|
300
|
+
if ('response' in response) {
|
301
|
+
this.response = response.response;
|
302
|
+
} else {
|
303
|
+
this.response = this.responseValue();
|
304
|
+
}
|
305
|
+
|
306
|
+
this.onreadystatechange();
|
307
|
+
this.events.progress();
|
308
|
+
this.events.load();
|
309
|
+
this.events.loadend();
|
310
|
+
},
|
311
|
+
|
312
|
+
responseTimeout: function() {
|
313
|
+
if (this.readyState === 4) {
|
314
|
+
throw new Error("FakeXMLHttpRequest already completed");
|
315
|
+
}
|
316
|
+
this.readyState = 4;
|
317
|
+
jasmine.clock().tick(30000);
|
318
|
+
this.onreadystatechange('timeout');
|
319
|
+
this.events.progress();
|
320
|
+
this.events.timeout();
|
321
|
+
this.events.loadend();
|
322
|
+
},
|
323
|
+
|
324
|
+
responseError: function() {
|
325
|
+
if (this.readyState === 4) {
|
326
|
+
throw new Error("FakeXMLHttpRequest already completed");
|
327
|
+
}
|
328
|
+
this.readyState = 4;
|
329
|
+
this.onreadystatechange();
|
330
|
+
this.events.progress();
|
331
|
+
this.events.error();
|
332
|
+
this.events.loadend();
|
333
|
+
}
|
334
|
+
});
|
335
|
+
|
336
|
+
return FakeXMLHttpRequest;
|
337
|
+
}
|
338
|
+
|
339
|
+
return fakeRequest;
|
340
|
+
};
|
341
|
+
|
342
|
+
getJasmineRequireObj().MockAjax = function($ajax) {
|
343
|
+
function MockAjax(global) {
|
344
|
+
var requestTracker = new $ajax.RequestTracker(),
|
345
|
+
stubTracker = new $ajax.StubTracker(),
|
346
|
+
paramParser = new $ajax.ParamParser(),
|
347
|
+
realAjaxFunction = global.XMLHttpRequest,
|
348
|
+
mockAjaxFunction = $ajax.fakeRequest(global, requestTracker, stubTracker, paramParser);
|
349
|
+
|
350
|
+
this.install = function() {
|
351
|
+
global.XMLHttpRequest = mockAjaxFunction;
|
352
|
+
};
|
353
|
+
|
354
|
+
this.uninstall = function() {
|
355
|
+
global.XMLHttpRequest = realAjaxFunction;
|
356
|
+
|
357
|
+
this.stubs.reset();
|
358
|
+
this.requests.reset();
|
359
|
+
paramParser.reset();
|
360
|
+
};
|
361
|
+
|
362
|
+
this.stubRequest = function(url, data, method) {
|
363
|
+
var stub = new $ajax.RequestStub(url, data, method);
|
364
|
+
stubTracker.addStub(stub);
|
365
|
+
return stub;
|
366
|
+
};
|
367
|
+
|
368
|
+
this.withMock = function(closure) {
|
369
|
+
this.install();
|
370
|
+
try {
|
371
|
+
closure();
|
372
|
+
} finally {
|
373
|
+
this.uninstall();
|
374
|
+
}
|
375
|
+
};
|
376
|
+
|
377
|
+
this.addCustomParamParser = function(parser) {
|
378
|
+
paramParser.add(parser);
|
379
|
+
};
|
380
|
+
|
381
|
+
this.requests = requestTracker;
|
382
|
+
this.stubs = stubTracker;
|
383
|
+
}
|
384
|
+
|
385
|
+
return MockAjax;
|
386
|
+
};
|
387
|
+
|
388
|
+
getJasmineRequireObj().AjaxParamParser = function() {
|
389
|
+
function ParamParser() {
|
390
|
+
var defaults = [
|
391
|
+
{
|
392
|
+
test: function(xhr) {
|
393
|
+
return (/^application\/json/).test(xhr.contentType());
|
394
|
+
},
|
395
|
+
parse: function jsonParser(paramString) {
|
396
|
+
return JSON.parse(paramString);
|
397
|
+
}
|
398
|
+
},
|
399
|
+
{
|
400
|
+
test: function(xhr) {
|
401
|
+
return true;
|
402
|
+
},
|
403
|
+
parse: function naiveParser(paramString) {
|
404
|
+
var data = {};
|
405
|
+
var params = paramString.split('&');
|
406
|
+
|
407
|
+
for (var i = 0; i < params.length; ++i) {
|
408
|
+
var kv = params[i].replace(/\+/g, ' ').split('=');
|
409
|
+
var key = decodeURIComponent(kv[0]);
|
410
|
+
data[key] = data[key] || [];
|
411
|
+
data[key].push(decodeURIComponent(kv[1]));
|
412
|
+
}
|
413
|
+
return data;
|
414
|
+
}
|
415
|
+
}
|
416
|
+
];
|
417
|
+
var paramParsers = [];
|
418
|
+
|
419
|
+
this.add = function(parser) {
|
420
|
+
paramParsers.unshift(parser);
|
421
|
+
};
|
422
|
+
|
423
|
+
this.findParser = function(xhr) {
|
424
|
+
for(var i in paramParsers) {
|
425
|
+
var parser = paramParsers[i];
|
426
|
+
if (parser.test(xhr)) {
|
427
|
+
return parser;
|
428
|
+
}
|
429
|
+
}
|
430
|
+
};
|
431
|
+
|
432
|
+
this.reset = function() {
|
433
|
+
paramParsers = [];
|
434
|
+
for(var i in defaults) {
|
435
|
+
paramParsers.push(defaults[i]);
|
436
|
+
}
|
437
|
+
};
|
438
|
+
|
439
|
+
this.reset();
|
440
|
+
}
|
441
|
+
|
442
|
+
return ParamParser;
|
443
|
+
};
|
444
|
+
|
445
|
+
getJasmineRequireObj().AjaxRequestStub = function() {
|
446
|
+
function RequestStub(url, stubData, method) {
|
447
|
+
var normalizeQuery = function(query) {
|
448
|
+
return query ? query.split('&').sort().join('&') : undefined;
|
449
|
+
};
|
450
|
+
|
451
|
+
if (url instanceof RegExp) {
|
452
|
+
this.url = url;
|
453
|
+
this.query = undefined;
|
454
|
+
} else {
|
455
|
+
var split = url.split('?');
|
456
|
+
this.url = split[0];
|
457
|
+
this.query = split.length > 1 ? normalizeQuery(split[1]) : undefined;
|
458
|
+
}
|
459
|
+
|
460
|
+
this.data = normalizeQuery(stubData);
|
461
|
+
this.method = method;
|
462
|
+
|
463
|
+
this.andReturn = function(options) {
|
464
|
+
this.status = options.status || 200;
|
465
|
+
|
466
|
+
this.contentType = options.contentType;
|
467
|
+
this.response = options.response;
|
468
|
+
this.responseText = options.responseText;
|
469
|
+
};
|
470
|
+
|
471
|
+
this.matches = function(fullUrl, data, method) {
|
472
|
+
var matches = false;
|
473
|
+
fullUrl = fullUrl.toString();
|
474
|
+
if (this.url instanceof RegExp) {
|
475
|
+
matches = this.url.test(fullUrl);
|
476
|
+
} else {
|
477
|
+
var urlSplit = fullUrl.split('?'),
|
478
|
+
url = urlSplit[0],
|
479
|
+
query = urlSplit[1];
|
480
|
+
matches = this.url === url && this.query === normalizeQuery(query);
|
481
|
+
}
|
482
|
+
return matches && (!this.data || this.data === normalizeQuery(data)) && (!this.method || this.method === method);
|
483
|
+
};
|
484
|
+
}
|
485
|
+
|
486
|
+
return RequestStub;
|
487
|
+
};
|
488
|
+
|
489
|
+
getJasmineRequireObj().AjaxRequestTracker = function() {
|
490
|
+
function RequestTracker() {
|
491
|
+
var requests = [];
|
492
|
+
|
493
|
+
this.track = function(request) {
|
494
|
+
requests.push(request);
|
495
|
+
};
|
496
|
+
|
497
|
+
this.first = function() {
|
498
|
+
return requests[0];
|
499
|
+
};
|
500
|
+
|
501
|
+
this.count = function() {
|
502
|
+
return requests.length;
|
503
|
+
};
|
504
|
+
|
505
|
+
this.reset = function() {
|
506
|
+
requests = [];
|
507
|
+
};
|
508
|
+
|
509
|
+
this.mostRecent = function() {
|
510
|
+
return requests[requests.length - 1];
|
511
|
+
};
|
512
|
+
|
513
|
+
this.at = function(index) {
|
514
|
+
return requests[index];
|
515
|
+
};
|
516
|
+
|
517
|
+
this.filter = function(url_to_match) {
|
518
|
+
var matching_requests = [];
|
519
|
+
|
520
|
+
for (var i = 0; i < requests.length; i++) {
|
521
|
+
if (url_to_match instanceof RegExp &&
|
522
|
+
url_to_match.test(requests[i].url)) {
|
523
|
+
matching_requests.push(requests[i]);
|
524
|
+
} else if (url_to_match instanceof Function &&
|
525
|
+
url_to_match(requests[i])) {
|
526
|
+
matching_requests.push(requests[i]);
|
527
|
+
} else {
|
528
|
+
if (requests[i].url === url_to_match) {
|
529
|
+
matching_requests.push(requests[i]);
|
530
|
+
}
|
531
|
+
}
|
532
|
+
}
|
533
|
+
|
534
|
+
return matching_requests;
|
535
|
+
};
|
536
|
+
}
|
537
|
+
|
538
|
+
return RequestTracker;
|
539
|
+
};
|
540
|
+
|
541
|
+
getJasmineRequireObj().AjaxStubTracker = function() {
|
542
|
+
function StubTracker() {
|
543
|
+
var stubs = [];
|
544
|
+
|
545
|
+
this.addStub = function(stub) {
|
546
|
+
stubs.push(stub);
|
547
|
+
};
|
548
|
+
|
549
|
+
this.reset = function() {
|
550
|
+
stubs = [];
|
551
|
+
};
|
552
|
+
|
553
|
+
this.findStub = function(url, data, method) {
|
554
|
+
for (var i = stubs.length - 1; i >= 0; i--) {
|
555
|
+
var stub = stubs[i];
|
556
|
+
if (stub.matches(url, data, method)) {
|
557
|
+
return stub;
|
558
|
+
}
|
559
|
+
}
|
560
|
+
};
|
561
|
+
}
|
562
|
+
|
563
|
+
return StubTracker;
|
564
|
+
};
|
565
|
+
|
566
|
+
(function() {
|
567
|
+
var jRequire = getJasmineRequireObj(),
|
568
|
+
MockAjax = jRequire.ajax(jRequire);
|
569
|
+
if (typeof window === "undefined" && typeof exports === "object") {
|
570
|
+
exports.MockAjax = MockAjax;
|
571
|
+
jasmine.Ajax = new MockAjax(exports);
|
572
|
+
} else {
|
573
|
+
window.MockAjax = MockAjax;
|
574
|
+
jasmine.Ajax = new MockAjax(window);
|
575
|
+
}
|
576
|
+
}());
|