netzke-core 0.7.7 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/.travis.yml +1 -2
  2. data/CHANGELOG.md +572 -0
  3. data/LICENSE +7 -1
  4. data/README.md +345 -29
  5. data/Rakefile +3 -3
  6. data/app/controllers/netzke_controller.rb +37 -48
  7. data/config/ci/before-travis.sh +3 -4
  8. data/javascripts/base.js +86 -150
  9. data/javascripts/ext.js +180 -210
  10. data/javascripts/{core_extensions.js → js_extensions.js} +0 -0
  11. data/lib/netzke-core.rb +16 -6
  12. data/lib/netzke/base.rb +84 -107
  13. data/lib/netzke/core.rb +7 -41
  14. data/lib/netzke/core/action_config.rb +37 -0
  15. data/lib/netzke/core/actions.rb +123 -0
  16. data/lib/netzke/core/client_class.rb +252 -0
  17. data/lib/netzke/core/component_config.rb +12 -0
  18. data/lib/netzke/core/composition.rb +274 -0
  19. data/lib/netzke/core/config_to_dsl_delegator.rb +69 -0
  20. data/lib/netzke/core/configuration.rb +63 -0
  21. data/lib/netzke/core/css_config.rb +51 -0
  22. data/lib/netzke/core/dynamic_assets.rb +19 -49
  23. data/lib/netzke/{embedding.rb → core/embedding.rb} +4 -6
  24. data/lib/netzke/core/endpoint_response.rb +15 -0
  25. data/lib/netzke/core/javascript.rb +111 -0
  26. data/lib/netzke/core/panel.rb +11 -0
  27. data/lib/netzke/{plugins.rb → core/plugins.rb} +10 -5
  28. data/lib/netzke/core/railz.rb +4 -0
  29. data/lib/netzke/{railz → core/railz}/action_view_ext.rb +22 -18
  30. data/lib/netzke/core/railz/action_view_ext/ext.rb +49 -0
  31. data/lib/netzke/core/railz/controller_extensions.rb +17 -0
  32. data/lib/netzke/core/railz/engine.rb +16 -0
  33. data/lib/netzke/core/railz/routes.rb +10 -0
  34. data/lib/netzke/core/ruby_ext.rb +5 -0
  35. data/lib/netzke/core/ruby_ext/array.rb +23 -0
  36. data/lib/netzke/core/ruby_ext/hash.rb +47 -0
  37. data/lib/netzke/{core_ext → core/ruby_ext}/string.rb +2 -7
  38. data/lib/netzke/core/ruby_ext/symbol.rb +13 -0
  39. data/lib/netzke/{core_ext → core/ruby_ext}/time_with_zone.rb +0 -0
  40. data/lib/netzke/core/services.rb +130 -0
  41. data/lib/netzke/core/session.rb +15 -19
  42. data/lib/netzke/core/state.rb +40 -0
  43. data/lib/netzke/core/stylesheets.rb +48 -0
  44. data/lib/netzke/core/version.rb +2 -2
  45. data/lib/netzke/plugin.rb +8 -11
  46. data/netzke-core.gemspec +69 -59
  47. data/test/core_test_app/Gemfile +2 -20
  48. data/test/core_test_app/Gemfile.lock +65 -74
  49. data/test/core_test_app/app/components/card_component_loader.rb +4 -4
  50. data/test/core_test_app/app/components/component_loader.rb +40 -120
  51. data/test/core_test_app/app/components/component_loader/javascripts/component_loader.js +49 -0
  52. data/test/core_test_app/app/components/component_with_actions.rb +61 -47
  53. data/test/core_test_app/app/components/component_with_custom_css.rb +8 -5
  54. data/test/core_test_app/app/components/component_with_js_mixin.rb +11 -5
  55. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_one.js +1 -1
  56. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_two.js +1 -1
  57. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/method_set_one.js +1 -1
  58. data/test/core_test_app/app/components/component_with_nested_through.rb +2 -2
  59. data/test/core_test_app/app/components/component_with_prebuilt_toolbar_control.rb +12 -0
  60. data/test/core_test_app/app/components/component_with_prebuilt_toolbar_control/javascripts/component_with_prebuilt_toolbar_control.js +12 -0
  61. data/test/core_test_app/app/components/component_with_required_js.rb +24 -0
  62. data/test/core_test_app/app/components/configurable_on_class_level.rb +8 -0
  63. data/test/core_test_app/app/components/dsl_delegated_properties.rb +4 -0
  64. data/test/core_test_app/app/components/dsl_delegated_properties_base.rb +5 -0
  65. data/test/core_test_app/app/components/dynamic_tab_panel/javascripts/dynamic_tab_panel.js +2 -2
  66. data/test/core_test_app/app/components/ext_direct/composite.rb +32 -33
  67. data/test/core_test_app/app/components/ext_direct/details.rb +2 -4
  68. data/test/core_test_app/app/components/ext_direct/selector.rb +20 -22
  69. data/test/core_test_app/app/components/ext_direct/statistics.rb +2 -4
  70. data/test/core_test_app/app/components/extended_component_with_actions.rb +7 -3
  71. data/test/core_test_app/app/components/extended_component_with_js_mixin.rb +7 -4
  72. data/test/core_test_app/app/components/extended_component_with_js_mixin/javascripts/some_method_set.js +1 -1
  73. data/test/core_test_app/app/components/extended_server_caller.rb +20 -14
  74. data/test/core_test_app/app/components/hello_world.rb +23 -0
  75. data/test/core_test_app/app/components/hello_world/javascripts/hello_world.js +12 -0
  76. data/test/core_test_app/app/components/included.js +2 -2
  77. data/test/core_test_app/app/components/kinda_complex_component.rb +1 -3
  78. data/test/core_test_app/app/components/kinda_complex_component/basic_stuff.rb +15 -17
  79. data/test/core_test_app/app/components/kinda_complex_component/extra_stuff.rb +4 -5
  80. data/test/core_test_app/app/components/loader_of_component_with_custom_css.rb +14 -5
  81. data/test/core_test_app/app/components/localized_panel.rb +23 -25
  82. data/test/core_test_app/app/components/multipane_component_loader.rb +19 -20
  83. data/test/core_test_app/app/components/nested_component.rb +4 -5
  84. data/test/core_test_app/app/components/panel_with_plugin.rb +8 -3
  85. data/test/core_test_app/app/components/panel_with_tools.rb +15 -14
  86. data/test/core_test_app/app/components/plugin_with_components.rb +20 -12
  87. data/test/core_test_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb +5 -2
  88. data/test/core_test_app/app/components/scoped_components/extended_scoped_component.rb +5 -2
  89. data/test/core_test_app/app/components/scoped_components/some_scoped_component.rb +5 -2
  90. data/test/core_test_app/app/components/server_caller.rb +39 -17
  91. data/test/core_test_app/app/components/server_caller/javascripts/server_caller.js +42 -0
  92. data/test/core_test_app/app/components/server_counter.rb +18 -82
  93. data/test/core_test_app/app/components/server_counter/javascripts/server_counter.js +53 -0
  94. data/test/core_test_app/app/components/simple_authentication_component.rb +46 -0
  95. data/test/core_test_app/app/components/simple_component.rb +8 -3
  96. data/test/core_test_app/app/components/simple_composite.rb +12 -0
  97. data/test/core_test_app/app/components/simple_form_with_file_upload.rb +49 -0
  98. data/test/core_test_app/app/components/simple_panel.rb +2 -2
  99. data/test/core_test_app/app/components/simple_tab_panel.rb +24 -3
  100. data/test/core_test_app/app/components/simple_window.rb +4 -2
  101. data/test/core_test_app/app/components/some_composite.rb +77 -48
  102. data/test/core_test_app/app/components/some_plugin.rb +31 -30
  103. data/test/core_test_app/app/components/stateful_component.rb +46 -0
  104. data/test/core_test_app/app/components/stateful_component_with_shared_state.rb +11 -0
  105. data/test/core_test_app/app/components/window_with_simple_component.rb +14 -0
  106. data/test/core_test_app/app/views/layouts/application.html.erb +1 -1
  107. data/test/core_test_app/app/views/simple_rails/multiple_nested.html.erb +7 -19
  108. data/test/core_test_app/app/views/simple_rails/panel.html.erb +1 -0
  109. data/test/core_test_app/config/database.yml.travis +3 -5
  110. data/test/core_test_app/config/environments/production.rb +1 -1
  111. data/test/core_test_app/config/initializers/netzke.rb +3 -1
  112. data/test/core_test_app/config/locales/en.yml +9 -4
  113. data/test/core_test_app/config/locales/es.yml +4 -2
  114. data/test/core_test_app/config/routes.rb +2 -8
  115. data/test/core_test_app/db/schema.rb +3 -11
  116. data/test/core_test_app/features/actions_and_tools.feature +1 -0
  117. data/test/core_test_app/features/client-server.feature +7 -0
  118. data/test/core_test_app/features/component_loader.feature +13 -13
  119. data/test/core_test_app/features/composition.feature +14 -0
  120. data/test/core_test_app/features/config_to_dsl_delegation.feature +10 -0
  121. data/test/core_test_app/features/file_inclusion.feature +1 -1
  122. data/test/core_test_app/features/i18n.feature +4 -4
  123. data/test/core_test_app/features/js_include.feature +1 -1
  124. data/test/core_test_app/features/persistence.feature +21 -5
  125. data/test/core_test_app/features/step_definitions/generic_steps.rb +14 -0
  126. data/test/core_test_app/features/support/paths.rb +0 -3
  127. data/test/core_test_app/public/images/icons/accept.png +0 -0
  128. data/test/core_test_app/public/images/icons/anchor.png +0 -0
  129. data/test/core_test_app/public/images/icons/tick.png +0 -0
  130. data/test/core_test_app/spec/action_config_spec.rb +15 -0
  131. data/test/core_test_app/spec/{component/actions_spec.rb → actions_spec.rb} +38 -36
  132. data/test/core_test_app/spec/base_spec.rb +35 -0
  133. data/test/core_test_app/spec/client_class_spec.rb +17 -0
  134. data/test/core_test_app/spec/component +0 -0
  135. data/test/core_test_app/spec/composition_spec.rb +118 -0
  136. data/test/core_test_app/spec/core_ext_spec.rb +3 -14
  137. data/test/core_test_app/spec/endpoint_response_spec.rb +17 -0
  138. data/test/core_test_app/spec/javascript_spec.rb +33 -0
  139. data/test/core_test_app/spec/js_class_config_scope.rb +37 -0
  140. data/test/core_test_app/spec/panel_spec.rb +11 -0
  141. data/test/core_test_app/spec/services_spec.rb +16 -0
  142. data/test/core_test_app/spec/state_spec.rb +20 -0
  143. data/test/unit/core_ext_test.rb +0 -53
  144. data/test/unit/netzke_core_test.rb +11 -11
  145. metadata +76 -62
  146. data/CHANGELOG.rdoc +0 -325
  147. data/javascripts/touch.js +0 -58
  148. data/lib/netzke/actions.rb +0 -107
  149. data/lib/netzke/composition.rb +0 -224
  150. data/lib/netzke/config_to_dsl_delegator.rb +0 -43
  151. data/lib/netzke/configuration.rb +0 -195
  152. data/lib/netzke/core/masquerading.rb +0 -34
  153. data/lib/netzke/core_ext.rb +0 -6
  154. data/lib/netzke/core_ext/array.rb +0 -30
  155. data/lib/netzke/core_ext/hash.rb +0 -86
  156. data/lib/netzke/core_ext/symbol.rb +0 -21
  157. data/lib/netzke/ext_component.rb +0 -25
  158. data/lib/netzke/inheritance.rb +0 -31
  159. data/lib/netzke/javascript.rb +0 -382
  160. data/lib/netzke/javascript/scopes.rb +0 -39
  161. data/lib/netzke/railz.rb +0 -4
  162. data/lib/netzke/railz/action_view_ext/ext.rb +0 -64
  163. data/lib/netzke/railz/action_view_ext/touch.rb +0 -52
  164. data/lib/netzke/railz/controller_extensions.rb +0 -33
  165. data/lib/netzke/railz/engine.rb +0 -48
  166. data/lib/netzke/railz/routes.rb +0 -7
  167. data/lib/netzke/services.rb +0 -101
  168. data/lib/netzke/session.rb +0 -54
  169. data/lib/netzke/state.rb +0 -91
  170. data/lib/netzke/stylesheets.rb +0 -65
  171. data/test/core_test_app/app/components/component_with_included_js.rb +0 -16
  172. data/test/core_test_app/app/components/component_with_session_persistence.rb +0 -35
  173. data/test/core_test_app/app/components/deprecated/server_caller.rb +0 -20
  174. data/test/core_test_app/app/components/dynamic_tab_panel.rb +0 -19
  175. data/test/core_test_app/app/components/hello_world_component.rb +0 -31
  176. data/test/core_test_app/app/components/touch/hello_world_component.rb +0 -25
  177. data/test/core_test_app/app/components/touch/server_caller.rb +0 -28
  178. data/test/core_test_app/app/components/touch/simple_carousel.rb +0 -17
  179. data/test/core_test_app/app/controllers/touch_controller.rb +0 -6
  180. data/test/core_test_app/app/helpers/touch_helper.rb +0 -2
  181. data/test/core_test_app/app/views/layouts/touch.html.erb +0 -13
  182. data/test/core_test_app/db/migrate/20110110132720_create_netzke_component_states.rb +0 -20
  183. data/test/core_test_app/features/step_definitions/touch_steps.rb +0 -3
  184. data/test/core_test_app/features/touch.feature +0 -10
  185. data/test/core_test_app/gemfiles/rails3_1.gemfile +0 -16
  186. data/test/core_test_app/gemfiles/rails3_2.gemfile +0 -16
  187. data/test/core_test_app/spec/component/base_spec.rb +0 -36
  188. data/test/core_test_app/spec/component/component_spec.rb +0 -20
  189. data/test/core_test_app/spec/component/composition_spec.rb +0 -132
  190. data/test/core_test_app/spec/component/configuration_spec.rb +0 -61
  191. data/test/core_test_app/spec/component/javascript_spec.rb +0 -16
  192. data/test/core_test_app/spec/component/state_spec.rb +0 -18
