rails_audit 1.0.0 → 1.0.4

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 (143) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +20 -165
  3. data/README.md +17 -5
  4. data/app/controllers/auditor/admin/approvals_controller.rb +44 -0
  5. data/app/controllers/auditor/admin/audits_controller.rb +11 -0
  6. data/app/controllers/auditor/admin/base_controller.rb +4 -0
  7. data/app/controllers/auditor/admin/verifications_controller.rb +61 -0
  8. data/app/controllers/auditor/admin/verifiers_controller.rb +69 -0
  9. data/app/controllers/auditor/controller/application.rb +32 -0
  10. data/app/models/auditor/approval.rb +5 -0
  11. data/app/models/auditor/audit.rb +5 -0
  12. data/app/models/auditor/ext/audited.rb +58 -0
  13. data/app/models/auditor/ext/verifiable.rb +10 -0
  14. data/app/models/auditor/ext/verified.rb +25 -0
  15. data/app/models/auditor/model/approval.rb +59 -0
  16. data/app/models/auditor/model/approving.rb +65 -0
  17. data/app/models/auditor/model/audit.rb +25 -0
  18. data/app/models/auditor/model/verification.rb +32 -0
  19. data/app/models/auditor/model/verifier.rb +20 -0
  20. data/app/models/auditor/verification.rb +5 -0
  21. data/app/models/auditor/verifier.rb +5 -0
  22. data/app/models/auditor.rb +11 -0
  23. data/app/views/auditor/_approvals.html.erb +14 -0
  24. data/app/views/auditor/_checks.html.erb +16 -0
  25. data/app/views/auditor/admin/approvals/_filter.html.erb +7 -0
  26. data/app/views/auditor/admin/approvals/_form.html.erb +6 -0
  27. data/app/views/auditor/admin/approvals/_index.html.erb +10 -0
  28. data/app/views/auditor/admin/approvals/_show_table.html.erb +28 -0
  29. data/app/views/auditor/admin/approvals/_table.html.erb +28 -0
  30. data/app/views/auditor/admin/approvals/index.js.erb +3 -0
  31. data/app/views/auditor/admin/audits/_button.html.erb +0 -0
  32. data/app/views/auditor/admin/audits/_index_tbody.html.erb +38 -0
  33. data/app/views/auditor/admin/audits/_index_thead.html.erb +4 -0
  34. data/app/views/auditor/admin/audits/index.html.erb +7 -0
  35. data/app/views/auditor/admin/verifications/_edit_form.html.erb +7 -0
  36. data/app/views/auditor/admin/verifications/_filter_form.html.erb +5 -0
  37. data/app/views/auditor/admin/verifications/_index_tbody.html.erb +4 -0
  38. data/app/views/auditor/admin/verifications/_index_thead.html.erb +5 -0
  39. data/app/views/auditor/admin/verifications/_new_form.html.erb +7 -0
  40. data/app/views/auditor/admin/verifications/_show_table.html.erb +16 -0
  41. data/app/views/auditor/admin/verifiers/_edit_form.html.erb +3 -0
  42. data/app/views/auditor/admin/verifiers/_filter_form.html.erb +9 -0
  43. data/app/views/auditor/admin/verifiers/_form.html.erb +5 -0
  44. data/app/views/auditor/admin/verifiers/_index_tbody.html.erb +3 -0
  45. data/app/views/auditor/admin/verifiers/_index_thead.html.erb +4 -0
  46. data/app/views/auditor/admin/verifiers/_member_field.html.erb +1 -0
  47. data/app/views/auditor/admin/verifiers/_new_form.html.erb +3 -0
  48. data/app/views/auditor/admin/verifiers/_show_table.html.erb +24 -0
  49. data/app/views/auditor/admin/verifiers/members.turbo_stream.erb +3 -0
  50. data/config/locales/en.yml +12 -0
  51. data/config/locales/zh.controller.yml +13 -0
  52. data/config/locales/zh.enum.yml +7 -0
  53. data/config/locales/zh.yml +21 -0
  54. data/config/routes.rb +22 -2
  55. data/lib/rails_audit/config.rb +14 -0
  56. data/lib/rails_audit/engine.rb +15 -6
  57. data/lib/rails_audit.rb +3 -2
  58. data/test/controllers/audit/admin/approvals_controller_test.rb +36 -0
  59. data/test/dummy/Gemfile +54 -0
  60. data/test/dummy/Gemfile.lock +382 -0
  61. data/test/dummy/README.md +8 -1
  62. data/test/dummy/app/assets/images/default_avatar.jpg +0 -0
  63. data/test/dummy/app/assets/images/logo.png +0 -0
  64. data/test/dummy/app/assets/javascripts/admin/application.js +1 -0
  65. data/test/dummy/app/assets/javascripts/application.js +11 -2
  66. data/test/dummy/app/assets/javascripts/phone.js +5 -0
  67. data/test/dummy/app/assets/stylesheets/css.scss +4 -0
  68. data/test/dummy/app/controllers/active_storage/base_controller.rb +19 -0
  69. data/test/dummy/app/controllers/admin_controller.rb +3 -0
  70. data/test/dummy/app/controllers/application_controller.rb +10 -1
  71. data/test/dummy/app/controllers/home_controller.rb +0 -5
  72. data/test/dummy/app/controllers/me_controller.rb +4 -0
  73. data/test/dummy/app/controllers/my_controller.rb +4 -0
  74. data/test/dummy/app/models/auth/user.rb +7 -0
  75. data/test/dummy/app/views/home/index.css +3 -0
  76. data/test/dummy/app/views/home/index.html.erb +0 -0
  77. data/test/dummy/app/views/layouts/_right_menu.html.erb +0 -20
  78. data/test/dummy/bin/bundle +1 -1
  79. data/test/dummy/bin/setup +1 -1
  80. data/test/dummy/bin/vite +19 -0
  81. data/test/dummy/bin/yarn +11 -0
  82. data/test/dummy/config/application.rb +12 -5
  83. data/test/dummy/config/boot.rb +8 -4
  84. data/test/dummy/config/credentials/development.key +1 -0
  85. data/test/dummy/config/credentials/test.key +1 -0
  86. data/test/dummy/config/credentials.yml.enc +1 -0
  87. data/test/dummy/config/database.yml +16 -0
  88. data/test/dummy/config/environment.rb +0 -2
  89. data/test/dummy/config/environments/development.rb +19 -32
  90. data/test/dummy/config/environments/production.rb +1 -13
  91. data/test/dummy/config/environments/test.rb +5 -0
  92. data/test/dummy/config/initializers/mime_types.rb +0 -4
  93. data/test/dummy/config/initializers/new_framework_defaults.rb +0 -4
  94. data/test/dummy/config/locales/en.yml +1 -22
  95. data/test/dummy/config/master.key +1 -0
  96. data/test/dummy/config/puma.rb +28 -41
  97. data/test/dummy/config/routes.rb +9 -2
  98. data/test/dummy/config/storage.yml +11 -0
  99. data/test/dummy/config/vite/base.js +5 -0
  100. data/test/dummy/config/vite/development.js +12 -0
  101. data/test/dummy/config/vite/production.js +6 -0
  102. data/test/dummy/config.ru +2 -0
  103. data/test/dummy/lib/deploy.rb +115 -0
  104. data/test/dummy/package.json +23 -2
  105. data/test/dummy/postcss.config.js +11 -0
  106. data/test/dummy/yarn.lock +2140 -4
  107. data/test/factories/approvals.rb +7 -0
  108. data/test/factories/infos.rb +8 -0
  109. data/test/{the_audit_test.rb → rails_audit_test.rb} +3 -1
  110. data/test/test_helper.rb +9 -16
  111. metadata +151 -97
  112. data/app/controllers/admin/audits_controller.rb +0 -12
  113. data/app/models/rails_audit/audit.rb +0 -14
  114. data/app/models/rails_audit/concerns/auditable.rb +0 -59
  115. data/app/models/rails_audit/history.rb +0 -36
  116. data/app/models/rails_audit/major_record.rb +0 -14
  117. data/app/models/rails_audit/minor_record.rb +0 -15
  118. data/app/views/admin/audits/_index.html.erb +0 -9
  119. data/app/views/admin/audits/_table.html.erb +0 -61
  120. data/app/views/admin/audits/index.html.erb +0 -3
  121. data/app/views/admin/audits/index.js.erb +0 -8
  122. data/db/migrate/20170314035239_create_audits.rb +0 -20
  123. data/lib/rails_audit/controller_helper.rb +0 -39
  124. data/lib/rails_audit/version.rb +0 -3
  125. data/lib/tasks/the_history_tasks.rake +0 -4
  126. data/test/dummy/app/assets/config/manifest.js +0 -3
  127. data/test/dummy/app/assets/javascripts/cable.js +0 -13
  128. data/test/dummy/app/assets/stylesheets/application.css +0 -5
  129. data/test/dummy/app/controllers/admin/base_controller.rb +0 -7
  130. data/test/dummy/app/controllers/my/base_controller.rb +0 -7
  131. data/test/dummy/app/models/application_record.rb +0 -3
  132. data/test/dummy/app/models/user.rb +0 -3
  133. data/test/dummy/app/views/layouts/_navbar.html.erb +0 -18
  134. data/test/dummy/app/views/layouts/application.html.erb +0 -19
  135. data/test/dummy/app/views/layouts/mailer.html.erb +0 -13
  136. data/test/dummy/app/views/layouts/mailer.text.erb +0 -1
  137. data/test/dummy/bin/update +0 -29
  138. data/test/dummy/config/database.yml.mysql +0 -14
  139. data/test/dummy/config/database.yml.sqlite3 +0 -12
  140. data/test/dummy/config/initializers/assets.rb +0 -6
  141. data/test/dummy/config/secrets.yml +0 -22
  142. data/test/dummy/db/migrate/20180525090830_create_active_storage_tables.active_storage.rb +0 -26
  143. data/test/dummy/log/development.log +0 -2
