Skip to content

Instantly share code, notes, and snippets.

@azisaka
Created January 19, 2010 19:26
Show Gist options
  • Save azisaka/281193 to your computer and use it in GitHub Desktop.
Save azisaka/281193 to your computer and use it in GitHub Desktop.
class Campaign
include Mongoid::Document
field :name
index :name, :unique => true
validates_presence_of :name
end
describe Campaign do
context "validation" do
it "should validate uniqueness of name" do
campaign_a = campaign_b = Campaign.new(:name => 'Testing')
campaign_a.save
campaign_b.valid?.should be_true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment