Sha256: 33a8a1c517ed9f60c06c3b1731d67fb90393db541f9277380e993bbbf84deff3

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require "spec_helper"

RSpec.describe PaperTrail::VersionConcern do
  before(:all) { require "support/alt_db_init" }

  it "allows included class to have different connections" do
    expect(Foo::Version.connection).not_to eq(Bar::Version.connection)
  end

  it "allows custom version class to share connection with superclass" do
    expect(Foo::Version.connection).to eq(Foo::Document.connection)
    expect(Bar::Version.connection).to eq(Bar::Document.connection)
  end

  it "can be used with class_name option" do
    expect(Foo::Document.version_class_name).to eq("Foo::Version")
    expect(Bar::Document.version_class_name).to eq("Bar::Version")
  end

  describe "persistence", versioning: true do
    it "stores versions in the correct corresponding db location" do
      foo_doc = Foo::Document.create!(name: "foobar")
      bar_doc = Bar::Document.create!(name: "raboof")
      expect(foo_doc.versions.first).to be_instance_of(Foo::Version)
      expect(bar_doc.versions.first).to be_instance_of(Bar::Version)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
paper_trail-7.1.0 spec/modules/version_concern_spec.rb
paper_trail-7.0.3 spec/modules/version_concern_spec.rb