paper_trail_manager 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +54 -0
  3. data/.gitignore +3 -2
  4. data/.rubocop.yml +33 -0
  5. data/.ruby-version +1 -0
  6. data/Appraisals +15 -12
  7. data/CHANGES.md +24 -0
  8. data/Gemfile +2 -1
  9. data/README.md +130 -66
  10. data/Rakefile +19 -5
  11. data/app/controllers/paper_trail_manager/changes_controller.rb +119 -101
  12. data/app/helpers/paper_trail_manager/changes_helper.rb +17 -13
  13. data/app/views/paper_trail_manager/changes/_version.html.erb +1 -1
  14. data/app/views/paper_trail_manager/changes/index.atom.builder +23 -19
  15. data/app/views/paper_trail_manager/changes/index.html.erb +41 -28
  16. data/app/views/paper_trail_manager/changes/show.html.erb +9 -6
  17. data/gemfiles/rails_6.1_paper_trail_12.0_kaminari.gemfile +10 -0
  18. data/gemfiles/rails_6.1_paper_trail_12.0_will_paginate.gemfile +10 -0
  19. data/gemfiles/rails_7.0_paper_trail_12.0_kaminari.gemfile +10 -0
  20. data/gemfiles/rails_7.0_paper_trail_12.0_will_paginate.gemfile +10 -0
  21. data/gemfiles/rails_7.0_paper_trail_15.0_kaminari.gemfile +10 -0
  22. data/gemfiles/rails_7.0_paper_trail_15.0_will_paginate.gemfile +10 -0
  23. data/gemfiles/rails_7.1_paper_trail_15.0_kaminari.gemfile +10 -0
  24. data/gemfiles/rails_7.1_paper_trail_15.0_will_paginate.gemfile +10 -0
  25. data/lib/paper_trail_manager.rb +11 -9
  26. data/paper_trail_manager.gemspec +25 -24
  27. data/spec/app_template.rb +39 -0
  28. data/spec/integration/authorization_spec.rb +84 -0
  29. data/spec/integration/date_filter_spec.rb +84 -0
  30. data/spec/integration/navigation_spec.rb +5 -3
  31. data/spec/integration/paper_trail_manager_spec.rb +94 -110
  32. data/spec/integration/response_formats_spec.rb +73 -0
  33. data/spec/rails_helper.rb +6 -4
  34. data/spec/spec_helper.rb +7 -5
  35. data/spec/support/factories.rb +4 -3
  36. data/spec/support/rspec_html_matchers.rb +7 -0
  37. data/spec/unit/authorization_spec.rb +42 -0
  38. data/spec/unit/changes_helper_spec.rb +81 -0
  39. metadata +103 -238
  40. data/.travis.yml +0 -23
  41. data/gemfiles/rails_3.2.0_paper_trail_3.0_kaminari.gemfile +0 -10
  42. data/gemfiles/rails_3.2.0_paper_trail_3.0_will_paginate.gemfile +0 -10
  43. data/gemfiles/rails_3.2.0_paper_trail_4.0_kaminari.gemfile +0 -10
  44. data/gemfiles/rails_3.2.0_paper_trail_4.0_will_paginate.gemfile +0 -10
  45. data/gemfiles/rails_4.0.0_paper_trail_3.0_kaminari.gemfile +0 -9
  46. data/gemfiles/rails_4.0.0_paper_trail_3.0_will_paginate.gemfile +0 -9
  47. data/gemfiles/rails_4.0.0_paper_trail_4.0_kaminari.gemfile +0 -9
  48. data/gemfiles/rails_4.0.0_paper_trail_4.0_will_paginate.gemfile +0 -9
  49. data/gemfiles/rails_4.1.0_paper_trail_3.0_kaminari.gemfile +0 -9
  50. data/gemfiles/rails_4.1.0_paper_trail_3.0_will_paginate.gemfile +0 -9
  51. data/gemfiles/rails_4.1.0_paper_trail_4.0_kaminari.gemfile +0 -9
  52. data/gemfiles/rails_4.1.0_paper_trail_4.0_will_paginate.gemfile +0 -9
  53. data/gemfiles/rails_4.2.2_paper_trail_3.0_kaminari.gemfile +0 -9
  54. data/gemfiles/rails_4.2.2_paper_trail_3.0_will_paginate.gemfile +0 -9
  55. data/gemfiles/rails_4.2.2_paper_trail_4.0_kaminari.gemfile +0 -9
  56. data/gemfiles/rails_4.2.2_paper_trail_4.0_will_paginate.gemfile +0 -9
  57. data/spec/controllers/entities_controller_spec.rb +0 -125
  58. data/spec/controllers/platforms_controller_spec.rb +0 -125
  59. data/spec/dummy/.gitignore +0 -15
  60. data/spec/dummy/Gemfile +0 -9
  61. data/spec/dummy/README.rdoc +0 -261
  62. data/spec/dummy/Rakefile +0 -7
  63. data/spec/dummy/app/assets/images/rails.png +0 -0
  64. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  65. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  66. data/spec/dummy/app/controllers/application_controller.rb +0 -6
  67. data/spec/dummy/app/controllers/entities_controller.rb +0 -83
  68. data/spec/dummy/app/controllers/platforms_controller.rb +0 -83
  69. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  70. data/spec/dummy/app/helpers/entities_helper.rb +0 -2
  71. data/spec/dummy/app/helpers/platforms_helper.rb +0 -2
  72. data/spec/dummy/app/mailers/.gitkeep +0 -0
  73. data/spec/dummy/app/models/.gitkeep +0 -0
  74. data/spec/dummy/app/models/entity.rb +0 -6
  75. data/spec/dummy/app/models/platform.rb +0 -6
  76. data/spec/dummy/app/views/application/index.html.erb +0 -6
  77. data/spec/dummy/app/views/entities/_form.html.erb +0 -17
  78. data/spec/dummy/app/views/entities/edit.html.erb +0 -6
  79. data/spec/dummy/app/views/entities/index.html.erb +0 -21
  80. data/spec/dummy/app/views/entities/new.html.erb +0 -5
  81. data/spec/dummy/app/views/entities/show.html.erb +0 -5
  82. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  83. data/spec/dummy/app/views/platforms/_form.html.erb +0 -17
  84. data/spec/dummy/app/views/platforms/edit.html.erb +0 -6
  85. data/spec/dummy/app/views/platforms/index.html.erb +0 -21
  86. data/spec/dummy/app/views/platforms/new.html.erb +0 -5
  87. data/spec/dummy/app/views/platforms/show.html.erb +0 -5
  88. data/spec/dummy/config/application.rb +0 -64
  89. data/spec/dummy/config/boot.rb +0 -6
  90. data/spec/dummy/config/database.yml +0 -22
  91. data/spec/dummy/config/environment.rb +0 -5
  92. data/spec/dummy/config/environments/development.rb +0 -37
  93. data/spec/dummy/config/environments/production.rb +0 -67
  94. data/spec/dummy/config/environments/test.rb +0 -36
  95. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  96. data/spec/dummy/config/initializers/inflections.rb +0 -15
  97. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  98. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  99. data/spec/dummy/config/initializers/session_store.rb +0 -8
  100. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  101. data/spec/dummy/config/locales/en.yml +0 -5
  102. data/spec/dummy/config/routes.rb +0 -8
  103. data/spec/dummy/config.ru +0 -4
  104. data/spec/dummy/db/migrate/20110228091428_create_entities.rb +0 -14
  105. data/spec/dummy/db/migrate/20110228093241_create_platforms.rb +0 -14
  106. data/spec/dummy/db/migrate/20110228094444_create_versions.rb +0 -18
  107. data/spec/dummy/db/schema.rb +0 -41
  108. data/spec/dummy/db/seeds.rb +0 -7
  109. data/spec/dummy/doc/README_FOR_APP +0 -2
  110. data/spec/dummy/lib/assets/.gitkeep +0 -0
  111. data/spec/dummy/lib/tasks/.gitkeep +0 -0
  112. data/spec/dummy/log/.gitkeep +0 -0
  113. data/spec/dummy/public/404.html +0 -26
  114. data/spec/dummy/public/422.html +0 -26
  115. data/spec/dummy/public/500.html +0 -25
  116. data/spec/dummy/public/favicon.ico +0 -0
  117. data/spec/dummy/public/index.html +0 -241
  118. data/spec/dummy/public/robots.txt +0 -5
  119. data/spec/dummy/script/rails +0 -6
  120. data/spec/dummy/test/fixtures/.gitkeep +0 -0
  121. data/spec/dummy/test/functional/.gitkeep +0 -0
  122. data/spec/dummy/test/integration/.gitkeep +0 -0
  123. data/spec/dummy/test/performance/browsing_test.rb +0 -12
  124. data/spec/dummy/test/test_helper.rb +0 -13
  125. data/spec/dummy/test/unit/.gitkeep +0 -0
  126. data/spec/dummy/vendor/assets/javascripts/.gitkeep +0 -0
  127. data/spec/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
  128. data/spec/dummy/vendor/plugins/.gitkeep +0 -0
  129. data/spec/helpers/entities_helper_spec.rb +0 -15
  130. data/spec/helpers/platforms_helper_spec.rb +0 -15
  131. data/spec/models/entity_spec.rb +0 -14
  132. data/spec/models/platform_spec.rb +0 -14
  133. data/spec/requests/entities_spec.rb +0 -11
  134. data/spec/requests/platforms_spec.rb +0 -11
  135. data/spec/routing/entities_routing_spec.rb +0 -35
  136. data/spec/routing/platforms_routing_spec.rb +0 -35
  137. data/spec/views/entities/edit.html.erb_spec.rb +0 -15
  138. data/spec/views/entities/index.html.erb_spec.rb +0 -14
  139. data/spec/views/entities/new.html.erb_spec.rb +0 -15
  140. data/spec/views/entities/show.html.erb_spec.rb +0 -11
  141. data/spec/views/platforms/edit.html.erb_spec.rb +0 -15
  142. data/spec/views/platforms/index.html.erb_spec.rb +0 -14
  143. data/spec/views/platforms/new.html.erb_spec.rb +0 -15
  144. data/spec/views/platforms/show.html.erb_spec.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 35fba5ebc680f50b0e7ce1caaf6078516a961172
