<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/models/list.rb</filename>
    </added>
    <added>
      <filename>test/fixtures/lists.yml</filename>
    </added>
    <added>
      <filename>test/unit/list_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,7 @@
 class ListitemsController &lt; ApplicationController
 	before_filter :activation_required,
 		:only=&gt;[:new, :create, :edit, :update, :destroy]
+	before_filter :setup
 	
 	def new
 		pre_new
@@ -13,7 +14,7 @@ class ListitemsController &lt; ApplicationController
 		pre_new
 		@success = @listitem.save
 		if @success
-			message = &quot;The #{@listitem.item.class.name} was added to your &#8220;#{@listitem.title}&#8221; list.&quot;
+			message = &quot;The #{@listitem.item.class.name} was added to your &#8220;#{@list.title}&#8221; list.&quot;
 			respond_to do |format|
 				format.html do
 					flash[:notice] = message
@@ -23,7 +24,7 @@ class ListitemsController &lt; ApplicationController
 				format.xml { render :xml=&gt;@listitem.to_xml }
 			end
 		else
-			flash.now[:error] = &quot;Unable to add the #{@listitem.item.class.name} to your &#8220;#{@listitem.title}&#8221; list.&quot;
+			flash.now[:error] = &quot;Unable to add the #{@listitem.item.class.name} to your &#8220;#{@list.title}&#8221; list.&quot;
 			respond_to do |format|
 				format.html { render :action=&gt;'new' }
 				format.js {}
@@ -45,14 +46,14 @@ class ListitemsController &lt; ApplicationController
 	
 	def destroy
 		@listitem = Listitem.find(params[:id])
-		if @listitem.user == current_user or current_user.admin?
+		if @listitem.list.user == current_user or current_user.admin?
 			@listitem.destroy
 			@success = true
 		end
 		respond_to do |format|
 			format.html do
 				if @success
-					flash[:notice] = &quot;The #{@listitem.item.class.name} has been removed from your &#8220;#{@listitem.title}&#8221; list.&quot;
+					flash[:notice] = &quot;The #{@listitem.item.class.name} has been removed from your &#8220;#{@list.title}&#8221; list.&quot;
 					redirect_to lists_path
 				else
 					flash[:error] = 'That is not a list you have access to modify.'
@@ -61,8 +62,8 @@ class ListitemsController &lt; ApplicationController
 			end
 			format.js do
 				if @success
-					@listitem_count = Listitem.count_user_list(current_user, @listitem.title)
-					flash.now[:notice] = &quot;The #{@listitem.item.class.name} has been removed from your &#8220;#{@listitem.title}&#8221; list.&quot;
+					@listitem_count = @list.listitems.count
+					flash.now[:notice] = &quot;The #{@listitem.item.class.name} has been removed from your &#8220;#{@list.title}&#8221; list.&quot;
 				else
 					flash.now[:error] = 'That is not a list you have access to modify.'
 				end
@@ -73,15 +74,28 @@ class ListitemsController &lt; ApplicationController
 		missing
 	end
 	
+	
 	protected
 	
+	def setup
+		if params[:list_id].blank?
+			@list = List.find_default_list_for_user(current_user)
+		else
+			@list = List.find(params[:list_id]) rescue ActiveRecord::RecordNotFound
+		end
+		if @list.nil?
+			@list = List.new(:title=&gt;'')
+			@list.user = current_user
+		end
+		@section = 'lists'
+		@page_title = @list.nil? ? '' : &quot;#{@list.title}: &quot;
+	end
+	
 	def pre_new
-		@listitem = Listitem.new(params[:listitem])
+		@listitem = @list.listitems.new(params[:listitem])
 		@listitem.item_type ||= params[:item_type]
 		@listitem.item_id ||= params[:item_id]
-		@listitem.title ||= params[:title]
-		@listitem.user = current_user
-		@page_title = 'Add item to your list'
+		@page_title += 'Add item to your list'
 		if @listitem.item.nil?
 			@err_msg = 'No item was specified &#8212; nothing to add to a list.'
 			raise Wayground::NilObject</diff>
      <filename>app/controllers/listitems_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,17 +3,18 @@ class ListsController &lt; ApplicationController
 	
 	def index
 		@page_title = 'Your Lists'