@@ -0,0 +1,11 @@
1
+ # This component shares state with StatefulComponent by setting +persistence_key+ to that component's js_id (which is used as persestence_key by default)
2
+ class StatefulComponentWithSharedState < Netzke::Base
3
+ def configure(c)
4
+ super
5
+ c.persistence = true
6
+ c.persistence_key = :stateful_component
7
+
8
+ # title will be gotten from component's state
9
+ c.title = state[:title] || "Default Title"
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ class WindowWithSimpleComponent < SimpleWindow
2
+ js_configure do |c|
3
+ c.layout = :fit
4
+ end
5
+
6
+ def configure(c)
7
+ c.items = [:simple_component]
8
+ super
9
+ end
10
+
11
+ component :simple_component do |c|
12
+ c.title = "Simple Component Inside Window"
13
+ end
14
+ end
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <title>Netzke Core Test App</title>
5
5
  <%= csrf_meta_tag %>
6
- <%= netzke_init %>
6
+ <%= load_netzke minified: true %>
7
7
  </head>
8
8
  <body>
9
9
 
@@ -1,23 +1,11 @@
1
1
  <%= netzke :tab_panel_one, {
2
- :height => 300,
3
- :class_name => "SimpleTabPanel",
4
- :items => [{
5
- :class_name => "ServerCaller",
6
- :title => "Server Caller One"
7
- },{
8
- :class_name => "ServerCaller",
9
- :title => "Server Caller Two"
10
- }]
2
+ height: 200,
3
+ class_name: "SimpleTabPanel",
4
+ items: [:server_caller, :extended_server_caller]
11
5
  } %>
