Skip to content

Commit

Permalink
Added tests for dynamically loading some view containing a Netzke com…
Browse files Browse the repository at this point in the history
…ponent into a Ext.Panel
  • Loading branch information
Sergei Kozlov committed Nov 17, 2010
1 parent 29cccb4 commit f17d507
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 2 deletions.
9 changes: 9 additions & 0 deletions features/nested_views.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Nested views
In order to value
As a role
I want feature

@javascript
Scenario: A component with auto loaded content should render properly
When I go to the "panel with autoload" view
Then I should see "Autoloaded Panel"
3 changes: 3 additions & 0 deletions features/support/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def path_to(page_name)
when /the component loader page/
'/panel/component_loader'

when /the "(.*)" view/
embedded_components_path(:action => $1.gsub(" ", "_"))

when /the (.*) test page/
components_path(:component => $1)

Expand Down
5 changes: 5 additions & 0 deletions netzke-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Gem::Specification.new do |s|
"features/file_inclusion.feature",
"features/inheritance.feature",
"features/js_mixins.feature",
"features/nested_views.feature",
"features/persistence.feature",
"features/scopes.feature",
"features/step_definitions/custom_css_steps.rb",
Expand Down Expand Up @@ -118,6 +119,7 @@ Gem::Specification.new do |s|
"test/rails_app/app/components/scoped_components/some_scoped_component.rb",
"test/rails_app/app/components/server_caller.rb",
"test/rails_app/app/components/simple_component.rb",
"test/rails_app/app/components/simple_panel.rb",
"test/rails_app/app/components/simple_tab_panel.rb",
"test/rails_app/app/components/simple_window.rb",
"test/rails_app/app/components/some_composite.rb",
Expand All @@ -127,7 +129,10 @@ Gem::Specification.new do |s|
"test/rails_app/app/controllers/multiple_components_controller.rb",
"test/rails_app/app/controllers/welcome_controller.rb",
"test/rails_app/app/helpers/application_helper.rb",
"test/rails_app/app/views/components/panel_with_autoload.html.erb",
"test/rails_app/app/views/components/some_tab_panel.html.erb",
"test/rails_app/app/views/layouts/application.html.erb",
"test/rails_app/app/views/layouts/nested.html.erb",
"test/rails_app/app/views/multiple_components/set_one.html.erb",
"test/rails_app/config.ru",
"test/rails_app/config/application.rb",
Expand Down
2 changes: 2 additions & 0 deletions test/rails_app/app/components/simple_panel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class SimplePanel < Netzke::Base
end
7 changes: 6 additions & 1 deletion test/rails_app/app/controllers/components_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
class ComponentsController < ApplicationController
def show
def index
component_name = params[:component].gsub("::", "_").underscore
render :inline => "<%= netzke :#{component_name}, :class_name => '#{params[:component]}' %>", :layout => true
end

# For panel_with_autoload
def autoloaded_content
render :inline => "<%= netzke :simple_panel, :height => 300, :bbar => ['->', 'Some text'], :html => 'Autoloaded Panel' %>", :layout => "nested"
end

# Just a test for a pure Ext component - not sure if it's useful.
def ext
component_name = params[:component].gsub("::", "_").underscore
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%# This is just a panel that has +autoload+ option to load some content from the autoloaded_content action, which in its turn renders a view with a Netzke component in it %>
<%= netzke :panel_with_autoload, :class_name => "SimplePanel", :html => "Some content", :autoLoad => {:url => "autoloaded_content", :scripts => true}%>
11 changes: 11 additions & 0 deletions test/rails_app/app/views/components/some_tab_panel.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%= netzke :tabs,
:class_name => "SimpleTabPanel",
:active_tab => 0,
:items => [{
:html => "I'm a simple Ext.Panel",
:title => "Panel One"
},{
:html => "I'm a second simple Ext.Panel",
:title => "Panel Two"
}]
%>
5 changes: 5 additions & 0 deletions test/rails_app/app/views/layouts/nested.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<%# Use this layout when you dynamically load views with other Netzke components into some Ext.Panel, e.g. with Ext.updater.
Because the main Netzke/Ext code is already loaded, all we need to load is the JavaScript for components that are
embedded in the loaded view. TODO: fix class caching in this scenario. %>
<%= netzke_js %>
<%= yield %>
8 changes: 7 additions & 1 deletion test/rails_app/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.

match 'components/:component' => 'components#show', :as => "components"
# Components that don't need configuration in the view, view code rendered inline
match 'components/:component' => 'components#index', :as => "components"

# Components configured in Rails views
match 'components/embedded/:action' => 'components', :as => "embedded_components"

# Non-Netzke Ext components
match 'ext/:component' => 'components#ext', :as => "ext"

match ':controller(/:action(/:id(.:format)))'
Expand Down

0 comments on commit f17d507

Please sign in to comment.