Skip to content

Instantly share code, notes, and snippets.

@stevenspiel
Last active March 30, 2016 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenspiel/b6913b7fd259a21eb6839c7f5554795f to your computer and use it in GitHub Desktop.
Save stevenspiel/b6913b7fd259a21eb6839c7f5554795f to your computer and use it in GitHub Desktop.
Tests that all ActiveRecord models are using paper_trail. It finds all classes that inherit from ActiveRecord::Base and checks to see if :paper_trail_options is defined on each one.
require 'rails_helper'
describe 'paper_trail' do
before { Rails.application.eager_load! }
let(:excluded_classes) { [ActiveRecord::SchemaMigration, PaperTrail::Version, PaperTrail::VersionAssociation] }
let(:models) { ActiveRecord::Base.descendants - excluded_classes }
it 'is implemented in all ActiveRecord::Base models' do
expect(models).to all(respond_to(:paper_trail_options))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment