Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adicionada validação de atributo único

  • Loading branch information...
commit 7394a9b4264f30bbca6484d3b65de63b98344ad9 1 parent 520fd18
Rafael Mendonça França authored

Showing 2 changed files with 7 additions and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  app/models/article.rb
  2. +6 0 spec/models/article_spec.rb
2  app/models/article.rb
... ... @@ -1,4 +1,4 @@
1 1 class Article < ActiveRecord::Base
2   - validates :title, :presence => true
  2 + validates :title, :presence => true, :uniqueness => true
3 3 validates :body, :presence => true
4 4 end
6 spec/models/article_spec.rb
@@ -15,4 +15,10 @@
15 15 article = Factory.build(:article, :body => nil)
16 16 article.should_not be_valid
17 17 end
  18 +
  19 + it "deveria ter um titulo" do
  20 + article = Factory.create(:article)
  21 + other_article = Factory.build(:article)
  22 + other_article.should_not be_valid
  23 + end
18 24 end

0 comments on commit 7394a9b

Please sign in to comment.
Something went wrong with that request. Please try again.