Sha256: 9c29c67dfd994bdd5334a67c6a92ca9a0be6343c36ea5f5d32506b215aac118b
Contents?: true
Size: 1.59 KB
Versions: 10
Compression:
Stored size: 1.59 KB
Contents
# frozen_string_literal: true require "spec_helper" describe RuboCop::Cop::Discourse::NoAddReferenceOrAliasesActiveRecordMigration, :config do subject(:cop) { described_class.new(config) } let(:config) { RuboCop::Config.new } it "raises an offense if add_reference is used, with or without arguments" do inspect_source(<<~RUBY) add_reference :posts, :users, foreign_key: true, null: false RUBY expect(cop.offenses.first.message).to match(described_class::MSG) end it "raises an offense if add_belongs_to is used, with or without arguments" do inspect_source(<<~RUBY) add_belongs_to :posts, :users, foreign_key: true, null: false RUBY expect(cop.offenses.first.message).to match(described_class::MSG) end it "raises an offense if t.references, or any variable.references is used, with or without arguments" do inspect_source(<<~RUBY) create_table do |t| t.references :topic, null: false end create_table do |mytable| mytable.references :topic, null: false end RUBY expect(cop.offenses.count).to eq(2) expect(cop.offenses.first.message).to match(described_class::MSG) end it "raises an offense if t.belongs_to, or any variable.belongs_to is used, with or without arguments" do inspect_source(<<~RUBY) create_table do |t| t.belongs_to :topic, null: false end create_table do |mytable| mytable.belongs_to :topic, null: false end RUBY expect(cop.offenses.count).to eq(2) expect(cop.offenses.first.message).to match(described_class::MSG) end end
Version data entries
10 entries across 10 versions & 1 rubygems