paper_trail_scrapbook 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +52 -0
  3. data/.rubocop.yml +2 -1
  4. data/.ruby-version +1 -0
  5. data/Changelog.md +2 -2
  6. data/Gemfile +2 -0
  7. data/Gemfile.lock +5 -2
  8. data/Rakefile +2 -0
  9. data/lib/paper_trail_scrapbook.rb +2 -4
  10. data/lib/paper_trail_scrapbook/changes.rb +21 -21
  11. data/lib/paper_trail_scrapbook/chapter.rb +2 -0
  12. data/lib/paper_trail_scrapbook/config.rb +4 -2
  13. data/lib/paper_trail_scrapbook/journal_entry.rb +2 -0
  14. data/lib/paper_trail_scrapbook/life_history.rb +2 -0
  15. data/lib/paper_trail_scrapbook/secondary_chapter.rb +2 -0
  16. data/lib/paper_trail_scrapbook/user_journal.rb +2 -0
  17. data/lib/paper_trail_scrapbook/version.rb +3 -1
  18. data/lib/paper_trail_scrapbook/version_helpers.rb +2 -0
  19. data/paper_trail_scrapbook.gemspec +5 -2
  20. data/spec/dummy_app/Rakefile +3 -1
  21. data/spec/dummy_app/app/models/animal.rb +2 -0
  22. data/spec/dummy_app/app/models/article.rb +2 -0
  23. data/spec/dummy_app/app/models/authorship.rb +2 -0
  24. data/spec/dummy_app/app/models/bar_habtm.rb +2 -0
  25. data/spec/dummy_app/app/models/book.rb +2 -0
  26. data/spec/dummy_app/app/models/boolit.rb +2 -0
  27. data/spec/dummy_app/app/models/callback_modifier.rb +2 -0
  28. data/spec/dummy_app/app/models/car.rb +2 -0
  29. data/spec/dummy_app/app/models/cat.rb +2 -0
  30. data/spec/dummy_app/app/models/chapter.rb +2 -0
  31. data/spec/dummy_app/app/models/citation.rb +2 -0
  32. data/spec/dummy_app/app/models/custom_primary_key_record.rb +2 -0
  33. data/spec/dummy_app/app/models/customer.rb +2 -0
  34. data/spec/dummy_app/app/models/document.rb +2 -0
  35. data/spec/dummy_app/app/models/dog.rb +2 -0
  36. data/spec/dummy_app/app/models/editor.rb +2 -0
  37. data/spec/dummy_app/app/models/editorship.rb +2 -0
  38. data/spec/dummy_app/app/models/elephant.rb +2 -0
  39. data/spec/dummy_app/app/models/fluxor.rb +2 -0
  40. data/spec/dummy_app/app/models/foo_habtm.rb +2 -0
  41. data/spec/dummy_app/app/models/foo_widget.rb +2 -0
  42. data/spec/dummy_app/app/models/fruit.rb +2 -0
  43. data/spec/dummy_app/app/models/gadget.rb +2 -0
  44. data/spec/dummy_app/app/models/kitchen/banana.rb +2 -0
  45. data/spec/dummy_app/app/models/legacy_widget.rb +2 -0
  46. data/spec/dummy_app/app/models/line_item.rb +2 -0
  47. data/spec/dummy_app/app/models/not_on_update.rb +2 -0
  48. data/spec/dummy_app/app/models/on/create.rb +2 -0
  49. data/spec/dummy_app/app/models/on/destroy.rb +2 -0
  50. data/spec/dummy_app/app/models/on/empty_array.rb +2 -0
  51. data/spec/dummy_app/app/models/on/update.rb +2 -0
  52. data/spec/dummy_app/app/models/order.rb +2 -0
  53. data/spec/dummy_app/app/models/paragraph.rb +2 -0
  54. data/spec/dummy_app/app/models/person.rb +2 -0
  55. data/spec/dummy_app/app/models/post.rb +2 -0
  56. data/spec/dummy_app/app/models/post_with_status.rb +2 -0
  57. data/spec/dummy_app/app/models/quotation.rb +2 -0
  58. data/spec/dummy_app/app/models/section.rb +2 -0
  59. data/spec/dummy_app/app/models/skipper.rb +2 -0
  60. data/spec/dummy_app/app/models/song.rb +2 -0
  61. data/spec/dummy_app/app/models/thing.rb +2 -0
  62. data/spec/dummy_app/app/models/translation.rb +2 -0
  63. data/spec/dummy_app/app/models/truck.rb +2 -0
  64. data/spec/dummy_app/app/models/vehicle.rb +2 -0
  65. data/spec/dummy_app/app/models/whatchamajigger.rb +2 -0
  66. data/spec/dummy_app/app/models/widget.rb +3 -1
  67. data/spec/dummy_app/app/models/wotsit.rb +2 -0
  68. data/spec/dummy_app/app/versions/custom_primary_key_record_version.rb +2 -0
  69. data/spec/dummy_app/app/versions/joined_version.rb +2 -0
  70. data/spec/dummy_app/app/versions/json_version.rb +2 -0
  71. data/spec/dummy_app/app/versions/kitchen/banana_version.rb +2 -0
  72. data/spec/dummy_app/app/versions/post_version.rb +2 -0
  73. data/spec/dummy_app/config.ru +2 -0
  74. data/spec/dummy_app/config/application.rb +3 -1
  75. data/spec/dummy_app/config/boot.rb +4 -2
  76. data/spec/dummy_app/config/environment.rb +3 -1
  77. data/spec/dummy_app/config/environments/development.rb +2 -0
  78. data/spec/dummy_app/config/environments/production.rb +2 -0
  79. data/spec/dummy_app/config/environments/test.rb +2 -0
  80. data/spec/dummy_app/config/initializers/backtrace_silencers.rb +2 -0
  81. data/spec/dummy_app/config/initializers/inflections.rb +2 -0
  82. data/spec/dummy_app/config/initializers/mime_types.rb +2 -0
  83. data/spec/dummy_app/config/initializers/paper_trail.rb +2 -0
  84. data/spec/dummy_app/config/initializers/secret_token.rb +2 -0
  85. data/spec/dummy_app/config/initializers/session_store.rb +2 -0
  86. data/spec/dummy_app/config/routes.rb +2 -0
  87. data/spec/paper_trail_scrapbook/changes_spec.rb +2 -0
  88. data/spec/paper_trail_scrapbook/chapter_spec.rb +2 -0
  89. data/spec/paper_trail_scrapbook/config_spec.rb +2 -0
  90. data/spec/paper_trail_scrapbook/life_history_spec.rb +8 -6
  91. data/spec/paper_trail_scrapbook/secondary_chapter_spec.rb +2 -0
  92. data/spec/paper_trail_scrapbook/user_journal_spec.rb +47 -43
  93. data/spec/paper_trail_scrapbook/version_helpers_spec.rb +9 -7
  94. data/spec/paper_trail_scrapbook/version_spec.rb +2 -0
  95. data/spec/paper_trail_scrapbook_spec.rb +2 -0
  96. data/spec/spec_helper.rb +3 -1
  97. metadata +20 -5
  98. data/circle.yml +0 -22
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'securerandom'
2
4
 
