Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adicionada validação de atributo único

  • Loading branch information...
commit 7394a9b4264f30bbca6484d3b65de63b98344ad9 1 parent 520fd18
@rafaelfranca authored
Showing with 7 additions and 1 deletion.
  1. +1 −1  app/models/article.rb
  2. +6 −0 spec/models/article_spec.rb
View
2  app/models/article.rb
@@ -1,4 +1,4 @@
class Article < ActiveRecord::Base
- validates :title, :presence => true
+ validates :title, :presence => true, :uniqueness => true
validates :body, :presence => true
end
View
6 spec/models/article_spec.rb
@@ -15,4 +15,10 @@
article = Factory.build(:article, :body => nil)
article.should_not be_valid
end
+
+ it "deveria ter um titulo" do
+ article = Factory.create(:article)
+ other_article = Factory.build(:article)
+ other_article.should_not be_valid
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.