Created
January 20, 2010 04:56
-
-
Save durran/281621 to your computer and use it in GitHub Desktop.
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
| class Campaign | |
| include Mongoid::Document | |
| field :name | |
| index :name, :unique => true | |
| validates_presence_of :name | |
| validates_uniqueness_of :name | |
| end | |
| describe Campaign do | |
| context "validation" do | |
| it "should validate uniqueness of name" do | |
| campaign_a = Campaign.new(:name => 'Testing') | |
| campaign_b = Campaign.new(:name => 'Testing') | |
| campaign_a.save | |
| campaign_b.valid?.should be_false | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment