lanes 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -0
- data/Gemfile +2 -2
- data/client/lanes/components/Base.coffee +12 -11
- data/client/lanes/components/enabled.js.erb +1 -1
- data/client/lanes/components/grid/Editor.coffee +2 -2
- data/client/lanes/components/grid/Grid.coffee +60 -58
- data/client/lanes/components/grid/PopOverEditor.coffee +3 -3
- data/client/lanes/components/grid/RowEditor.coffee +1 -1
- data/client/lanes/components/grid/{grid.scss → _index.scss} +0 -0
- data/client/lanes/components/grid/template.html +1 -1
- data/client/lanes/components/modal/ModalDialog.coffee +1 -1
- data/client/lanes/components/modal/{modal.scss → _index.scss} +1 -1
- data/client/lanes/components/modal/index.js +1 -1
- data/client/lanes/components/popover/PopOver.coffee +1 -1
- data/client/lanes/components/popover/_index.scss +1 -0
- data/client/lanes/components/popover/index.js +1 -1
- data/client/lanes/components/select_field/{select_field.scss → _index.scss} +0 -0
- data/client/lanes/extension/Extensions.coffee +3 -2
- data/client/lanes/lib/Templates.coffee +7 -0
- data/client/lanes/minimal.js +1 -1
- data/client/lanes/minimal.scss.erb +1 -1
- data/client/lanes/models/Base.coffee +16 -19
- data/client/lanes/models/Bootstrap.coffee +1 -2
- data/client/lanes/models/Collection.coffee +37 -25
- data/client/lanes/models/Screens.coffee +6 -18
- data/client/lanes/models/Sync.coffee +12 -5
- data/client/lanes/screens/Base.coffee +1 -2
- data/client/lanes/screens/Instance.coffee +2 -5
- data/client/lanes/screens/screen-definitions.js.erb +10 -2
- data/client/{styles → lanes/styles}/components/all.scss +0 -0
- data/client/{styles → lanes/styles}/components/changes-notification.scss +0 -0
- data/client/{styles → lanes/styles}/components/record-finder.scss +0 -0
- data/client/{styles → lanes/styles}/components/suggest.scss +0 -0
- data/client/{styles → lanes/styles}/fonts/icomoon.eot +0 -0
- data/client/{styles → lanes/styles}/fonts/icomoon.svg +0 -0
- data/client/{styles → lanes/styles}/fonts/icomoon.ttf +0 -0
- data/client/{styles → lanes/styles}/fonts/icomoon.woff +0 -0
- data/client/{styles → lanes/styles}/fonts/selection.json +0 -0
- data/client/{styles → lanes/styles}/fonts/style.scss +0 -0
- data/client/{styles → lanes/styles}/fonts.scss +5 -5
- data/client/{styles → lanes/styles}/forms.scss +0 -0
- data/client/{styles → lanes/styles}/index.css +0 -0
- data/client/{styles → lanes/styles}/keybindings.scss +0 -0
- data/client/{styles → lanes/styles}/layout.scss +0 -0
- data/client/{styles → lanes/styles}/plugins/all.scss +0 -0
- data/client/{styles → lanes/styles}/plugins/overlay.scss +0 -0
- data/client/{styles → lanes/styles}/plugins/resize-sensor.scss +0 -0
- data/client/{styles → lanes/styles}/screens.scss +0 -0
- data/client/{styles → lanes/styles}/tabs.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_alerts.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_badges.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_breadcrumbs.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_button-groups.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_buttons.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_carousel.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_close.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_code.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_component-animations.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_dropdowns.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_forms.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_glyphicons.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_grid.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_input-groups.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_jumbotron.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_labels.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_list-group.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_media.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_mixins.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_modals.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_navbar.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_navs.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_normalize.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_pager.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_pagination.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_panels.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_popovers.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_print.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_progress-bars.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_responsive-embed.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_responsive-utilities.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_scaffolding.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_tables.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_theme.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_thumbnails.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_tooltip.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_type.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_utilities.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_variables.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/_wells.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_alerts.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_background-variant.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_border-radius.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_buttons.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_center-block.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_clearfix.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_forms.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_gradients.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_grid-framework.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_grid.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_hide-text.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_image.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_labels.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_list-group.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_nav-divider.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_nav-vertical-align.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_opacity.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_pagination.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_panels.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_progress-bar.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_reset-filter.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_resize.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_responsive-visibility.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_size.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_tab-focus.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_table-row.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_text-emphasis.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_text-overflow.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/mixins/_vendor-prefixes.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_alerts.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_badges.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_breadcrumbs.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_button-groups.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_buttons.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_carousel.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_close.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_code.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_component-animations.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_dropdowns.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_forms.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_glyphicons.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_grid.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_input-groups.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_jumbotron.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_labels.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_list-group.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_media.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_mixins.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_modals.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_navbar.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_navs.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_normalize.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_pager.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_pagination.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_panels.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_popovers.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_print.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_progress-bars.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_responsive-embed.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_responsive-utilities.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_scaffolding.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_tables.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_theme.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_thumbnails.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_tooltip.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_type.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_utilities.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_variables.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/_wells.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/bootstrap.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_alerts.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_background-variant.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_border-radius.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_buttons.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_center-block.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_clearfix.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_forms.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_gradients.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_grid-framework.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_grid.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_hide-text.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_image.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_labels.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_list-group.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_nav-divider.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_nav-vertical-align.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_opacity.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_pagination.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_panels.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_progress-bar.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_reset-filter.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_resize.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_responsive-visibility.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_size.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_tab-focus.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_table-row.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_text-emphasis.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_text-overflow.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap/old/mixins/_vendor-prefixes.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap-custom-grid.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap-custom-modals.scss +0 -0
- data/client/{styles → lanes/styles}/vendor/bootstrap.scss +2 -2
- data/client/{styles → lanes/styles}/vendor/dataTables.scss +0 -0
- data/client/lanes/views/Base.coffee +34 -49
- data/client/lanes/views/FormBindings.coffee +22 -20
- data/client/lanes/views/Helpers.coffee +1 -1
- data/client/lanes/views/empty-span.html +1 -0
- data/client/lanes/workspace/ActiveScreensSwitcher.coffee +8 -1
- data/client/lanes/workspace/Layout.coffee +7 -4
- data/client/lanes/workspace/Navbar.coffee +6 -2
- data/client/lanes/workspace/Pages.coffee +5 -1
- data/client/lanes/workspace/ScreensMenu.coffee +14 -2
- data/client/lanes/workspace/WorkspaceView.coffee +5 -0
- data/client/lanes/workspace/index.js +1 -0
- data/client/lanes/workspace.scss.erb +6 -1
- data/lanes.gemspec +1 -1
- data/lib/lanes/api/controller.rb +5 -7
- data/lib/lanes/api/helper_methods.rb +1 -1
- data/lib/lanes/api/javascript_processor.rb +3 -2
- data/lib/lanes/command/app.rb +8 -4
- data/lib/lanes/command/generate_model.rb +13 -11
- data/lib/lanes/command/generate_screen.rb +9 -2
- data/lib/lanes/command/generate_view.rb +15 -3
- data/lib/lanes/command/generate_view.usage +7 -7
- data/lib/lanes/command/named_command.rb +2 -2
- data/lib/lanes/command/templates/client/index.js +3 -0
- data/lib/lanes/command/templates/client/models/BaseModel.coffee +5 -0
- data/lib/lanes/command/templates/client/models/Model.coffee +1 -1
- data/lib/lanes/command/templates/client/views/BaseView.coffee +5 -0
- data/lib/lanes/command/templates/client/views/View.coffee +1 -1
- data/lib/lanes/command/templates/config/screen.rb +8 -0
- data/lib/lanes/command/templates/lib/namespace/base_model.rb +9 -0
- data/lib/lanes/command/templates/lib/namespace/model.rb +1 -1
- data/lib/lanes/command/templates/spec/client/models/ModelSpec.coffee +1 -1
- data/lib/lanes/command/templates/spec/client/views/ViewSpec.coffee +1 -1
- data/lib/lanes/command.rb +1 -2
- data/lib/lanes/components.rb +5 -4
- data/lib/lanes/concerns/all.rb +0 -5
- data/lib/lanes/concerns/attr_accessor_with_default.rb +5 -3
- data/lib/lanes/concerns/set_attribute_data.rb +6 -23
- data/lib/lanes/configuration.rb +1 -0
- data/lib/lanes/extension.rb +19 -10
- data/lib/lanes/guard_tasks.rb +1 -1
- data/lib/lanes/model.rb +1 -6
- data/lib/lanes/{screens.rb → screen.rb} +40 -23
- data/lib/lanes/spec_helper.rb +4 -2
- data/lib/lanes/version.rb +1 -1
- data/lib/lanes.rb +1 -1
- data/spec/api/javascript_processor_spec.rb +3 -3
- data/spec/command_spec.rb +49 -0
- data/spec/concerns/attr_accessor_with_default_spec.rb +7 -0
- data/spec/helpers/lanes-helpers.coffee +46 -22
- data/spec/helpers/minitest_assertions.rb +23 -0
- data/spec/lanes/models/BaseSpec.coffee +57 -56
- data/spec/lanes/models/CollectionSpec.coffee +14 -0
- data/spec/lanes/models/PubSubSpec.coffee +5 -5
- data/spec/lanes/views/BaseSpec.coffee +32 -31
- data/spec/lanes/views/FormBindingsSpec.coffee +32 -0
- metadata +183 -179
- data/client/lanes/components/popover/popover.scss +0 -1
- data/lib/lanes/command/templates/lib/namespace/screen.rb +0 -17
- data/lib/lanes/concerns/code_identifier.rb +0 -43
- data/lib/lanes/concerns/immutable_model.rb +0 -32
- data/lib/lanes/concerns/locked_fields.rb +0 -84
- data/lib/lanes/concerns/random_hash_code.rb +0 -40
- data/lib/lanes/concerns/visible_id_identifier.rb +0 -53
- data/spec/concerns/code_identifier_spec.rb +0 -45
@@ -1,17 +1,15 @@
|
|
1
|
-
Lanes.namespace '
|
1
|
+
Lanes.namespace 'Test'
|
2
2
|
|
3
|
-
|
3
|
+
View = undefined
|
4
|
+
Model = undefined
|
5
|
+
Collection = undefined
|
6
|
+
|
7
|
+
class Lanes.Test.DummyView extends Lanes.Views.Base
|
4
8
|
template: "<p>hi</p"
|
5
9
|
events: { "click #mylink": 'onClick' }
|
6
10
|
onClick: Lanes.emptyFn
|
7
11
|
|
8
|
-
Lanes.
|
9
|
-
subscribe: jasmine.createSpy('subscribe')
|
10
|
-
unsubscribe: jasmine.createSpy('unsubscribe')
|
11
|
-
start: Lanes.emptyFn
|
12
|
-
}
|
13
|
-
|
14
|
-
class Lanes.Testing.Model extends Lanes.Models.Base
|
12
|
+
class Lanes.Test.DummyModel extends Lanes.Models.Base
|
15
13
|
api_path: "test"
|
16
14
|
props:
|
17
15
|
id: 'number',
|
@@ -29,23 +27,49 @@ class Lanes.Testing.Model extends Lanes.Models.Base
|
|
29
27
|
deps: ['something', 'fireDanger', 'active'],
|
30
28
|
fn: -> this.something + this.active;
|
31
29
|
|
32
|
-
|
33
|
-
|
30
|
+
Lanes.Test.makeModel = (props={}, args={})->
|
31
|
+
_.extend(Model.prototype, props)
|
32
|
+
Lanes.Models.Base.extend(Model)
|
33
|
+
Collection::model = Model
|
34
|
+
Lanes.Models.Collection.extend(Collection)
|
35
|
+
collection = new Collection
|
36
|
+
return collection.add(new Model(args))
|
37
|
+
|
38
|
+
Lanes.Test.makeView = (props={}, args={})->
|
39
|
+
_.extend(View.prototype, props)
|
40
|
+
Lanes.Views.Base.extend(View)
|
41
|
+
return new View(args)
|
34
42
|
|
35
|
-
syncResponse = (method,model,options)->
|
36
|
-
|
37
|
-
options.success
|
38
|
-
|
39
|
-
options.failure
|
40
|
-
|
43
|
+
syncResponse = (method, model, options)->
|
44
|
+
_.defer ->
|
45
|
+
if options.success && syncReply.success
|
46
|
+
options.success(syncReply, "success", {})
|
47
|
+
if options.failure && !syncReply.success
|
48
|
+
options.failure(syncReply, "failure", {})
|
49
|
+
_.Promise.resolve(model, options)
|
41
50
|
|
42
51
|
syncReply = {}
|
43
52
|
|
53
|
+
Lanes.Vendor.MessageBus = {
|
54
|
+
subscribe: jasmine.createSpy('subscribe')
|
55
|
+
unsubscribe: jasmine.createSpy('unsubscribe')
|
56
|
+
start: Lanes.emptyFn
|
57
|
+
}
|
58
|
+
|
44
59
|
window.syncSucceedWith = (data)->
|
45
60
|
syncReply.success = true
|
46
61
|
syncReply.data = data
|
47
|
-
|
62
|
+
|
48
63
|
beforeEach ->
|
64
|
+
class TestModel
|
65
|
+
constructor: -> super
|
66
|
+
Model = TestModel
|
67
|
+
class TestCollection
|
68
|
+
constructor: -> super
|
69
|
+
Collection = TestCollection
|
70
|
+
class TestView
|
71
|
+
constructor: -> super
|
72
|
+
View = TestView
|
49
73
|
|
50
74
|
syncReply = {
|
51
75
|
success: true
|
@@ -53,10 +77,10 @@ beforeEach ->
|
|
53
77
|
data: {}
|
54
78
|
}
|
55
79
|
|
56
|
-
Lanes.
|
57
|
-
Lanes.
|
80
|
+
Lanes.Test.syncSpy = jasmine.createSpy('sync').and.callFake(syncResponse)
|
81
|
+
Lanes.Test.syncSpy.lastOptions = ->
|
58
82
|
this.calls.mostRecent().args[2]
|
59
|
-
Lanes.Models.Base::sync = Lanes.
|
60
|
-
Lanes.Models.Collection::sync = Lanes.
|
83
|
+
Lanes.Models.Base::sync = Lanes.Test.syncSpy
|
84
|
+
Lanes.Models.Collection::sync = Lanes.Test.syncSpy
|
61
85
|
|
62
86
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'minitest/assertions'
|
2
|
+
|
3
|
+
module Minitest::Assertions
|
4
|
+
#
|
5
|
+
# Fails unless +expected and +actual have the same items.
|
6
|
+
#
|
7
|
+
def assert_executes(cmd)
|
8
|
+
assert execute_cmd(cmd),
|
9
|
+
"Expected #{cmd} exited with status #{$?.exitstatus}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def last_cmd_execution_output
|
13
|
+
@cmd_last_output
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def execute_cmd(cmd)
|
19
|
+
@cmd_last_output = `#{cmd} 2>&1`
|
20
|
+
$?.exitstatus == 0
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -1,31 +1,31 @@
|
|
1
1
|
|
2
|
-
describe "Base
|
3
|
-
Model = undefined
|
4
|
-
Collection = undefined
|
2
|
+
describe "Lanes.Models.Base", ->
|
3
|
+
# Model = undefined
|
4
|
+
# Collection = undefined
|
5
5
|
class Color
|
6
6
|
constructor: -> super
|
7
7
|
props: { id: 'integer', rgb: 'string' }
|
8
8
|
Lanes.Models.Base.extend(Color)
|
9
9
|
|
10
|
-
makeModel = (props,args={})->
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
# makeModel = (props,args={})->
|
11
|
+
# _.extend(Model.prototype, props)
|
12
|
+
# Lanes.Models.Base.extend(Model)
|
13
|
+
# Collection::model = Model
|
14
|
+
# Lanes.Models.Collection.extend(Collection)
|
15
|
+
# collection = new Collection
|
16
|
+
# return collection.add(new Model(args))
|
17
17
|
|
18
|
-
beforeEach ->
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
# beforeEach ->
|
19
|
+
# class TestModel
|
20
|
+
# constructor: -> super
|
21
|
+
# Model = TestModel
|
22
|
+
# class TestCollection
|
23
|
+
# constructor: -> super
|
24
|
+
# Collection = TestCollection
|
25
25
|
|
26
26
|
|
27
27
|
it "tracks unsaved attributes", ->
|
28
|
-
model = makeModel({
|
28
|
+
model = Lanes.Test.makeModel({
|
29
29
|
session:
|
30
30
|
foo: 'string'
|
31
31
|
bar: 'integer'
|
@@ -35,13 +35,13 @@ describe "Base Model Suite", ->
|
|
35
35
|
expect(model.isDirty()).toBeFalse()
|
36
36
|
model.foo = 'baz' # session prop
|
37
37
|
expect(model.isDirty()).toBeFalse()
|
38
|
-
expect(model.
|
38
|
+
expect(model.unsavedAttributes()).toBeEmptyObject()
|
39
39
|
model.set( saved: 'true' )
|
40
40
|
expect(model.isDirty()).toBeTrue()
|
41
41
|
|
42
42
|
|
43
43
|
it "can tell if it has attributes", ->
|
44
|
-
model = makeModel({
|
44
|
+
model = Lanes.Test.makeModel({
|
45
45
|
session:
|
46
46
|
foo: 'string'
|
47
47
|
props:
|
@@ -53,7 +53,7 @@ describe "Base Model Suite", ->
|
|
53
53
|
|
54
54
|
it "provides data for saving", ->
|
55
55
|
# model with other types of data, but should only save "props"
|
56
|
-
model = makeModel({
|
56
|
+
model = Lanes.Test.makeModel({
|
57
57
|
associations:
|
58
58
|
color:{ model: Color }
|
59
59
|
session:
|
@@ -74,8 +74,8 @@ describe "Base Model Suite", ->
|
|
74
74
|
a=model.changeMonitor.changedAttributes()
|
75
75
|
expect( model.dataForSave() ).toEqual( id: 10, foo: 'a value', color: { rgb: '99FFFF' } )
|
76
76
|
|
77
|
-
it "can be saved", ->
|
78
|
-
model = makeModel({
|
77
|
+
it "can be saved", (done)->
|
78
|
+
model = Lanes.Test.makeModel({
|
79
79
|
props:
|
80
80
|
id: 'integer'
|
81
81
|
foo: 'string'
|
@@ -83,7 +83,7 @@ describe "Base Model Suite", ->
|
|
83
83
|
|
84
84
|
}, { foo: 'one, two, three'} )
|
85
85
|
expect(model.isDirty()).toBeTrue()
|
86
|
-
expect(model.
|
86
|
+
expect(model.unsavedAttributes()).toEqual( foo: 'one, two, three' )
|
87
87
|
model.save()
|
88
88
|
expect(model.sync).toHaveBeenCalledWith('create', model, jasmine.any(Object))
|
89
89
|
model.id=11
|
@@ -92,56 +92,57 @@ describe "Base Model Suite", ->
|
|
92
92
|
syncSucceedWith({
|
93
93
|
foo: 'a new foo value'
|
94
94
|
})
|
95
|
-
model.save()
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
model.save().then ->
|
96
|
+
expect(model.sync).toHaveBeenCalledWith('patch', model, jasmine.any(Object))
|
97
|
+
expect(model.foo).toEqual('a new foo value')
|
98
|
+
done()
|
99
|
+
|
100
|
+
it "can be fetched", (done)->
|
101
|
+
model = Lanes.Test.makeModel({
|
101
102
|
props:
|
102
103
|
{ id: 'integer', foo: 'string' }
|
103
104
|
})
|
104
105
|
syncSucceedWith({
|
105
106
|
foo: 'foo value'
|
106
107
|
})
|
107
|
-
model.fetch()
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
108
|
+
model.fetch().then ->
|
109
|
+
expect(model.sync).toHaveBeenCalledWith('read', model, jasmine.any(Object))
|
110
|
+
expect(model.foo).toEqual('foo value')
|
111
|
+
options = model.sync.lastOptions()
|
112
|
+
expect(options).toHaveTrue('ignoreUnsaved')
|
113
|
+
expect(options).toHaveNumberWithinRange('limit',1,1)
|
114
|
+
done()
|
113
115
|
|
114
116
|
it "creates a Collection property", ->
|
115
|
-
|
117
|
+
Model = Lanes.Test.DummyModel
|
116
118
|
expect(Model.Collection::model).toEqual(Model)
|
117
119
|
|
118
|
-
it "loads using where", ->
|
119
|
-
|
120
|
-
props:
|
121
|
-
{ id: 'integer', title: 'string' }
|
122
|
-
})
|
120
|
+
it "loads using where", (done)->
|
121
|
+
Model = Lanes.Test.DummyModel
|
123
122
|
syncSucceedWith([
|
124
|
-
{ id: 1, title: 'first value'
|
123
|
+
{ id: 1, title: 'first value' }
|
125
124
|
{ id: 2, title: 'second value' }
|
126
125
|
])
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
126
|
+
Model.where(title: 'first value').whenLoaded (collection)->
|
127
|
+
options = Model::sync.lastOptions()
|
128
|
+
expect(options.query).toEqual({title:'first value'})
|
129
|
+
expect(collection.length).toEqual(2)
|
130
|
+
done()
|
131
131
|
|
132
|
-
it "can be destroyed", ->
|
133
|
-
model = makeModel({
|
132
|
+
it "can be destroyed", (done)->
|
133
|
+
model = Lanes.Test.makeModel({
|
134
134
|
props: { id: 'integer' }
|
135
135
|
},{ id: 1 })
|
136
136
|
collection = model.collection
|
137
137
|
expect(collection.length).toEqual(1)
|
138
|
-
model.destroy()
|
139
|
-
|
140
|
-
|
141
|
-
|
138
|
+
model.destroy().then ->
|
139
|
+
expect(model.sync)
|
140
|
+
.toHaveBeenCalledWith('delete', model, jasmine.any(Object))
|
141
|
+
expect(collection.length).toEqual(0)
|
142
|
+
done()
|
142
143
|
|
143
144
|
it "sets associations", ->
|
144
|
-
model = makeModel({
|
145
|
+
model = Lanes.Test.makeModel({
|
145
146
|
associations:
|
146
147
|
color:{ model: Color }
|
147
148
|
props: { id: 'integer', foo: 'string' }
|
@@ -149,11 +150,11 @@ describe "Base Model Suite", ->
|
|
149
150
|
expect(model.color).toBeObject()
|
150
151
|
model.set(color: { rgb: '99FFFF' })
|
151
152
|
expect(model.color.rgb).toEqual('99FFFF')
|
152
|
-
model.
|
153
|
+
model.setFromServer(color:{ rgb: 'FFA500' })
|
153
154
|
expect(model.color.rgb).toEqual('FFA500')
|
154
155
|
|
155
156
|
it "can fetch associations", ->
|
156
|
-
model = makeModel({
|
157
|
+
model = Lanes.Test.makeModel({
|
157
158
|
associations:
|
158
159
|
color:{ model: Color }
|
159
160
|
props: { id: 'integer', foo: 'string' }
|
@@ -0,0 +1,14 @@
|
|
1
|
+
describe "Lanes.Models.Collection", ->
|
2
|
+
|
3
|
+
|
4
|
+
it "it triggers promise on loading", (done)->
|
5
|
+
Model = Lanes.Test.DummyModel
|
6
|
+
syncSucceedWith([
|
7
|
+
{ id: 1, title: 'first value' }
|
8
|
+
{ id: 2, title: 'second value' }
|
9
|
+
])
|
10
|
+
collection = Model.where( name: 'foo' )
|
11
|
+
collection.whenLoaded ->
|
12
|
+
expect( collection.isLoaded() ).toBeTrue()
|
13
|
+
done()
|
14
|
+
|
@@ -1,9 +1,9 @@
|
|
1
1
|
|
2
|
-
describe "PubSub
|
2
|
+
describe "Lanes.Model.PubSub", ->
|
3
3
|
|
4
4
|
it "checks in/out a model when it binds to a view", ->
|
5
|
-
view = new Lanes.
|
6
|
-
model = new Lanes.
|
5
|
+
view = new Lanes.Test.DummyView
|
6
|
+
model = new Lanes.Test.DummyModel(id:1)
|
7
7
|
spyOn(Lanes.Models.PubSub,'add').and.callThrough()
|
8
8
|
spyOn(Lanes.Models.PubSub,'remove')
|
9
9
|
view.model = model
|
@@ -14,8 +14,8 @@ describe "PubSub Suite", ->
|
|
14
14
|
expect(Lanes.Models.PubSub.remove).toHaveBeenCalledWith(model)
|
15
15
|
|
16
16
|
it "can retrieve a model after checkin", ->
|
17
|
-
model = new Lanes.
|
17
|
+
model = new Lanes.Test.DummyModel(id: 11, name:'bar')
|
18
18
|
Lanes.Models.PubSub.add(model)
|
19
|
-
checkin = Lanes.Models.PubSub.instanceFor(Lanes.
|
19
|
+
checkin = Lanes.Models.PubSub.instanceFor(Lanes.Test.DummyModel, 11)
|
20
20
|
expect(checkin).toEqual(model)
|
21
21
|
|
@@ -1,39 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe "BaseView Suite", ->
|
4
|
-
View = undefined
|
5
|
-
makeView = (props,args={})->
|
6
|
-
_.extend(View.prototype, props)
|
7
|
-
Lanes.Views.Base.extend(View)
|
8
|
-
return new View(args)
|
9
|
-
|
10
|
-
beforeEach ->
|
11
|
-
class TestView
|
12
|
-
constructor: -> super
|
13
|
-
View = TestView
|
1
|
+
describe "Lanes.Views.Base", ->
|
14
2
|
|
15
3
|
it "fires el change on render", ->
|
16
4
|
spy = jasmine.createSpy()
|
17
|
-
view = makeView({
|
5
|
+
view = Lanes.Test.makeView({
|
18
6
|
template: "<p>hi</p"
|
19
7
|
})
|
20
8
|
view.on("change:el", spy)
|
21
9
|
view.render()
|
22
10
|
expect(spy).toHaveBeenCalled()
|
23
11
|
|
12
|
+
it "renders a template file", ->
|
13
|
+
spy = jasmine.createSpy('view-test').and.callFake ->
|
14
|
+
"<p>a test</p>"
|
15
|
+
Lanes.Templates['view-test'] = spy
|
16
|
+
|
17
|
+
view = Lanes.Test.makeView({
|
18
|
+
templatePrefix: ''
|
19
|
+
templateName: "view-test"
|
20
|
+
}, { model: new Lanes.Test.DummyModel({name: 'foo'}) } )
|
21
|
+
view.render()
|
22
|
+
expect(spy).toHaveBeenCalledWith( model: { name: 'foo' }, collection: undefined )
|
23
|
+
expect(view.el.innerHTML).toEqual("a test")
|
24
|
+
|
24
25
|
it "renders a template string", ->
|
25
|
-
view = makeView({
|
26
|
-
template: "<p>
|
26
|
+
view = Lanes.Test.makeView({
|
27
|
+
template: "<p>hello test</p"
|
27
28
|
})
|
28
|
-
expect(view.template).toEqual "<p>
|
29
|
+
expect(view.template).toEqual "<p>hello test</p"
|
29
30
|
view.render()
|
30
31
|
expect(view.el.tagName).toEqual("P")
|
31
|
-
expect(view.el.innerHTML).toEqual("
|
32
|
+
expect(view.el.innerHTML).toEqual("hello test")
|
32
33
|
|
33
34
|
it "listens to events", ->
|
34
35
|
spy = jasmine.createSpy('onClick')
|
35
36
|
el = _.el( 'div',{id: 'testdiv'} )
|
36
|
-
view = makeView({
|
37
|
+
view = Lanes.Test.makeView({
|
37
38
|
events: { "click #mylink": 'onClick' }
|
38
39
|
template: "<div>text,text,text<a id='mylink'>click me</a>mor text</div>"
|
39
40
|
onClick: spy
|
@@ -44,8 +45,8 @@ describe "BaseView Suite", ->
|
|
44
45
|
expect(spy).toHaveBeenCalledWith(jasmine.any(Object),22)
|
45
46
|
|
46
47
|
it "updates from bindings", ->
|
47
|
-
model = new Lanes.
|
48
|
-
view = makeView({
|
48
|
+
model = new Lanes.Test.DummyModel({ name: "Bob" })
|
49
|
+
view = Lanes.Test.makeView({
|
49
50
|
bindings: {
|
50
51
|
"model.name": { hook: 'link' }
|
51
52
|
"model.url": { type:'attribute', name: 'href', hook: 'link' }
|
@@ -65,8 +66,8 @@ describe "BaseView Suite", ->
|
|
65
66
|
constructor: -> super
|
66
67
|
session: { answer: 'string' }
|
67
68
|
Lanes.Views.Base.extend(LowerView)
|
68
|
-
model = new Lanes.
|
69
|
-
view = makeView({
|
69
|
+
model = new Lanes.Test.DummyModel
|
70
|
+
view = Lanes.Test.makeView({
|
70
71
|
subviews:
|
71
72
|
lower:
|
72
73
|
hook: 'lower'
|
@@ -88,8 +89,8 @@ describe "BaseView Suite", ->
|
|
88
89
|
constructor: -> super
|
89
90
|
bindings: { "model.name": { type: "text" } }
|
90
91
|
Lanes.Views.Base.extend(LowerView)
|
91
|
-
collection = new Lanes.
|
92
|
-
view = makeView({
|
92
|
+
collection = new Lanes.Test.DummyModel.Collection
|
93
|
+
view = Lanes.Test.makeView({
|
93
94
|
subviews:
|
94
95
|
lower:
|
95
96
|
hook: 'lower'
|
@@ -105,7 +106,7 @@ describe "BaseView Suite", ->
|
|
105
106
|
|
106
107
|
it "caches elements in ui", ->
|
107
108
|
spy = jasmine.createSpy('onClick')
|
108
|
-
view = makeView({
|
109
|
+
view = Lanes.Test.makeView({
|
109
110
|
ui:
|
110
111
|
link: '#linky'
|
111
112
|
events:
|
@@ -121,8 +122,8 @@ describe "BaseView Suite", ->
|
|
121
122
|
it "invokes model events", ->
|
122
123
|
nameSpy = jasmine.createSpy()
|
123
124
|
urlSpy = jasmine.createSpy()
|
124
|
-
model = new Lanes.
|
125
|
-
view = makeView({
|
125
|
+
model = new Lanes.Test.DummyModel
|
126
|
+
view = Lanes.Test.makeView({
|
126
127
|
modelEvents:
|
127
128
|
'change:name': nameSpy
|
128
129
|
'change:url' : 'onURLChange'
|
@@ -135,12 +136,12 @@ describe "BaseView Suite", ->
|
|
135
136
|
|
136
137
|
it "invokes collection events", ->
|
137
138
|
eventSpy = jasmine.createSpy('event')
|
138
|
-
view = makeView({
|
139
|
+
view = Lanes.Test.makeView({
|
139
140
|
collectionEvents:
|
140
141
|
all: 'onEvent'
|
141
142
|
onEvent: eventSpy
|
142
|
-
initialize: -> this.collection = new Lanes.
|
143
|
+
initialize: -> this.collection = new Lanes.Test.DummyModel.Collection
|
143
144
|
})
|
144
145
|
expect(eventSpy).not.toHaveBeenCalled()
|
145
|
-
view.collection.add(new Lanes.
|
146
|
+
view.collection.add(new Lanes.Test.DummyModel)
|
146
147
|
expect(eventSpy).toHaveBeenCalled()
|
@@ -0,0 +1,32 @@
|
|
1
|
+
describe "Lanes.Views.FormBindings", ->
|
2
|
+
|
3
|
+
it "updates inputs", ->
|
4
|
+
model = new Lanes.Test.DummyModel({name: 'start'})
|
5
|
+
view = Lanes.Test.makeView({
|
6
|
+
template: '<div><h1>foo</h1><input type="text" name="name"></div>'
|
7
|
+
}, { formBindings: true, model: model })
|
8
|
+
view.render()
|
9
|
+
input = view.$('input')
|
10
|
+
expect(input.val()).toEqual('start')
|
11
|
+
input.val('test')
|
12
|
+
input.trigger('change')
|
13
|
+
expect(model.name).toEqual('test')
|
14
|
+
|
15
|
+
it "updates radio fields", ->
|
16
|
+
model = new Lanes.Test.DummyModel({name: 'start'})
|
17
|
+
view = Lanes.Test.makeView({
|
18
|
+
template: """
|
19
|
+
<div>
|
20
|
+
<input id="a" type="radio" name="name" value="one">One
|
21
|
+
<input id="b" type="radio" name="name" value="two">Two
|
22
|
+
<input id="c" type="radio" name="name" value="three">Three
|
23
|
+
</div>
|
24
|
+
"""
|
25
|
+
}, { formBindings: true, model: model })
|
26
|
+
view.render()
|
27
|
+
.$("#b")
|
28
|
+
.attr('checked', true)
|
29
|
+
.trigger('change')
|
30
|
+
expect(model.name).toEqual('two')
|
31
|
+
model.name="three"
|
32
|
+
expect(view.$("input:checked").attr("id")).toEqual('c')
|