Sha256: 51fcc7a9c4c100658e79c97add54577d16ddfce8c5a8a45a102d5c1039514eff

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

class UserstampsTest < Test::Unit::TestCase
  class AltUser
    include MongoMapper::Document
  end

  context "userstamping" do
    setup do
      @document = Doc do
        userstamps!
      end
      @document_alt_user = Doc do
        userstamps! :class_name => 'AltUser'
      end
      @document_alt_user_class = Doc do
        userstamps! :class => AltUser
      end
      @docs = [@document, @document_alt_user, @document_alt_user_class]
    end

    should "add creator_id key" do
      @docs.each{ |d| d.keys.should include('creator_id') }
    end

    should "add updater_id key" do
      @docs.each{ |d| d.keys.should include('updater_id') }
    end

    should "add belongs_to creator" do
      @docs.each{ |d| d.associations.keys.should include(:creator) }
    end

    should "add belongs_to updater" do
      @docs.each{ |d| d.associations.keys.should include(:updater) }
    end

    should "properly set class names" do
      @document.associations[:creator].class_name.should == 'User'
      @document_alt_user.associations[:creator].class_name.should == 'AltUser'
      @document_alt_user_class.associations[:creator].class_name.should == 'UserstampsTest::AltUser'
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
mongo_mapper-0.12.0 test/functional/test_userstamps.rb
lookout-mongo_mapper-0.11.3 test/functional/test_userstamps.rb
mongo_mapper-0.11.2 test/functional/test_userstamps.rb
jamieorc-mongo_mapper-0.11.1.1 test/functional/test_userstamps.rb
mongo_mapper-0.11.1 test/functional/test_userstamps.rb
mongo_mapper-0.11.0 test/functional/test_userstamps.rb
mongo_mapper-0.10.1 test/functional/test_userstamps.rb
mongo_mapper-0.10.0 test/functional/test_userstamps.rb
mongo_mapper-0.9.2 test/functional/test_userstamps.rb