12
6
 
13
7
  <%= netzke :tab_panel_two, {
14
- :height => 300,
15
- :class_name => "SimpleTabPanel",
16
- :items => [{
17
- :class_name => "ExtendedServerCaller",
18
- :title => "Server Caller One"
19
- },{
20
- :class_name => "ExtendedServerCaller",
21
- :title => "Server Caller Two"
22
- }]
23
- } %>
8
+ height: 200,
9
+ class_name: "SimpleTabPanel",
10
+ items: [:extended_server_caller, :server_caller]
11
+ } %>
@@ -0,0 +1 @@
1
+ <%= netzke :panel, class_name: "Netzke::Core::Panel" %>
@@ -2,12 +2,10 @@
2
2
  # re-generated from your development database when you run "rake".
3
3
  # Do not set this db to the same as development or production.
4
4
  test: &test
5
- adapter: mysql2
6
- encoding: utf8
7
- reconnect: false
8
- database: nct_test
5
+ adapter: sqlite3
6
+ database: db/test.sqlite3
9
7
  pool: 5
10
- username:
8
+ timeout: 5000
11
9
 
12
10
  cucumber:
13
11
  <<: *test
@@ -29,7 +29,7 @@ RailsApp::Application.configure do
29
29
 
30
30
  # Disable Rails's static asset server