4
- data.tar.gz: 683db80277392f81fdc645725e4461b5ab0c168b
2
+ SHA256:
3
+ metadata.gz: 007f0fa99ee11e2fdd0d615ec29d66e74788062b3a8e479091c31427d54add6c
4
+ data.tar.gz: a71dfd4c73909f185c580a11eae304ac0fb75e8c16fe92fe890ddeb90d7ace71
5
5
  SHA512:
6
- metadata.gz: ce56dc3af2eda372dd4d48c0ca627938cc8d8ff6e56110039debc108fe21af56b37f419a11d04ab1165102020cd7defd12324fee3fe6087d71a88fdc2f5d48b6
7
- data.tar.gz: 20802255bfba5b797940ba22da1c6adda96ebdbe628290e71bd1ca80e9c79e643d32b34eb56fde02afe53625bb63eb6ab90342759cfb96563e1d7e9c0224a69a
6
+ metadata.gz: b019f63c912f3627025427264b6b48be3347e8fe9ec1145ee1b97347e807e0d5642ff6c06ec5085635d6fe5d18354397865bc85734ade8c015284fa484287220
7
+ data.tar.gz: 0f60e85a369b84075a088f2e2cbca20d85895c7ff42c38fcb7d1595f7e503954bd5ea3c19cfa8b393b433ab003e4309f367caeb03dc3997e2e7f913fda167220
@@ -0,0 +1,54 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - opened
7
+ - reopened
8
+ - synchronize
9
+ - ready_for_review
10
+ push:
11
+ branches:
12
+ - 'master'
13
+
14
+ jobs:
15
+ test:
16
+ runs-on: ubuntu-latest
17
+
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby:
22
+ - '3.1'
23
+ - '3.2'
24
+ - '3.3'
25
+ gemfile:
26
+ - gemfiles/rails_7.0_paper_trail_12.0_kaminari.gemfile
27
+ - gemfiles/rails_7.0_paper_trail_12.0_will_paginate.gemfile
28
+ - gemfiles/rails_7.0_paper_trail_15.0_kaminari.gemfile
29
+ - gemfiles/rails_7.0_paper_trail_15.0_will_paginate.gemfile
30
+ - gemfiles/rails_7.1_paper_trail_15.0_kaminari.gemfile
31
+ - gemfiles/rails_7.1_paper_trail_15.0_will_paginate.gemfile
32
+
33
+ env:
34
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
35
+
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+ - uses: ruby/setup-ruby@v1
39
+ with:
40
+ ruby-version: ${{ matrix.ruby }}
41
+ bundler-cache: true
42
+ - name: Install System Dependencies
43
+ run: |
44
+ sudo apt-get update
45
+ sudo apt-get install -y sqlite3 libsqlite3-dev
46
+ - name: bundle install
47
+ run: |
48
+ bundle config path vendor/bundle
49
+ bundle install --jobs 4 --retry 3
50
+ - name: Generate host app for testing
51
+ run: bundle exec rake generate_spec_app
52
+ - name: Run RSpec
53
+ run: |
54
+ bundle exec rake spec
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
@@ -12,4 +11,6 @@ Gemfile.lock
12
11
  *.o
