Commit 3e766a823a144f7e8c799169696e4ac87c68db10

Authored by Rafael Manzo
Committed by Rafael Manzo
1 parent 88ba8e20

User model

.gitignore
... ... @@ -14,3 +14,5 @@
14 14 # Ignore all logfiles and tempfiles.
15 15 /log/*.log
16 16 /tmp
  17 +
  18 +coverage
... ...
app/models/user.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +class User < ActiveRecord::Base
  2 + validates :name, presence: true
  3 + validates :email, presence: true
  4 + validates :email, uniqueness: true
  5 +end
... ...
db/migrate/20130627170417_create_users.rb 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +class CreateUsers < ActiveRecord::Migration
  2 + def change
  3 + create_table :users do |t|
  4 + t.string :name
  5 + t.string :email
  6 +
  7 + t.timestamps
  8 + end
  9 + end
  10 +end
... ...
db/schema.rb
... ... @@ -11,6 +11,13 @@
11 11 #
12 12 # It's strongly recommended that you check this file into your version control system.
13 13  
14   -ActiveRecord::Schema.define(version: 0) do
  14 +ActiveRecord::Schema.define(version: 20130627170417) do
  15 +
  16 + create_table "users", force: true do |t|
  17 + t.string "name"
  18 + t.string "email"
  19 + t.datetime "created_at"
  20 + t.datetime "updated_at"
  21 + end
15 22  
16 23 end
... ...
spec/factories/users.rb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +# Read about factories at https://github.com/thoughtbot/factory_girl
  2 +
  3 +FactoryGirl.define do
  4 + factory :user do
  5 + name "Diego Martinez"
  6 + email "diego@email.com"
  7 + end
  8 +end
... ...
spec/models/user_spec.rb 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +require 'spec_helper'
  2 +
  3 +describe User do
  4 + context 'validations' do
  5 + subject { FactoryGirl.build(:user) }
  6 +
  7 + it { should validate_presence_of(:name) }
  8 + it { should validate_presence_of(:email) }
  9 + it { should validate_uniqueness_of(:email) }
  10 + end
  11 +end
... ...