31
31
  # In production, Apache or nginx will already do this
32
- config.serve_static_assets = false
32
+ # config.serve_static_assets = false
33
33
 
34
34
  # Enable serving of images, stylesheets, and javascripts from an asset server
35
35
  # config.action_controller.asset_host = "http://assets.example.com"
@@ -1,4 +1,6 @@
1
1
  Netzke::Core.setup do |config|
2
2
  config.js_direct_max_retries = 2
3
3
  # config.ext_uri = "/extjs4"
4
- end
4
+ end
5
+
6
+ ConfigurableOnClassLevel.title = "Overridden"
@@ -4,15 +4,20 @@
4
4
  en:
5
5
  server_caller:
6
6
  actions:
7
- bug_server: "Call server"
7
+ bug_server:
8
+ text: Call server
9
+ tooltip: This bugs server
10
+ icon: tick
8
11
  extended_server_caller:
9
12
  actions:
10
- bug_server: "Call server extensively"
11
- bug_server_tooltip: "With custom tooltip"
13
+ bug_server:
14
+ text: Call server extensively
15
+ tooltip: This bugs server in its own way
12
16
  localized_panel:
13
17
  title: Localized Panel
14
18
  property_one: First property
15
19
  property_two: Second property
16
20
  action_two: Second action
17
21
  actions:
18
- action_one: First action
22
+ action_one:
23
+ text: First action
@@ -8,5 +8,7 @@ es:
8
8
  property_two: Segunda propriedad
9
9
  action_two: Segunda acción
10
10
  actions:
11
- action_one: Primera acción
12
- action_three: Tercera acción
11
+ action_one:
12
+ text: Primera acción
13
+ action_three:
14
+ text: Tercera acción
@@ -1,4 +1,6 @@
1
1
  RailsApp::Application.routes.draw do
2
+ netzke "/some/path/netzke" # the path is optional
3
+
2
4
  # The priority is based upon order of creation:
3
5
  # first created -> highest priority.
4
6
 
@@ -61,13 +63,5 @@ RailsApp::Application.routes.draw do
61
63
  # Components configured in Rails views
62
64
  match 'simple_rails/:action' => 'simple_rails', :as => 'simple_rails_views'
63
65
 
64
- # Touch components
65
- match 'components/touch/:component' => 'touch#index', :as => "touch_components"
66
-
67
- # Non-Netzke Ext components
68
- match 'ext/:component' => 'components#ext', :as => "ext"
69
-
70
66
  match ':controller(/:action(/:id(.:format)))'
71
-
72
- netzke
73
67
  end
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  # This file is auto-generated from the current state of the database. Instead
2
3
  # of editing this file, please use the migrations feature of Active Record to
3
4
  # incrementally modify your database, and then regenerate this schema definition.
@@ -17,21 +18,12 @@ ActiveRecord::Schema.define(:version => 20110110132720) do
17
18
  t.integer "user_id"
18
19
  t.integer "role_id"
19
20
  t.text "value"
20
- t.datetime "created_at"
21
- t.datetime "updated_at"
21
+ t.datetime "created_at", :null => false
22
+ t.datetime "updated_at", :null => false
22
23
  end
23
24
 
24
25
  add_index "netzke_component_states", ["component"], :name => "index_netzke_component_states_on_component"
25
26
  add_index "netzke_component_states", ["role_id"], :name => "index_netzke_component_states_on_role_id"
26
27
  add_index "netzke_component_states", ["user_id"], :name => "index_netzke_component_states_on_user_id"
27
28
 
28
- create_table "netzke_preferences", :force => true do |t|
29
- t.string "key"
30
- t.text "value"
31
- t.integer "user_id"
32
- t.integer "role_id"
33
- t.datetime "created_at"
34
- t.datetime "updated_at"
35
- end
36
-
37
29
  end
@@ -6,6 +6,7 @@ Feature: Actions
6
6
  @javascript
7
7
  Scenario: Pressing button should result in corresponding actions
8
8
  When I go to the ComponentWithActions test page
