Sha256: 65139977909ec5b64afcd8fbc740742ae28a880f4bb6f23e24680714ea2c4398

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'helper'

class TestUser < AVTestCase

  def test_user_save
    VCR.use_cassette('test_user_save', :record => :new_episodes) do
      username = rand.to_s
      data = {
        :username => username,
        :password => "topsecret"
      }
      user = AV::User.new data
      user.save
      assert_equal user[AV::Protocol::KEY_OBJECT_ID].class, String
      assert_equal user[AV::Protocol::KEY_CREATED_AT].class, String
    end
  end

  def test_user_login
    #VCR.use_cassette('test_user_login', :record => :new_episodes) do
      u = "alan" + rand(10000000000000).to_s
      data = {
        :username => u,
        :password => "secret"
      }

      user = AV::User.new(data)

      user.save

      assert_equal user["username"], u
      assert_equal user[AV::Protocol::KEY_USER_SESSION_TOKEN].class, String

      login = AV::User.authenticate(u, "secret")

      assert_equal login["username"], user["username"]
      assert_equal login["sessionToken"].class, String

      user = user.pointer.get
      user.save
    #end
  end

  def test_reset_password
    u =  "alan" + rand(10000000000000).to_s + "@gmail.com"
    data = {
      :username => u,
      :password => "secret"
    }

    user = AV::User.new(data)

    user.save

    reset_password = AV::User.reset_password(u)

    assert_equal Hash.new, reset_password
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
leancloud-ruby-client-0.1.1 test/test_user.rb
leancloud-ruby-client-0.1.0 test/test_user.rb