Created
May 14, 2012 03:52
-
-
Save zr2d2/2691693 to your computer and use it in GitHub Desktop.
parent test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## feed.rb | |
| validate :parent_id_cannot_be_this_feed | |
| def parent_id_cannot_be_this_feed | |
| if !parent_id.blank? and parent_id == id | |
| errors.add(:parent_id, "can't be this feed") | |
| end | |
| end | |
| ## feed_test.rb | |
| test "that a feed cannot be it's own parent" do | |
| feed = Feed.new(:name => "New", | |
| :description => "A new feed.", | |
| :group => groups(:rpitv), | |
| :parent_id => :id) | |
| #assert feed.invalid? | |
| assert_not_equal feed.id, feed.parent_id | |
| assert feed.errors[:parent_id].any? | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment