Sha256: e484fefd857dad0704631cf786eb7327e16cd5b5cdc86f2e815ae8e17d0cb4ab

Contents?: true

Size: 1.42 KB

Versions: 13

Compression:

Stored size: 1.42 KB

Contents

require "rails_helper"
require "generators/paper_trail/templates/create_versions"

RSpec.describe CreateVersions do
  describe "#change", verify_stubs: false do
    let(:migration) { described_class.new }

    before do
      allow(migration).to receive(:add_index)
      allow(migration).to receive(:create_table)
    end

    it "creates the versions table" do
      migration.change
      expect(migration).to have_received(:create_table) do |arg1|
        expect(arg1).to eq(:versions)
      end
    end

    case ENV["DB"]
    when "mysql"
      it "uses InnoDB engine" do
        migration.change
        expect(migration).to have_received(:create_table) do |_, arg2|
          expect(arg2[:options]).to match(/ENGINE=InnoDB/)
        end
      end

      it "uses utf8mb4 character set" do
        migration.change
        expect(migration).to have_received(:create_table) do |_, arg2|
          expect(arg2[:options]).to match(/DEFAULT CHARSET=utf8mb4/)
        end
      end

      it "uses utf8mb4_col collation" do
        migration.change
        expect(migration).to have_received(:create_table) do |_, arg2|
          expect(arg2[:options]).to match(/COLLATE=utf8mb4_general_ci/)
        end
      end
    else
      it "passes an empty options hash to create_table" do
        migration.change
        expect(migration).to have_received(:create_table) do |_, arg2|
          expect(arg2).to eq({})
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/paper_trail-5.2.3/spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-7.0.0 spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-6.0.2 spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-6.0.1 spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-6.0.0 spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-5.2.3 spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-5.2.2 spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-5.2.1 spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-5.2.0 spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-5.1.1 spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-5.1.0 spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-5.0.1 spec/generators/paper_trail/templates/create_versions_spec.rb
paper_trail-5.0.0 spec/generators/paper_trail/templates/create_versions_spec.rb