<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/index.rhtml</filename>
    </added>
    <added>
      <filename>test/lock.rb</filename>
    </added>
    <added>
      <filename>test/lock_controller.rb</filename>
    </added>
    <added>
      <filename>test/migration.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -4,7 +4,7 @@ module ActionView #:nodoc:
     
       def attribute_locked
         object.is_a?(ActiveRecord::Base) and
-            object.class.locked_attributes.to_a.collect(&amp;:to_s).include?(method_name.to_s) and
+            object.class.has_locked_attribute?(method_name) and
             !object.new_record?
       end
       </diff>
      <filename>lib/action_view.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,10 +17,22 @@ module ActiveRecord #:nodoc:
           end
         end
       end
+      
+      def has_locked_attribute?(attr_name)
+        locked_attributes.to_a.collect(&amp;:to_s).include?(attr_name.to_s)
+      end
+    end
+    
+    define_method('[]=_with_attribute_locking') do |attr_name, value|
+      if !self.class.has_locked_attribute?(attr_name) or new_record?
+        write_attribute(attr_name, value)
+      end
     end
+    alias_method('[]=_without_attribute_locking', '[]=')
+    alias_method('[]=', '[]=_with_attribute_locking')
     
     def update_attribute_with_attribute_locking(name, value)
-      if self.class.locked_attributes.to_a.collect(&amp;:to_s).include?(name.to_s)
+      if self.class.has_locked_attribute?(name)
         return false
       else
         update_attribute_without_attribute_locking(name, value)</diff>
      <filename>lib/active_record.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,15 @@
-# desc &quot;Explaining what the task does&quot;
-# task :attr_locked do
-#   # Task goes here
-# end
\ No newline at end of file
+namespace :attr_locked do
+
+  desc &quot;Create attr_locked test table&quot;
+  task :migrate do
+    require File.dirname(__FILE__) + '/../test/migration'
+    AttrLockedMigration.up
+  end
+  
+  desc &quot;Drop attr_locked test table&quot;
+  task :rollback do
+    require File.dirname(__FILE__) + '/../test/migration'
+    AttrLockedMigration.down
+  end
+
+end</diff>
      <filename>tasks/attr_locked_tasks.rake</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,98 @@
 require 'test/unit'
+require File.dirname(__FILE__) + '/../../../../config/environment'
+require File.dirname(__FILE__) + '/../init'
+require File.dirname(__FILE__) + '/lock'
 
 class AttrLockedTest &lt; Test::Unit::TestCase
-  # Replace this with your real tests.
-  def test_this_plugin
-    flunk
+  
+  Data = {
+    :name =&gt; &quot;Bob&quot;,
+    :description =&gt; &quot;He's the guy doing our tests&quot;,
+    :date =&gt; Date.new(2007, 6, 1),
+    :flag =&gt; true,
+    :unlocked =&gt; &quot;Free and easy&quot;
+  }
+  
+  def setup
+    Lock.delete_all
+    Lock.create(AttrLockedTest::Data)
+    @lock = Lock.find(:first)
+  end
+  
+  def check_values
+    assert_equal AttrLockedTest::Data[:name], @lock.name
+    assert_equal AttrLockedTest::Data[:description], @lock.description
+    assert_equal AttrLockedTest::Data[:date], @lock.date
+    assert_equal AttrLockedTest::Data[:flag], @lock.flag
+  end
+  
+  def test_assignment_of_single_attributes_on_new_record
+    @lock = Lock.new
+    assert_equal nil, @lock.name
+    @lock.name = AttrLockedTest::Data[:name]
+    @lock.description = AttrLockedTest::Data[:description]
+    @lock.date = AttrLockedTest::Data[:date]
+    @lock.flag = AttrLockedTest::Data[:flag]
+    check_values
+    @lock.unlocked = &quot;all change&quot;
+    assert_equal &quot;all change&quot;, @lock.unlocked
+  end
+  
+  def test_assignment_of_single_attributes_by_symbol_on_new_record
+    @lock = Lock.new
+    assert_equal nil, @lock.name
+    @lock[:name] = AttrLockedTest::Data[:name]
+    @lock[:description] = AttrLockedTest::Data[:description]
+    @lock[:date] = AttrLockedTest::Data[:date]
+    @lock[:flag] = AttrLockedTest::Data[:flag]
+    check_values
+    @lock[:unlocked] = &quot;all change&quot;
+    assert_equal &quot;all change&quot;, @lock.unlocked
+  end
+  
+  def test_mass_assignment_on_new_record
+    @lock = Lock.new
+    @lock.attributes = AttrLockedTest::Data
+    check_values
+  end
+  
+  def test_assignment_of_single_attributes_without_saving
+    @lock.name = &quot;Mike&quot;
+    @lock.description = &quot;He's Bob's sidekick&quot;
+    @lock.date = Date.new(2005, 10, 13)
+    @lock.flag = false
+    check_values
+    @lock.unlocked = &quot;all change&quot;
+    assert_equal &quot;all change&quot;, @lock.unlocked
+  end
+  
+  def test_assignment_of_single_attributes_by_symbol_without_saving
+    @lock[:name] = &quot;Mike&quot;
+    @lock[:description] = &quot;He's Bob's sidekick&quot;
+    @lock[:date] = Date.new(2005, 10, 13)
+    @lock[:flag] = false
+    check_values
+    @lock[:unlocked] = &quot;all change&quot;
+    assert_equal &quot;all change&quot;, @lock.unlocked
+  end
+  
+  def test_mass_assignment_without_saving
+    @lock.attributes = {:name =&gt; &quot;Mike&quot;, :description =&gt; &quot;Just some guy&quot;,
+        :date =&gt; Date.new(1979, 4, 23), :flag =&gt; false}
+    check_values
+  end
+  
+  def test_update_attributes
+    @lock.update_attributes(:name =&gt; &quot;Mike&quot;, :description =&gt; &quot;Just some guy&quot;,
+        :date =&gt; Date.new(1979, 4, 23), :flag =&gt; false, :unlocked =&gt; &quot;anything, really&quot;)
+    @lock.reload
+    check_values
+    assert_equal &quot;anything, really&quot;, @lock.unlocked
+  end
+  
+  def test_update_attribute
+    assert_equal false, @lock.update_attribute(:name, &quot;Mike&quot;)
+    @lock.reload
+    check_values
   end
 end</diff>
      <filename>test/attr_locked_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6b6f33cca868598b8e1c9ecba98a881241cfd943</id>
    </parent>
  </parents>
  <author>
    <name>James Coglan</name>
    <email>jcoglan@googlemail.com</email>
  </author>
  <url>http://github.com/jcoglan/attr_locked/commit/de65f5e21c90033413fb5b4f4b6570f0dcf7c60b</url>
  <id>de65f5e21c90033413fb5b4f4b6570f0dcf7c60b</id>
  <committed-date>2007-06-10T13:41:15-07:00</committed-date>
  <authored-date>2007-06-10T13:41:15-07:00</authored-date>
  <message>Added test suite (requires plugging in to an actual application) and fixed bug that allowed setting attributes using record[:attr]= style.</message>
  <tree>8a08c20aa47f325dadfb34afbbd76ed1bf0c8f4d</tree>
  <committer>
    <name>James Coglan</name>
    <email>jcoglan@googlemail.com</email>
  </committer>
</commit>