@@ -1,20 +0,0 @@
1
- class CreateAudits < ActiveRecord::Migration[5.1]
2
- def change
3
-
4
- create_table :audits do |t|
5
- t.references :auditable, polymorphic: true
6
- t.references :operator, polymorphic: true
7
- t.string :action
8
- t.string :audited_changes, limit: 4096
9
- t.string :related_changes, limit: 4096
10
- t.string :unconfirmed_changes, limit: 4096
11
- t.string :note, limit: 1024
12
- t.string :remote_ip
13
- t.string :controller_path
14
- t.string :action_name
15
- t.string :extra, limit: 4096
16
- t.datetime :created_at, index: true, null: false
17
- end
18
-
19
- end
20
- end
@@ -1,39 +0,0 @@
1
- module RailsAudit::ControllerHelper
2
-
3
- def mark_audits(**options)
4
- record_classes = options.select { |k, _|
5
- record_class = k.to_s.safe_constantize
6
- record_class && record_class.ancestors.include?(ActiveRecord::Base)
7
- }
8
-
9
- record_classes.each do |record_symbol, includes|
10
- record_class = record_symbol.to_s.constantize
11
- valid_ivars.find do |ivar|
12
- record = instance_variable_get(ivar)
13
- if record.is_a? record_class
14
- record.save_audits current_operator: rails_audit_user,
15
- include: includes,
16
- note: options[:note],
17
- controller_path: controller_path,
18
- action_name: action_name,
19
- remote_ip: request.remote_ip,
20
- extra: options[:extra]
21
- end
22
- end
23
- end
24
- end
25
-
26
- def rails_audit_user
27
- current_user
28
- end
29
-
30
- def valid_ivars
31
- _except = self._protected_ivars.to_a + [:@marked_for_same_origin_verification]
32
- self.instance_variables - _except
33
- end
34
-
35
- end
36
-
37
- ActiveSupport.on_load :action_controller_base do
38
- include RailsAudit::ControllerHelper
39
- end
@@ -1,3 +0,0 @@
1
- module RailsAudit
2
- VERSION = '1.0.0'
3
- end
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :the_history do
3
- # # Task goes here
4
- # end
@@ -1,3 +0,0 @@
1
- //= link_tree ../images
2
- //= link_directory ../javascripts .js
3
- //= link_directory ../stylesheets .css
@@ -1,13 +0,0 @@
1
- // Action Cable provides the framework to deal with WebSockets in Rails.
2
- // You can generate new channels where WebSocket features live using the rails generate channel command.
3
- //
4
- //= require action_cable
5
- //= require_self
6
- //= require_tree ./channels
7
-
8
- (function() {
9
- this.App || (this.App = {});
10
-
11
- App.cable = ActionCable.createConsumer();
12
-
13
- }).call(this);
@@ -1,5 +0,0 @@
1
- /*
2
- *= require yigexiangfa_ui/dist/stylesheets/semantic
3
- *= require_tree .
4
- *= require_self
5
- */
@@ -1,7 +0,0 @@
1
- class Admin::BaseController < ApplicationController
2
-
3
- default_form_builder 'AdminBuilder' do |config|
4
-
5
- end
6
-
7
- end
@@ -1,7 +0,0 @@
1
- class My::BaseController < ApplicationController
2
-
3
- default_form_builder 'MyFormBuilder' do |config|
4
-
5
- end
6
-
7
- end
@@ -1,3 +0,0 @@
1
- class ApplicationRecord < ActiveRecord::Base
2
- self.abstract_class = true
3
- end
@@ -1,3 +0,0 @@
1
- class User < ApplicationRecord
2
-
3
- end
@@ -1,18 +0,0 @@
1
- <header class="ui inverted site borderless menu">
2
- <div class="ui container">
3
-
4
- <% if current_user %>
5
- <%= link_to root_path, class: 'item header' do %>
6
- <span>MDPI</span>
7
- <% end %>
8
- <%= link_to 'Team', members_path, class: active_helper(controller: '/members') %>
9
- <% else %>
10
- <%= link_to 'MDPI', root_path, class: 'item header' %>
11
- <% end %>
12
-
13
- <%= render 'layouts/right_menu' %>
14
-
15
- </div>
16
- </header>
17
-
18
-
@@ -1,19 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= csrf_meta_tags %>
6
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
7
- <%= css_load media: 'all' %>
8
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9
- <%= js_ready 'data-turbolinks-track': 'reload' %>
10
- </head>
11
-
12
- <body>
13
- <%= render 'layouts/navbar' %>
14
- <main class="ui container">
15
- <%= yield %>
16
- </main>
17
- <%= js_load %>
18
- </body>
19
- </html>
@@ -1,13 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
- <style>
6
- /* Email styles need to be inline */
7
- </style>
8
- </head>
9
-
10
- <body>
11
- <%= yield %>
12
- </body>
13
- </html>
@@ -1 +0,0 @@
1
- <%= yield %>
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'pathname'
3
- require 'fileutils'
4
- include FileUtils
5
-
6
- # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
-
9
- def system!(*args)
10
- system(*args) || abort("\n== Command #{args} failed ==")
11
- end
12
-
13
- chdir APP_ROOT do
14
- # This script is a way to update your development environment automatically.
15
- # Add necessary update steps to this file.
16
-
17
- puts '== Installing dependencies =='
18
- system! 'gem install bundler --conservative'
19
- system('bundle check') || system!('bundle install')
20
-
21
- puts "\n== Updating database =="
22
- system! 'bin/rails db:migrate'
23
-
24
- puts "\n== Removing old logs and tempfiles =="
25
- system! 'bin/rails log:clear tmp:clear'
26
-
27
- puts "\n== Restarting application server =="
28
- system! 'bin/rails restart'
29
- end
@@ -1,14 +0,0 @@
1
- default: &default
2
- adapter: mysql2
3
- pool: 5
4
- timeout: 5000
5
- username: root
6
- password: root
7
-
8
- development:
9
- <<: *default
10
- database: dummy_development
11
-
12
- test:
13
- <<: *default
14
- database: dummy_test
@@ -1,12 +0,0 @@
1
- default: &default
2
- adapter: sqlite3
3
- pool: 5
4
- timeout: 5000
5
-
6
- development:
7
- <<: *default
8
- database: db/development.sqlite3
9
-
10
- test:
11
- <<: *default
12
- database: db/test.sqlite3
@@ -1,6 +0,0 @@
1
- Rails.application.config.assets.version = '1.0'
2
-
3
- Rails.application.config.assets.paths += [
4
- Rails.root.join('node_modules'),
5
- *Dir[File.expand_path('vendor/nondigest_assets/*', Rails.root)]
6
- ]
@@ -1,22 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key is used for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
-
6
- # Make sure the secret is at least 30 characters and all random,
7
- # no regular words or you'll be exposed to dictionary attacks.
8
- # You can use `rails secret` to generate a secure secret key.
9
-
10
- # Make sure the secrets in this file are kept private
11
- # if you're sharing your code publicly.
12
-
13
- development:
14
- secret_key_base: d1994ea3a3510e902411b78cb185a1c527a7f8d811264e578909fbc5910e36b7bd9501db720d6b7253178cf7ea05afb254cc9780123013d7de2f78b3926c7983
15
-
16
- test:
17
- secret_key_base: a0f9c1a6efa5a3110639533cf661793521048ba80f861c70dc024657e7fb5ec016f7582f65c811f88722c669582d2d396d0029887e88e939c89cd69a063c8656
18
-
19
- # Do not keep production secrets in the repository,
20
- # instead read values from the environment.
21
- production:
22
- secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -1,26 +0,0 @@
1
- # This migration comes from active_storage (originally 20170806125915)
2
- class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
3
- def change
4
- create_table :active_storage_blobs do |t|
5
- t.string :key, null: false
6
- t.string :filename, null: false
7
- t.string :content_type
8
- t.text :metadata
9
- t.bigint :byte_size, null: false
10
- t.string :checksum, null: false
11
- t.datetime :created_at, null: false
12
-
13
- t.index [ :key ], unique: true
14
- end
15
-
16
- create_table :active_storage_attachments do |t|
17
- t.string :name, null: false
18
- t.references :record, null: false, polymorphic: true, index: false
19
- t.references :blob, null: false
20
-
21
- t.datetime :created_at, null: false
22
-
23
- t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
24
- end
25
- end
26
- end
@@ -1,2 +0,0 @@
1
- DEPRECATION WARNING: ActiveSupport.halt_callback_chains_on_return_false= is deprecated and will be removed in Rails 5.2. (called from <top (required)> at /Users/qin/work/engine/rails_audit/test/dummy/config/initializers/new_framework_defaults.rb:21)
2
- DEPRECATION WARNING: ActiveSupport.halt_callback_chains_on_return_false= is deprecated and will be removed in Rails 5.2. (called from <top (required)> at /Users/qin/work/engine/rails_audit/test/dummy/config/initializers/new_framework_defaults.rb:21)