Sha256: 3892ec02f4dea7366b92230503b6d9bf090085772b4db181ef1ad4361281f331

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

# -*- encoding : utf-8 -*-
require 'spec_helper'

describe Mongoid::Userstamp::ModelConfig do

  subject { Mongoid::Userstamp::ModelConfig.new }
  before  { Mongoid::Userstamp.stub('config').and_return(OpenStruct.new(created_name: :created_by,
                                                                        updated_name: :updated_by)) }
  before  { Mongoid::Userstamp.stub('user_classes').and_return(['User']) }

  describe '#initialize' do

    context 'with opts hash' do
      subject { Mongoid::Userstamp::ModelConfig.new(user_model: :bar,
                                                    created_name: :c_by,
                                                    updated_name: :u_by) }

      it { should be_a Mongoid::Userstamp::ModelConfig }
      it { subject.user_model.should eq :bar }
      it { subject.created_name.should eq :c_by }
      it { subject.updated_name.should eq :u_by }
    end

    context 'without opts hash' do
      it { should be_a Mongoid::Userstamp::ModelConfig }
      it { subject.user_model.should eq 'User' }
      it { subject.created_name.should eq :created_by }
      it { subject.updated_name.should eq :updated_by }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mongoid-userstamps-3.1.3 spec/unit/model_config_spec.rb
mongoid-userstamps-3.1.2 spec/unit/model_config_spec.rb
mongoid-userstamps-3.1.1 spec/unit/model_config_spec.rb
mongoid-userstamps-3.1.0 spec/unit/model_config_spec.rb
mongoid-userstamps-3.0.0.alpha1 spec/unit/model_config_spec.rb
mongoid-userstamps-2.0.0 spec/unit/model_config_spec.rb
mongoid-userstamps-1.0.0 spec/unit/model_config_spec.rb