source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/plant_spec.rb
Ruby
mit
6,998
master
777
# frozen_string_literal: true require "spec_helper" RSpec.describe Plant, :versioning do it "baseline test setup" do expect(described_class.new).to be_versioned expect(described_class.inheritance_column).to eq("species") end describe "#descends_from_active_record?" do it "returns true, meaning that...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/not_on_update_spec.rb
Ruby
mit
6,998
master
604
# frozen_string_literal: true require "spec_helper" RSpec.describe NotOnUpdate do describe "#save_with_version", :versioning do let!(:record) { described_class.create! } it "creates a version, regardless" do expect { record.paper_trail.save_with_version }.to change(PaperTrail::Version, :count).by(+1)...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/management_spec.rb
Ruby
mit
6,998
master
1,073
# frozen_string_literal: true require "spec_helper" RSpec.describe(Management, :versioning) do it "utilises the base_class for STI classes having no type column" do expect(described_class.inheritance_column).to eq("type") expect(described_class.columns.map(&:name)).not_to include("type") # Create, upda...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/wotsit_spec.rb
Ruby
mit
6,998
master
524
# frozen_string_literal: true require "spec_helper" RSpec.describe Wotsit, :versioning do it "update! records timestamps" do wotsit = described_class.create!(name: "wotsit") wotsit.update!(name: "changed") reified = wotsit.versions.last.reify expect(reified.created_at).not_to(be_nil) expect(reif...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/car_spec.rb
Ruby
mit
6,998
master
1,129
# frozen_string_literal: true require "spec_helper" RSpec.describe Car do it { is_expected.to be_versioned } describe "changeset", :versioning do it "has the expected keys (see issue 738)" do car = described_class.create!(name: "Alice") car.update(name: "Bob") assert_includes car.versions.l...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/json_version_spec.rb
Ruby
mit
6,998
master
4,687
# frozen_string_literal: true require "spec_helper" # The `json_versions` table tests postgres' `json` data type. So, that # table is only created when testing against postgres. if JsonVersion.table_exists? RSpec.describe JsonVersion, :versioning do it "includes the VersionConcern module" do expect(descri...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/callback_modifier_spec.rb
Ruby
mit
6,998
master
3,406
# frozen_string_literal: true require "spec_helper" RSpec.describe CallbackModifier, :versioning do describe "paper_trail_on_destroy" do it "adds :destroy to paper_trail_options[:on]" do modifier = NoArgDestroyModifier.create!(some_content: FFaker::Lorem.sentence) expect(modifier.paper_trail_options...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/legacy_widget_spec.rb
Ruby
mit
6,998
master
1,343
# frozen_string_literal: true require "spec_helper" RSpec.describe LegacyWidget, :versioning do describe "#custom_version" do it "knows which version it came from" do widget = described_class.create(name: "foo", version: 2) %w[bar baz].each { |name| widget.update(name: name) } version = widget...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/fruit_spec.rb
Ruby
mit
6,998
master
2,061
# frozen_string_literal: true require "spec_helper" if ENV["DB"] == "postgres" && JsonVersion.table_exists? RSpec.describe Fruit, :versioning do describe "have_a_version_with_changes matcher" do it "works with Fruit because Fruit uses JsonVersion" do # As of PT 9.0.0, with_version_changes only sup...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/document_spec.rb
Ruby
mit
6,998
master
1,500
# frozen_string_literal: true require "spec_helper" RSpec.describe Document, :versioning do describe "have_a_version_with matcher" do it "works with custom versions association" do document = described_class.create!(name: "Foo") document.update!(name: "Bar") expect(document).to have_a_version_...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/custom_primary_key_record_spec.rb
Ruby
mit
6,998
master
721
# frozen_string_literal: true require "spec_helper" RSpec.describe CustomPrimaryKeyRecord do it { is_expected.to be_versioned } describe "#versions" do it "returns instances of CustomPrimaryKeyRecordVersion", :versioning do custom_primary_key_record = described_class.create! custom_primary_key_re...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/foo_widget_spec.rb
Ruby
mit
6,998
master
987
# frozen_string_literal: true require "spec_helper" require "support/performance_helpers" RSpec.describe(FooWidget, :versioning) do context "with a subclass" do let(:foo) { described_class.create } before do foo.update!(name: "Foo") end it "reify with the correct type" do expect(PaperT...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/vegetable_spec.rb
Ruby
mit
6,998
master
1,503
# frozen_string_literal: true require "spec_helper" require "support/performance_helpers" if ENV["DB"] == "postgres" && JsonbVersion.table_exists? RSpec.describe Vegetable do describe "queries of versions", :versioning do let!(:vegetable) { described_class.create(name: "Veggie", mass: 1, color: "green") }...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/translation_spec.rb
Ruby
mit
6,998
master
3,256
# frozen_string_literal: true require "spec_helper" RSpec.describe Translation, :versioning do context "with non-US translations" do it "not change the number of versions" do described_class.create!(headline: "Headline") expect(PaperTrail::Version.count).to(eq(0)) end context "when after up...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/post_spec.rb
Ruby
mit
6,998
master
1,032
# frozen_string_literal: true require "spec_helper" # The `Post` model uses a custom version class, `PostVersion` RSpec.describe Post, :versioning do it "inserts records into the correct table, post_versions" do post = described_class.create expect(PostVersion.count).to(eq(1)) post.update(content: "Some...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/joined_version_spec.rb
Ruby
mit
6,998
master
1,271
# frozen_string_literal: true require "spec_helper" RSpec.describe JoinedVersion, :versioning do let(:widget) { Widget.create!(name: FFaker::Name.name) } let(:version) { described_class.first } describe "default_scope" do it { expect(described_class.default_scopes).not_to be_empty } end describe "Vers...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/gizmo_spec.rb
Ruby
mit
6,998
master
470
# frozen_string_literal: true require "spec_helper" require "support/performance_helpers" RSpec.describe Gizmo, :versioning do context "with a persisted record" do it "does not use the gizmo `updated_at` as the version's `created_at`" do gizmo = described_class.create(name: "Fred", created_at: 1.day.ago) ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/on/empty_array_spec.rb
Ruby
mit
6,998
master
875
# frozen_string_literal: true require "spec_helper" require_dependency "on/empty_array" module On RSpec.describe EmptyArray, :versioning do describe "#create" do it "does not create any version records" do record = described_class.create(name: "Alice") expect(record.versions.length).to(eq(...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/on/create_spec.rb
Ruby
mit
6,998
master
1,053
# frozen_string_literal: true require "spec_helper" require_dependency "on/create" module On RSpec.describe Create, :versioning do describe "#versions" do it "only have a version for the create event" do record = described_class.create(name: "Alice") record.update(name: "blah") rec...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/on/touch_spec.rb
Ruby
mit
6,998
master
1,020
# frozen_string_literal: true require "spec_helper" require_dependency "on/create" module On RSpec.describe Touch, :versioning do describe "#create" do it "does not create a version" do record = described_class.create(name: "Alice") expect(record.versions.count).to eq(0) end end ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/on/destroy_spec.rb
Ruby
mit
6,998
master
856
# frozen_string_literal: true require "spec_helper" require_dependency "on/destroy" module On RSpec.describe Destroy, :versioning do describe "#versions" do it "only creates one version record, for the destroy event" do record = described_class.create(name: "Alice") record.update(name: "bl...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/on/update_spec.rb
Ruby
mit
6,998
master
1,084
# frozen_string_literal: true require "spec_helper" require_dependency "on/update" module On RSpec.describe Update, :versioning do describe "#versions" do it "only creates one version record, for the update event" do record = described_class.create(name: "Alice") record.update(name: "blah"...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/kitchen/banana_spec.rb
Ruby
mit
6,998
master
374
# frozen_string_literal: true require "spec_helper" module Kitchen RSpec.describe Banana do it { is_expected.to be_versioned } describe "#versions" do it "returns instances of Kitchen::BananaVersion", :versioning do banana = described_class.create! expect(banana.versions.first).to be_...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/models/family/celebrity_family_spec.rb
Ruby
mit
6,998
master
4,920
# frozen_string_literal: true require "spec_helper" module Family RSpec.describe CelebrityFamily, :versioning do describe "#joins" do it "works on an STI model" do described_class.create! result = described_class. joins(:versions). select("families.id, max(versions.even...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/Rakefile
Ruby
mit
6,998
master
292
# frozen_string_literal: true # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path("config/application", __dir__) require "rake" Dummy::Application.load_tasks
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/db/migrate/20110208155312_set_up_test_tables.rb
Ruby
mit
6,998
master
11,242
# frozen_string_literal: true # Parts of this migration must be kept in sync with # `lib/generators/paper_trail/templates/create_versions.rb` # # Starting with AR 5.1, we must specify which version of AR we are using. # I tried using `const_get` but I got a `NameError`, then I learned about # `::ActiveRecord::Migratio...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/controllers/articles_controller.rb
Ruby
mit
6,998
master
276
# frozen_string_literal: true class ArticlesController < ApplicationController def create @article = Article.create article_params head :ok end def current_user "foobar" end private def article_params params.require(:article).permit! end end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/controllers/widgets_controller.rb
Ruby
mit
6,998
master
514
# frozen_string_literal: true class WidgetsController < ApplicationController def paper_trail_enabled_for_controller request.user_agent != "Disable User-Agent" end def create @widget = Widget.create widget_params head :ok end def update @widget = Widget.find params[:id] @widget.update w...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/controllers/application_controller.rb
Ruby
mit
6,998
master
906
# frozen_string_literal: true class ApplicationController < ActionController::Base protect_from_forgery # Some applications and libraries modify `current_user`. Their changes need # to be reflected in `whodunnit`, so the `set_paper_trail_whodunnit` below # must happen after this. before_action :modify_curre...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/versions/comment_version.rb
Ruby
mit
6,998
master
202
# frozen_string_literal: true class CommentVersion < PaperTrail::Version self.table_name = "comment_versions" # add rails validation to require whodunnit validates :whodunnit, presence: true end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/versions/joined_version.rb
Ruby
mit
6,998
master
358
# frozen_string_literal: true # The purpose of this custom version class is to test the scope methods on the # VersionConcern::ClassMethods module. See # https://github.com/paper-trail-gem/paper_trail/issues/295 for more details. class JoinedVersion < PaperTrail::Version default_scope { joins("INNER JOIN widgets ON ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/song.rb
Ruby
mit
6,998
master
304
# frozen_string_literal: true class Song < ApplicationRecord has_paper_trail attribute :name, :string # Uses an integer of seconds to hold the length of the song def length=(minutes) write_attribute(:length, minutes.to_i * 60) end def length read_attribute(:length) / 60 end end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/vegetable.rb
Ruby
mit
6,998
master
276
# frozen_string_literal: true # See also `Fruit` which uses `JsonVersion`. class Vegetable < ApplicationRecord has_paper_trail versions: { class_name: ENV["DB"] == "postgres" ? "JsonbVersion" : "PaperTrail::Version" }, on: %i[create update] encrypts :supplier end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/translation.rb
Ruby
mit
6,998
master
253
# frozen_string_literal: true # Demonstrates the `if` and `unless` configuration options. class Translation < ApplicationRecord has_paper_trail( if: proc { |t| t.language_code == "US" }, unless: proc { |t| t.draft_status == "DRAFT" } ) end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/vehicle.rb
Ruby
mit
6,998
master
263
# frozen_string_literal: true class Vehicle < ApplicationRecord # This STI parent class specifically does not call `has_paper_trail`. # Of its sub-classes, only `Car` and `Bicycle` are versioned. belongs_to :owner, class_name: "Person", optional: true end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/thing.rb
Ruby
mit
6,998
master
217
# frozen_string_literal: true class Thing < ApplicationRecord has_paper_trail versions: { scope: -> { order("id desc") }, extend: PrefixVersionsInspectWithCount } belongs_to :person, optional: true end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/chapter.rb
Ruby
mit
6,998
master
262
# frozen_string_literal: true class Chapter < ApplicationRecord has_many :sections, dependent: :destroy has_many :paragraphs, through: :sections has_many :quotations, dependent: :destroy has_many :citations, through: :quotations has_paper_trail end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/management.rb
Ruby
mit
6,998
master
228
# frozen_string_literal: true # Note that there is no `type` column for this subclassed model, so changes to # Management objects should result in Versions which have an item_type of # Customer. class Management < Customer end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/custom_primary_key_record.rb
Ruby
mit
6,998
master
483
# frozen_string_literal: true require "securerandom" class CustomPrimaryKeyRecord < ApplicationRecord self.primary_key = :uuid has_paper_trail versions: { class_name: "CustomPrimaryKeyRecordVersion" } # This default_scope is to test the case of the Version#item association # not returning the item due to un...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/truck.rb
Ruby
mit
6,998
master
205
# frozen_string_literal: true class Truck < Vehicle # This STI child class specifically does not call `has_paper_trail`. # Of the sub-classes of `Vehicle`, only `Car` and `Bicycle` are versioned. end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/post_with_status.rb
Ruby
mit
6,998
master
406
# frozen_string_literal: true # This model tests ActiveRecord::Enum, which was added in AR 4.1 # http://edgeguides.rubyonrails.org/4_1_release_notes.html#active-record-enums class PostWithStatus < ApplicationRecord has_paper_trail if ActiveRecord::VERSION::MAJOR >= 7 enum :status, { draft: 0, published: 1, ar...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/book.rb
Ruby
mit
6,998
master
262
# frozen_string_literal: true class Book < ApplicationRecord has_many :authorships, dependent: :destroy has_many :authors, through: :authorships has_many :editorships, dependent: :destroy has_many :editors, through: :editorships has_paper_trail end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/no_object.rb
Ruby
mit
6,998
master
280
# frozen_string_literal: true # Demonstrates a table that omits the `object` column. class NoObject < ApplicationRecord has_paper_trail( versions: { class_name: "NoObjectVersion" }, meta: { metadatum: 42 } ) validates :letter, length: { is: 1 }, presence: true end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/callback_modifier.rb
Ruby
mit
6,998
master
1,152
# frozen_string_literal: true module CallbackModifier extend ActiveSupport::Concern included do self.table_name = "callback_modifiers" end def test_destroy transaction do run_callbacks(:destroy) do self.deleted = true save! end end end def flagged_deleted? del...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/plant.rb
Ruby
mit
6,998
master
565
# frozen_string_literal: true class Plant < ApplicationRecord has_paper_trail self.inheritance_column = "species" class << self # Rails 6.1 adds a public method to overwrite sti finder methods. In earlier versions, users # may use the private method find_sti_class. # # See https://github.com/rai...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/legacy_widget.rb
Ruby
mit
6,998
master
307
# frozen_string_literal: true # The `legacy_widgets` table has a `version` column that would conflict with our # `version` method. It is configured to define a method named `custom_version` # instead. class LegacyWidget < ApplicationRecord has_paper_trail ignore: :version, version: "custom_version" end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/article.rb
Ruby
mit
6,998
master
677
# frozen_string_literal: true # Demonstrates the `only` and `ignore` attributes, among other things. class Article < ApplicationRecord has_paper_trail( ignore: [ :title, { abstract: proc { |obj| ["ignore abstract", "Other abstract"].include? obj.abstract } } ], only:...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/fruit.rb
Ruby
mit
6,998
master
234
# frozen_string_literal: true # See also `Vegetable` which uses `JsonbVersion`. class Fruit < ApplicationRecord if ENV["DB"] == "postgres" has_paper_trail versions: { class_name: "JsonVersion" } end encrypts :supplier end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/widget.rb
Ruby
mit
6,998
master
268
# frozen_string_literal: true class Widget < ApplicationRecord EXCLUDED_NAME = "Biglet" has_paper_trail has_one :wotsit has_many(:fluxors, -> { order(:name) }) has_many :whatchamajiggers, as: :owner validates :name, exclusion: { in: [EXCLUDED_NAME] } end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/elephant.rb
Ruby
mit
6,998
master
788
# frozen_string_literal: true class Elephant < Animal end # Nice! We used to have `paper_trail.disable` inside the class, which was really # misleading because it looked like a permanent, global setting. It's so much # more obvious now that we are disabling the model for this request only. Of # course, we run the PT ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/document.rb
Ruby
mit
6,998
master
313
# frozen_string_literal: true # Demonstrates a "custom versions association name". Instead of the association # being named `versions`, it will be named `paper_trail_versions`. class Document < ApplicationRecord has_paper_trail( versions: { name: :paper_trail_versions }, on: %i[create update] ) end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/person.rb
Ruby
mit
6,998
master
1,422
# frozen_string_literal: true class Person < ApplicationRecord has_many :authorships, foreign_key: :author_id, dependent: :destroy has_many :books, through: :authorships has_many :pets, foreign_key: :owner_id, dependent: :destroy has_many :animals, through: :pets has_many :dogs, class_name: "Dog", through: ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/family/family.rb
Ruby
mit
6,998
master
662
# frozen_string_literal: true module Family class Family < ApplicationRecord has_paper_trail has_many :familie_lines, class_name: "::Family::FamilyLine", foreign_key: :parent_id has_many :children, class_name: "::Family::Family", foreign_key: :parent_id has_many :grandsons, through: :familie_lines ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/app/models/family/family_line.rb
Ruby
mit
6,998
master
282
# frozen_string_literal: true module Family class FamilyLine < ApplicationRecord has_paper_trail belongs_to :parent, class_name: "::Family::Family", optional: true belongs_to :grandson, class_name: "::Family::Family", optional: true end end
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/config/application.rb
Ruby
mit
6,998
master
1,620
# frozen_string_literal: true require File.expand_path("boot", __dir__) # Here a conventional app would load the Rails components it needs, but we have # already loaded these in our spec_helper. # require "active_record/railtie" # require "action_controller/railtie" # Here a conventional app would require gems, but ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/config/initializers/session_store.rb
Ruby
mit
6,998
master
438
# frozen_string_literal: true # Be sure to restart your server when you modify this file. Dummy::Application.config.session_store :cookie_store, key: "_dummy_session" # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/config/initializers/mime_types.rb
Ruby
mit
6,998
master
236
# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/config/initializers/backtrace_silencers.rb
Ruby
mit
6,998
master
439
# frozen_string_literal: true # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish # to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/config/initializers/inflections.rb
Ruby
mit
6,998
master
407
# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' #...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/config/environments/production.rb
Ruby
mit
6,998
master
2,788
# frozen_string_literal: true Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, al...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/config/environments/development.rb
Ruby
mit
6,998
master
1,366
# frozen_string_literal: true Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/dummy_app/config/environments/test.rb
Ruby
mit
6,998
master
1,921
# frozen_string_literal: true Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "s...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/support/paper_trail_spec_migrator.rb
Ruby
mit
6,998
master
2,815
# frozen_string_literal: true # AR 6.1 does not autoload MigrationContext, so we must `require` it. # # ``` # # lib/active_record.rb # autoload :Migration # autoload :Migrator, "active_record/migration" # ``` # # The above may indicate that we should use `Migrator` instead of # MigrationContext. require "active_record...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/support/custom_object_changes_adapter.rb
Ruby
mit
6,998
master
543
# frozen_string_literal: true # This custom serializer excludes nil values class CustomObjectChangesAdapter def diff(changes) changes end def load_changeset(version) version.changeset end def where_attribute_changes(klass, attribute) klass.where(attribute) end def where_object_changes(klas...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/support/performance_helpers.rb
Ruby
mit
6,998
master
782
# frozen_string_literal: true require "memory_profiler" RSpec::Matchers.define :allocate_less_than do |expected| supports_block_expectations chain :bytes do @scale = :bs end chain :kilobytes do @scale = :kbs end chain :and_print_report do @report = true end match do |actual| @scale...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/support/custom_json_serializer.rb
Ruby
mit
6,998
master
387
# frozen_string_literal: true # This custom serializer excludes nil values module CustomJsonSerializer extend PaperTrail::Serializers::JSON def self.load(string) parsed_value = super parsed_value.is_a?(Hash) ? parsed_value.reject { |k, v| k.blank? || v.blank? } : parsed_value end def self.dump(object...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/support/shared_examples/queries.rb
Ruby
mit
6,998
master
14,405
# frozen_string_literal: true require "support/custom_object_changes_adapter" RSpec.shared_examples "queries" do |column_type, model, name_of_integer_column| let(:record) { model.new } let(:name) { FFaker::Name.first_name } let(:int) { column_type == :text ? 1 : rand(2..6) } after do PaperTrail.serialize...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/support/shared_examples/active_record_encryption.rb
Ruby
mit
6,998
master
2,304
# frozen_string_literal: true RSpec.shared_examples "active_record_encryption" do |model| context "when ActiveRecord Encryption is enabled", :versioning do let(:record) { model.create(supplier: "ABC", name: "Tomato") } before do ActiveRecord::Encryption.configure( primary_key: "test", ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/generators/paper_trail/install_generator_spec.rb
Ruby
mit
6,998
master
6,543
# frozen_string_literal: true require "spec_helper" require "generator_spec/test_case" require "generators/paper_trail/install/install_generator" RSpec.describe PaperTrail::InstallGenerator, type: :generator do include GeneratorSpec::TestCase destination File.expand_path("tmp", __dir__) after do prepare_d...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
spec/requests/articles_spec.rb
Ruby
mit
6,998
master
936
# frozen_string_literal: true require "spec_helper" RSpec.describe "Articles management", order: :defined do let(:valid_params) { { article: { title: "Doh", content: FFaker::Lorem.sentence } } } context "with versioning disabled" do specify { expect(PaperTrail).not_to be_enabled } it "does not create a ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail.rb
Ruby
mit
6,998
master
4,573
# frozen_string_literal: true # AR does not require all of AS, but PT does. PT uses core_ext like # `String#squish`, so we require `active_support/all`. Instead of eagerly # loading all of AS here, we could put specific `require`s in only the various # PT files that need them, but this seems easier to troubleshoot, th...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/generators/paper_trail/migration_generator.rb
Ruby
mit
6,998
master
1,908
# frozen_string_literal: true require "rails/generators" require "rails/generators/active_record" module PaperTrail # Basic structure to support a generator that builds a migration class MigrationGenerator < ::Rails::Generators::Base include ::Rails::Generators::Migration # Define arguments for the gener...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/generators/paper_trail/update_item_subtype/update_item_subtype_generator.rb
Ruby
mit
6,998
master
1,233
# frozen_string_literal: true require_relative "../migration_generator" module PaperTrail # Updates STI entries for PaperTrail class UpdateItemSubtypeGenerator < MigrationGenerator source_root File.expand_path("templates", __dir__) # Remove the inherited version_class_name argument as we use an option in...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/generators/paper_trail/install/install_generator.rb
Ruby
mit
6,998
master
3,266
# frozen_string_literal: true require_relative "../migration_generator" module PaperTrail # Installs PaperTrail in a rails app. class InstallGenerator < MigrationGenerator # Class names of MySQL adapters. # - `MysqlAdapter` - Used by gems: `mysql`, `activerecord-jdbcmysql-adapter`. # - `Mysql2Adapter`...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/config.rb
Ruby
mit
6,998
master
1,074
# frozen_string_literal: true require "singleton" require "paper_trail/serializers/yaml" module PaperTrail # Global configuration affecting all threads. Some thread-specific # configuration can be found in `paper_trail.rb`, others in `controller.rb`. class Config include Singleton attr_accessor( ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/version_number.rb
Ruby
mit
6,998
master
663
# frozen_string_literal: true module PaperTrail # The version number of the paper_trail gem. Not to be confused with # `PaperTrail::Version`. Ruby constants are case-sensitive, apparently, # and they are two different modules! It would be nice to remove `VERSION`, # because of this confusion, but it's not wort...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/cleaner.rb
Ruby
mit
6,998
master
2,515
# frozen_string_literal: true module PaperTrail # Utilities for deleting version records. module Cleaner # Destroys all but the most recent version(s) for items on a given date # (or on all dates). Useful for deleting drafts. # # Options: # # - :keeping - An `integer` indicating the number ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/version_concern.rb
Ruby
mit
6,998
master
14,002
# frozen_string_literal: true require "paper_trail/attribute_serializers/object_changes_attribute" require "paper_trail/queries/versions/where_attribute_changes" require "paper_trail/queries/versions/where_object" require "paper_trail/queries/versions/where_object_changes" require "paper_trail/queries/versions/where_o...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/has_paper_trail.rb
Ruby
mit
6,998
master
4,276
# frozen_string_literal: true require "paper_trail/attribute_serializers/object_attribute" require "paper_trail/attribute_serializers/object_changes_attribute" require "paper_trail/model_config" require "paper_trail/record_trail" module PaperTrail # Extensions to `ActiveRecord::Base`. See `frameworks/active_record...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/errors.rb
Ruby
mit
6,998
master
717
# frozen_string_literal: true module PaperTrail # Generic PaperTrail exception. # @api public class Error < StandardError end # An unexpected option, perhaps a typo, was passed to a public API method. # @api public class InvalidOption < Error end # The application's database schema is not supported...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/record_trail.rb
Ruby
mit
6,998
master
11,649
# frozen_string_literal: true require "paper_trail/events/create" require "paper_trail/events/destroy" require "paper_trail/events/update" module PaperTrail # Represents the "paper trail" for a single record. class RecordTrail def initialize(record) @record = record end # Invoked after rollback...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/reifier.rb
Ruby
mit
6,998
master
5,888
# frozen_string_literal: true require "paper_trail/attribute_serializers/object_attribute" module PaperTrail # Given a version record and some options, builds a new model object. # @api private module Reifier class << self # See `VersionConcern#reify` for documentation. # @api private def ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/record_history.rb
Ruby
mit
6,998
master
1,442
# frozen_string_literal: true module PaperTrail # Represents the history of a single record. # @api private class RecordHistory # @param versions - ActiveRecord::Relation - All versions of the record. # @param version_class - Class - Usually PaperTrail::Version, # but it could also be a custom vers...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/model_config.rb
Ruby
mit
6,998
master
8,926
# frozen_string_literal: true module PaperTrail # Configures an ActiveRecord model, mostly at application boot time, but also # sometimes mid-request, with methods like enable/disable. class ModelConfig E_CANNOT_RECORD_AFTER_DESTROY = <<~STR paper_trail.on_destroy(:after) is incompatible with ActiveRec...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/request.rb
Ruby
mit
6,998
master
5,094
# frozen_string_literal: true require "request_store" module PaperTrail # Manages variables that affect the current HTTP request, such as `whodunnit`. # # Please do not use `PaperTrail::Request` directly, use `PaperTrail.request`. # Currently, `Request` is a `Module`, but in the future it is quite possible ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/compatibility.rb
Ruby
mit
6,998
master
2,168
# frozen_string_literal: true module PaperTrail # Rails does not follow SemVer, makes breaking changes in minor versions. # Breaking changes are expected, and are generally good for the rails # ecosystem. However, they often require dozens of hours to fix, even with the # [help of experts](https://github.com/p...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/queries/versions/where_object.rb
Ruby
mit
6,998
master
1,875
# frozen_string_literal: true module PaperTrail module Queries module Versions # For public API documentation, see `where_object` in # `paper_trail/version_concern.rb`. # @api private class WhereObject # - version_model_class - The class that VersionConcern was mixed into. ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/queries/versions/where_object_changes_to.rb
Ruby
mit
6,998
master
1,744
# frozen_string_literal: true module PaperTrail module Queries module Versions # For public API documentation, see `where_object_changes_to` in # `paper_trail/version_concern.rb`. # @api private class WhereObjectChangesTo # - version_model_class - The class that VersionConcern was...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/queries/versions/where_object_changes_from.rb
Ruby
mit
6,998
master
1,754
# frozen_string_literal: true module PaperTrail module Queries module Versions # For public API documentation, see `where_object_changes_from` in # `paper_trail/version_concern.rb`. # @api private class WhereObjectChangesFrom # - version_model_class - The class that VersionConcern...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/queries/versions/where_attribute_changes.rb
Ruby
mit
6,998
master
1,496
# frozen_string_literal: true module PaperTrail module Queries module Versions # For public API documentation, see `where_attribute_changes` in # `paper_trail/version_concern.rb`. # @api private class WhereAttributeChanges # - version_model_class - The class that VersionConcern wa...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/queries/versions/where_object_changes.rb
Ruby
mit
6,998
master
2,311
# frozen_string_literal: true module PaperTrail module Queries module Versions # For public API documentation, see `where_object_changes` in # `paper_trail/version_concern.rb`. # @api private class WhereObjectChanges # - version_model_class - The class that VersionConcern was mixe...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/serializers/yaml.rb
Ruby
mit
6,998
master
2,286
# frozen_string_literal: true require "yaml" module PaperTrail module Serializers # The default serializer for, e.g. `versions.object`. module YAML extend self # makes all instance methods become module methods as well def load(string) if use_safe_load? ::YAML.safe_load( ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/serializers/json.rb
Ruby
mit
6,998
master
1,172
# frozen_string_literal: true module PaperTrail module Serializers # An alternate serializer for, e.g. `versions.object`. module JSON extend self # makes all instance methods become module methods as well def load(string) ActiveSupport::JSON.decode string end def dump(object...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/type_serializers/postgres_array_serializer.rb
Ruby
mit
6,998
master
854
# frozen_string_literal: true module PaperTrail module TypeSerializers # Provides an alternative method of serialization # and deserialization of PostgreSQL array columns. class PostgresArraySerializer def initialize(subtype, delimiter) @subtype = subtype @delimiter = delimiter ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/events/base.rb
Ruby
mit
6,998
master
11,821
# frozen_string_literal: true module PaperTrail module Events # We refer to times in the lifecycle of a record as "events". There are # three events: # # - create # - `after_create` we call `RecordTrail#record_create` # - update # - `after_update` we call `RecordTrail#record_update` ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/events/update.rb
Ruby
mit
6,998
master
2,278
# frozen_string_literal: true require "paper_trail/events/base" module PaperTrail module Events # See docs in `Base`. # # @api private class Update < Base # - is_touch - [boolean] - Used in the two situations that are touch-like: # - `after_touch` we call `RecordTrail#record_update` ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/events/create.rb
Ruby
mit
6,998
master
805
# frozen_string_literal: true require "paper_trail/events/base" module PaperTrail module Events # See docs in `Base`. # # @api private class Create < Base # Return attributes of nascent `Version` record. # # @api private def data data = { item: @record, ...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/events/destroy.rb
Ruby
mit
6,998
master
1,092
# frozen_string_literal: true require "paper_trail/events/base" module PaperTrail module Events # See docs in `Base`. # # @api private class Destroy < Base # Return attributes of nascent `Version` record. # # @api private def data data = { item_id: @record.i...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/frameworks/rspec.rb
Ruby
mit
6,998
master
1,376
# frozen_string_literal: true require "rspec/core" require "rspec/matchers" require "paper_trail/frameworks/rspec/helpers" RSpec.configure do |config| config.include PaperTrail::RSpec::Helpers::InstanceMethods config.extend PaperTrail::RSpec::Helpers::ClassMethods config.before(:each) do PaperTrail.enabled...
github
paper-trail-gem/paper_trail
https://github.com/paper-trail-gem/paper_trail
lib/paper_trail/frameworks/active_record.rb
Ruby
mit
6,998
master
477
# frozen_string_literal: true # Either ActiveRecord has already been loaded by the Lazy Load Hook in our # Railtie, or else we load it now. require "active_record" PaperTrail::Compatibility.check_activerecord(ActiveRecord.gem_version) # Now we can load the parts of PT that depend on AR. require "paper_trail/has_paper...