Sha256: 27dd1415f3b33ac859c44b4f96b4bf69a6ab15592645390c1b9eb007bc8f1861

Contents?: true

Size: 980 Bytes

Versions: 1

Compression:

Stored size: 980 Bytes

Contents

# frozen_string_literal: true

RSpec.describe RuboCop::Cop::Discourse::NoResetColumnInformationInMigrations, :config do
  subject(:cop) { described_class.new(config) }

  let(:config) { RuboCop::Config.new }

  before { config["Discourse/NoResetColumnInformationInMigrations"]["Enabled"] = true }

  it "raises an offense if reset_column_information is used" do
    offenses = inspect_source(<<~RUBY)
      class SomeMigration < ActiveRecord::Migration[6.0]
        def up
          Post.reset_column_information
        end
      end
    RUBY

    expect(offenses.first.message).to match(described_class::MSG)
  end

  it "raise an offense if reset_column_information is used without AR model" do
    offenses = inspect_source(<<~RUBY)
      class SomeMigration < ActiveRecord::Migration[6.0]
        def up
          "post".classify.constantize.reset_column_information
        end
      end
    RUBY

    expect(offenses.first.message).to match(described_class::MSG)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-discourse-3.9.2 spec/lib/rubocop/cop/no_reset_column_information_migrations_spec.rb