13
12
  *.a
14
13
  mkmf.log
15
- *.gemfile.lock
14
+ spec/dummy
15
+ Gemfile.lock
16
+ gemfiles/*.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,33 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rails
4
+ - rubocop-rspec
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.5
8
+ Exclude:
9
+ - 'spec/dummy/**/*'
10
+
11
+ Rails:
12
+ Enabled: true
13
+
14
+ Style/HashEachMethods:
15
+ Enabled: true
16
+
17
+ Style/HashTransformKeys:
18
+ Enabled: true
19
+
20
+ Style/HashTransformValues:
21
+ Enabled: true
22
+
23
+ Layout/LineLength:
24
+ Max: 120
25
+
26
+ RSpec/NestedGroups:
27
+ Enabled: false
28
+
29
+ RSpec/MultipleExpectations:
30
+ Enabled: false
31
+
32
+ Metrics/BlockLength:
33
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.0
data/Appraisals CHANGED
@@ -1,20 +1,23 @@
1
- RAILS_VERSIONS = ["3.2.0", "4.0.0", "4.1.0", "4.2.2"]
2
- PAPER_TRAIL_VERSIONS = ["3.0", "4.0"]
1
+ # frozen_string_literal: true
3
2
 
4
- RAILS_VERSIONS.each do |rails_version|
5
- PAPER_TRAIL_VERSIONS.each do |paper_trail_version|
3
+ {
4
+ '6.1' => %w[12.0],
5
+ '7.0' => %w[12.0 15.0],
6
+ '7.1' => %w[15.0]
7
+ }.each do |rails_version, paper_trail_versions|
8
+ paper_trail_versions.each do |paper_trail_version|
6
9
  appraise "rails-#{rails_version}-paper_trail-#{paper_trail_version}-will-paginate" do
