Sha256: da48307ea33fad087ba1cfb873f203dfd3e1a5b7c686f866f0610bd6ef14cce9

Contents?: true

Size: 1.29 KB

Versions: 9

Compression:

Stored size: 1.29 KB

Contents

require "test_helper"

class UserTest < ActiveSupport::TestCase
  test "should create user" do
    user = Fabricate "concen/user"
    assert_not_nil user.id
  end

  test "shoud have password_digest" do
    user = Fabricate "concen/user"
    assert_not_nil user.password_digest
  end

  test "shoud have auth_token" do
    user = Fabricate "concen/user"
    assert_not_nil user.auth_token
  end

  test "should have username" do
    user = Fabricate.build "concen/user", :username => nil
    assert_raise(Mongoid::Errors::Validations) { user.save! }
    assert_equal user.errors[:username].first, "can't be blank"
  end

  test "should have email" do
    user = Fabricate.build "concen/user", :email => nil
    assert_raise(Mongoid::Errors::Validations) { user.save! }
    assert_equal user.errors[:email].first, "can't be blank"
  end

  test "should have full_name" do
    user = Fabricate.build("concen/user", :full_name => nil)
    assert_raise(Mongoid::Errors::Validations) { user.save! }
    assert_equal user.errors[:full_name].first, "can't be blank"
  end

  test "should authenticate user" do
    password = {:password => "newpassword", :password_confirmation => "newpassword"}
    user = Fabricate "concen/user", password
    assert user.authenticate("newpassword"), "Cannot authenticate user."
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
concen-0.2.2 test/unit/user_test.rb
concen-0.2.1 test/unit/user_test.rb
concen-0.2.0 test/unit/user_test.rb
concen-0.1.7 test/unit/user_test.rb
concen-0.1.6 test/unit/user_test.rb
concen-0.1.5 test/unit/user_test.rb
concen-0.1.4 test/unit/user_test.rb
concen-0.1.3 test/unit/user_test.rb
concen-0.1.2 test/unit/user_test.rb