Skip to content

Commit

Permalink
Working user model
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlabouve committed Apr 12, 2016
1 parent 7f8591c commit 7de8084
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gem 'rails', '4.2.6'
gem 'rails-api'

gem 'spring', :group => :development
gem 'bcrypt'


gem 'sqlite3'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ GEM
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
bcrypt (3.1.11)
builder (3.2.2)
concurrent-ruby (1.0.1)
erubis (2.7.0)
Expand Down Expand Up @@ -104,6 +105,7 @@ PLATFORMS
ruby

DEPENDENCIES
bcrypt
rails (= 4.2.6)
rails-api
spring
Expand Down
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
class User < ActiveRecord::Base
has_secure_password

validates :name, presence: true
validates :email, presence: true
end
15 changes: 4 additions & 11 deletions test/fixtures/users.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
password_digest: MyString
name: MyString
email: MyString

two:
password_digest: MyString
name: MyString
email: MyString
valid:
password_digest: hotdog
name: Lester Test
email: test@user.com
25 changes: 22 additions & 3 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
require 'test_helper'

class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
setup do
@valid_user = users(:valid)
end

test "User has correct attributes" do
assert @valid_user.respond_to?(:name)
assert @valid_user.respond_to?(:password_digest)
assert @valid_user.respond_to?(:email)
end

test "invalid without name" do
@valid_user.name = nil
assert_not @valid_user.valid?
end

test "invalid without password and password_confirmation" do
end

test "invalid without email" do
@valid_user.email= nil
assert_not @valid_user.valid?
end
end

0 comments on commit 7de8084

Please sign in to comment.