7
- gem "rails", "~> #{rails_version}"
8
- gem "paper_trail", "~> #{paper_trail_version}"
9
- gem "will_paginate", "~> 3.0"
10
- gem "test-unit", "~> 3.0" if rails_version == "3.2.0"
10
+ gem 'rails', "~> #{rails_version}.0"
11
+ gem 'sqlite3', '~> 1.7'
12
+ gem 'paper_trail', "~> #{paper_trail_version}"
13
+ gem 'will_paginate', '~> 4.0'
11
14
  end
12
15
 
13
16
  appraise "rails-#{rails_version}-paper_trail-#{paper_trail_version}-kaminari" do
14
- gem "rails", "~> #{rails_version}"
15
- gem "paper_trail", "~> #{paper_trail_version}"
16
- gem "kaminari", "~> 0.16"
17
- gem "test-unit", "~> 3.0" if rails_version == "3.2.0"
17
+ gem 'rails', "~> #{rails_version}.0"
18
+ gem 'sqlite3', '~> 1.7'
19
+ gem 'paper_trail', "~> #{paper_trail_version}"
20
+ gem 'kaminari', '>= 1.0'
18
21
  end
19
22
  end
20
23
  end
data/CHANGES.md CHANGED
@@ -1,6 +1,30 @@
1
1
  Changes to `paper_trail_manager`
