Skip to content

Commit

Permalink
Adding note/spec about validates_uniqueness_of and the todo list
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey Chupp committed Mar 24, 2009
1 parent 0b47839 commit 1293eca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.textile
Expand Up @@ -57,10 +57,18 @@ One thing to note, destroying is always undo-able, but deleting is not.
# And you may say to yourself, "My god! What have I done?"
</pre>

h3. Note:

validates_uniqueness_of does not ignore items marked with a deleted_at flag. This is a behavior difference between is_paranoid and acts_as_paranoid. I'm going to treat this as a bug until I get a chance to make it an optional feature. Be aware of it.

h3. and you may ask yourself, where does that highway go to?

If you find any bugs, have any ideas of features you think are missing, or find things you're like to see work differently, feel free to send me a message or a pull request.

Currently on the todo list:
* deal with validates_uniqueness_of issue
* add options for merging additional default_scope options (i.e. order, etc.)

h3. Thanks

Thanks to Rick Olson for acts_as_paranoid which is obviously an inspiration in concept and execution, Ryan Bates for mentioning the idea of using default_scope for this on Ryan Daigle's "post introducing default_scope":defscope, and the Talking Heads for being the Talking Heads.
Expand Down
10 changes: 10 additions & 0 deletions spec/android_spec.rb
Expand Up @@ -5,6 +5,7 @@ class Person < ActiveRecord::Base
end

class Android < ActiveRecord::Base
validates_uniqueness_of :name
is_paranoid
end

Expand Down Expand Up @@ -73,4 +74,13 @@ class Android < ActiveRecord::Base
@r2d2.restore
}.should change(Android, :count).from(1).to(2)
end

# Note: this isn't necessarily ideal, this just serves to demostrate
# how it currently works
it "should not ignore deleted items in validation checks" do
@r2d2.destroy
lambda{
Android.create!(:name => 'R2D2')
}.should raise_error(ActiveRecord::RecordInvalid)
end
end

0 comments on commit 1293eca

Please sign in to comment.