You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by fa...@apache.org on 2009/08/30 18:30:39 UTC

svn commit: r809371 [8/10] - in /labs/consite/trunk/conferences: ./ app/views/admin/con/dashboard/ app/views/layouts/ db/ db/migrate/ lib/ lib/tasks/ public/images/conferences/ vendor/plugins/active_scaffold/ vendor/plugins/active_scaffold/.git/ vendor...

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/lib/paginator.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/lib/paginator.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/lib/paginator.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/lib/paginator.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,136 @@
+require 'forwardable'
+
+class Paginator
+  
+  VERSION = '1.0.9'
+
+  class ArgumentError < ::ArgumentError; end
+  class MissingCountError < ArgumentError; end
+  class MissingSelectError < ArgumentError; end  
+  
+  attr_reader :per_page, :count 
+  
+  # Instantiate a new Paginator object
+  #
+  # Provide:
+  # * A total count of the number of objects to paginate
+  # * The number of objects in each page
+  # * A block that returns the array of items
+  #   * The block is passed the item offset 
+  #     (and the number of items to show per page, for
+  #     convenience, if the arity is 2)
+  def initialize(count, per_page, &select)
+    @count, @per_page = count, per_page
+    unless select
+      raise MissingSelectError, "Must provide block to select data for each page"
+    end
+    @select = select
+  end
+  
+  # Total number of pages
+  def number_of_pages
+     (@count / @per_page).to_i + (@count % @per_page > 0 ? 1 : 0)
+  end
+  
+  # First page object
+  def first
+    page 1
+  end
+  
+  # Last page object
+  def last
+    page number_of_pages
+  end
+  
+  # Iterate through pages
+  def each
+    each_with_index do |item, index|
+      yield item
+    end
+  end
+  
+  # Iterate through pages with indices
+  def each_with_index
+    1.upto(number_of_pages) do |number|
+      yield(page(number), number - 1)
+    end
+  end
+  
+  # Retrieve page object by number
+  def page(number)
+    number = (n = number.to_i) > 0 ? n : 1
+    Page.new(self, number, lambda { 
+      offset = (number - 1) * @per_page
+      args = [offset]
+      args << @per_page if @select.arity == 2
+      @select.call(*args)
+    })
+  end
+  
+  # Page object
+  #
+  # Retrieves items for a page and provides metadata about the position
+  # of the page in the paginator
+  class Page
+    
+    extend Forwardable
+    def_delegator :@pager, :first, :first
+    def_delegator :@pager, :last, :last
+    def_delegator :items, :each
+    def_delegator :items, :each_with_index    
+        
+    attr_reader :number, :pager
+    
+    def initialize(pager, number, select) #:nodoc:
+      @pager, @number = pager, number
+      @offset = (number - 1) * pager.per_page
+      @select = select
+    end
+    
+    # Retrieve the items for this page
+    # * Caches
+    def items
+      @items ||= @select.call
+    end
+    
+    # Checks to see if there's a page before this one
+    def prev?
+      @number > 1
+    end
+    
+    # Get previous page (if possible)
+    def prev
+      @pager.page(@number - 1) if prev?
+    end
+    
+    # Checks to see if there's a page after this one
+    def next?
+      @number < @pager.number_of_pages
+    end
+    
+    # Get next page (if possible)
+    def next
+      @pager.page(@number + 1) if next?
+    end
+    
+    # The "item number" of the first item on this page
+    def first_item_number
+      1 + @offset
+    end
+    
+    # The "item number" of the last item on this page
+    def last_item_number
+      if next?
+        @offset + @pager.per_page
+      else
+        @pager.count
+      end
+    end
+    
+    def ==(other) #:nodoc:
+      @pager == other.pager && self.number == other.number
+    end
+    
+  end
+  
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/lib/paginator.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/lib/responds_to_parent.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/lib/responds_to_parent.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/lib/responds_to_parent.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/lib/responds_to_parent.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,68 @@
+#  Copyright (c) 2006 Sean Treadway
+#  
+#  Permission is hereby granted, free of charge, to any person obtaining
+#  a copy of this software and associated documentation files (the
+#  "Software"), to deal in the Software without restriction, including
+#  without limitation the rights to use, copy, modify, merge, publish,
+#  distribute, sublicense, and/or sell copies of the Software, and to
+#  permit persons to whom the Software is furnished to do so, subject to
+#  the following conditions:
+#  
+#  The above copyright notice and this permission notice shall be
+#  included in all copies or substantial portions of the Software.
+#  
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+#  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+#  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+#  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+#  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+#  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+#  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+# Module containing the methods useful for child IFRAME to parent window communication
+module RespondsToParent
+  
+  # Executes the response body as JavaScript in the context of the parent window.
+  # Use this method of you are posting a form to a hidden IFRAME or if you would like
+  # to use IFRAME base RPC.
+  def responds_to_parent(&block)
+    yield
+    
+    if performed?
+      # We're returning HTML instead of JS or XML now
+      response.headers['Content-Type'] = 'text/html; charset=UTF-8'
+      
+      # Either pull out a redirect or the request body
+      script =  if location = erase_redirect_results
+                  "document.location.href = #{location.to_s.inspect}"
+                else
+                  response.body
+                end
+                
+      # Escape quotes, linebreaks and slashes, maintaining previously escaped slashes
+      # Suggestions for improvement?
+      script = (script || '').
+        gsub('\\', '\\\\\\').
+        gsub(/\r\n|\r|\n/, '\\n').
+        gsub(/['"]/, '\\\\\&').
+        gsub('</script>','</scr"+"ipt>')
+
+      # Clear out the previous render to prevent double render
+      erase_results
+      
+      # Eval in parent scope and replace document location of this frame 
+      # so back button doesn't replay action on targeted forms
+      # loc = document.location to be set after parent is updated for IE
+      # with(window.parent) - pull in variables from parent window
+      # setTimeout - scope the execution in the windows parent for safari
+      # window.eval - legal eval for Opera
+      render :text => "<html><body><script type='text/javascript' charset='utf-8'>
+        var loc = document.location;
+        with(window.parent) { setTimeout(function() { window.eval('#{script}'); loc.replace('about:blank'); }, 1) } 
+      </script></body></html>"
+    end
+  end
+  alias respond_to_parent responds_to_parent
+end
+

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/lib/responds_to_parent.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/public/blank.html
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/public/blank.html?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/public/blank.html (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/public/blank.html Sun Aug 30 16:30:26 2009
@@ -0,0 +1,33 @@
+<!--    
+   Copyright (c) 2005, Brad Neuberg, bkn3@columbia.edu
+   http://codinginparadise.org
+   
+   Permission is hereby granted, free of charge, to any person obtaining 
+   a copy of this software and associated documentation files (the "Software"), 
+   to deal in the Software without restriction, including without limitation 
+   the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+   and/or sell copies of the Software, and to permit persons to whom the 
+   Software is furnished to do so, subject to the following conditions:
+   
+   The above copyright notice and this permission notice shall be 
+   included in all copies or substantial portions of the Software.
+   
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
+   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
+   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
+   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 
+   OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 
+   THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+-->
+
+<html>
+   <script language="JavaScript">
+            function pageLoaded() {
+               window.parent.dhtmlHistory.iframeLoaded(window.location);
+            }
+   </script>
+   <body onload="pageLoaded()">
+      <h1>blank.html - Needed for Internet Explorer's hidden IFrame</h1>
+   </body>
+</html>

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/public/blank.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/bridges/bridge_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/bridges/bridge_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/bridges/bridge_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/bridges/bridge_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,47 @@
+def dbg; require "ruby-debug"; debugger; end;
+
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+
+class Bridges::BridgeTest < Test::Unit::TestCase
+  def setup
+    @const_store = {}
+  end
+  
+  def teardown
+  end
+  
+  def test__shouldnt_throw_errors
+    ActiveScaffold::Bridge.run_all
+  end
+  
+  def test__cds_bridge
+    ConstMocker.mock("CalendarDateSelect") do |cm|
+      cm.remove
+      assert(! bridge_will_be_installed("CalendarDateSelect"))
+      cm.declare
+      assert(bridge_will_be_installed("CalendarDateSelect"))
+    end
+  end
+  
+  def test__file_column_bridge
+    ConstMocker.mock("FileColumn") do |cm|
+      cm.remove
+      assert(! bridge_will_be_installed("FileColumn"))
+      cm.declare
+      assert(bridge_will_be_installed("FileColumn"))
+    end
+  end
+
+protected
+
+  def find_bridge(name)
+    ActiveScaffold::Bridge.bridges.find{|b| b.name.to_s==name.to_s}
+  end
+  
+  def bridge_will_be_installed(name)
+    assert bridge=find_bridge(name), "No bridge found matching #{name}"
+    
+    bridge.instance_variable_get("@install_if").call
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/bridges/bridge_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/base_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/base_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/base_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/base_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,15 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class Config::BaseTest < Test::Unit::TestCase
+  def setup
+    @base = ActiveScaffold::Config::Base.new
+  end
+  
+  def test_formats
+    assert_equal [], @base.formats
+    @base.formats << :pdf
+    assert_equal [:pdf], @base.formats
+    @base.formats = [:html]
+    assert_equal [:html], @base.formats
+  end
+end

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/base_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/create_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/create_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/create_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/create_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,55 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class Config::CreateTest < Test::Unit::TestCase
+  def setup
+    @config = ActiveScaffold::Config::Core.new :model_stub
+    @default_link = @config.create.link
+  end
+  
+  def teardown
+    @config.create.link = @default_link
+  end
+  
+  def test_default_options
+    assert !@config.create.persistent
+    assert !@config.create.edit_after_create
+    assert_equal 'Create Modelstub', @config.create.label
+  end
+
+  def test_link_defaults
+    link = @config.create.link
+    assert !link.page?
+    assert !link.popup?
+    assert !link.confirm?
+    assert_equal "new", link.action
+    assert_equal "Create New", link.label
+    assert link.inline?
+    blank = {}
+    assert_equal blank, link.html_options
+    assert_equal :get, link.method
+    assert_equal :table, link.type
+    assert_equal :create, link.crud_type
+    assert_equal :create_authorized?, link.security_method
+  end
+  
+  def test_setting_link
+    @config.create.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys')
+    assert_not_equal(@default_link, @config.create.link)
+  end
+  
+  def test_label
+    label = 'create new monkeys'
+    @config.create.label = label
+    assert_equal label, @config.create.label
+  end
+  
+  def test_persistent
+    @config.create.persistent = true
+    assert @config.create.persistent
+  end
+ 
+  def test_edit_after_create
+    @config.create.edit_after_create = true
+    assert @config.create.edit_after_create
+  end
+end

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/create_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/list_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/list_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/list_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/list_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,74 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class Config::ListTest < Test::Unit::TestCase
+  def setup
+    @config = ActiveScaffold::Config::Core.new :model_stub
+  end
+
+  def test_default_options
+    assert_equal 15, @config.list.per_page
+    assert_equal '-', @config.list.empty_field_text
+    assert @config.actions.include?(:search)
+    assert_equal 'search', @config.list.search_partial
+    assert_equal :no_entries, @config.list.no_entries_message
+    assert_equal :filtered, @config.list.filtered_message
+    assert !@config.list.always_show_create
+    assert !@config.list.always_show_search
+  end
+  
+  def test_no_entries
+    @config.list.no_entries_message = 'No items'
+    assert_equal 'No items', @config.list.no_entries_message
+  end
+  
+  def test_filtered_message
+    @config.list.filtered_message = 'filtered items'
+    assert_equal 'filtered items', @config.list.filtered_message
+  end
+  
+  def test_per_page
+    per_page = 35
+    @config.list.per_page = per_page
+    assert_equal per_page, @config.list.per_page
+  end
+  
+  def test_always_show_create
+    always_show_create = true
+    @config.list.always_show_create = always_show_create
+    assert_equal always_show_create, @config.list.always_show_create
+  end
+  
+  def test_always_show_create_when_create_is_not_enabled
+    always_show_create = true
+    @config.list.always_show_create = always_show_create
+    @config.actions.exclude :create
+    assert_equal false, @config.list.always_show_create
+  end
+  
+  def test_always_show_search
+    @config.list.always_show_search = true
+    assert @config.list.always_show_search
+    assert_equal 'search', @config.list.search_partial
+  end
+  
+  def test_always_show_search_when_search_is_not_enabled
+    @config.list.always_show_search = true
+    @config.actions.exclude :search
+    assert_equal false, @config.list.always_show_search
+  end
+
+  def test_always_show_search_when_field_search
+    @config.list.always_show_search = true
+    @config.actions.swap :search, :live_search
+    assert @config.list.always_show_search
+    assert_equal 'live_search', @config.list.search_partial
+  end
+  
+  def test_always_show_search_when_field_search
+    @config.list.always_show_search = true
+    @config.actions.swap :search, :field_search
+    assert @config.list.always_show_search
+    assert_equal 'field_search', @config.list.search_partial
+  end
+
+end

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/list_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/show_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/show_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/show_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/show_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,43 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class Config::ShowTest < Test::Unit::TestCase
+  def setup
+    @config = ActiveScaffold::Config::Core.new :model_stub
+    @default_link = @config.show.link
+  end
+  
+  def teardown
+    @config.show.link = @default_link
+  end
+  
+  def test_default_options
+    assert_equal 'Show Modelstub', @config.show.label
+  end
+
+  def test_link_defaults
+    link = @config.show.link
+    assert !link.page?
+    assert !link.popup?
+    assert !link.confirm?
+    assert_equal "show", link.action
+    assert_equal "Show", link.label
+    assert link.inline?
+    blank = {}
+    assert_equal blank, link.html_options
+    assert_equal :get, link.method
+    assert_equal :record, link.type
+    assert_equal :read, link.crud_type
+    assert_equal :show_authorized?, link.security_method
+  end
+  
+  def test_setting_link
+    @config.show.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys')
+    assert_not_equal(@default_link, @config.show.link)
+  end
+  
+  def test_label
+    label = 'create new monkeys'
+    @config.show.label = label
+    assert_equal label, @config.show.label
+  end
+end

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/show_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/update_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/update_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/update_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/update_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,17 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class Config::UpdateTest < Test::Unit::TestCase
+  def setup
+    @config = ActiveScaffold::Config::Core.new :model_stub
+    @update = @config.update
+    
+    @config._load_action_columns
+  end
+  
+  def test__params_for_columns__returns_all_params
+    @config.columns[:a].params.add :keep_a, :a_temp
+    
+    assert @config.columns[:a].params.include?(:keep_a)
+    assert @config.columns[:a].params.include?(:a_temp)
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/config/update_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/const_mocker.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/const_mocker.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/const_mocker.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/const_mocker.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,36 @@
+class ConstMocker
+  def initialize(*const_names)
+    @const_names = const_names
+    @const_states = {}
+    @const_names.each{|const_name|
+      @const_states[const_name] = Object.const_defined?(const_name) ? Object.const_get(const_name) : nil
+    }
+  end
+  
+  def remove
+    @const_names.each{|const_name|
+      Object.send :remove_const, const_name if Object.const_defined?(const_name)
+    }
+  end
+  
+  def declare
+    @const_names.each{|const_name|
+      Object.class_eval "class #{const_name}; end;" unless Object.const_defined?(const_name)
+    }
+  end
+  
+  def restore
+    remove
+    
+    @const_states.each_pair{|const_name, const|
+      Object.const_set const_name, const if const
+    }
+  end
+  
+  def self.mock(*const_names, &block)
+    cm = new(*const_names)
+    yield(cm)
+    cm.restore
+    true
+  end
+end

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/const_mocker.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,121 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+# require 'test/model_stub'
+require File.join(File.dirname(__FILE__), '../../lib/active_scaffold/data_structures/set.rb')
+
+ActiveScaffold::DataStructures::ActionColumns.class_eval do
+  #include Enumerable
+  include ActiveScaffold::DataStructures::ActionColumns::AfterConfiguration
+  def each
+    @set.each {|i| yield i}
+  end
+end
+
+class ActionColumnsTest < Test::Unit::TestCase
+  def setup
+    @columns = ActiveScaffold::DataStructures::ActionColumns.new([:a, :b])
+  end
+
+  def test_label
+    assert_nothing_raised do
+      @columns.label = 'foo';
+    end
+    assert @columns.label == 'foo'
+  end
+
+  def test_initialization
+    assert @columns.include?(:a)
+    assert @columns.include?(:b)
+    assert !@columns.include?(:c)
+  end
+
+  def test_exclude
+    # exclude with a symbol
+    assert @columns.include?(:b)
+    @columns.exclude :b
+    assert !@columns.include?(:b)
+
+    # exclude with a string
+    assert @columns.include?(:a)
+    @columns.exclude 'a'
+    assert !@columns.include?(:a)
+  end
+
+  def test_exclude_array
+    # exclude with a symbol
+    assert @columns.include?(:b)
+    @columns.exclude [:a, :b]
+    assert !@columns.include?(:b)
+    assert !@columns.include?(:a)
+  end
+
+  def test_add
+    # try adding a simple column using a string
+    assert !@columns.include?(:c)
+    @columns.add 'c'
+    assert @columns.include?(:c)
+
+    # try adding a simple column using a symbol
+    assert !@columns.include?(:d)
+    @columns.add :d
+    assert @columns.include?(:d)
+
+    # test that << also adds
+    assert !@columns.include?(:e)
+    @columns << :e
+    assert @columns.include?(:e)
+
+    # try adding an array of columns
+    assert !@columns.include?(:f)
+    @columns.add [:f, :g]
+    assert @columns.include?(:f)
+    assert @columns.include?(:g)
+
+  end
+
+  def test_length
+    assert_equal 2, @columns.length
+  end
+
+  def test_add_subgroup
+    # first, use @columns.add directly
+    @c2 = ActiveScaffold::DataStructures::ActionColumns.new
+    @columns.add @c2
+    assert @columns.any? { |c| c == @c2 }
+
+    # then use the shortcut
+    @columns.add_subgroup 'foo' do
+    end
+    assert @columns.any? { |c| c.respond_to? :label and c.label == 'foo' }
+  end
+
+  def test_block_config
+    @columns.configure do |config|
+      # we may use the config argument
+      config.add :c
+      # or we may not
+      exclude :b
+      add_subgroup 'my subgroup' do
+        add :e
+      end
+    end
+
+    assert @columns.include?(:c)
+    assert !@columns.include?(:b)
+    @columns.each { |c|
+      next unless c.is_a? ActiveScaffold::DataStructures::Columns
+      assert c.include?(:e)
+      assert_equal 'my subgroup', c.name
+    }
+  end
+
+  def test_include
+    @columns.add_subgroup 'foo' do
+      add :c
+    end
+
+    assert @columns.include?(:a)
+    assert @columns.include?(:b)
+    assert @columns.include?(:c)
+    assert !@columns.include?(:d)
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_link_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_link_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_link_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_link_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,78 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class ActionLinkTest < Test::Unit::TestCase
+  def setup
+    @link = ActiveScaffold::DataStructures::ActionLink.new('foo')
+  end
+
+  def test_simple_attributes
+    assert_equal 'foo', @link.action
+    @link.action = 'bar'
+    assert_equal 'bar', @link.action
+
+    hash = {:a => :b}
+    @link.parameters = hash
+    assert_equal hash, @link.parameters
+
+    @link.label = 'hello world'
+    assert_equal 'hello world', @link.label
+
+    assert !@link.confirm
+    @link.confirm = true
+    assert @link.confirm
+
+    @link.label = 'Hello World'
+    assert_equal 'hello_world_authorized?', @link.security_method
+    @link.label = 'HelloWorld'
+    assert_equal 'hello_world_authorized?', @link.security_method
+    @link.security_method = 'blueberry_pie'
+    assert_equal 'blueberry_pie', @link.security_method
+
+    @link.type = :table
+    assert_equal :table, @link.type
+    @link.type = :record
+    assert_equal :record, @link.type
+
+    assert_equal :get, @link.method
+    @link.method = :put
+    assert_equal :put, @link.method
+  end
+
+  def test_position
+    @link.position = true
+
+    @link.type = :table
+    assert_equal :top, @link.position
+
+    @link.type = :record
+    assert_equal :replace, @link.position
+
+    @link.position = :before
+    assert_equal :before, @link.position
+
+    @link.position = false
+    assert_equal false, @link.position
+  end
+
+  def test_presentation_style
+    # default
+    assert @link.inline?
+    assert !@link.popup?
+    assert !@link.page?
+
+    @link.popup = true
+    assert !@link.inline?
+    assert @link.popup?
+    assert !@link.page?
+
+    @link.page = true
+    assert !@link.inline?
+    assert !@link.popup?
+    assert @link.page?
+
+    @link.inline = true
+    assert @link.inline?
+    assert !@link.popup?
+    assert !@link.page?
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_link_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,78 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class ActionLinksTest < Test::Unit::TestCase
+  def setup
+    @links = ActiveScaffold::DataStructures::ActionLinks.new
+  end
+
+  def test_add_and_find
+    # test adding with a shortcut
+    @links.add 'foo/bar'
+
+    assert_equal 1, @links.find_all{true}.size
+    assert_equal 'foo/bar', @links.find_all{true}[0].action
+    assert_equal 'foo/bar', @links['foo/bar'].action
+
+    # test adding an ActionLink object directly
+    @links.add ActiveScaffold::DataStructures::ActionLink.new('hello/world')
+
+    assert_equal 2, @links.find_all{true}.size
+
+    # test the << alias
+    @links << 'a/b'
+
+    assert_equal 3, @links.find_all{true}.size
+  end
+
+  def test_array_access
+    @link1 = ActiveScaffold::DataStructures::ActionLink.new 'foo/bar'
+    @link2 = ActiveScaffold::DataStructures::ActionLink.new 'hello_world'
+
+    @links.add @link1
+    @links.add @link2
+
+    assert_equal @link1, @links[@link1.action]
+    assert_equal @link2, @links[@link2.action]
+  end
+
+  def test_empty
+    assert @links.empty?
+    @links.add 'a'
+    assert !@links.empty?
+  end
+
+  def test_cloning
+    @links.add 'foo/bar'
+    @links_copy = @links.clone
+
+    assert !@links.equal?(@links_copy)
+    assert !@links['foo/bar'].equal?(@links_copy['foo/bar'])
+  end
+
+  def test_each
+    @links.add 'foo', :type => :table
+    @links.add 'bar', :type => :record
+
+    @links.each :table do |link|
+      assert_equal 'foo', link.action
+    end
+    @links.each :record do |link|
+      assert_equal 'bar', link.action
+    end
+  end
+  
+  def test_delete
+    @links.add 'foo'
+    @links.add 'bar'
+
+    @links.delete :foo
+    assert @links['foo'].nil?
+    begin
+      @links.delete :foo
+    @links.delete 'foo'
+    rescue
+      assert false, "deleting from action links when item doesn't exist should not throw an error"
+    end
+    assert !@links['bar'].nil?
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/actions_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/actions_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/actions_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/actions_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,25 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class ActionsTest < Test::Unit::TestCase
+  def setup
+    @actions = ActiveScaffold::DataStructures::Actions.new(:a, 'b')
+  end
+
+  def test_initialization
+    assert @actions.include?('a')
+    assert @actions.include?(:b)
+    assert !@actions.include?(:c)
+  end
+
+  def test_exclude
+    assert @actions.include?('b')
+    @actions.exclude :b
+    assert !@actions.include?(:b)
+  end
+
+  def test_add
+    assert !@actions.include?(:c)
+    @actions.add 'c'
+    assert @actions.include?('c')
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/actions_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/association_column_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/association_column_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/association_column_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/association_column_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,41 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+require File.join(File.dirname(__FILE__), '../model_stub')
+
+class AssociationColumnTest < Test::Unit::TestCase
+  def setup
+    @association_column = ActiveScaffold::DataStructures::Column.new('other_model', ModelStub)
+  end
+
+  def test_virtuality
+    assert @association_column.association
+    assert !@association_column.virtual?
+  end
+
+  def test_sorting
+    # sorting on association columns is method-based
+    hash = {:method => "other_model.to_s"}
+    assert_equal hash, @association_column.sort
+  end
+
+  def test_searching
+    # right now, there's no intelligent searching on association columns
+    assert !@association_column.searchable?
+  end
+
+  def test_association
+    assert @association_column.association.is_a?(ActiveRecord::Reflection::AssociationReflection)
+  end
+
+  def test_includes
+    assert_equal [:other_model], @association_column.includes
+  end
+
+  def test_plurality
+    assert @association_column.singular_association?
+    assert !@association_column.plural_association?
+
+    plural_association_column = ActiveScaffold::DataStructures::Column.new('other_models', ModelStub)
+    assert plural_association_column.plural_association?
+    assert !plural_association_column.singular_association?
+  end
+end

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/association_column_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/column_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/column_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/column_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/column_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,160 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class ColumnTest < Test::Unit::TestCase
+  def setup
+    @column = ActiveScaffold::DataStructures::Column.new(:a, ModelStub)
+  end
+
+  def test_column
+    assert @column.column.is_a?(ActiveRecord::ConnectionAdapters::Column)
+    assert @column.column.name == 'a'
+  end
+
+  def test_basic_properties
+    # test that it was set during initialization
+    assert_equal @column.name, :a
+    # test that we can change it
+    @column.name = :b
+    assert_equal @column.name, :b
+
+    # label
+    @column.label = 'foo'
+    assert_equal 'foo', @column.label
+
+    # description
+    @column.description = 'hello world'
+    assert_equal 'hello world', @column.description
+
+    # css class
+    @column.css_class = 'style_me'
+    assert_equal 'style_me', @column.css_class
+
+    # required
+    assert !@column.required?, 'default is false'
+    @column.required = true
+    assert @column.required?, 'can be changed'
+
+    # calculation
+    assert !@column.calculation?, 'default is nil'
+    @column.calculate = :sum
+    assert @column.calculation?, 'can be changed'
+  end
+
+  def test_field
+    assert_equal 'model_stubs.a', @column.send(:field)
+  end
+
+  def test_table
+    assert_equal 'model_stubs', @column.send(:table)
+  end
+
+  def test_equality
+    # create a separate columns object, and make sure it's not ==
+    columns = ActiveScaffold::DataStructures::Columns.new(ModelStub, :a, :b)
+    assert columns != @column
+
+    # create a separate action_columns object, and make sure it's not ==
+    columns = ActiveScaffold::DataStructures::ActionColumns.new(:a, :b)
+    assert columns != @column
+
+    # identity
+    assert @column == @column
+
+    # string comparison
+    assert @column == 'a'
+    assert @column != 'fake'
+
+    # symbol comparison
+    assert @column == :a
+    assert @column != :fake
+
+    # comparison with different object of same type
+    column2 = ActiveScaffold::DataStructures::Column.new(:fake, ModelStub)
+    assert @column != column2
+    column2.name = 'a'
+    assert @column == column2
+
+    # special comparisons
+    assert @column != nil
+    assert @column != ''
+    assert @column != 0
+  end
+
+  def test_searchable
+    @column.search_sql = nil
+    assert !@column.searchable?
+    @column.search_sql = true
+    assert @column.searchable?
+  end
+
+  def test_sortable
+    @column.sort = nil
+    assert !@column.sortable?
+    @column.sort = true
+    assert @column.sortable?
+  end
+
+  def test_custom_search
+    @column.search_sql = true
+    assert_equal 'model_stubs.a', @column.search_sql
+    @column.search_sql = 'foobar'
+    assert_equal 'foobar', @column.search_sql
+    assert @column.searchable?
+  end
+
+  def test_custom_sort
+    @column.sort = true
+    hash = {:sql => 'model_stubs.a'}
+    assert_equal hash, @column.sort
+    @column.sort_by :sql => 'foobar'
+    hash = {:sql => 'foobar'}
+    assert_equal hash, @column.sort
+
+    some_proc = proc {'foobar'}
+    @column.sort_by :method => some_proc
+    hash = {:method => some_proc}
+    assert_equal hash, @column.sort
+    assert @column.sortable?
+  end
+
+  def test_custom_sort__should_assert_keys
+    assert_raise(ArgumentError) { @column.sort_by :proc => "invalid config"  }
+    assert_raise(ArgumentError) { @column.sort={:proc => "invalid config" } }
+    assert_nothing_raised(ArgumentError) {@column.sort_by :method => "method"  }
+    assert_nothing_raised(ArgumentError) {@column.sort_by :sql => "method"  }
+  end
+  
+  def test_config_block
+    @column.configure do |config|
+      # we can use the config object
+      config.name = 'foo'
+      # or not
+      self.label = 'hello'
+    end
+
+    assert_equal 'foo', @column.name
+    assert_equal 'hello', @column.label
+  end
+
+  def test_action_link
+    link = ActiveScaffold::DataStructures::ActionLink.new('foo/bar')
+    @column.set_link link
+    assert_equal link, @column.link
+
+    @column.set_link 'hello_world'
+    assert_equal 'hello_world', @column.link.action
+    assert_equal @column.label, @column.link.label
+  end
+
+  def test_includes
+    assert_equal [], @column.includes
+    
+    # make sure that when a non-array comes in, an array comes out
+    @column.includes = :column_name
+    assert_equal([:column_name], @column.includes)
+
+    # make sure that when a non-array comes in, an array comes out
+    @column.includes = [:column_name]
+    assert_equal([:column_name], @column.includes)
+  end
+end

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/column_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/columns_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/columns_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/columns_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/columns_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,69 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+# require 'test/model_stub'
+
+class ColumnsTest < Test::Unit::TestCase
+  def setup
+    @columns = ActiveScaffold::DataStructures::Columns.new(ModelStub, :a, :b)
+  end
+
+  def test_initialization
+    assert_equal ModelStub, @columns.active_record_class
+
+    assert @columns.include?('a'), 'checking via string'
+    assert @columns.include?(:b), 'checking via symbol'
+    assert !@columns.include?(:c)
+  end
+
+  def test_add
+    assert !@columns.include?(:c)
+    @columns.add 'c'
+    assert @columns.include?('c')
+
+    # test the alias
+    assert !@columns.include?(:d)
+    @columns << :d
+    assert @columns.include?(:d)
+
+    # try adding an array of columns
+    assert !@columns.include?(:f)
+    @columns.add [:f, :g]
+    assert @columns.include?(:f)
+    assert @columns.include?(:g)
+  end
+
+  def test_finders
+    # test some basic assumptions before testing the finders
+    assert @columns.include?(:a)
+    assert @columns[:a].is_a?(ActiveScaffold::DataStructures::Column)
+
+    # test the single finders
+    assert @columns.find_by_name(:a).name == :a
+    assert @columns[:b].name == :b
+
+    # test the collection finders
+    found = @columns.find_by_names(:a, :b)
+    assert found.any? {|c| c.name == :a}
+    assert found.any? {|c| c.name == :b}
+  end
+
+  def test_each
+    @columns.each do |column|
+      assert [:a, :b].include?(column.name)
+    end
+  end
+
+  def test_block_config
+    assert !@columns.include?(:d)
+    assert !@columns.include?(:c)
+
+    @columns.configure do |config|
+      # test that we can use the config object
+      config << :d
+      # but test that we don't have to
+      add 'c'
+    end
+
+    assert @columns.include?(:d)
+    assert @columns.include?(:c)
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/columns_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/error_message_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/error_message_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/error_message_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/error_message_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,28 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class ErrorMessageTest < Test::Unit::TestCase
+  def setup
+    @error = ActiveScaffold::DataStructures::ErrorMessage.new 'foo'
+  end
+
+  def test_attributes
+    assert @error.public_attributes.has_key?(:error)
+    assert_equal 'foo', @error.public_attributes[:error]
+  end
+
+  def test_xml
+    xml = Hash.from_xml(@error.to_xml)
+    assert xml.has_key?('errors')
+    assert xml['errors'].has_key?('error')
+    assert_equal 'foo', xml['errors']['error']
+  end
+
+  def test_yaml
+    yml = nil
+    assert_nothing_raised do
+      yml = YAML.load(@error.to_yaml)
+    end
+    assert yml.has_key?(:error)
+    assert_equal 'foo', yml[:error]
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/error_message_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/set_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/set_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/set_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/set_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,86 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+# require 'test/model_stub'
+
+class SetTest < Test::Unit::TestCase
+  def setup
+    @items = ActiveScaffold::DataStructures::Set.new(:a, :b)
+  end
+
+  def test_initialization
+    assert @items.include?(:a)
+    assert @items.include?(:b)
+    assert !@items.include?(:c)
+  end
+
+  def test_exclude
+    # exclude with a symbol
+    assert @items.include?(:b)
+    @items.exclude :b
+    assert !@items.include?(:b)
+
+    # exclude with a string
+    assert @items.include?(:a)
+    @items.exclude 'a'
+    assert !@items.include?(:a)
+  end
+
+  def test_exclude_array
+    # exclude with a symbol
+    assert @items.include?(:b)
+    @items.exclude [:a, :b]
+    assert !@items.include?(:b)
+    assert !@items.include?(:a)
+  end
+
+  def test_remove
+    assert @items.include?(:a)
+    @items.remove 'a'
+    assert !@items.include?(:a)
+  end
+
+  def test_add
+    # try adding a simple column using a string
+    assert !@items.include?(:c)
+    @items.add 'c'
+    assert @items.include?(:c)
+
+    # try adding a simple column using a symbol
+    assert !@items.include?(:d)
+    @items.add :d
+    assert @items.include?(:d)
+
+    # test that << also adds
+    assert !@items.include?(:e)
+    @items << "e"
+    assert @items.include?(:e)
+
+    # try adding an array of columns
+    assert !@items.include?(:f)
+    @items.add [:f, :g]
+    assert @items.include?(:f)
+    assert @items.include?(:g)
+
+  end
+
+  def test_length
+    assert_equal 2, @items.length
+  end
+
+  def test_block_config
+    @items.configure do |config|
+      # we may use the config argument
+      config.add :c
+      # or we may not
+      exclude :b
+    end
+
+    assert @items.include?(:c)
+    assert !@items.include?(:b)
+  end
+
+  def test_include
+    assert @items.include?(:a)
+    assert @items.include?(:b)
+    assert !@items.include?(:d)
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/set_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/sorting_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/sorting_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/sorting_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/sorting_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,96 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+# require 'test/model_stub'
+
+class SortingTest < Test::Unit::TestCase
+  def setup
+    @columns = ActiveScaffold::DataStructures::Columns.new(ModelStub, :a, :b, :c, :d)
+    @sorting = ActiveScaffold::DataStructures::Sorting.new(@columns)
+  end
+
+  def test_add
+    @sorting.add :a, 'ASC'
+    # test adding by symbol
+    assert @sorting.sorts_on?(:a)
+    # test adding an uppercase string direction
+    assert_equal 'ASC', @sorting.direction_of(:a)
+
+    @sorting.add 'b', :ASC
+    # test adding by string
+    assert @sorting.sorts_on?(:b)
+    # test adding an uppercase symbol direction
+    assert_equal 'ASC', @sorting.direction_of(:b)
+
+    @sorting.add @columns[:c], 'desc'
+    # test adding by object
+    assert @sorting.sorts_on?(:c)
+    # test adding a lowercase string direction
+    assert_equal 'DESC', @sorting.direction_of(:c)
+
+    @sorting << [:d, :desc]
+    # testing adding with the alias
+    assert @sorting.sorts_on?(:d)
+    assert_equal 'DESC', @sorting.direction_of(:d)
+
+    @sorting.clear
+
+    # test adding without a direction (test default)
+    @sorting.add :a
+    assert_equal 'ASC', @sorting.direction_of(:a)
+
+    # test adding a bad column
+    assert_raises ArgumentError do
+      @sorting.add :foo
+    end
+
+    # test adding a bad direction
+    assert_raises ArgumentError do
+      @sorting.add :b, :FOO
+    end
+  end
+
+  def test_set
+    @sorting.add :a, 'ASC'
+    assert @sorting.sorts_on?(:a)
+
+    @sorting.set :b, 'DESC'
+    assert @sorting.instance_variable_get('@clauses').size == 1
+    assert !@sorting.sorts_on?(:a)
+    assert @sorting.sorts_on?(:b)
+    assert_equal 'DESC', @sorting.direction_of(:b)
+  end
+
+  def test_sorts_on
+    @sorting.add :a
+    @sorting.add :b
+
+    assert @sorting.sorts_on?(:a)
+    assert @sorting.sorts_on?(:b)
+    assert !@sorting.sorts_on?(:c)
+  end
+
+  def test_direction_of
+    @sorting.add :a, 'ASC'
+    @sorting.add :b, :DESC
+
+    assert_equal 'ASC', @sorting.direction_of(:a)
+    assert_equal 'DESC', @sorting.direction_of(:b)
+  end
+
+  def test_sorts_by_method
+    @columns[:a].sort_by :method => proc{0}
+
+    #test pure method sorting: true
+    @sorting.add :a
+    assert @sorting.sorts_by_method?
+
+    #test mixed sql/method sorting: raise error
+    assert_raise ArgumentError do
+      @sorting.add :b
+    end
+    
+    #test pure sql sorting: false
+    @sorting.clear
+    @sorting.add :b
+    assert !@sorting.sorts_by_method?
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/sorting_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/standard_column_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/standard_column_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/standard_column_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/standard_column_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,24 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+# require 'test/model_stub'
+
+class StandardColumnTest < Test::Unit::TestCase
+  def setup
+    @standard_column = ActiveScaffold::DataStructures::Column.new(ModelStub.columns.first.name, ModelStub)
+  end
+
+  def test_virtuality
+    assert @standard_column.column
+    assert !@standard_column.virtual?
+  end
+
+  def test_sorting
+    hash = {:sql => 'model_stubs.a'}
+    assert @standard_column.sortable?
+    assert_equal hash, @standard_column.sort # check default
+  end
+
+  def test_searching
+    assert @standard_column.searchable?
+    assert_equal 'model_stubs.a', @standard_column.search_sql # check default
+  end
+end

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/standard_column_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/virtual_column_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/virtual_column_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/virtual_column_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/virtual_column_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,23 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class VirtualColumnTest < Test::Unit::TestCase
+  def setup
+    @virtual_column = ActiveScaffold::DataStructures::Column.new(:fake, ModelStub)
+  end
+
+  def test_virtuality
+    assert !@virtual_column.column
+    assert !@virtual_column.association
+    assert @virtual_column.virtual?
+  end
+
+  def test_sorting
+    # right now, there's no intelligent sorting on virtual columns
+    assert !@virtual_column.sortable?
+  end
+
+  def test_searching
+    # right now, there's no intelligent searching on virtual columns
+    assert !@virtual_column.searchable?
+  end
+end

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/data_structures/virtual_column_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/extensions/active_record_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/extensions/active_record_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/extensions/active_record_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/extensions/active_record_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,45 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+#require 'test/model_stub'
+
+class ActiveRecordTest < Test::Unit::TestCase
+  def setup
+    @record = ModelStub.new
+  end
+
+  def test_to_label
+    # without anything defined, it'll use the to_s method (e.g. #<ModelStub:0xb7379300>)
+    assert_match /^#<[a-z]+:0x[0-9a-f]+>$/i, @record.to_label
+
+    class << @record
+      def to_s
+        'to_s'
+      end
+    end
+
+    assert_equal 'to_s', @record.to_label
+
+    class << @record
+      def title
+        'title'
+      end
+    end
+
+    assert_equal 'title', @record.to_label
+
+    class << @record
+      def label
+        'label'
+      end
+    end
+
+    assert_equal 'label', @record.to_label
+
+    class << @record
+      def name
+        'name'
+      end
+    end
+
+    assert_equal 'name', @record.to_label
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/extensions/active_record_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/extensions/array.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/extensions/array.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/extensions/array.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/extensions/array.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,12 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class ArrayTest < Test::Unit::TestCase
+  def test_after
+    @sequence = ['a', 'b', 'c']
+
+    assert_equal 'b', @sequence.after('a')
+    assert_equal 'c', @sequence.after('b')
+    assert_equal 'a', @sequence.after('c')
+    assert_equal nil, @sequence.after('d')
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/extensions/array.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,154 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class PermissionModel < ActiveRecord::Base
+  def self.columns; [] end
+
+  def authorized_for_read?; true; end
+  def authorized_for_update?; false; end
+  #def authorized_for_create?; end
+
+  def a1_authorized?; true; end
+  def a2_authorized?; false; end
+  #def a3_authorized?; end
+
+  def b1_authorized?; true; end
+  def b2_authorized?; false; end
+  #def b3_authorized?; end
+
+  def c1_authorized?; true; end
+  def c2_authorized?; false; end
+  #def c3_authorized?; end
+
+  def a3_authorized_for_create?; true; end
+  def b3_authorized_for_create?; false; end
+  #def c3_authorized_for_create?; end
+  def a2_authorized_for_create?; true; end
+  def b2_authorized_for_create?; false; end
+  #def c2_authorized_for_create?; end
+  def a1_authorized_for_create?; true; end
+  def b1_authorized_for_create?; false; end
+  #def c1_authorized_for_create?; end
+
+  def a3_authorized_for_read?; true; end
+  def b3_authorized_for_read?; false; end
+  #def c3_authorized_for_read?; end
+  def a2_authorized_for_read?; true; end
+  def b2_authorized_for_read?; false; end
+  #def c2_authorized_for_read?; end
+  def a1_authorized_for_read?; true; end
+  def b1_authorized_for_read?; false; end
+  #def c1_authorized_for_read?; end
+
+  def a3_authorized_for_update?; true; end
+  def b3_authorized_for_update?; false; end
+  #def c3_authorized_for_update?; end
+  def a2_authorized_for_update?; true; end
+  def b2_authorized_for_update?; false; end
+  #def c2_authorized_for_update?; end
+  def a1_authorized_for_update?; true; end
+  def b1_authorized_for_update?; false; end
+  #def c1_authorized_for_update?; end
+end
+
+class ActiveRecordPermissionsTest < Test::Unit::TestCase
+  def setup
+    @model = PermissionModel.new
+  end
+
+  # Combinations Legend:
+  #   columns are: action method, column method, action/column method
+  #   symbols are: is (a)bsent, returns (f)alse, returns (t)rue, or n/a (_)
+  def test_method_combinations_with_default_true
+    ActiveRecordPermissions.default_permission = true
+
+    pass(@model.authorized_for?(:column => :a3), '_a_')
+    fail(@model.authorized_for?(:column => :a2), '_f_')
+    pass(@model.authorized_for?(:column => :a1), '_t_')
+
+    pass(@model.authorized_for?(:action => :create), 'a__')
+    fail(@model.authorized_for?(:action => :update), 'f__')
+    pass(@model.authorized_for?(:action => :read), 't__')
+
+    pass(@model.authorized_for?(:action => :create, :column => :c3), 'aaa')
+    fail(@model.authorized_for?(:action => :create, :column => :b3), 'aaf')
+    pass(@model.authorized_for?(:action => :create, :column => :a3), 'aat')
+    fail(@model.authorized_for?(:action => :create, :column => :c2), 'afa')
+    fail(@model.authorized_for?(:action => :create, :column => :b2), 'aff')
+    fail(@model.authorized_for?(:action => :create, :column => :a2), 'aft')
+    pass(@model.authorized_for?(:action => :create, :column => :c1), 'ata')
+    fail(@model.authorized_for?(:action => :create, :column => :b1), 'atf')
+    pass(@model.authorized_for?(:action => :create, :column => :a1), 'att')
+
+    fail(@model.authorized_for?(:action => :update, :column => :c3), 'faa')
+    fail(@model.authorized_for?(:action => :update, :column => :b3), 'faf')
+    fail(@model.authorized_for?(:action => :update, :column => :a3), 'fat')
+    fail(@model.authorized_for?(:action => :update, :column => :c2), 'ffa')
+    fail(@model.authorized_for?(:action => :update, :column => :b2), 'fff')
+    fail(@model.authorized_for?(:action => :update, :column => :a2), 'fft')
+    fail(@model.authorized_for?(:action => :update, :column => :c1), 'fta')
+    fail(@model.authorized_for?(:action => :update, :column => :b1), 'ftf')
+    fail(@model.authorized_for?(:action => :update, :column => :a1), 'ftt')
+
+    pass(@model.authorized_for?(:action => :read, :column => :c3), 'taa')
+    fail(@model.authorized_for?(:action => :read, :column => :b3), 'taf')
+    pass(@model.authorized_for?(:action => :read, :column => :a3), 'tat')
+    fail(@model.authorized_for?(:action => :read, :column => :c2), 'tfa')
+    fail(@model.authorized_for?(:action => :read, :column => :b2), 'tff')
+    fail(@model.authorized_for?(:action => :read, :column => :a2), 'tft')
+    pass(@model.authorized_for?(:action => :read, :column => :c1), 'tta')
+    fail(@model.authorized_for?(:action => :read, :column => :b1), 'ttf')
+    pass(@model.authorized_for?(:action => :read, :column => :a1), 'ttt')
+  end
+
+  def test_method_combinations_with_default_false
+    ActiveRecordPermissions.default_permission = false
+
+    fail(@model.authorized_for?(:column => :a3), '_a_')
+    fail(@model.authorized_for?(:column => :a2), '_f_')
+    pass(@model.authorized_for?(:column => :a1), '_t_')
+
+    fail(@model.authorized_for?(:action => :create), 'a__')
+    fail(@model.authorized_for?(:action => :update), 'f__')
+    pass(@model.authorized_for?(:action => :read), 't__')
+
+    fail(@model.authorized_for?(:action => :create, :column => :c3), 'aaa')
+    fail(@model.authorized_for?(:action => :create, :column => :b3), 'aaf')
+    pass(@model.authorized_for?(:action => :create, :column => :a3), 'aat')
+    fail(@model.authorized_for?(:action => :create, :column => :c2), 'afa')
+    fail(@model.authorized_for?(:action => :create, :column => :b2), 'aff')
+    fail(@model.authorized_for?(:action => :create, :column => :a2), 'aft')
+    pass(@model.authorized_for?(:action => :create, :column => :c1), 'ata')
+    fail(@model.authorized_for?(:action => :create, :column => :b1), 'atf')
+    pass(@model.authorized_for?(:action => :create, :column => :a1), 'att')
+
+    fail(@model.authorized_for?(:action => :update, :column => :c3), 'faa')
+    fail(@model.authorized_for?(:action => :update, :column => :b3), 'faf')
+    fail(@model.authorized_for?(:action => :update, :column => :a3), 'fat')
+    fail(@model.authorized_for?(:action => :update, :column => :c2), 'ffa')
+    fail(@model.authorized_for?(:action => :update, :column => :b2), 'fff')
+    fail(@model.authorized_for?(:action => :update, :column => :a2), 'fft')
+    fail(@model.authorized_for?(:action => :update, :column => :c1), 'fta')
+    fail(@model.authorized_for?(:action => :update, :column => :b1), 'ftf')
+    fail(@model.authorized_for?(:action => :update, :column => :a1), 'ftt')
+
+    pass(@model.authorized_for?(:action => :read, :column => :c3), 'taa')
+    fail(@model.authorized_for?(:action => :read, :column => :b3), 'taf')
+    pass(@model.authorized_for?(:action => :read, :column => :a3), 'tat')
+    fail(@model.authorized_for?(:action => :read, :column => :c2), 'tfa')
+    fail(@model.authorized_for?(:action => :read, :column => :b2), 'tff')
+    fail(@model.authorized_for?(:action => :read, :column => :a2), 'tft')
+    pass(@model.authorized_for?(:action => :read, :column => :c1), 'tta')
+    fail(@model.authorized_for?(:action => :read, :column => :b1), 'ttf')
+    pass(@model.authorized_for?(:action => :read, :column => :a1), 'ttt')
+  end
+
+  private
+
+  def pass(value, message = nil)
+    assert value, "#{message} should pass"
+  end
+
+  def fail(value, message = nil)
+    assert !value, "#{message} should fail"
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/configurable_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/configurable_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/configurable_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/configurable_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,96 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class ConfigurableClass
+  FOO = 'bar'
+  def foo; FOO end
+  def self.foo; FOO end
+end
+
+
+class ConfigurableTest < Test::Unit::TestCase
+  ##
+  ## constants and methods for tests to check against
+  ##
+  def hello; 'world' end
+  HELLO = 'world'
+
+  def test_instance_configuration
+    ConfigurableClass.send :include, ActiveScaffold::Configurable
+
+    configurable_class = ConfigurableClass.new
+
+    ##
+    ## sanity checks
+    ##
+    # make sure the configure method is available
+    assert ConfigurableClass.respond_to?(:configure)
+    # make sure real functions still work
+    assert_equal 'bar', configurable_class.foo
+    # make sure other functions still don't work
+    assert_raise NoMethodError do
+      configurable_class.i_do_not_exist
+    end
+
+    ##
+    ## test normal block behaviors
+    ##
+    # functions
+    assert_equal hello, configurable_class.configure {hello}
+    # variables
+    assert_equal configurable_class, configurable_class.configure {configurable_class}
+    # constants
+    assert_equal HELLO, configurable_class.configure {HELLO}
+
+    ##
+    ## test extra "localized" block behavior
+    ##
+    # functions
+    assert_equal configurable_class.foo, configurable_class.configure {foo}
+    # constants - not working
+#    assert_equal configurable_class.FOO, configurable_class.configure {FOO}
+
+  end
+
+  def test_class_configuration
+    ConfigurableClass.send :extend, ActiveScaffold::Configurable
+
+    ##
+    ## sanity checks
+    ##
+    # make sure the configure method is available
+    assert ConfigurableClass.respond_to?(:configure)
+    # make sure real functions still work
+    assert_equal 'bar', ConfigurableClass.foo
+    # make sure other functions still don't work
+    assert_raise NoMethodError do
+      ConfigurableClass.i_do_not_exist
+    end
+
+    ##
+    ## test normal block behaviors
+    ##
+    # functions
+    assert_equal hello, ConfigurableClass.configure {hello}
+    # variables
+    assert_equal ConfigurableClass, ConfigurableClass.configure {ConfigurableClass}
+    # constants
+    assert_equal HELLO, ConfigurableClass.configure {HELLO}
+
+    ##
+    ## test extra "localized" block behavior
+    ##
+    # functions
+    assert_equal ConfigurableClass.foo, ConfigurableClass.configure {foo}
+    # constants - not working
+#    assert_equal ConfigurableClass.FOO, ConfigurableClass.configure {FOO}
+  end
+
+  def test_arity
+    ConfigurableClass.send :extend, ActiveScaffold::Configurable
+
+    # this is the main style
+    assert_equal 'foo', ConfigurableClass.configure {'foo'}
+    # but we want to let people accept the configurable class as the first argument, too
+    assert_equal 'bar', ConfigurableClass.configure {|a| a.foo}
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/configurable_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/constraints_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/constraints_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/constraints_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/constraints_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,177 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+module ModelStubs
+  class ModelStub < ActiveRecord::Base
+    abstract_class = true
+    def self.columns; [ActiveRecord::ConnectionAdapters::Column.new('foo', '')] end
+    def self.table_name
+      to_s.split('::').last.underscore.pluralize
+    end
+  end
+
+  ##
+  ## Standard associations
+  ##
+
+  class Address < ModelStub
+    belongs_to :addressable, :polymorphic => true
+  end
+
+  class User < ModelStub
+    has_and_belongs_to_many :roles
+    has_one :subscription
+    has_one :address, :as => :addressable
+  end
+
+  class Service < ModelStub
+    has_many :subscriptions
+    has_many :users, :through => :subscriptions
+  end
+
+  class Subscription < ModelStub
+    belongs_to :service
+    belongs_to :user
+  end
+
+  class Role < ModelStub
+    has_and_belongs_to_many :users
+  end
+
+  ##
+  ## These versions of the associations require extra configuration to work properly
+  ##
+
+  class OtherAddress < ModelStub
+    set_table_name 'addresses'
+    belongs_to :other_addressable, :polymorphic => true
+  end
+
+  class OtherUser < ModelStub
+    set_table_name 'users'
+    has_and_belongs_to_many :other_roles, :class_name => 'ModelStubs::OtherRole', :foreign_key => 'user_id', :association_foreign_key => 'role_id', :join_table => 'roles_users'
+    has_one :other_subscription, :class_name => 'ModelStubs::OtherSubscription', :foreign_key => 'user_id'
+    has_one :other_address, :as => :other_addressable, :class_name => 'ModelStubs::OtherAddress', :foreign_key => 'addressable_id'
+  end
+
+  class OtherService < ModelStub
+    set_table_name 'services'
+    has_many :other_subscriptions, :class_name => 'ModelStubs::OtherSubscription', :foreign_key => 'service_id'
+    has_many :other_users, :through => :subscriptions # :class_name and :foreign_key are ignored for :through
+  end
+
+  class OtherSubscription < ModelStub
+    set_table_name 'subscriptions'
+    belongs_to :other_service, :class_name => 'ModelStubs::OtherService', :foreign_key => 'service_id'
+    belongs_to :other_user, :class_name => 'ModelStubs::OtherUser', :foreign_key => 'user_id'
+  end
+
+  class OtherRole < ModelStub
+    set_table_name 'roles'
+    has_and_belongs_to_many :other_users, :class_name => 'ModelStubs::OtherUser', :foreign_key => 'role_id', :association_foreign_key => 'user_id', :join_table => 'roles_users'
+  end
+end
+
+class ConstraintsTestObject
+  # stub out what the mixin expects to find ...
+  def self.before_filter(*args); end
+  attr_accessor :active_scaffold_joins
+  attr_accessor :active_scaffold_habtm_joins
+  attr_accessor :active_scaffold_config
+  attr_accessor :params
+  def merge_conditions(old, new)
+    [old, new].compact.flatten
+  end
+
+  # mixin the constraint code
+  include ActiveScaffold::Constraints
+
+  # make the constraints read-write, instead of coming from the session
+  attr_accessor :active_scaffold_constraints
+
+  def initialize
+    @active_scaffold_joins = []
+    @active_scaffold_habtm_joins = []
+    @params = {}
+  end
+end
+
+class ConstraintsTest < Test::Unit::TestCase
+  def setup
+    @test_object = ConstraintsTestObject.new
+  end
+
+  def test_constraint_conditions_for_default_associations
+    @test_object.active_scaffold_config = config_for('user')
+    # has_one (vs belongs_to)
+    assert_constraint_condition({:subscription => 5}, ['subscriptions.id = ?', 5], 'find the user with subscription #5')
+    # habtm (vs habtm)
+    assert_constraint_condition({:roles => 4}, ['roles_users.role_id = ?', 4], 'find all users with role #4')
+    # has_one (vs polymorphic)
+    assert_constraint_condition({:address => 11}, ['addresses.id = ?', 11], 'find the user with address #11')
+    # reverse of a has_many :through
+    assert_constraint_condition({:subscription => {:service => 5}}, ['services.id = ?', 5], 'find all users subscribed to service #5')
+    assert(@test_object.active_scaffold_joins.include?({:subscription => :service}), 'multi-level association include')
+
+    @test_object.active_scaffold_config = config_for('subscription')
+    # belongs_to (vs has_one)
+    assert_constraint_condition({:user => 2}, ['subscriptions.user_id = ?', 2], 'find the subscription for user #2')
+    # belongs_to (vs has_many)
+    assert_constraint_condition({:service => 1}, ['subscriptions.service_id = ?', 1], 'find all subscriptions for service #1')
+
+    @test_object.active_scaffold_config = config_for('service')
+    # has_many (vs belongs_to)
+    assert_constraint_condition({:subscriptions => 10}, ['subscriptions.id = ?', 10], 'find the service with subscription #10')
+    # has_many :through (through has_many)
+    assert_constraint_condition({:users => 7}, ['users.id = ?', 7], 'find the service with user #7')
+
+    @test_object.active_scaffold_config = config_for('address')
+    # belongs_to :polymorphic => true
+    @test_object.params[:parent_model] = 'User'
+    assert_constraint_condition({:addressable => 14}, ['addresses.addressable_id = ?', 14, 'addresses.addressable_type = ?', 'User'], 'find all addresses for user #14')
+  end
+
+  def test_constraint_conditions_for_configured_associations
+    @test_object.active_scaffold_config = config_for('other_user')
+    # has_one (vs belongs_to)
+    assert_constraint_condition({:other_subscription => 5}, ['subscriptions.id = ?', 5], 'find the user with subscription #5')
+    # habtm (vs habtm)
+    assert_constraint_condition({:other_roles => 4}, ['roles_users.role_id = ?', 4], 'find all users with role #4')
+    # has_one (vs polymorphic)
+    assert_constraint_condition({:other_address => 11}, ['addresses.id = ?', 11], 'find the user with address #11')
+    # reverse of a has_many :through
+    assert_constraint_condition({:other_subscription => {:other_service => 5}}, ['services.id = ?', 5], 'find all users subscribed to service #5')
+
+    @test_object.active_scaffold_config = config_for('other_subscription')
+    # belongs_to (vs has_one)
+    assert_constraint_condition({:other_user => 2}, ['subscriptions.user_id = ?', 2], 'find the subscription for user #2')
+    # belongs_to (vs has_many)
+    assert_constraint_condition({:other_service => 1}, ['subscriptions.service_id = ?', 1], 'find all subscriptions for service #1')
+
+    @test_object.active_scaffold_config = config_for('other_service')
+    # has_many (vs belongs_to)
+    assert_constraint_condition({:other_subscriptions => 10}, ['subscriptions.id = ?', 10], 'find the service with subscription #10')
+    # has_many :through (through has_many)
+    assert_constraint_condition({:other_users => 7}, ['users.id = ?', 7], 'find the service with user #7')
+
+    @test_object.active_scaffold_config = config_for('other_address')
+    # belongs_to :polymorphic => true
+    @test_object.params[:parent_model] = 'OtherUser'
+    assert_constraint_condition({:other_addressable => 14}, ['addresses.other_addressable_id = ?', 14, 'addresses.other_addressable_type = ?', 'OtherUser'], 'find all addresses for user #14')
+  end
+
+  def test_constraint_conditions_for_normal_attributes
+    @test_object.active_scaffold_config = config_for('user')
+    assert_constraint_condition({'foo' => 'bar'}, ['users.foo = ?', 'bar'], 'normal column-based constraint')
+  end
+
+  protected
+
+  def assert_constraint_condition(constraint, condition, message = nil)
+    @test_object.active_scaffold_constraints = constraint
+    assert_equal condition, @test_object.send(:conditions_from_constraints), message
+  end
+
+  def config_for(klass)
+    ActiveScaffold::Config::Core.new("model_stubs/#{klass.to_s.underscore.downcase}")
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/constraints_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/finder_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/finder_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/finder_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/finder_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,70 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+# require 'test/model_stub'
+
+class ClassWithFinder
+  include ActiveScaffold::Finder
+end
+
+class FinderTest < Test::Unit::TestCase
+  def setup
+    @klass = ClassWithFinder.new
+  end
+
+  def test_create_conditions_for_columns
+    columns = [
+      ActiveScaffold::DataStructures::Column.new(:a, ModelStub),
+      ActiveScaffold::DataStructures::Column.new(:b, ModelStub)
+    ]
+    tokens = [
+      'foo',
+      'bar'
+    ]
+
+    expected_conditions = [
+			'(LOWER(model_stubs.a) LIKE ? OR LOWER(model_stubs.b) LIKE ?) AND (LOWER(model_stubs.a) LIKE ? OR LOWER(model_stubs.b) LIKE ?)',
+		  '%foo%', '%foo%', '%bar%', '%bar%'
+		]
+    assert_equal expected_conditions, ClassWithFinder.create_conditions_for_columns(tokens, columns)
+
+    expected_conditions = [
+      '(LOWER(model_stubs.a) LIKE ? OR LOWER(model_stubs.b) LIKE ?)',
+      '%foo%', '%foo%'
+    ]
+    assert_equal expected_conditions, ActiveScaffold::Finder.create_conditions_for_columns('foo', columns)
+
+    assert_equal nil, ActiveScaffold::Finder.create_conditions_for_columns('foo', [])
+  end
+
+  def test_build_order_clause
+    columns = ActiveScaffold::DataStructures::Columns.new(ModelStub, :a, :b, :c, :d)
+    sorting = ActiveScaffold::DataStructures::Sorting.new(columns)
+
+    assert @klass.send(:build_order_clause, nil).nil?
+    assert @klass.send(:build_order_clause, sorting).nil?
+
+    sorting << [:a, 'desc']
+    sorting << [:b, 'asc']
+
+    assert_equal 'model_stubs.a DESC, model_stubs.b ASC', @klass.send(:build_order_clause, sorting)
+  end
+
+  def test_method_sorting
+    column = ActiveScaffold::DataStructures::Column.new('a', ModelStub)
+    column.sort_by :method => proc{self}
+
+    collection = [16000, 2853, 98765, 6188, 4]
+    assert_equal collection.sort, @klass.send(:sort_collection_by_column, collection, column, 'asc')
+    assert_equal collection.sort.reverse, @klass.send(:sort_collection_by_column, collection, column, 'desc')
+
+    collection = ['a', nil, 'b']
+    result = nil
+    assert_nothing_raised do
+      result = @klass.send(:sort_collection_by_column, collection, column, 'asc')
+    end
+    assert_equal [nil, 'a', 'b'], result
+
+    column.sort_by :method => 'self'
+    collection = [3, 1, 2]
+    assert_equal collection.sort, @klass.send(:sort_collection_by_column, collection, column, 'asc')
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/finder_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/lang_test.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/lang_test.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/lang_test.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/lang_test.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,12 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class LocalizationTest < Test::Unit::TestCase
+
+  def test_localization
+    ##
+    ## test no language specified
+    ##
+    assert_equal "Dutch", as_(:dutch)
+    assert_equal "Create Test", as_(:create_model, :model => 'Test')
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/misc/lang_test.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/model_stub.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/model_stub.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/model_stub.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/model_stub.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,39 @@
+class ModelStub < ActiveRecord::Base
+  abstract_class = true
+  has_one :other_model, :class_name => 'ModelStub'
+  has_many :other_models, :class_name => 'ModelStub'
+  
+  cattr_accessor :stubbed_columns
+  self.stubbed_columns = [:a, :b, :c, :d, :id]
+  attr_accessor *self.stubbed_columns
+
+  def other_model=(val)
+    @other_model = val
+  end
+  def other_model
+    @other_model || nil
+  end
+
+  def other_models=(val)
+    @other_models = val
+  end
+  def other_models
+    @other_models || []
+  end
+
+  def self.columns
+    @columns ||= self.stubbed_columns.map{|c| ActiveRecord::ConnectionAdapters::Column.new(c.to_s, '') }
+  end
+
+  def self.columns_hash
+    @columns_hash ||= columns.inject({}) { |hash, column| hash[column.name.to_s] = column; hash }
+  end
+
+  # column-level security methods, used for testing
+  def self.a_authorized_for_bar?(user)
+    true
+  end
+  def self.b_authorized?(user)
+    false
+  end
+end

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/model_stub.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/run_all.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/run_all.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/run_all.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/run_all.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,8 @@
+test_folders = %w[bridges config data_structures extensions misc]
+
+all_tests = test_folders.inject([]) {|output, folder|
+  output + Dir[File.join(File.dirname(__FILE__), "#{folder}/**/*.rb")] 
+}
+all_tests.each{|filename|
+  require filename
+}
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/run_all.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/test_helper.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/test_helper.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/test_helper.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/test_helper.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,13 @@
+require 'test/unit'
+
+require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
+
+for file in %w[model_stub const_mocker]
+  require File.join(File.dirname(__FILE__), file)
+end
+
+ModelStub.connection.instance_eval do
+  def quote_column_name(name)
+    name
+  end
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/test/test_helper.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/uninstall.rb
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/active_scaffold/uninstall.rb?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/active_scaffold/uninstall.rb (added)
+++ labs/consite/trunk/conferences/vendor/plugins/active_scaffold/uninstall.rb Sun Aug 30 16:30:26 2009
@@ -0,0 +1,12 @@
+##
+## Delete public asset files
+##
+
+require 'fileutils'
+
+directory = File.dirname(__FILE__)
+
+[ :stylesheets, :javascripts, :images].each do |asset_type|
+  path = File.join(directory, "../../../public/#{asset_type}/active_scaffold")
+  FileUtils.rm_r(path)
+end
\ No newline at end of file

Propchange: labs/consite/trunk/conferences/vendor/plugins/active_scaffold/uninstall.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: labs/consite/trunk/conferences/vendor/plugins/file_column/.git/HEAD
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/file_column/.git/HEAD?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/file_column/.git/HEAD (added)
+++ labs/consite/trunk/conferences/vendor/plugins/file_column/.git/HEAD Sun Aug 30 16:30:26 2009
@@ -0,0 +1 @@
+ref: refs/heads/master

Added: labs/consite/trunk/conferences/vendor/plugins/file_column/.git/config
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/file_column/.git/config?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/file_column/.git/config (added)
+++ labs/consite/trunk/conferences/vendor/plugins/file_column/.git/config Sun Aug 30 16:30:26 2009
@@ -0,0 +1,11 @@
+[core]
+	repositoryformatversion = 0
+	filemode = true
+	bare = false
+	logallrefupdates = true
+[remote "origin"]
+	url = git://github.com/kch/file_column.git
+	fetch = +refs/heads/*:refs/remotes/origin/*
+[branch "master"]
+	remote = origin
+	merge = refs/heads/master

Added: labs/consite/trunk/conferences/vendor/plugins/file_column/.git/description
URL: http://svn.apache.org/viewvc/labs/consite/trunk/conferences/vendor/plugins/file_column/.git/description?rev=809371&view=auto
==============================================================================
--- labs/consite/trunk/conferences/vendor/plugins/file_column/.git/description (added)
+++ labs/consite/trunk/conferences/vendor/plugins/file_column/.git/description Sun Aug 30 16:30:26 2009
@@ -0,0 +1 @@
+Unnamed repository; edit this file to name it for gitweb.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org