3
5
  class CustomPrimaryKeyRecord < ActiveRecord::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Customer < ActiveRecord::Base
2
4
  has_many :orders, dependent: :destroy
3
5
  has_paper_trail
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Document < ActiveRecord::Base
2
4
  has_paper_trail(
3
5
  versions: :paper_trail_versions,
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Dog < Animal
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # to demonstrate a has_through association that does not have paper_trail enabled
2
4
  class Editor < ActiveRecord::Base
3
5
  has_many :editorships, dependent: :destroy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Editorship < ActiveRecord::Base
2
4
  belongs_to :book
3
5
  belongs_to :editor
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Elephant < Animal
2
4
  PaperTrail.request.disable_model(Elephant)
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Fluxor < ActiveRecord::Base
2
4
  belongs_to :widget
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class FooHabtm < ActiveRecord::Base
2
4
  has_and_belongs_to_many :bar_habtms
3
5
  accepts_nested_attributes_for :bar_habtms
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class FooWidget < Widget
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Fruit < ActiveRecord::Base
2
4
  has_paper_trail class_name: 'JsonVersion' if ENV['DB'] == 'postgres' || JsonVersion.table_exists?
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gadget < ActiveRecord::Base
2
4
  has_paper_trail ignore: :brand
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kitchen
2
4
  class Banana < ActiveRecord::Base
3
5
  has_paper_trail class_name: 'Kitchen::BananaVersion'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class LegacyWidget < ActiveRecord::Base
2
4
  has_paper_trail ignore: :version, version: 'custom_version'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class LineItem < ActiveRecord::Base
2
4
  belongs_to :order, dependent: :destroy
3
5
  has_paper_trail
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This model does not record versions when updated.
2
4
  class NotOnUpdate < ActiveRecord::Base
3
5
  has_paper_trail on: %i[create destroy]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module On
2
4
  class Create < ActiveRecord::Base
3
5
  self.table_name = :on_create
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module On
2
4
  class Destroy < ActiveRecord::Base
3
5
  self.table_name = :on_destroy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module On
2
4
  class EmptyArray < ActiveRecord::Base
3
5
  self.table_name = :on_empty_array
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module On
2
4
  class Update < ActiveRecord::Base
3
5
  self.table_name = :on_update
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Order < ActiveRecord::Base
2
4
  belongs_to :customer
3
5
  has_many :line_items
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Paragraph < ActiveRecord::Base
2
4
  belongs_to :section
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Person < ActiveRecord::Base
2
4
  has_many :authorships, foreign_key: :author_id, dependent: :destroy
3
5
  has_many :books, through: :authorships
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Post < ActiveRecord::Base
2
4
  has_paper_trail class_name: 'PostVersion'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This model tests ActiveRecord::Enum, which was added in AR 4.1
2
4
  # http://edgeguides.rubyonrails.org/4_1_release_notes.html#active-record-enums
3
5
  class PostWithStatus < ActiveRecord::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Quotation < ActiveRecord::Base
2
4
  belongs_to :chapter
3
5
  has_many :citations, dependent: :destroy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Section < ActiveRecord::Base
2
4
  belongs_to :chapter
3
5
  has_many :paragraphs, dependent: :destroy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Skipper < ActiveRecord::Base
2
4
  has_paper_trail ignore: [:created_at], skip: [:another_timestamp]
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OverrideSongAttributesTheRails4Way
2
4
  def attributes
3
5
  if name
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Thing < ActiveRecord::Base
2
4
  has_paper_trail save_changes: false
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Translation < ActiveRecord::Base
2
4
  has_paper_trail(
3
5
  if: proc { |t| t.language_code == 'US' },
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Truck < Vehicle
2
4
  # This STI child class specifically does not call `has_paper_trail`.
3
5
  # Of the sub-classes of `Vehicle`, only `Car` is versioned.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Vehicle < ActiveRecord::Base
2
4
  # This STI parent class specifically does not call `has_paper_trail`.
3
5
  # Of its sub-classes, only `Car` is versioned.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Whatchamajigger < ActiveRecord::Base
2
4
  has_paper_trail
3
5
  belongs_to :owner, polymorphic: true
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Widget < ActiveRecord::Base
2
- EXCLUDED_NAME = 'Biglet'.freeze
4
+ EXCLUDED_NAME = 'Biglet'
3
5
  has_paper_trail
4
6
  has_one :wotsit
5
7
  has_many(:fluxors, -> { order(:name) })
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Wotsit < ActiveRecord::Base
2
4
  has_paper_trail
3
5
  belongs_to :widget
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CustomPrimaryKeyRecordVersion < PaperTrail::Version
2
4
  self.table_name = 'custom_primary_key_record_versions'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The purpose of this custom version class is to test the scope methods on the
2
4
  # VersionConcern::ClassMethods module. See
3
5
  # https://github.com/airblade/paper_trail/issues/295 for more details.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class JsonVersion < PaperTrail::Version
2
4
  self.table_name = 'json_versions'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kitchen
2
4
  class BananaVersion < PaperTrail::Version
3
5
  self.table_name = 'banana_versions'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PostVersion < PaperTrail::Version
2
4
  self.table_name = 'post_versions'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is used by Rack-based servers to start the application.
2
4
 
3
5
  require ::File.expand_path('../config/environment', __FILE__)
@@ -1,4 +1,6 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('boot', __dir__)
2
4
 
3
5
  # Pick the frameworks you want:
4
6
  require 'active_record/railtie'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubygems'
2
4
 
3
5
  # We normally use the root project Gemfile (and gemspec), but when we run rake
@@ -12,7 +14,7 @@ require 'rubygems'
12
14
  # we should keep the ability to specify BUNDLE_GEMFILE because the same
13
15
  # situation could come up in the future.
14
16
  unless ENV.key?('BUNDLE_GEMFILE')
15
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
17
+ gemfile = File.expand_path('../../../Gemfile', __dir__)
16
18
  if File.exist?(gemfile)
17
19
  puts "Booting PT test dummy app: Using gemfile: #{gemfile}"
18
20
  ENV['BUNDLE_GEMFILE'] = gemfile
@@ -21,4 +23,4 @@ end
21
23
  require 'bundler'
22
24
  Bundler.setup
23
25
 
24
- $LOAD_PATH.unshift(File.expand_path('../../../../lib', __FILE__))
26
+ $LOAD_PATH.unshift(File.expand_path('../../../lib', __dir__))
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Load the rails application
2
- require File.expand_path('../application', __FILE__)
4
+ require File.expand_path('application', __dir__)
3
5
 
4
6
  # Initialize the rails application
5
7
  Dummy::Application.initialize!
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # You can add backtrace silencers for libraries that you're using but don't wish
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Add new inflection rules using the following format
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Add new mime types for use in respond_to blocks:
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  PaperTrail.config.track_associations = true
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Your secret key for verifying the integrity of signed cookies.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.routes.draw do
2
4
  resources :articles, only: [:create]
3
5
  resources :widgets, only: %i[create update destroy]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module PaperTrailScrapbook
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module PaperTrailScrapbook
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module PaperTrailScrapbook
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module PaperTrailScrapbook
@@ -7,7 +9,7 @@ module PaperTrailScrapbook
7
9
  PaperTrail.request.whodunnit = person.id
8
10
  end
9
11
 
10
- let(:person) {Person.create(name: 'The Tim Man')}
12
+ let(:person) { Person.create(name: 'The Tim Man') }
11
13
 
12
14
  let(:book) do
13
15
  b = Book.new(title: 'How the Grinch stole Xmas')
@@ -27,8 +29,8 @@ module PaperTrailScrapbook
27
29
  a
28
30
  end
29
31
 
30
- let(:object) {described_class.new(target)}
31
- let(:subject) {object.story}
32
+ let(:object) { described_class.new(target) }
33
+ let(:subject) { object.story }
32
34
 
33
35
  describe '#story' do
34
36
  it 'provides a whole story' do
@@ -56,7 +58,7 @@ module PaperTrailScrapbook
56
58
  target.save!
57
59
 
58
60
  expect(subject)
59
- .to match(/How the Grinch stole Xmas\[\d+\] was \*removed\*/)
61
+ .to match(/How the Grinch stole Xmas\[\d+\] was \*removed\*/)
60
62
  end
61
63
 
62
64
  context 'it handles missing whodunnit record' do
@@ -66,7 +68,7 @@ module PaperTrailScrapbook
66
68
  person.destroy
67
69
 
68
70
  expect(subject)
69
- .to match(/\*missing \(#{pid}\)\* created the following/)
71
+ .to match(/\*missing \(#{pid}\)\* created the following/)
70
72
  end
71
73
  end
72
74
 
@@ -74,7 +76,7 @@ module PaperTrailScrapbook
74
76
  it 'allows for a custom invalid_whodunnit handler' do
75
77
  config = PaperTrailScrapbook.config
76
78
  handler = config.invalid_whodunnit
77
- config.invalid_whodunnit = proc {|w| "*WHO (#{w})*"}
79
+ config.invalid_whodunnit = proc { |w| "*WHO (#{w})*" }
78
80
 
79
81
  target
80
82
  pid = person.id