2
2
  ================================
3
3
 
4
+ * 0.8.0
5
+ * Fix `allow_show?` calling `allow_index_block` instead of `allow_show_block` — `allow_show_when` configuration was previously silently ignored (security fix)
6
+ * Fix gemspec `authors` field being overwritten by misplaced `email` assignment
7
+ * Fix `PER_PAGE` constant (50) not being used as default pagination
8
+ * Fix broken HTML structure in show view (nested `<tr>` tags) and index view (unwrapped `<td>`)
9
+ * Add date range filtering to changes index via `from` and `to` query parameters
10
+ * Add date filter UI with date inputs, filter button, and clear link
11
+ * Add authorization integration tests (unauthorized index/show/revert, non-existent records)
12
+ * Add unit tests for ChangesHelper methods (text_or_nil, changes_for, change_item_types, version_reify)
13
+ * Add specs for JSON and Atom response formats with filter coverage
14
+ * Add date range filter tests
15
+ * Drop support for Rails < 7.0
16
+ * Drop Rails 6.1 from CI matrix (incompatible with Ruby 3.1+)
17
+ * Fix `rails new` asset pipeline error in CI for Rails 7.0/7.1
18
+ * Fix `Psych::DisallowedClass` error on revert tests (Ruby 3.1+ YAML deserialization)
19
+ * Add support for Ruby 3.1, 3.2, and 3.3
20
+ * Add support for PaperTrail 12.x and 15.x
21
+
22
+ * 0.7.0
23
+ * Add support for Rails 5 and 6
24
+ * Add support for paper_trail 5.x – 10.x
25
+ * Drop support for Rails < 4.1
26
+ * Drop support for Ruby < 2.5
27
+
4
28
  * 0.6.0
5
29
  * Add support for linking changes to user records via `PaperTrailManager.whodunnit_name_method` and `PaperTrailManager.user_path_method`
6
30
  * Add new `PaperTrailManager.item_name_method` configuration option
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in paper_trail_manager.gemspec
4
6
  gemspec