-		@lists = Listitem.find_lists_for_user(current_user)
+		@lists = List.find(:all, :conditions=&gt;List.search_conditions(:user=&gt;current_user),
+			:order=&gt;List.default_order, :include=&gt;List.default_include)
 	end
 
 	def show
-		@page_title = &quot;Your List: #{h(params[:id])}&quot;
-		@listitems = Listitem.find(:all, :order=&gt;Listitem.default_order,
-			:conditions=&gt;Listitem.search_conditions(:title=&gt;params[:id]),
-			:include=&gt;Listitem.default_include)
-		if !@listitems or @listitems.size &lt; 1
+		@list = List.find(params[:id], :conditions=&gt;List.search_conditions({:u=&gt;current_user}))
+		@page_title = (@list.user == current_user ? 'Your' : &quot;#{@list.user.title}&#8217;s&quot;) + &quot; List: #{@list.title}&quot;
+		if @list.listitems.size &lt; 1
 			flash.now[:notice] = 'The list is empty.'
 		end
+	rescue ActiveRecord::RecordNotFound
+		missing
 	end
 	
 	# deletes all the rows in the listitems table that match the current_user and the list title (id)</diff>
      <filename>app/controllers/lists_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,42 +2,39 @@
 class Listitem &lt; ActiveRecord::Base
 	attr_accessible :item_id, :item_type, :title
 	
+	validates_presence_of :list
 	validates_presence_of :item
-	validates_presence_of :user
-	validates_format_of :title, :with=&gt;/\A([A-Za-z0-9]([A-Za-z0-9 \-]*[A-Za-z0-9])?)?\z/, :allow_nil=&gt;true,
-		:message=&gt;'can only use letters, numbers, spaces and dashes; and must start and end with letters or numbers'
-	# an item cannot be added more than once to a given user&#8217;s list
-	validates_uniqueness_of :title, :scope=&gt;[:user_id, :item_type, :item_id]
+	#validates_presence_of :user
+	# an item cannot be added more than once to a given list
+	validates_uniqueness_of :item_id, :scope=&gt;[:list_id, :item_type]
 	
 	# TODO: validate that the user has access to the item
 	
+	belongs_to :list
 	belongs_to :item, :polymorphic=&gt;true
-	belongs_to :user
+	#belongs_to :user
+	
 	
 	def self.default_include
 		nil # unfortunately, we can&#8217;t eager-load :item because it&#8217;s polymorphic
 	end
 	def self.default_order(p={})
 		(p[:recent].blank? ? '' : 'listitems.updated_at DESC, ') +
-			'listitems.created_at'
+			'listitems.position'
 	end
 	# Returns a conditions array for find.
 	# p is a hash of parameters:
-	# - :key is a search restriction key
-	# - :u is the current_user to use to determine access to private items.
-	# - :title is the list title to match
+	## - :key is a search restriction key
+	## - :u is the current_user to use to determine access to private items.
+	## - :title is the list title to match
 	# strs is a list of condition strings (with &#8216;?&#8217; for params) to be joined by &#8220;AND&#8221;
 	# vals is a list of condition values to be appended to the result array (matching &#8216;?&#8217; in the strs)
 	def self.search_conditions(p={}, strs=[], vals=[])
+		#if p[:u]
+		#	strs &lt;&lt; 'listitems.user_id = ?'
+		#	vals &lt;&lt; p[:u]
+		#end
 		# TODO: support keyword searching in a list of items
-		unless p[:title].blank?
-			strs &lt;&lt; 'listitems.title = ?'
-			vals &lt;&lt; p[:title]
-		end
-		if p[:u]
-			strs &lt;&lt; 'listitems.user_id = ?'
-			vals &lt;&lt; p[:u]
-		end
 		#unless p[:key].blank?
 		#	strs &lt;&lt; 'listitems.title LIKE ?'
 		#	vals &lt;&lt; &quot;%#{p[:key]}%&quot;
@@ -45,19 +42,20 @@ class Listitem &lt; ActiveRecord::Base
 		strs.size &gt; 0 ? [strs.join(' AND ')] + vals : nil
 	end
 	
-	def self.find_lists_for_user(u)
-		lists = find_by_sql(&quot;SELECT listitems.title FROM listitems &quot; +
-			&quot;WHERE listitems.user_id = #{u.id} &quot; +
-			&quot;GROUP BY listitems.title ORDER BY listitems.title&quot;)
+	
+	def before_save
+		if self.position.nil? or self.position == 0
+			autoset_position
+		end
 	end
 	
-	def self.count_user_list(u, title)
-		Listitem.count(:conditions=&gt;
-			['listitems.user_id = ? AND listitems.title = ?', u.id, title])
+	def autoset_position
+		last_item = list.listitems.find(:last, :order=&gt;'listitems.position')
+		self.position = last_item.position + 1
 	end
 	
 	# standard Wayground instance methods for displayable items
 	def css_class(name_prefix='')
-		&quot;#{name_prefix}list&quot;
+		self.item.css_class(name_prefix)
 	end
 end</diff>
      <filename>app/models/listitem.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,9 +2,9 @@ class CreateLists &lt; ActiveRecord::Migration
 	def self.up
 		create_table :lists, :force=&gt;true,
 		:options=&gt;'COMMENT=&quot;Allows users to save their own custom lists of items.&quot; ENGINE=InnoDB CHARSET=utf8' do |t|
-			t.belongs_to :user, :null=&gt;false
-			t.string :title
-			t.boolean :is_public, :default=&gt;false
+			t.belongs_to :user, :null=&gt;false # owner of the List
+			t.string :title, :null=&gt;false # name of the List
+			t.boolean :is_public, :null=&gt;false, :default=&gt;false # if false, only User (owner) can see it
 			t.timestamps
 		end
 		change_table :lists do |t|
@@ -13,15 +13,15 @@ class CreateLists &lt; ActiveRecord::Migration
 		
 		create_table :listitems, :force=&gt;true,
 		:options=&gt;'COMMENT=&quot;Items for custom lists.&quot; ENGINE=InnoDB CHARSET=utf8' do |t|
+			t.belongs_to :list, :null=&gt;false
 			t.belongs_to :item, :null=&gt;false, :polymorphic=&gt;true
-			t.belongs_to :user, :null=&gt;false
-			t.string :title
+			#t.belongs_to :user, :null=&gt;false # User who added this item to the List
+			t.integer :position, :null=&gt;false
 			t.timestamps
 		end
 		change_table :listitems do |t|
+			t.index [:list_id, :position], :name=&gt;'list'
 			t.index [:item_type, :item_id], :name=&gt;'item'
-			t.index [:user_id, :item_type, :item_id], :name=&gt;'user'
-			t.index [:user_id, :title, :item_type, :item_id], :name=&gt;'title', :unique=&gt;true
 		end
 	end
 </diff>
      <filename>db/migrate/012_create_lists.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,22 +1,21 @@
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 
 one:
+  list: one
   item: one (Event)
-  user: login
-  title: Test List
+  position: 1
 
 two:
+  list: two
   item: two (Page)
-  user: login
-  title: Test List
+  position: 1
 
 destroy_this:
-  item: one (Event)
-  user: regular
-  title: Destroy This
+  list: one
+  item: two (Event)
+  position: 2
 
 destroy_this2:
-  item: two (Page)
-  user: regular
-  title: Destroy This
-
+  list: two
+  item: one (Page)
+  position: 2</diff>
      <filename>test/fixtures/listitems.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 require 'test_helper'
 
 class ListitemsControllerTest &lt; ActionController::TestCase
-	fixtures :listitems, :users, :events, :pages, :weblinks
+	fixtures :lists, :listitems, :users, :events, :pages, :weblinks
 
 	def setup
 		@controller = ListitemsController.new
@@ -21,14 +21,12 @@ class ListitemsControllerTest &lt; ActionController::TestCase
 	
 	test &quot;create&quot; do
 		assert_difference(Listitem, :count, 1) do
-			post :create, {:listitem=&gt;{:title=&gt;'Test List',
-				:item_type=&gt;'Weblink', :item_id=&gt;weblinks(:one).id}},
-				{:user=&gt;users(:regular).id}
+			post :create, {:list_id=&gt;lists(:one).id,
+				:listitem=&gt;{:item_type=&gt;'Weblink', :item_id=&gt;weblinks(:one).id}},
+				{:user=&gt;users(:login).id}
 		end
-		assert assigns(:listitem)
 		assert assigns(:listitem).is_a?(Listitem)
 		assert_equal weblinks(:one), assigns(:listitem).item
-		assert_equal users(:regular), assigns(:listitem).user
 		assert flash[:notice]
 		assert_response :redirect
 		assert_redirected_to({:controller=&gt;'weblinks', :action=&gt;'show', :id=&gt;weblinks(:one)})
@@ -37,7 +35,7 @@ class ListitemsControllerTest &lt; ActionController::TestCase
 	end
 	test &quot;create no params&quot; do
 		assert_difference(Listitem, :count, 0) do
-			post :create, {:listitem=&gt;{}}, {:user=&gt;users(:regular).id}
+			post :create, {:list_id=&gt;lists(:one).id, :listitem=&gt;{}}, {:user=&gt;users(:login).id}
 		end
 		assert assigns(:listitem)
 		assert assigns(:listitem).is_a?(Listitem)
@@ -50,15 +48,14 @@ class ListitemsControllerTest &lt; ActionController::TestCase
 		# create a listitem to be destroyed
 		listitem = nil
 		assert_difference(Listitem, :count, 1) do
-			listitem = Listitem.new({:title=&gt;'Delete This',
-				:item_type=&gt;'Page', :item_id=&gt;pages(:one).id})
-			listitem.user = users(:regular)
+			listitem = lists(:one).listitems.new
+			listitem.item = pages(:three)
 			listitem.save!
 		end
 		# destroy the listitem
 		assert_difference(Listitem, :count, -1) do
 			@request.accept = &quot;text/html&quot;
-			delete :destroy, {:id=&gt;listitem.id}, {:user=&gt;users(:regular).id}
+			delete :destroy, {:id=&gt;listitem.id}, {:user=&gt;users(:login).id}
 		end
 		assert flash[:notice]
 		assert_response :redirect
@@ -68,9 +65,8 @@ class ListitemsControllerTest &lt; ActionController::TestCase
 		# create a listitem to be destroyed
 		listitem = nil
 		assert_difference(Listitem, :count, 1) do
-			listitem = Listitem.new({:title=&gt;'Delete This',
-				:item_type=&gt;'Page', :item_id=&gt;pages(:one).id})
-			listitem.user = users(:regular)
+			listitem = lists(:one).listitems.new
+			listitem.item = pages(:three)
 			listitem.save!
 		end
 		# destroy the listitem
@@ -115,15 +111,14 @@ class ListitemsControllerTest &lt; ActionController::TestCase
 		# create a listitem to be destroyed
 		listitem = nil
 		assert_difference(Listitem, :count, 1) do
-			listitem = Listitem.new({:title=&gt;'Delete This',
-				:item_type=&gt;'Page', :item_id=&gt;pages(:one).id})
-			listitem.user = users(:regular)
+			listitem = lists(:one).listitems.new
+			listitem.item = pages(:three)
 			listitem.save!
 		end
 		# destroy the listitem
 		assert_difference(Listitem, :count, -1) do
 			@request.accept = &quot;text/javascript&quot;
-			delete :destroy, {:id=&gt;listitem.id}, {:user=&gt;users(:regular).id}
+			delete :destroy, {:id=&gt;listitem.id}, {:user=&gt;users(:login).id}
 		end
 		assert flash[:notice]
 		assert_response :success</diff>
      <filename>test/functional/listitems_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 require 'test_helper'
 
 class ListsControllerTest &lt; ActionController::TestCase
-	fixtures :listitems, :users, :events, :pages, :weblinks
+	fixtures :lists, :listitems, :users, :events, :pages, :weblinks
 
 	def setup
 		@controller = ListsController.new
@@ -19,73 +19,73 @@ class ListsControllerTest &lt; ActionController::TestCase
 	
 	# ACTIONS
 	
-	test &quot;index&quot; do
-		assert_efficient_sql do
-			get :index, {}, {:user=&gt;users(:login).id}
-		end
-		assert_equal 'Your Lists', assigns(:page_title)
-		assert_equal 1, assigns(:lists).size
-		assert_nil flash[:notice]
-		assert_response :success
-		# view result
-		assert_template 'index'
-		assert_select 'div#flash:empty'
-		assert_select 'div#content' do
-			# TODO: test html content for test_events_index
-			assigns(:lists).each do |list|
-				assert_select &quot;li&quot;, list.title
-			end
-		end
-	end
-	
-	test &quot;show&quot; do
+#	test &quot;index&quot; do
 #		assert_efficient_sql do
-			get :show, {:id=&gt;listitems(:one).title}, {:user=&gt;users(:login).id}
+#			get :index, {}, {:user=&gt;users(:login).id}
 #		end
-		assert_equal &quot;Your List: #{listitems(:one).title}&quot;, assigns(:page_title)
-		assert_equal 2, assigns(:listitems).size
-		assert_nil flash[:notice]
-		assert_response :success
-		# view result
-		assert_template 'show'
-		assert_select 'div#flash:empty'
-		assert_select 'div#content' do
-			# TODO: test html content for test_events_index
-			assigns(:listitems).each do |listitem|
-				assert_select &quot;li#listitem_#{listitem.id}&quot;, listitem.item.title
-			end
-		end
-	end
-	test &quot;show empty list&quot; do
+#		assert_equal 'Your Lists', assigns(:page_title)
+#		assert_equal 1, assigns(:lists).size
+#		assert_nil flash[:notice]
+#		assert_response :success
+#		# view result
+#		assert_template 'index'
+#		assert_select 'div#flash:empty'
+#		assert_select 'div#content' do
+#			# TODO: test html content for test_events_index
+#			assigns(:lists).each do |list|
+#				assert_select &quot;li&quot;, list.title
+#			end
+#		end
+#	end
+#	
+#	test &quot;show&quot; do
+##		assert_efficient_sql do
+#			get :show, {:id=&gt;listitems(:one).title}, {:user=&gt;users(:login).id}
+##		end
+#		assert_equal &quot;Your List: #{listitems(:one).title}&quot;, assigns(:page_title)
+#		assert_equal 2, assigns(:listitems).size
+#		assert_nil flash[:notice]
+#		assert_response :success
+#		# view result
+#		assert_template 'show'
+#		assert_select 'div#flash:empty'
+#		assert_select 'div#content' do
+#			# TODO: test html content for test_events_index
+#			assigns(:listitems).each do |listitem|
+#				assert_select &quot;li#listitem_#{listitem.id}&quot;, listitem.item.title
+#			end
+#		end
+#	end
+#	test &quot;show empty list&quot; do
+##		assert_efficient_sql do
+#			get :show, {:id=&gt;'Non-existent list'}, {:user=&gt;users(:login).id}
+##		end
+#		assert_equal &quot;Your List: Non-existent list&quot;, assigns(:page_title)
+#		assert_equal 0, assigns(:listitems).size
+#		assert flash[:notice]
+#		assert_response :success
+#		assert_template 'show'
+#	end
+#	
+#	test &quot;destroy&quot; do
+#		conditions = ['listitems.user_id = ? AND listitems.title = ?',
+#			users(:regular).id, listitems(:destroy_this).title]
+#		assert Listitem.count(:conditions=&gt;conditions) &gt; 0
 #		assert_efficient_sql do
-			get :show, {:id=&gt;'Non-existent list'}, {:user=&gt;users(:login).id}
+#			delete :destroy, {:id=&gt;listitems(:destroy_this).title},
+#				{:user=&gt;users(:regular).id}
 #		end
-		assert_equal &quot;Your List: Non-existent list&quot;, assigns(:page_title)
-		assert_equal 0, assigns(:listitems).size
-		assert flash[:notice]
-		assert_response :success
-		assert_template 'show'
-	end
-	
-	test &quot;destroy&quot; do
-		conditions = ['listitems.user_id = ? AND listitems.title = ?',
-			users(:regular).id, listitems(:destroy_this).title]
-		assert Listitem.count(:conditions=&gt;conditions) &gt; 0
-		assert_efficient_sql do
-			delete :destroy, {:id=&gt;listitems(:destroy_this).title},
-				{:user=&gt;users(:regular).id}
-		end
-		assert_equal 0, Listitem.count(:conditions=&gt;conditions)
-		assert flash[:notice]
-		assert_response :redirect
-		assert_redirected_to lists_path
-	end
-	test &quot;destroy empty list&quot; do
-		assert_efficient_sql do
-			delete :destroy, {:id=&gt;'non-existent list'}, {:user=&gt;users(:regular).id}
-		end
-		assert flash[:error]
-		assert_response :redirect
-		assert_redirected_to lists_path
-	end
+#		assert_equal 0, Listitem.count(:conditions=&gt;conditions)
+#		assert flash[:notice]
+#		assert_response :redirect
+#		assert_redirected_to lists_path
+#	end
+#	test &quot;destroy empty list&quot; do
+#		assert_efficient_sql do
+#			delete :destroy, {:id=&gt;'non-existent list'}, {:user=&gt;users(:regular).id}
+#		end
+#		assert flash[:error]
+#		assert_response :redirect
+#		assert_redirected_to lists_path
+#	end
 end</diff>
      <filename>test/functional/lists_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 require 'test_helper'
 
 class ListitemTest &lt; ActiveSupport::TestCase
-	fixtures :listitems, :pages, :users, :events
+	fixtures :lists, :listitems, :pages, :users, :events
 	
 	# Replace this with your real tests.
 	test &quot;associations&quot; do
@@ -12,80 +12,18 @@ class ListitemTest &lt; ActiveSupport::TestCase
 	# VALIDATIONS
 	
 	test &quot;validation with all values set&quot; do
-		li = Listitem.new(:title=&gt;'test1')
-		li.item = pages(:one)
-		li.user = users(:login)
+		li = lists(:one).listitems.new()
+		li.item = pages(:three)
 		assert_valid li
 	end
 	test &quot;validation fails in absence of item&quot; do
-		li = Listitem.new(:title=&gt;'test2')
-		li.user = users(:login)
+		li = lists(:one).listitems.new()
 		assert_validation_fails_for(li, ['item'])
 	end
-	test &quot;validation fails in absence of user&quot; do
-		li = Listitem.new(:title=&gt;'test3')
-		li.item = pages(:one)
-		assert_validation_fails_for(li, ['user'])
-	end
-	test &quot;validation passes in absence of title&quot; do
-		li = Listitem.new()
-		li.item = pages(:one)
-		li.user = users(:login)
-		assert_valid li
-	end
-	test &quot;validation passes with empty title&quot; do
-		li = Listitem.new(:title=&gt;'')
-		li.item = pages(:one)
-		li.user = users(:login)
-		assert_valid li
-	end
-	test &quot;validation passes with space in title&quot; do
-		li = Listitem.new(:title=&gt;&quot;test 4&quot;)
-		li.item = pages(:one)
-		li.user = users(:login)
-		assert_valid li
-	end
-	test &quot;validation fails with space at beginning of title&quot; do
-		li = Listitem.new(:title=&gt;&quot; test5&quot;)
-		li.item = pages(:one)
-		li.user = users(:login)
-		assert_validation_fails_for(li, ['title'])
-	end
-	test &quot;validation fails with space at end of title&quot; do
-		li = Listitem.new(:title=&gt;&quot;test6 &quot;)
-		li.item = pages(:one)
-		li.user = users(:login)
-		assert_validation_fails_for(li, ['title'])
-	end
-	test &quot;validation passes with dash in title&quot; do
-		li = Listitem.new(:title=&gt;&quot;test-7&quot;)
-		li.item = pages(:one)
-		li.user = users(:login)
-		assert_valid li
-	end
-	test &quot;validation fails with dash at beginning of title&quot; do
-		li = Listitem.new(:title=&gt;&quot;-test8&quot;)
-		li.item = pages(:one)
-		li.user = users(:login)
-		assert_validation_fails_for(li, ['title'])
-	end
-	test &quot;validation fails with dash at end of title&quot; do
-		li = Listitem.new(:title=&gt;&quot;test9-&quot;)
-		li.item = pages(:one)
-		li.user = users(:login)
-		assert_validation_fails_for(li, ['title'])
-	end
-	test &quot;validation fails with CR in title&quot; do
-		li = Listitem.new(:title=&gt;&quot;\r&quot;)
-		li.item = pages(:one)
-		li.user = users(:login)
-		assert_validation_fails_for(li, ['title'])
-	end
 	test &quot;validation fails for duplicate entry&quot; do
-		li = Listitem.new(:title=&gt;listitems(:one).title)
+		li = listitems(:one).list.listitems.new()
 		li.item = listitems(:one).item
-		li.user = listitems(:one).user
-		assert_validation_fails_for(li, ['title'])
+		assert_validation_fails_for(li, ['item_id'])
 	end
 	
 	
@@ -96,10 +34,10 @@ class ListitemTest &lt; ActiveSupport::TestCase
 	end
 	
 	test &quot;default order&quot; do
-		assert_equal 'listitems.created_at', Listitem.default_order
+		assert_equal 'listitems.position', Listitem.default_order
 	end
 	test &quot;default order recent&quot; do
-		assert_equal 'listitems.updated_at DESC, listitems.created_at',
+		assert_equal 'listitems.updated_at DESC, listitems.position',
 			Listitem.default_order(:recent=&gt;true)
 	end
 	
@@ -109,61 +47,33 @@ class ListitemTest &lt; ActiveSupport::TestCase
 	test &quot;search conditions custom&quot; do
 		assert_equal ['a AND b',1,2], Listitem.search_conditions({}, ['a','b'], [1,2])
 	end
-	test &quot;search conditions title&quot; do
-		assert_equal ['listitems.title = ?', 'Title'],
-			Listitem.search_conditions({:title=&gt;'Title'})
-	end
-	test &quot;search conditions user&quot; do
-		assert_equal ['listitems.user_id = ?', 1],
-			Listitem.search_conditions({:u=&gt;1})
-	end
 	test &quot;search conditions all&quot; do
-		assert_equal ['a AND b AND listitems.title = ? AND listitems.user_id = ?',
-				1, 2, 'Title', 3],
-			Listitem.search_conditions({:title=&gt;'Title', :u=&gt;3}, ['a','b'], [1,2])
+		assert_equal ['a AND b',
+				1, 2],
+			Listitem.search_conditions({}, ['a','b'], [1,2])
 	end
 	
-	test &quot;find lists for user&quot; do
-		lists = Listitem.find_lists_for_user(users(:login))
-		assert_equal 1, lists.size
-		assert_equal 'Test List', lists[0].title
-	end
-	test &quot;find lists for user with no lists&quot; do
-		assert_equal [], Listitem.find_lists_for_user(users(:another))
-	end
-	test &quot;find lists for user with nil user&quot; do
-		assert_raise RuntimeError do
-			Listitem.find_lists_for_user(nil)
-		end
-	end
 	
-	def self.count_user_list(u, title)
-		Listitem.count(:conditions=&gt;
-			['listitems.user_id = ? AND listitems.title = ?', u.id, title])
-	end
+	# INSTANCE METHODS
 	
-	test &quot;count items in user list&quot; do
-		assert_equal 2, Listitem.count_user_list(listitems(:one).user, listitems(:one).title)
-	end
-	test &quot;count items in empty user list&quot; do
-		assert_equal 0, Listitem.count_user_list(listitems(:one).user, 'non-existent list')
-	end
-	test &quot;count items in user list for wrong user&quot; do
-		assert_equal 0, Listitem.count_user_list(users(:another), listitems(:one).title)
-	end
-	test &quot;count items in user list for no user&quot; do
-		assert_raise RuntimeError do
-			Listitem.count_user_list(nil, listitems(:one).title)
-		end
+	test &quot;before save sets position&quot; do
+		li = lists(:one).listitems.new()
+		li.item = events(:searchable)
+		li.save!
+		assert_equal 3, li.position
+		li.destroy
 	end
 	
-	
-	# INSTANCE METHODS
+	test &quot;autoset_position&quot; do
+		li = lists(:one).listitems.new()
+		li.autoset_position
+		assert_equal 3, li.position
+	end
 	
 	test &quot;css class&quot; do
-		assert_equal 'list', listitems(:one).css_class
+		assert_equal 'event', listitems(:one).css_class
 	end
 	test &quot;css class with prefix&quot; do
-		assert_equal 'test-list', listitems(:one).css_class('test-')
+		assert_equal 'test-event', listitems(:one).css_class('test-')
 	end
 end</diff>
      <filename>test/unit/listitem_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>90674375a60404a258a231658699accd7cc1add5</id>
    </parent>
  </parents>
  <author>
    <name>Grant Neufeld</name>
    <email>grant@grantneufeld.ca</email>
  </author>
  <url>http://github.com/grantneufeld/wayground/commit/7d9e1b692500e6b32f94552269cc943c321262dd</url>
  <id>7d9e1b692500e6b32f94552269cc943c321262dd</id>
  <committed-date>2009-03-29T14:17:02-07:00</committed-date>
  <authored-date>2009-03-29T14:17:02-07:00</authored-date>
  <message>List and Listitem models and controllers.

Not fully complete yet, but a lot more stuff implemented.</message>
  <tree>05669e9a998b56a0e5db74a23d268fd0d022a4e6</tree>
  <committer>
    <name>Grant Neufeld</name>
    <email>grant@grantneufeld.ca</email>
  </committer>
</commit>