9
+ Then I should not see "Excluded action"
9
10
  Then I should see "Disabled action"
10
11
  And button "Disabled action" should be disabled
11
12
 
@@ -9,4 +9,11 @@ Scenario: Ask server to set our title
9
9
  Then I should see "Server Caller"
10
10
 
11
11
  When I press "Call server"
12
+ And I wait for response from server
12
13
  Then I should see "All quiet here on the server"
14
+
15
+ @selenium
16
+ Scenario: Calling an endpoint with callback and scope
17
+ Given I am on the ServerCaller test page
18
+ When I press "Call with generic callback and scope"
19
+ Then I should see "Fancy title set!"
@@ -19,18 +19,6 @@ Feature: Component loader
19
19
  When I press "Load with feedback"
20
20
  Then I should see "Callback invoked!"
21
21
 
22
- @selenium
23
- Scenario: Component loader should invoke a generic endpoint callback
24
- Given I am on the ComponentLoader test page
25
- When I press "Load with generic callback"
26
- Then I should see "Generic callback invoked!"
27
-
28
- @selenium
29
- Scenario: Component loader should invoke a generic endpoint callback
30
- Given I am on the ComponentLoader test page
31
- When I press "Load with generic callback and scope"
32
- Then I should see "Fancy title set!"
33
-
34
22
  @selenium
35
23
  Scenario: Component loader should load a window component with another component in it
36
24
  Given I am on the ComponentLoader test page
@@ -45,8 +33,20 @@ Feature: Component loader
45
33
  Then I should see "Simple Component with changed HTML"
46
34
 
47
35
  @javascript
48
- Scenario: Component loader should report that it can't load a component
36
+ Scenario: Component loader should report that it can't load a component and stay adequate
49
37
  Given I am on the ComponentLoader test page
50
38
  When I press "Non-existing component"
51
39
  Then I should see "Couldn't load component 'non_existing_component'"
52
40
  And I should not see "Loading"
41
+
42
+ @javascript
43
+ Scenario: Component loader not be able to load a component marked as excluded
44
+ Given I am on the ComponentLoader test page
45
+ When I press "Inaccessible"
46
+ Then I should see "Couldn't load component 'inaccessible'"
47
+
48
+ @javascript
49
+ Scenario: Loading component's config
50
+ Given I am on the ComponentLoader test page
51
+ When I press "Config only"
52
+ Then I should see "SimpleComponent (overridden)"
@@ -29,3 +29,17 @@ Feature: Composition
29
29
  When I press "Update east south from server"
30
30
  And I wait for response from server
31
31
  Then I should see "Here's an update for south panel in east panel"
32
+
33
+ @javascript
34
+ Scenario: Instantiation of pre-loaded Netzke components
35
+ Given I am on the SomeComposite test page
36
+ When I press "Show hidden window"
37
+ And I wait for response from server
38
+ Then I should see "Hidden window gone visible!"
39
+
40
+ @javascript
41
+ Scenario: Excluding components for the layout
42
+ When I go to the SimpleTabPanel test page
43
+ Then tab panel should have tab with title "Server Caller"
44
+ And tab panel should have tab with title "Extended Server Caller"
45
+ But tab panel should not have tab with title "Hello World component"
@@ -0,0 +1,10 @@
1
+ Feature: Config to dsl delegation
2
+ In order to value
3
+ As a role
4
+ I want feature
5
+
6
+ @javascript
7
+ Scenario: A base components delegates its configuration options to DSL
8
+ When I go to the DslDelegatedProperties test page
9
+ Then I should see "Title set via DSL"
10
+ And I should see "HTML set via DSL"
@@ -5,6 +5,6 @@ Feature: File inclusion
5
5
 
6
6
  @javascript
7
7
  Scenario: A component with external JS file included
8
- Given I am on the ComponentWithIncludedJs test page
8
+ Given I am on the ComponentWithRequiredJs test page
9
9
  When I press "Print message"
10
10
  Then I should see "Some message shown in the body"
@@ -17,8 +17,9 @@ Scenario: LocalizedPanel should be available in 2 languages
17
17
  And I should see "Primera acción"
18
18
  And I should see "Segunda acción"
19
19
 
20
- When I press "Tercera acción"
21
- Then I should see "Cargando..."
20
+ # Ext.LoadMask.prototype.msg is not translated in Ext 4.1.1
21
+ # When I press "Tercera acción"
22
+ # Then I should see "Cargando..."
22
23
 
