Sha256: 926db4214327c570c4c0bd52cc04f94d3bf683430753e5e85a88c0eb24fff5bb

Contents?: true

Size: 775 Bytes

Versions: 1

Compression:

Stored size: 775 Bytes

Contents

require "test_helper"

class MongoidSecureTokenTest < MiniTest::Unit::TestCase
  def setup
    @post = Post.new
  end

  def teardown
    Mongoid.purge!
  end

  def test_token_values_are_generated_for_specified_attributes_and_persisted_on_save
    @post.save
    refute_nil @post.token
    refute_nil @post.auth_token
  end

  def test_regenerating_the_secure_token
    @post.save
    old_token = @post.token
    old_auth_token = @post.auth_token
    @post.regenerate_token
    @post.regenerate_auth_token

    refute_equal @post.token, old_token
    refute_equal @post.auth_token, old_auth_token
  end

  def test_token_value_not_overwritten_when_present
    @post.token = "custom-secure-token"
    @post.save

    assert_equal @post.token, "custom-secure-token"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_model_secure_token-1.0.0 test/mongoid_test.rb