<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/authorizable.rb</filename>
    </added>
    <added>
      <filename>test/fixtures/forum_memberships.yml</filename>
    </added>
    <added>
      <filename>test/fixtures/forum_threads.yml</filename>
    </added>
    <added>
      <filename>test/fixtures/forums.yml</filename>
    </added>
    <added>
      <filename>test/fixtures/posts.yml</filename>
    </added>
    <added>
      <filename>test/fixtures/roles.yml</filename>
    </added>
    <added>
      <filename>test/fixtures/users.yml</filename>
    </added>
    <added>
      <filename>test/models/forum.rb</filename>
    </added>
    <added>
      <filename>test/models/forum_membership.rb</filename>
    </added>
    <added>
      <filename>test/models/forum_thread.rb</filename>
    </added>
    <added>
      <filename>test/models/post.rb</filename>
    </added>
    <added>
      <filename>test/models/role.rb</filename>
    </added>
    <added>
      <filename>test/models/user.rb</filename>
    </added>
    <added>
      <filename>test/test_helper.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,2 +1,2 @@
-require &quot;#{File.dirname(__FILE__)}/lib/active_record/acts/authorizable&quot;
+require &quot;#{File.dirname(__FILE__)}/lib/authorizable&quot;
 ActiveRecord::Base.send(:include, ActiveRecord::Acts::Authorizable)</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,90 @@
-require 'test/unit'
+require File.dirname(__FILE__) + &quot;/test_helper&quot;
 
 class ActsAsAuthorizableTest &lt; Test::Unit::TestCase
-  # Replace this with your real tests.
-  def test_this_plugin
-    flunk
+  fixtures :users, :forums, :forum_memberships, :forum_threads, :roles, :posts
+  
+  #Tests that options are set correctly
+  def test_acts_as_authorizable_options
+    assert_equal 'Role', Forum.acts_as_authorizable_options[:role_class_name]
+    assert_equal 'find_by_name', Forum.acts_as_authorizable_options[:role_locate_method]
   end
+  
+  #Tests that sources is an array with appropriate sizes
+  def test_acts_as_authorizable_sources_size
+    assert_equal 2, Post.acts_as_authorizable_sources.size
+    assert_equal 1, ForumMembership.acts_as_authorizable_sources.size 
+  end
+  
+  #Tests that sources is lexically ordered
+  def test_acts_as_authorizable_sources_lexical_ordering
+    assert_equal :belongs_to_user, Post.acts_as_authorizable_sources.first[:type]
+    assert_equal :belongs_to_parent, Post.acts_as_authorizable_sources.last[:type]
+  end
+  
+  #Tests that sources is getting belongs_to_user role associated properly
+  def test_acts_as_authorizable_sources_auth_belongs_to_user_with_role_association
+    assert_equal :belongs_to_user, ForumMembership.acts_as_authorizable_sources.first[:type]
+    assert_equal :user, ForumMembership.acts_as_authorizable_sources.first[:association]
+    assert_equal :role, ForumMembership.acts_as_authorizable_sources.first[:role_association]
+    assert_nil ForumMembership.acts_as_authorizable_sources.first[:role]
+  end
+  
+  #Tests that sources is getting belongs_to_user hardcoded
+  def test_acts_as_authorizable_sources_auth_belongs_to_user_with_role_hardcoded
+    assert_equal 'Post Owner', Post.acts_as_authorizable_sources.first[:role] 
+  end
+  
+  #Tests that sources is getting belongs_to_parent properly
+  def test_acts_as_authorizable_sources_auth_belongs_to_parent
+    assert_equal :forum_thread, Post.acts_as_authorizable_sources.last[:association]
+  end
+  
+  #Tests that sources is getting has_many parents properly
+  def test_acts_as_authorizable_sources_auth_has_many_parents
+    assert_equal :forum_memberships, Forum.acts_as_authorizable_sources.first[:association]
+  end
+  
+  #Tests that sources is getting has_many parents properly with scope
+  def test_acts_as_authorizable_sources_auth_has_many_parents_scoped
+    assert_equal :with_user, Forum.acts_as_authorizable_sources.first[:user_scope]
+  end
+  
+  #Tests that auth_user_association_matches? works
+  def test_auth_user_association_matches
+    u = User.find_by_name('Dave')
+    u2 = User.find_by_name('Matt')
+    f = u.forum_memberships.first
+    assert f.send('auth_user_association_matches?',:user,u )
+    assert !f.send('auth_user_association_matches?',:user,u2 )
+  end
+  
+  #Tests that auth_locate_role_object works
+  def test_auth_locate_role_object
+    r = Role.find_by_name('Post Owner')
+    p = Post.first
+    assert_equal r, p.send('auth_locate_role_object','Post Owner')
+  end
+  
+  #Tests that auth_assoc_using_has_many_parents works with scope
+  def test_auth_assoc_using_has_many_parents
+    f = Forum.find_by_name(&quot;Support&quot;)
+    u = User.find_by_name(&quot;Matt&quot;)
+    assoc = f.send('auth_assoc_using_has_many_parents',f.acts_as_authorizable_sources.first,u)
+    assert_equal 1, assoc.size
+    assert_equal 'Forum Moderator', assoc.first.role.name
+  end
+  
+  #Tests that auth_using_belongs_to_user fetches the correct role object
+  def test_auth_using_belongs_to_user
+    p = Post.first
+    u = User.find_by_name('Matt')
+    u2 = User.find_by_name('Dave')
+    assert_equal 'Post Owner', p.send('auth_using_belongs_to_user',Post.acts_as_authorizable_sources.first,u,'owns').name
+    assert_nil p.send('auth_using_belongs_to_user',Post.acts_as_authorizable_sources.first,u2,'owns')
+    assert_nil p.send('auth_using_belongs_to_user',Post.acts_as_authorizable_sources.first,u,'ow2ns')
+  end
+  
+  
+  
+  
 end</diff>
      <filename>test/acts_as_authorizable_test.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/active_controller/authorizable.rb</filename>
    </removed>
    <removed>
      <filename>lib/active_record/acts/authorizable.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>a595e53769910e1179c78dfc5337cf786ec28d8b</id>
    </parent>
  </parents>
  <author>
    <name>Matthew</name>
    <email>mleventi@gmail.com</email>
  </author>
  <url>http://github.com/mleventi/acts_as_authorizable/commit/603045799e62f4fb2356b9fd984a8d8af90214ef</url>
  <id>603045799e62f4fb2356b9fd984a8d8af90214ef</id>
  <committed-date>2008-09-02T23:55:32-07:00</committed-date>
  <authored-date>2008-09-02T23:55:32-07:00</authored-date>
  <message>finished most of the testing harness. Corrected a few errors, documentation update will come tomorrow. Look to the testing fixtures and models for a concrete example as well.</message>
  <tree>ffa03f21ca4c4d456b0cf77e4be4c17f155873fd</tree>
  <committer>
    <name>Matthew</name>
    <email>mleventi@gmail.com</email>
  </committer>
</commit>