23
24
  When I go to the "es" version of the ExtendedLocalizedPanel page
24
25
  Then I should see "Panel Localizada"
@@ -26,10 +27,9 @@ Scenario: LocalizedPanel should be available in 2 languages
26
27
  And I should see "Action one"
27
28
  And I should see "Segunda acción"
28
29
 
30
+ # Making sure that the locale is restored to "en" in the end
29
31
  When I go to the "en" version of the ExtendedLocalizedPanel page
30
32
  Then I should see "Localized Panel"
31
33
  And I should see "First property, Second property"
32
34
  And I should see "Action one"
33
35
  And I should see "Second action"
34
-
35
- # NOTE: make sure that the locale is restored to "en" in the end!
@@ -17,4 +17,4 @@ Feature: JsMixins
17
17
  Scenario: ExtendedComponentWithJsMixin should behave, too
18
18
  Given I am on the ExtendedComponentWithJsMixin test page
19
19
  When I press "Action three"
20
- Then I should see "Action Three triggered!"
20
+ Then I should see "Modified action Three triggered!"
@@ -5,14 +5,30 @@ Feature: Persistence
5
5
 
6
6
  @javascript
7
7
  Scenario: The component with persistence should be able to store and retrieve a persistence setting
8
- When I go to the ComponentWithSessionPersistence test page
8
+ When I go to the StatefulComponent test page
9
9
  Then I should see "Default Title"
10
10
  And I should see "Default HTML"
11
- But I should not see "Title From Session"
11
+ But I should not see "Title From State"
12
12
  And I should not see "HTML from session"
13
13
 
14
- When I press "Tell server to store new title"
14
+ When I press "Set session and state"
15
15
  And I wait for response from server
16
- And I go to the ComponentWithSessionPersistence test page
17
- Then I should see "Title From Session"
16
+ And I go to the StatefulComponent test page
17
+ Then I should see "Title From State"
18
18
  And I should see "HTML from session"
19
+
20
+ When I press "Reset session and state"
21
+ And I wait for response from server
22
+ And I go to the StatefulComponent test page
23
+ Then I should see "Default Title"
24
+ And I should see "Default HTML"
25
+ But I should not see "Title From State"
26
+ And I should not see "HTML from session"
27
+
28
+ @javascript
29
+ Scenario: Sharing persistence key
30
+ When I go to the StatefulComponent test page
31
+ And I press "Set session and state"
32
+ And I wait for response from server
33
+ And I go to the StatefulComponentWithSharedState test page
34
+ Then I should see "Title From State"
@@ -41,6 +41,20 @@ When /^I press tool "([^"]*)"$/ do |tool|
41
41
  find("##{id} img").click
42
42
  end
43
43
 
44
+ Then /^tab panel should have tab with title "(.*?)"$/ do |arg1|
45
+ page.driver.browser.execute_script(<<-JS).should == true
46
+ var tabPanel = Ext.ComponentQuery.query('tabpanel')[0];
47
+ return !!tabPanel.down('[title="#{arg1}"]');
48
+ JS
49
+ end
50
+
51
+ Then /^tab panel should not have tab with title "(.*?)"$/ do |arg1|
52
+ page.driver.browser.execute_script(<<-JS).should == true
53
+ var tabPanel = Ext.ComponentQuery.query('tabpanel')[0];
54
+ return !tabPanel.down('[title="#{arg1}"]');
55
+ JS
56
+ end
57
+
44
58
  When /^I wait for response from server$/ do
45
59
  page.wait_until{ page.driver.browser.execute_script("return !Netzke.ajaxIsLoading()") }
46
60
  end
@@ -23,9 +23,6 @@ module NavigationHelpers
23
23
  when /the (.*) test page/
24
24
  components_path(:component => $1)
25
25
 
26
- when /the (.*) page for touch/
27
- touch_components_path(:component => $1)
28
-
29
26
  when /the "(.+)" version of the (.*) page/
30
27
  components_path(:component => $2, :locale => $1)
