Skip to content

Commit

Permalink
Teste unitário de usuário
Browse files Browse the repository at this point in the history
  • Loading branch information
rafael-fernandes committed Nov 26, 2017
1 parent 117684d commit dc6dc58
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class User < ApplicationRecord
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable

has_many :serie_acompanhadas
has_many :series, through: :serie_acompanhadas, source: :serie
belongs_to :series_list

validates :name, presence: true
end
7 changes: 7 additions & 0 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FactoryBot.define do
factory :user do
name "MyString"
email "MyString"
password "MyString"
end
end
9 changes: 9 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'rails_helper'

RSpec.describe User, type: :model do
it { should belong_to :series_list }

it { should validate_presence_of :name }
it { should validate_presence_of :email }
it { should validate_presence_of :password }
end

0 comments on commit dc6dc58

Please sign in to comment.