Sha256: 1302d677e9eca83e400cedaad945ce286142a124acd5cef4ef81f056bebced64

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require "spec_helper"

describe Mongoid::Userstamp::ModelConfig do
  subject { Mongoid::Userstamp::ModelConfig.new }
  before do
    Mongoid::Userstamp.stub("config").and_return(OpenStruct.new(created_name: :created_by,
                                                                updated_name: :updated_by))
  end
  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

4 entries across 4 versions & 1 rubygems

Version Path
mongoid-userstamps-3.4.1 spec/unit/model_config_spec.rb
mongoid-userstamps-3.4.0 spec/unit/model_config_spec.rb
mongoid-userstamps-3.3.0 spec/unit/model_config_spec.rb
mongoid-userstamps-3.2.1 spec/unit/model_config_spec.rb