netzke-core 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +16 -1
- data/Gemfile +12 -0
- data/README.md +22 -15
- data/Rakefile +19 -38
- data/app/controllers/netzke_controller.rb +1 -79
- data/javascripts/ext.js +17 -13
- data/lib/netzke/base.rb +6 -2
- data/lib/netzke/core/action_config.rb +7 -0
- data/lib/netzke/core/actions.rb +6 -32
- data/lib/netzke/core/client_class.rb +1 -1
- data/lib/netzke/core/component_config.rb +1 -1
- data/lib/netzke/core/composition.rb +17 -111
- data/lib/netzke/core/config_to_dsl_delegator.rb +0 -7
- data/lib/netzke/core/configuration.rb +48 -0
- data/lib/netzke/core/dsl_support.rb +71 -0
- data/lib/netzke/core/dynamic_assets.rb +10 -1
- data/lib/netzke/core/embedding.rb +2 -2
- data/lib/netzke/core/html.rb +29 -0
- data/lib/netzke/core/javascript.rb +32 -26
- data/lib/netzke/core/railz/action_view_ext/ext.rb +2 -2
- data/lib/netzke/core/railz/controller_extensions.rb +96 -3
- data/lib/netzke/core/railz/routes.rb +14 -3
- data/lib/netzke/core/ruby_ext/array.rb +4 -18
- data/lib/netzke/core/ruby_ext/hash.rb +19 -25
- data/lib/netzke/core/ruby_ext/time_with_zone.rb +1 -1
- data/lib/netzke/core/ruby_ext.rb +0 -2
- data/lib/netzke/core/session.rb +8 -1
- data/lib/netzke/core/state.rb +3 -3
- data/lib/netzke/core/version.rb +1 -1
- data/lib/netzke/core.rb +15 -7
- data/lib/netzke-core.rb +2 -9
- data/tasks/app_test_tasks.rake +94 -0
- data/tasks/rake_helper.rb +51 -0
- data/test/core_test_app/README +2 -2
- data/test/core_test_app/app/assets/javascripts/expect/expect.js +1253 -0
- data/test/core_test_app/app/assets/javascripts/mocha/mocha.js +5340 -0
- data/test/core_test_app/app/assets/stylesheets/mocha/mocha.css +231 -0
- data/test/core_test_app/app/components/{component_with_actions.rb → actions.rb} +7 -9
- data/test/core_test_app/app/components/{some_composite.rb → composition.rb} +16 -5
- data/test/core_test_app/app/components/{component_with_custom_css → css_inclusion}/stylesheets/custom.css +2 -2
- data/test/core_test_app/app/components/css_inclusion.rb +12 -0
- data/test/core_test_app/app/components/{component_loader/javascripts/component_loader.js → dynamic_loading/javascripts/dynamic_loading.js} +9 -1
- data/test/core_test_app/app/components/{component_loader.rb → dynamic_loading.rb} +12 -5
- data/test/core_test_app/app/components/{server_caller/javascripts/server_caller.js → endpoints/javascripts/endpoints.js} +10 -6
- data/test/core_test_app/app/components/{server_caller.rb → endpoints.rb} +12 -8
- data/test/core_test_app/app/components/{extended_server_caller.rb → endpoints_extended.rb} +6 -4
- data/test/core_test_app/app/components/ext_direct/composite.rb +5 -1
- data/test/core_test_app/app/components/feedback.rb +26 -0
- data/test/core_test_app/app/components/haml_panel/html/body.html.haml +10 -0
- data/test/core_test_app/app/components/haml_panel/html/server_response.html.haml +3 -0
- data/test/core_test_app/app/components/haml_panel.rb +32 -0
- data/test/core_test_app/app/components/hello_world.rb +1 -0
- data/test/core_test_app/app/components/js_inclusion/javascripts/extra_one.js +2 -0
- data/test/core_test_app/app/components/js_inclusion/javascripts/extra_two.js +2 -0
- data/test/core_test_app/app/components/js_inclusion/javascripts/js_inclusion.js +5 -0
- data/test/core_test_app/app/components/{component_with_js_mixin → js_inclusion}/javascripts/method_set_one.js +0 -0
- data/test/core_test_app/app/components/{component_with_js_mixin → js_inclusion}/javascripts/method_set_two.js +0 -0
- data/test/core_test_app/app/components/{component_with_js_mixin.rb → js_inclusion.rb} +3 -3
- data/test/core_test_app/app/components/js_inclusion_extended/javascripts/some_method_set.js +5 -0
- data/test/core_test_app/app/components/js_inclusion_extended.rb +6 -0
- data/test/core_test_app/app/components/loaded_css_inclusion.rb +22 -0
- data/test/core_test_app/app/components/{localized_panel.rb → localization.rb} +5 -5
- data/test/core_test_app/app/components/localization_extended.rb +2 -0
- data/test/core_test_app/app/components/persistence.rb +60 -0
- data/test/core_test_app/app/components/persistence_with_shared_state.rb +7 -0
- data/test/core_test_app/app/components/plugin_with_actions.rb +24 -0
- data/test/core_test_app/app/components/plugin_with_components.rb +3 -3
- data/test/core_test_app/app/components/plugin_with_endpoints.rb +29 -0
- data/test/core_test_app/app/components/plugins.rb +9 -0
- data/test/core_test_app/app/components/{kinda_complex_component → ruby_modules}/basic_stuff.rb +1 -1
- data/test/core_test_app/app/components/{kinda_complex_component → ruby_modules}/extra_stuff.rb +3 -3
- data/test/core_test_app/app/components/{kinda_complex_component.rb → ruby_modules.rb} +1 -1
- data/test/core_test_app/app/components/scoped/deeply_scoped/scoping.rb +10 -0
- data/test/core_test_app/app/components/scoped/scoping.rb +8 -0
- data/test/core_test_app/app/components/scoped/scoping_extended.rb +8 -0
- data/test/core_test_app/app/components/self_reloading.rb +25 -0
- data/test/core_test_app/app/components/server_counter/javascripts/server_counter.js +4 -4
- data/test/core_test_app/app/components/server_counter.rb +10 -10
- data/test/core_test_app/app/components/simple_authentication_component.rb +1 -0
- data/test/core_test_app/app/components/simple_component.rb +0 -4
- data/test/core_test_app/app/components/simple_composite.rb +1 -1
- data/test/core_test_app/app/components/simple_form_with_file_upload.rb +1 -2
- data/test/core_test_app/app/components/simple_tab_panel.rb +5 -3
- data/test/core_test_app/app/components/{panel_with_tools.rb → tools.rb} +3 -3
- data/test/core_test_app/app/components/window_with_simple_component.rb +1 -0
- data/test/core_test_app/app/controllers/alternative_controller.rb +10 -0
- data/test/core_test_app/app/controllers/specs_controller.rb +11 -0
- data/test/core_test_app/app/views/layouts/application.html.erb +19 -1
- data/test/core_test_app/app/views/simple_rails/multiple_nested.html.erb +2 -2
- data/test/core_test_app/config/boot.rb +3 -10
- data/test/core_test_app/config/environments/development.rb +1 -0
- data/test/core_test_app/config/initializers/netzke.rb +4 -1
- data/test/core_test_app/config/locales/en.yml +11 -4
- data/test/core_test_app/config/locales/es.yml +1 -4
- data/test/core_test_app/config/routes.rb +10 -1
- data/test/core_test_app/core_test_app.tmproj +254 -0
- data/test/core_test_app/db/development.sqlite3 +0 -0
- data/test/core_test_app/{lib/tasks/.gitkeep → db/test.sqlite3} +0 -0
- data/test/core_test_app/log/development.log +78046 -0
- data/test/core_test_app/log/production.log +18 -0
- data/test/core_test_app/log/test.log +120048 -0
- data/test/core_test_app/rails_app.tmproj +324 -0
- data/test/core_test_app/tmp/cache/assets/C8B/BF0/sprockets%2F54de2792b036d1dab855f88599503551 +0 -0
- data/test/core_test_app/tmp/cache/assets/C92/5A0/sprockets%2F39e75754782ee12179bf35c9a0971d80 +0 -0
- data/test/core_test_app/tmp/cache/assets/C99/720/sprockets%2F981d5a1b957a012e380b22011a6d176d +0 -0
- data/test/core_test_app/tmp/cache/assets/C9F/750/sprockets%2F20ce3d64040a5d3a0a8883bd60754356 +0 -0
- data/test/core_test_app/tmp/cache/assets/CC4/C00/sprockets%2Fc615df52887d8c2e67e8413576a419c5 +0 -0
- data/test/core_test_app/tmp/cache/assets/CF1/3F0/sprockets%2Fc69ee42924fab565a3533d56473ce878 +0 -0
- data/test/core_test_app/tmp/cache/assets/D0E/870/sprockets%2Fa593bf4fac106add88c9434141a49663 +0 -0
- data/test/core_test_app/tmp/cache/assets/D14/8E0/sprockets%2F20748e8d1d7d090d122904a9fe6f18fc +0 -0
- data/test/core_test_app/tmp/cache/assets/D3E/DA0/sprockets%2Fa175f1ac5996544b908ba3ba3f64c4f3 +0 -0
- data/test/core_test_app/tmp/cache/assets/D43/C00/sprockets%2F7bc60c758776356d615ab5edff201ee2 +0 -0
- data/test/core_test_app/tmp/cache/assets/D4B/C50/sprockets%2F8483b7e322da338e8f9eb3b30a957e9a +0 -0
- data/test/core_test_app/tmp/cache/assets/D64/090/sprockets%2F5a01ff309c3f2503eb5e4f5667cca4b3 +0 -0
- data/test/core_test_app/tmp/cache/assets/D8B/FB0/sprockets%2F7a86225caaa389f1be600b4f3a2d1ef0 +0 -0
- data/test/core_test_app/tmp/cache/assets/D98/9C0/sprockets%2F18b80e8fe200aebc522e561a867ea6fb +0 -0
- data/test/core_test_app/tmp/cache/assets/DB0/6E0/sprockets%2F03e33f5a4779eeb48bcfc86ee717fb55 +0 -0
- data/test/core_test_app/tmp/cache/assets/DED/7E0/sprockets%2Feaedd52ba538f19e4ab543a3e20ce2c4 +0 -0
- data/test/core_test_app/tmp/cache/assets/E07/FF0/sprockets%2Fb3c071e0a6de36f041adbbdaa8ab060b +0 -0
- data/test/core_test_app/tmp/capybara/capybara-20101214105940.html +40 -0
- data/test/core_test_app/tmp/capybara/capybara-20101214110642.html +40 -0
- data/test/core_test_app/tmp/capybara/capybara-20101214110749.html +40 -0
- data/test/core_test_app/tmp/capybara/capybara-20101214110750.html +40 -0
- data/test/core_test_app/tmp/capybara/capybara-20101214111025.html +40 -0
- data/test/core_test_app/tmp/capybara/capybara-20101214111027.html +40 -0
- data/test/core_test_app/tmp/capybara/capybara-20101214111213.html +40 -0
- data/test/core_test_app/tmp/capybara/capybara-20101214111214.html +40 -0
- data/test/core_test_app/tmp/capybara/capybara-20101214111332.html +40 -0
- data/test/core_test_app/tmp/capybara/capybara-20101214111333.html +40 -0
- data/test/core_test_app/{spec/component → tmp/pids/passenger.3000.pid.lock} +0 -0
- metadata +370 -133
- data/.autotest +0 -1
- data/.travis.yml +0 -18
- data/Manifest +0 -50
- data/config/ci/before-travis.sh +0 -10
- data/install.rb +0 -1
- data/lib/netzke/core/options_hash.rb +0 -27
- data/lib/netzke/core/ruby_ext/string.rb +0 -26
- data/lib/netzke/core/ruby_ext/symbol.rb +0 -13
- data/netzke-core.gemspec +0 -253
- data/test/core_test_app/.gitignore +0 -4
- data/test/core_test_app/.powrc +0 -4
- data/test/core_test_app/.rvmrc +0 -1
- data/test/core_test_app/Gemfile +0 -19
- data/test/core_test_app/Gemfile.lock +0 -147
- data/test/core_test_app/app/components/border_layout_panel.rb +0 -4
- data/test/core_test_app/app/components/card_component_loader.rb +0 -25
- data/test/core_test_app/app/components/component_with_custom_css.rb +0 -11
- data/test/core_test_app/app/components/component_with_js_mixin/javascripts/component_with_js_mixin.js +0 -5
- data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_one.js +0 -2
- data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_two.js +0 -2
- data/test/core_test_app/app/components/component_with_nested_through.rb +0 -28
- data/test/core_test_app/app/components/component_with_required_js.rb +0 -24
- data/test/core_test_app/app/components/dsl_delegated_properties.rb +0 -4
- data/test/core_test_app/app/components/dsl_delegated_properties_base.rb +0 -5
- data/test/core_test_app/app/components/extended_component_with_actions.rb +0 -9
- data/test/core_test_app/app/components/extended_component_with_js_mixin/javascripts/some_method_set.js +0 -5
- data/test/core_test_app/app/components/extended_component_with_js_mixin.rb +0 -10
- data/test/core_test_app/app/components/extended_localized_panel.rb +0 -2
- data/test/core_test_app/app/components/included.js +0 -5
- data/test/core_test_app/app/components/inline_composite.rb +0 -13
- data/test/core_test_app/app/components/loader_of_component_with_custom_css.rb +0 -23
- data/test/core_test_app/app/components/multipane_component_loader.rb +0 -41
- data/test/core_test_app/app/components/nested_component.rb +0 -17
- data/test/core_test_app/app/components/panel_with_plugin.rb +0 -9
- data/test/core_test_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb +0 -10
- data/test/core_test_app/app/components/scoped_components/extended_scoped_component.rb +0 -8
- data/test/core_test_app/app/components/scoped_components/some_scoped_component.rb +0 -8
- data/test/core_test_app/app/components/some_ext_component.rb +0 -8
- data/test/core_test_app/app/components/some_plugin.rb +0 -40
- data/test/core_test_app/app/components/stateful_component.rb +0 -46
- data/test/core_test_app/app/components/stateful_component_with_shared_state.rb +0 -11
- data/test/core_test_app/config/database.yml.travis +0 -11
- data/test/core_test_app/db/schema.rb +0 -29
- data/test/core_test_app/features/actions_and_tools.feature +0 -22
- data/test/core_test_app/features/basic.feature +0 -7
- data/test/core_test_app/features/client-server.feature +0 -19
- data/test/core_test_app/features/complex_component.feature +0 -18
- data/test/core_test_app/features/component.feature +0 -10
- data/test/core_test_app/features/component_loader.feature +0 -52
- data/test/core_test_app/features/composition.feature +0 -45
- data/test/core_test_app/features/config_to_dsl_delegation.feature +0 -10
- data/test/core_test_app/features/custom_css.feature +0 -17
- data/test/core_test_app/features/ext.direct.feature +0 -32
- data/test/core_test_app/features/file_inclusion.feature +0 -10
- data/test/core_test_app/features/i18n.feature +0 -35
- data/test/core_test_app/features/inheritance.feature +0 -18
- data/test/core_test_app/features/js_include.feature +0 -20
- data/test/core_test_app/features/nested_views.feature +0 -10
- data/test/core_test_app/features/persistence.feature +0 -34
- data/test/core_test_app/features/plugin.feature +0 -16
- data/test/core_test_app/features/rails_views.feature +0 -16
- data/test/core_test_app/features/scopes.feature +0 -14
- data/test/core_test_app/features/step_definitions/custom_css_steps.rb +0 -7
- data/test/core_test_app/features/step_definitions/generic_steps.rb +0 -64
- data/test/core_test_app/features/step_definitions/web_steps.rb +0 -219
- data/test/core_test_app/features/support/env.rb +0 -58
- data/test/core_test_app/features/support/paths.rb +0 -42
- data/test/core_test_app/spec/action_config_spec.rb +0 -15
- data/test/core_test_app/spec/actions_spec.rb +0 -96
- data/test/core_test_app/spec/base_spec.rb +0 -35
- data/test/core_test_app/spec/client_class_spec.rb +0 -17
- data/test/core_test_app/spec/composition_spec.rb +0 -118
- data/test/core_test_app/spec/core_ext_spec.rb +0 -27
- data/test/core_test_app/spec/endpoint_response_spec.rb +0 -17
- data/test/core_test_app/spec/javascript_spec.rb +0 -33
- data/test/core_test_app/spec/js_class_config_scope.rb +0 -37
- data/test/core_test_app/spec/panel_spec.rb +0 -11
- data/test/core_test_app/spec/services_spec.rb +0 -16
- data/test/core_test_app/spec/spec.opt +0 -2
- data/test/core_test_app/spec/spec_helper.rb +0 -27
- data/test/core_test_app/spec/state_spec.rb +0 -20
- data/test/core_test_app/vendor/plugins/.gitkeep +0 -0
- data/test/unit/core_ext_test.rb +0 -8
- data/test/unit/netzke_core_test.rb +0 -178
- data/uninstall.rb +0 -1
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class MyComponent < Netzke::Base
|
4
|
-
js_configure do |c|
|
5
|
-
c.title = "My stupid component"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe Netzke::Core::ClientClass do
|
10
|
-
it "should allow reading class-level properties" do
|
11
|
-
MyComponent.js_config.title.should == "My stupid component"
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should return nil when non-existing property is requested" do
|
15
|
-
MyComponent.js_config.foo.should be_nil
|
16
|
-
end
|
17
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class SomeComposite < Netzke::Base
|
4
|
-
component :nested_one do |c|
|
5
|
-
c.klass = NestedComponentOne
|
6
|
-
end
|
7
|
-
|
8
|
-
component :nested_two do |c|
|
9
|
-
c.klass = NestedComponentTwo
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class NestedComponentOne < Netzke::Base
|
14
|
-
end
|
15
|
-
|
16
|
-
class NestedComponentTwo < Netzke::Base
|
17
|
-
component :nested do |c|
|
18
|
-
c.klass = DeepNestedComponent
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class DeepNestedComponent < Netzke::Base
|
23
|
-
component :nested do |c|
|
24
|
-
c.klass = VeryDeepNestedComponent
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class VeryDeepNestedComponent < Netzke::Base
|
29
|
-
end
|
30
|
-
|
31
|
-
class ComponentOne < Netzke::Base
|
32
|
-
end
|
33
|
-
|
34
|
-
class ::ComponentTwo < Netzke::Base
|
35
|
-
end
|
36
|
-
|
37
|
-
class BaseComposite < Netzke::Base
|
38
|
-
component :component_one do |c|
|
39
|
-
c.klass = ComponentOne
|
40
|
-
c.title = "My Cool Component"
|
41
|
-
end
|
42
|
-
|
43
|
-
component :first_component_two do |c|
|
44
|
-
c.klass = ComponentTwo
|
45
|
-
end
|
46
|
-
|
47
|
-
component :second_component_two do |c|
|
48
|
-
c.klass = ComponentTwo
|
49
|
-
end
|
50
|
-
|
51
|
-
def configure(c)
|
52
|
-
super
|
53
|
-
c.items = [ :first_component_two, :second_component_two ]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class ExtendedComposite < BaseComposite
|
58
|
-
component :component_one do |c|
|
59
|
-
super c
|
60
|
-
c.title = c.title + ", extended"
|
61
|
-
end
|
62
|
-
|
63
|
-
component :component_two do |c|
|
64
|
-
c.title = "Another Nested Component"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
class ComponentWithExcluded < Netzke::Base
|
69
|
-
component :accessible do |c|
|
70
|
-
c.klass = Netzke::Core::Panel
|
71
|
-
end
|
72
|
-
component :inaccessible do |c|
|
73
|
-
c.klass = Netzke::Core::Panel
|
74
|
-
c.excluded = true
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
module Netzke::Core
|
79
|
-
describe Composition do
|
80
|
-
it "should set item_id to component's name by default" do
|
81
|
-
component = SomeComposite.new(:name => 'some_composite')
|
82
|
-
component.components[:nested_one][:item_id].should == "nested_one"
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should be possible to create (nested) component instances" do
|
86
|
-
component = SomeComposite.new(:name => 'some_composite')
|
87
|
-
|
88
|
-
# instantiate components
|
89
|
-
nested_component_one = component.component_instance(:nested_one)
|
90
|
-
nested_component_two = component.component_instance(:nested_two)
|
91
|
-
deep_nested_component = component.component_instance(:nested_two__nested)
|
92
|
-
|
93
|
-
nested_component_one.class.should == NestedComponentOne
|
94
|
-
nested_component_two.class.should == NestedComponentTwo
|
95
|
-
deep_nested_component.class.should == DeepNestedComponent
|
96
|
-
|
97
|
-
component.js_id.should == 'some_composite'
|
98
|
-
nested_component_one.js_id.should == 'some_composite__nested_one'
|
99
|
-
nested_component_two.js_id.should == 'some_composite__nested_two'
|
100
|
-
deep_nested_component.js_id.should == 'some_composite__nested_two__nested'
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should be possible to override the superclass's declaration of a component" do
|
104
|
-
composite = BaseComposite.new
|
105
|
-
composite.components[:component_one][:title].should == "My Cool Component"
|
106
|
-
|
107
|
-
extended_composite = ExtendedComposite.new
|
108
|
-
extended_composite.components[:component_one][:title].should == "My Cool Component, extended"
|
109
|
-
extended_composite.components[:component_one][:klass].should == ComponentOne
|
110
|
-
extended_composite.components[:component_two][:title].should == "Another Nested Component"
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should be impossible to access excluded component config" do
|
114
|
-
c = ComponentWithExcluded.new
|
115
|
-
c.components[:inaccessible].should == {excluded: true}
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
describe "Core extensions" do
|
3
|
-
it "should properly do deep_each_pair" do
|
4
|
-
res = {}
|
5
|
-
{
|
6
|
-
:one => 1,
|
7
|
-
:two => {:three => 3},
|
8
|
-
:nine => [
|
9
|
-
{:four => 4, :five => {:six => 6}},
|
10
|
-
{:seven => [{:eight => 8}]}
|
11
|
-
]
|
12
|
-
}.deep_each_pair{ |k,v| res[k] = v }
|
13
|
-
res.should == {:one => 1, :three => 3, :four => 4, :six => 6, :eight => 8}
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should properly do deep_map" do
|
17
|
-
{a: [1,2,{b:3},{c:[4,5]}], d: 6}.deep_map{|el| el.is_a?(Hash) ? el.merge(e:7) : el + 10}.should == { a: [11,12,{e:7, b:3},{e:7, c:[14,15]}], d: 6}
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should strip js comments" do
|
21
|
-
"var test;//commment".strip_js_comments.should == "var test;"
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should not strip // in strings" do
|
25
|
-
'var someVar = "abc//def";'.strip_js_comments.should == 'var someVar="abc//def";'
|
26
|
-
end
|
27
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Netzke::Core::EndpointResponse do
|
4
|
-
it "should allow to mimick calling methods on client side" do
|
5
|
-
this = Netzke::Core::EndpointResponse.new
|
6
|
-
|
7
|
-
this.set_title("Title")
|
8
|
-
this.set_title.should == ["Title"]
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should allow assigning values directly" do
|
12
|
-
this = Netzke::Core::EndpointResponse.new
|
13
|
-
|
14
|
-
this.result = 42
|
15
|
-
this.result.should == 42
|
16
|
-
end
|
17
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class HasMultipleJsConfigures < Netzke::Base
|
4
|
-
js_configure do |c|
|
5
|
-
c.title = "Original"
|
6
|
-
c.some_property = :some_property
|
7
|
-
end
|
8
|
-
|
9
|
-
# because this could be done from an included module
|
10
|
-
js_configure do |c|
|
11
|
-
c.title = "Overridden"
|
12
|
-
c.another_property = :another_property
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe Netzke::Core::Javascript do
|
17
|
-
it "should provide JS config from a component instance" do
|
18
|
-
c = Netzke::Core::Panel.new
|
19
|
-
c.js_config.should be_present
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should evaluate js_configure class-level block late" do
|
23
|
-
ConfigurableOnClassLevel.title = "Overridden"
|
24
|
-
ConfigurableOnClassLevel.js_config.title.should == "Overridden"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should evaluate all js_configure blocks" do
|
28
|
-
c = HasMultipleJsConfigures.js_config
|
29
|
-
c.title.should == "Overridden"
|
30
|
-
c.some_property.should == :some_property
|
31
|
-
c.another_property.should == :another_property
|
32
|
-
end
|
33
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class SomeComponent < Netzke::Base
|
4
|
-
end
|
5
|
-
|
6
|
-
module MyCompanyComponents
|
7
|
-
class SomeComponent < Netzke::Base
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class InheritedComponent < SomeComponent
|
12
|
-
end
|
13
|
-
|
14
|
-
module Netzke
|
15
|
-
module Basepack
|
16
|
-
class GridPanel < Netzke::Base
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe Netzke::Core::ClientClass do
|
22
|
-
it "should build scope based on component scope" do
|
23
|
-
SomeComponent.js_config.scope.should == "Netzke.classes"
|
24
|
-
MyCompanyComponents::SomeComponent.js_config.scope.should == "Netzke.classes.MyCompanyComponents"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should properly detect whether we are extending a Netzke component" do
|
28
|
-
SomeComponent.js_config.extending_extjs_component?.should be_true
|
29
|
-
InheritedComponent.js_config.extending_extjs_component?.should be_false
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should build full client class name based on class name" do
|
33
|
-
SomeComponent.js_config.class_name.should == "Netzke.classes.SomeComponent"
|
34
|
-
MyCompanyComponents::SomeComponent.js_config.class_name.should == "Netzke.classes.MyCompanyComponents.SomeComponent"
|
35
|
-
Netzke::Basepack::GridPanel.js_config.class_name.should == "Netzke.classes.Netzke.Basepack.GridPanel"
|
36
|
-
end
|
37
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class TestComponent < Netzke::Base
|
4
|
-
endpoint :some_action do |params, this|
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
describe Netzke::Core::Services do
|
9
|
-
it "should be able to register endpoints" do
|
10
|
-
TestComponent.endpoints.should include :some_action
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should have deliver_component endpoint" do
|
14
|
-
TestComponent.endpoints.should include :deliver_component
|
15
|
-
end
|
16
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
-
ENV["RAILS_ENV"] ||= 'test'
|
3
|
-
require File.expand_path("../../config/environment", __FILE__)
|
4
|
-
require 'rspec/rails'
|
5
|
-
|
6
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
7
|
-
# in spec/support/ and its subdirectories.
|
8
|
-
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
9
|
-
|
10
|
-
RSpec.configure do |config|
|
11
|
-
# == Mock Framework
|
12
|
-
#
|
13
|
-
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
14
|
-
#
|
15
|
-
# config.mock_with :mocha
|
16
|
-
# config.mock_with :flexmock
|
17
|
-
# config.mock_with :rr
|
18
|
-
config.mock_with :rspec
|
19
|
-
|
20
|
-
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
21
|
-
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
22
|
-
|
23
|
-
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
24
|
-
# examples within a transaction, remove the following line or assign false
|
25
|
-
# instead of true.
|
26
|
-
config.use_transactional_fixtures = true
|
27
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Netzke::Core
|
4
|
-
describe State do
|
5
|
-
it "should be possible to save component's state" do
|
6
|
-
Netzke::Base.session = {} # mimick session
|
7
|
-
|
8
|
-
component = Netzke::Base.new(:name => 'some_component', :persistence => true)
|
9
|
-
component.state.should == {}
|
10
|
-
|
11
|
-
component.state[:value_to_remember] = 42
|
12
|
-
component.state.should == {:value_to_remember => 42}
|
13
|
-
|
14
|
-
component.state[:more_to_remember] = "a string"
|
15
|
-
component.state[:and_yet_more] = "another string"
|
16
|
-
|
17
|
-
component.state.should == {:value_to_remember => 42, :more_to_remember => "a string", :and_yet_more => "another string"}
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
File without changes
|
data/test/unit/core_ext_test.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'netzke/core_ext'
|
3
|
-
|
4
|
-
class CoreExtTest < ActiveSupport::TestCase
|
5
|
-
test "jsonify" do
|
6
|
-
assert_equal({:aB => 1, "cD" => [[1, {:eF => "stay_same"}], {"literal_symbol" => :should_not_change, "literal_string".l => "also_should_not"}]}, {:a_b => 1, "c_d" => [[1, {:e_f => "stay_same"}], {:literal_symbol.l => :should_not_change, "literal_string".l => "also_should_not"}]}.jsonify)
|
7
|
-
end
|
8
|
-
end
|
@@ -1,178 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'netzke-core'
|
3
|
-
|
4
|
-
module Netzke
|
5
|
-
class Component < Base
|
6
|
-
endpoint :method_one, :method_two
|
7
|
-
|
8
|
-
def self.config
|
9
|
-
super.merge({
|
10
|
-
:pref_one => 1,
|
11
|
-
:pref_two => 2
|
12
|
-
})
|
13
|
-
end
|
14
|
-
|
15
|
-
component :nested_one, :class_name => 'NestedComponentOne'
|
16
|
-
component :nested_two, :class_name => 'NestedComponentTwo'
|
17
|
-
|
18
|
-
def available_permissions
|
19
|
-
%w(read update)
|
20
|
-
end
|
21
|
-
|
22
|
-
def default_config
|
23
|
-
{
|
24
|
-
:config_uno => true,
|
25
|
-
:config_dos => false
|
26
|
-
}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class NestedComponentOne < Base
|
31
|
-
end
|
32
|
-
|
33
|
-
class NestedComponentTwo < Base
|
34
|
-
def initial_components
|
35
|
-
{
|
36
|
-
:nested => {:class_name => 'DeepNestedComponent'}
|
37
|
-
}
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class DeepNestedComponent < Base
|
42
|
-
def initial_components
|
43
|
-
{
|
44
|
-
:nested => {:class_name => "VeryDeepNestedComponent"}
|
45
|
-
}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class VeryDeepNestedComponent < Base
|
50
|
-
end
|
51
|
-
|
52
|
-
class JsInheritanceComponent < Component
|
53
|
-
end
|
54
|
-
|
55
|
-
module ScopedComponents
|
56
|
-
class SomeScopedComponent < Base
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
class InheritedComponent < Component
|
61
|
-
def self.config
|
62
|
-
super.merge({
|
63
|
-
:pref_one => -1
|
64
|
-
})
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
class NetzkeCoreTest < ActiveSupport::TestCase
|
70
|
-
include Netzke
|
71
|
-
|
72
|
-
def setup
|
73
|
-
end
|
74
|
-
|
75
|
-
test "base class loaded" do
|
76
|
-
assert_kind_of Netzke::Base, Netzke::Base.new
|
77
|
-
end
|
78
|
-
|
79
|
-
test "short component class name" do
|
80
|
-
assert_equal 'Component', Component.short_component_class_name
|
81
|
-
end
|
82
|
-
|
83
|
-
test "api" do
|
84
|
-
component_class = Component
|
85
|
-
assert_equal [:deliver_component, :method_one, :method_two], component_class.endpoints
|
86
|
-
end
|
87
|
-
|
88
|
-
test "components" do
|
89
|
-
component = Component.new(:name => 'my_component')
|
90
|
-
|
91
|
-
# instantiate components
|
92
|
-
nested_component_one = component.component_instance(:nested_one)
|
93
|
-
nested_component_two = component.component_instance(:nested_two)
|
94
|
-
deep_nested_component = component.component_instance(:nested_two__nested)
|
95
|
-
|
96
|
-
assert_kind_of NestedComponentOne, nested_component_one
|
97
|
-
assert_kind_of NestedComponentTwo, nested_component_two
|
98
|
-
assert_kind_of DeepNestedComponent, deep_nested_component
|
99
|
-
|
100
|
-
assert_equal 'my_component', component.js_id
|
101
|
-
assert_equal 'my_component__nested_one', nested_component_one.js_id
|
102
|
-
assert_equal 'my_component__nested_two', nested_component_two.js_id
|
103
|
-
assert_equal 'my_component__nested_two__nested', deep_nested_component.js_id
|
104
|
-
end
|
105
|
-
|
106
|
-
test "js_id_by_reference" do
|
107
|
-
w = Component.new(:name => "a_component")
|
108
|
-
deep_nested_component = w.component_instance(:nested_two__nested)
|
109
|
-
assert_equal("a_component__nested_two", deep_nested_component.js_id_by_reference(:parent))
|
110
|
-
assert_equal("a_component", deep_nested_component.js_id_by_reference(:parent__parent))
|
111
|
-
assert_equal("a_component__nested_one", deep_nested_component.js_id_by_reference(:parent__parent__nested_one))
|
112
|
-
assert_equal("a_component__nested_two__nested__nested", deep_nested_component.js_id_by_reference(:nested))
|
113
|
-
assert_equal("a_component__nested_two__nested__non_existing", deep_nested_component.js_id_by_reference(:non_existing))
|
114
|
-
assert_nil(deep_nested_component.js_id_by_reference(:parent__parent__parent)) # too far up
|
115
|
-
end
|
116
|
-
|
117
|
-
test "default config" do
|
118
|
-
component = Component.new
|
119
|
-
assert_equal({:config_uno => true, :config_dos => false}, component.config)
|
120
|
-
|
121
|
-
component = Component.new(:name => 'component', :config_uno => false)
|
122
|
-
assert_equal({:name => 'component', :config_uno => false, :config_dos => false}, component.config)
|
123
|
-
end
|
124
|
-
|
125
|
-
test "dependencies calculated" do
|
126
|
-
component = Component.new
|
127
|
-
assert(component.dependencies.include?('NestedComponentOne'))
|
128
|
-
assert(component.dependencies.include?('NestedComponentTwo'))
|
129
|
-
assert(!component.dependencies.include?('DeepNestedComponent'))
|
130
|
-
end
|
131
|
-
|
132
|
-
test "dependency classes" do
|
133
|
-
component = Component.new
|
134
|
-
# not testing the order
|
135
|
-
assert(%w{DeepNestedComponent NestedComponentOne NestedComponentTwo Component}.inject(true){|r, k| r && component.dependency_classes.include?(k)})
|
136
|
-
end
|
137
|
-
|
138
|
-
test "component instance by config" do
|
139
|
-
component = Netzke::Base.instance_by_config({:class_name => 'Component', :name => 'a_component'})
|
140
|
-
assert_equal(Component, component.class)
|
141
|
-
assert_equal('a_component', component.name)
|
142
|
-
end
|
143
|
-
|
144
|
-
test "js inheritance" do
|
145
|
-
component = JsInheritanceComponent.new
|
146
|
-
assert(component.js_missing_code.index("Netzke.classes.JsInheritanceComponent"))
|
147
|
-
assert(component.js_missing_code.index("Netzke.classes.Component"))
|
148
|
-
end
|
149
|
-
|
150
|
-
test "class-level configuration" do
|
151
|
-
# predefined defaults
|
152
|
-
assert_equal(1, Netzke::Component.config[:pref_one])
|
153
|
-
assert_equal(2, Netzke::Component.config[:pref_two])
|
154
|
-
assert_equal(-1, Netzke::InheritedComponent.config[:pref_one])
|
155
|
-
assert_equal(2, Netzke::InheritedComponent.config[:pref_two])
|
156
|
-
|
157
|
-
Netzke::Component.config[:pref_for_component] = 1
|
158
|
-
Netzke::InheritedComponent.config[:pref_for_component] = 2
|
159
|
-
|
160
|
-
# this is broken in 1.9
|
161
|
-
# assert_equal(1, Netzke::Component.config[:pref_for_component])
|
162
|
-
# assert_equal(2, Netzke::InheritedComponent.config[:pref_for_component])
|
163
|
-
#
|
164
|
-
end
|
165
|
-
|
166
|
-
test "JS class names and scopes" do
|
167
|
-
klass = Netzke::NestedComponentOne
|
168
|
-
assert_equal("Netzke.classes", klass.js_full_scope)
|
169
|
-
assert_equal("", klass.js_class_name_to_scope(klass.short_component_class_name))
|
170
|
-
|
171
|
-
klass = Netzke::ScopedComponents::SomeScopedComponent
|
172
|
-
assert_equal("Netzke.classes", klass.js_default_scope)
|
173
|
-
assert_equal("ScopedComponents::SomeScopedComponent", klass.short_component_class_name)
|
174
|
-
assert_equal("ScopedComponents", klass.js_class_name_to_scope(klass.short_component_class_name))
|
175
|
-
assert_equal("Netzke.classes.ScopedComponents", klass.js_full_scope)
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|
data/uninstall.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Uninstall hook code here
|