5
-
data/README.md CHANGED
@@ -1,109 +1,173 @@
1
- [![Build Status](https://secure.travis-ci.org/fusion94/paper_trail_manager.png)](http://travis-ci.org/fusion94/paper_trail_manager)
2
-
3
1
  # PaperTrailManager
4
2
 
5
- Browse, subscribe, view and revert changes to records when using Ruby on Rails 3 and the `paper_trail` gem.
3
+ [![CI](https://github.com/DamageLabs/paper_trail_manager/actions/workflows/test.yml/badge.svg)](https://github.com/DamageLabs/paper_trail_manager/actions/workflows/test.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/paper_trail_manager.svg)](https://rubygems.org/gems/paper_trail_manager)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Ruby](https://img.shields.io/badge/Ruby-3.1%2B-red.svg)](https://www.ruby-lang.org/)
7
+ [![Rails](https://img.shields.io/badge/Rails-7.0%2B-red.svg)](https://rubyonrails.org/)
8
+
9
+ Browse, view, and revert changes to records in Ruby on Rails applications using the [paper_trail](https://github.com/paper-trail-gem/paper_trail) gem.
10
+
11
+ ## Requirements
6
12
 
7
- This software has been in use for a year at http://calagator.org and http://epdx.org. It works well. It has reasonable tests. However, it could definitely use more work.
13
+ - **Ruby** >= 3.1
14
+ - **Rails** >= 7.0, < 8.0
15
+ - **PaperTrail** >= 12.0
16
+ - A pagination library: [will_paginate](https://github.com/mislav/will_paginate) or [Kaminari](https://github.com/kaminari/kaminari)
8
17
 
9
18
  ## Installation
10
19
 
11
- If you have a Ruby on Rails 3 or 4 application where you're using the `paper_trail` gem to track changes to your records, you can make use of this like:
20
+ Add to your `Gemfile`:
21
+
22
+ ```ruby
23
+ gem 'paper_trail_manager'
24
+ ```
25
+
26
+ If you don't already use a pagination library, add one:
27
+
28
+ ```ruby
29
+ gem 'kaminari'
30
+ # or
31
+ gem 'will_paginate'
32
+ ```
33
+
34
+ Install:
35
+
36
+ ```sh
37
+ bundle install
38
+ ```
39
+
40
+ Add the route to `config/routes.rb`:
41
+
42
+ ```ruby
43
+ resources :changes, controller: 'paper_trail_manager/changes'
44
+ ```
12
45
 
13
- Add the following line to your `Gemfile`:
46
+ Restart your server and visit `/changes` to browse, view, and revert your changes.
14
47
 
15
- gem 'paper_trail_manager'
48
+ ## Configuration
16
49
 
17
- PaperTrailManager will use your existing paging library ([will_paginate](https://github.com/mislav/will_paginate) or [Kaminari](https://github.com/amatsuda/kaminari)). If you don't currently use one in your app, add one of the following lines to your `Gemfile`:
50
+ Create an initializer (e.g. `config/initializers/paper_trail_manager.rb`) to customize behavior.
18
51
 
19
- gem 'kaminari'
20
- #or
21
- gem 'will_paginate'
52
+ ### Authorization
22
53
 
23
- Install the libary:
54
+ Control access to the index, show, and revert actions independently:
24
55
 
25
- bundle install
56
+ ```ruby
57
+ # Control who can view the changes index
58
+ PaperTrailManager.allow_index_when do |controller|
59
+ controller.current_user.present?
60
+ end
26
61
 
27
- Add the following line to your `config/routes.rb`:
62
+ # Control who can view individual change details (defaults to allow_index rules)
63
+ PaperTrailManager.allow_show_when do |controller, version|
64
+ controller.current_user&.admin? || version.whodunnit == controller.current_user&.id&.to_s
65
+ end
28
66
 
29
- resources :changes, :controller => 'paper_trail_manager/changes'
67
+ # Control who can revert changes
68
+ PaperTrailManager.allow_revert_when do |controller, version|
69
+ controller.current_user&.admin?
70
+ end
71
+ ```
30
72
 
31
- Restart the server and go to the `/changes` URI to browse, subscribe, view and revert your changes. The top-level URL will look something like this:
73
+ > **Note:** If you only call `allow_index_when`, the same block is used as the default for `allow_show_when`. Call `allow_show_when` separately to override show authorization independently.
32
74
 
33
- http://localhost:3000/changes
75
+ ### Whodunnit
34
76
 
35
- ### Configuration
77
+ Configure how to look up users referenced in PaperTrail's `whodunnit` column:
36
78
 
37
- Several aspects of PaperTrailManager may be optionally configured
38
- by creating an initializer in your application
39
- (e.g. `config/initializers/paper_trail_manager.rb`).
79
+ ```ruby
80
+ PaperTrailManager.whodunnit_class = User
81
+ PaperTrailManager.whodunnit_name_method = :nicename # defaults to :name
82
+ ```
40
83
 
41
- To specify when reverts are allowed:
84
+ ### Item Names
42
85
 
43
- PaperTrailManager.allow_revert_when do |controller, version|
44
- controller.current_user and controller.current_user.admin?
45
- end
86
+ Specify a method to identify items on the index page:
46
87
 
47
- To specify how to look up users/memebers/etc specified in Paper Trail's 'whodunnit' column:
88
+ ```ruby
89
+ PaperTrailManager.item_name_method = :nicename
90
+ ```
48
91
 
49
- PaperTrailManager.whodunnit_class = User
50
- PaperTrailManager.whodunnit_name_method = :nicename # defaults to :name
92
+ ### User Links
51
93
 
52
- To specify a method to call to identify an item on an index page:
94
+ Customize (or disable) the user path helper:
53
95
 
54
- PaperTrailManager.item_name_method = :nicename
96
+ ```ruby
97
+ PaperTrailManager.user_path_method = :admin_path # defaults to :user_path
98
+ PaperTrailManager.user_path_method = nil # no user link
99
+ ```
55
100
 
56
- And for linking (or not) to the user with a custom path helper:
101
+ ### Pagination
57
102
 
58
- PaperTrailManager.user_path_method = :admin_path # defaults to :user_path
59
- PaperTrailManager.user_path_method = nil # no "show user" page in app
103
+ The index page defaults to 50 items per page. Override via query parameter:
60
104
 
61
- When including PaperTrailManager within another Rails engine, you may need to
62
- override PaperTrailManager::ChangesController's parent class to reference the
63
- engine's ApplicationController configure it to use your engine's url helpers:
105
+ ```
106
+ /changes?per_page=25
107
+ ```
64
108
 
65
- PaperTrailManager.base_controller = "MyEngine::ApplicationController"
66
- PaperTrailManager.route_helpers = MyEngine::Engine.routes.url_helpers
109
+ ### Engine Integration
67
110
 
68
- You can also specify the layout:
111
+ When embedding PaperTrailManager inside another Rails engine:
69
112
 
70
- PaperTrailManager.layout = 'my_engine/application'
113
+ ```ruby
114
+ PaperTrailManager.base_controller = "MyEngine::ApplicationController"
115
+ PaperTrailManager.route_helpers = MyEngine::Engine.routes.url_helpers
116
+ PaperTrailManager.layout = 'my_engine/application'
117
+ ```
71
118
 
72
119
  ## Development
73
120
 
74
121
  Setup:
75
122
 
76
- * Clone the repository
77
- * Go into the directory
78
- * Run `bundle` to install the development dependencies
123
+ ```sh
124
+ git clone https://github.com/DamageLabs/paper_trail_manager.git
125
+ cd paper_trail_manager
126
+ bundle install
127
+ ```
79
128
 
80
129
  Running tests:
81
130
 
82
- * Run `appraisal rake` to run the tests against all supported gem combinations. Note that the first time tests are run, gems will need to be downloaded for each individual version of Rails this app is tested against, which may take a while.
83
-
84
- Adding support for new Rails versions:
85
-
86
- * This repo uses the [Appraisal](https://github.com/thoughtbot/appraisal) gem, to add a new rails version modify the Appraisals file
87
- - Add both a 'will_paginate' and a 'kaminari' version like so:
88
- ```
89
- appraise "rails-5.0-will-paginate" do
90
- gem "rails", "5.0.0"
91
- gem "will_paginate", "~> 3.0"
92
- end
93
- appraise "rails-5.0-will-kaminari" do
94
- gem "rails", "5.0.0"
95
- gem "kaminari", "~> 0.16"
96
- end
97
- ```
98
- * Run `appraisal generate`
99
- * Run `appraisal install`
100
- * Fix whatever breaks.
101
- * Please contribute your fixes with a Github pull request.
131
+ ```sh
132
+ appraisal rake
133
+ ```
134
+
135
+ The first run downloads gems for each Rails version in the test matrix, which may take a while.
136
+
137
+ ### Test Matrix
138
+
139
+ Tests run against multiple combinations via [Appraisal](https://github.com/thoughtbot/appraisal):
140
+
141
+ | Rails | PaperTrail | Pagination |
142
+ |-------|-----------|------------|
143
+ | 7.0 | 12.0 | kaminari, will_paginate |
144
+ | 7.0 | 15.0 | kaminari, will_paginate |
145
+ | 7.1 | 15.0 | kaminari, will_paginate |
146
+
147
+ CI runs each combination across Ruby 3.1, 3.2, and 3.3 (18 jobs total).
148
+
149
+ ### Adding Support for New Versions
150
+
151
+ 1. Update the `Appraisals` file with new version combinations
152
+ 2. Run `appraisal generate && appraisal install`
153
+ 3. Fix any breaking changes
154
+ 4. Submit a pull request
155
+
156
+ ## Recent Changes (0.8.0)
157
+
158
+ - **Security fix:** `allow_show?` now correctly delegates to `allow_show_block` (was incorrectly using `allow_index_block`)
159
+ - **Bug fix:** Gemspec `authors` field was being overwritten by `email`
160
+ - **Bug fix:** `PER_PAGE` constant (50) now used as pagination default
161
+ - **CI:** Dropped Rails 6.1 (incompatible with Ruby 3.1+), fixed Psych deserialization, added asset pipeline skip
162
+ - **Tests:** Added unit tests for authorization block delegation
163
+ - Modernized for Ruby 3.1–3.3 and Rails 7.0–7.1
164
+
165
+ See [CHANGES.md](CHANGES.md) for full history.
102
166
 
103
167
  ## License
104
168
 
105
- This program is provided under an MIT open source license, read the [LICENSE.txt](http://github.com/igal/paper_trail_manager/blob/master/LICENSE.txt) file for details.
169
+ MIT see [LICENSE.txt](LICENSE.txt) for details.
106
170
 
107
- ## To Note:
171
+ ## History
108
172
 
109
- This project was originally devloped by [Igal Koshevoy](http://github.com/igal). Unfortunately @igal passed away on April 9th, 2013 and I took over the project afterwords.
173
+ This project was originally developed by [Igal Koshevoy](https://github.com/igal). Igal passed away on April 9th, 2013, and [Tony Guntharp](https://github.com/fusion94) took over maintenance of the project.
data/Rakefile CHANGED
@@ -1,18 +1,23 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'rubygems'
4
4
 
5
- require "bundler/gem_tasks"
5
+ require 'bundler/gem_tasks'
6
6
  Bundler::GemHelper.install_tasks
7
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
8
- load 'rails/tasks/engine.rake'
7
+
8
+ app_rakefile_path = File.expand_path('spec/dummy/Rakefile', __dir__)
9
+
10
+ if File.exist?(app_rakefile_path)
11
+ APP_RAKEFILE = app_rakefile_path
12
+ load 'rails/tasks/engine.rake'
13
+ end
9
14
 
10
15
  require 'rake'
11
16
  require 'rdoc/task'
12
17
 
13
18
  require 'rspec/core/rake_task'
14
19
  RSpec::Core::RakeTask.new
15
- task :default => ["db:create", "db:migrate", "spec"]
20
+ task default: ['db:create', 'db:migrate', 'spec']
16
21
 
17
22
  Rake::RDocTask.new(:rdoc) do |rdoc|
18
23
  rdoc.rdoc_dir = 'rdoc'
@@ -22,3 +27,12 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
22
27
  rdoc.rdoc_files.include('lib/**/*.rb')
23
28
  end
24
29
 
30
+ task :generate_spec_app do
31
+ sh 'rm -rf spec/dummy'
32
+ sh 'rails new spec/dummy --skip-bootsnap --skip-bundle \
33
+ --skip-git --skip-action-mailer --skip-puma --skip-test \
34
+ --skip-spring --skip-hotwire --skip-jbuilder \
35
+ --skip-action-mailbox --skip-action-text --skip-active-storage \
36
+ --skip-asset-pipeline \
37
+ --template=spec/app_template.rb'
38
+ end