31
28
 
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ module Netzke::Core
4
+ describe ActionConfig do
5
+ it "should preserve localized attributes from superclass if those are not overridden" do
6
+ sc = ServerCaller.new
7
+ esc = ExtendedServerCaller.new
8
+ sc.actions[:bug_server].text.should == "Call server"
9
+ esc.actions[:bug_server].text.should == "Call server extensively"
10
+
11
+ sc.actions[:bug_server].tooltip.should == "This bugs server"
12
+ esc.actions[:bug_server].tooltip.should == "This bugs server in its own way"
13
+ end
14
+ end
15
+ end
@@ -1,25 +1,17 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
- require 'netzke-core'
1
+ require 'spec_helper'
3
2
 
4
- module Netzke
3
+ module Netzke::Core
5
4
  describe Actions do
6
- # it "should be possible to override toolbars without overriding action settings" do
7
- # ExtendedComponentWithActions.new.actions[:another_action][:disabled].should == true
8
- # end
9
-
10
- class SomeComponent < Base
5
+ class SomeComponent < Netzke::Base
11
6
  action :action_one
12
7
  action :action_two
13
- action :action_three do
14
- {:text => "Action three"}
8
+ action :action_three do |a|
9
+ a.text = "Action three"
15
10
  end
16
11
 
17
- js_property :bbar, [:action_one.action, :action_two.action]
18
-
19
- def config
20
- {
21
- :tbar => [:action_three.action]
22
- }
12
+ def configure(c)
13
+ super
14
+ c.tbar = [:action_one, :action_two, :action_three]
23
15
  end
24
16
 
25
17
  def actions
@@ -28,40 +20,50 @@ module Netzke
28
20
  })
29
21
  end
30
22
 
31
- action :action_five, :text => "Action 5"
23
+ action :action_five do |a|
24
+ a.text = "Action 5"
25
+ end
32
26
  end
33
27
 
34
28
  class ExtendedComponent < SomeComponent
35
- js_property :bbar, [:action_one.action, :action_two.action, :action_three.action, :action_four.action, :action_five.action]
36
- js_property :tbar, [:action_one.action, :action_two.action, :action_three.action, :action_four.action, :action_five.action]
37
29
  end
38
30
 
39
31
  class AnotherExtendedComponent < ExtendedComponent
40
- action :action_one, :text => "Action 1"
41
- action :action_five, :text => "Action Five"
32
+ action :action_one do |a|
33
+ a.text = "Action 1"
34
+ end
42
35
 
43
- def action_two_action
44
- super.merge(:disabled => true, :text => normalize_action_config(super)[:text] + ", extended")
36
+ action :action_five do |a|
37
+ a.text = "Action Five"
45
38
  end
46
39
 
47
- action :action_three do
48
- {:text => "Action 3"}
40
+ action :action_two do |c|
41
+ super(c)
42
+ c.disabled = true
43
+ c.text = c.text + ", extended"
44
+ end
45
+
46
+ action :action_three do |a|
47
+ a.text = "Action 3"
49
48
  end
50
49
  end
51
50
 
52
51
  class YetAnotherExtendedComponent < AnotherExtendedComponent
53
- action :action_two, :disabled => false
52
+ action :action_two do |c|
53
+ super(c)
54
+ c.disabled = false
55
+ end
54
56
  end
55
57
 
56
- # it "should auto collect actions from both js_methods and config" do
57
- # component = SomeComponent.new
58
- # component.actions.keys.size.should == 5
59
- # component.actions[:action_one][:text].should == "Action one"
60
- # component.actions[:action_two][:text].should == "Action two"
61
- # component.actions[:action_three][:text].should == "Action three"
62
- # component.actions[:action_four][:text].should == "Action 4"
63
- # component.actions[:action_five][:text].should == "Action 5"
64
- # end
58
+ it "should auto collect actions from both js_methods and config" do
59
+ component = SomeComponent.new
60
+ component.actions.keys.size.should == 5
61
+ component.actions[:action_one][:text].should == "Action one"
62
+ component.actions[:action_two][:text].should == "Action two"
63
+ component.actions[:action_three][:text].should == "Action three"
64
+ component.actions[:action_four][:text].should == "Action 4"
65
+ component.actions[:action_five][:text].should == "Action 5"
66
+ end
65
67
 
66
68
  it "should not override previous actions when reconfiguring bars in child class" do
67
69
  component = ExtendedComponent.new
@@ -91,4 +93,4 @@ module Netzke
91
93
  end
92
94
 
93
95
  end
94
- end
96
+ end