Sha256: 0b32664fc1b6419ef99ffa0a09512e305bb09f2eb7103d8ec4fdb45655efdd12
Contents?: true
Size: 1.38 KB
Versions: 4
Compression:
Stored size: 1.38 KB
Contents
require "test_helper" class ConfigTest < BaseTest class ModelClass def self.userstamps_model self end def self.user_model Mongoid::Userstamps::Config.user_classes.last end def self.set_user_model! @@user_model = user_model end end class UserClass end teardown do Mongoid::Userstamps::Config.model_classes.delete(ModelClass) Mongoid::Userstamps::Config.user_classes.delete(UserClass) end test "should config using block" do Mongoid::Userstamps.config do |c| c.created_name = :creator c.updated_name = :updater c.deleted_name = :deleter end assert_equal :creator, Mongoid::Userstamps::Config.created_name assert_equal :updater, Mongoid::Userstamps::Config.updated_name assert_equal :deleter, Mongoid::Userstamps::Config.deleted_name end test "current_user" do Mongoid::Userstamps::Config.set_current_user(Mongoid, "test") assert_equal "test", Mongoid::Userstamps::Config.current_user(Mongoid) end test "add_model_class" do assert_difference(-> { Mongoid::Userstamps::Config.model_classes.count }) do Mongoid::Userstamps::Config.add_model_class(ModelClass) end end test "add_user_class" do Mongoid::Userstamps::Config.add_model_class(ModelClass) Mongoid::Userstamps::Config.add_user_class(UserClass) assert_equal UserClass, ModelClass.user_model end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mongoid-userstamps-3.4.1 | test/config_test.rb |
mongoid-userstamps-3.4.0 | test/config_test.rb |
mongoid-userstamps-3.3.0 | test/config_test.rb |
mongoid-userstamps-3.2.1 | test/config_test.rb |