├── .rspec ├── app ├── assets │ ├── javascripts │ │ ├── spree │ │ │ ├── backend │ │ │ │ └── solidus_papertrail.js │ │ │ └── frontend │ │ │ │ └── solidus_papertrail.js │ │ ├── admin │ │ │ └── solidus_papertrail.js │ │ └── store │ │ │ └── solidus_papertrail.js │ └── stylesheets │ │ ├── spree │ │ ├── backend │ │ │ └── solidus_papertrail.css │ │ └── frontend │ │ │ └── solidus_papertrail.css │ │ ├── admin │ │ └── solidus_papertrail.css │ │ └── store │ │ └── solidus_papertrail.css ├── models │ ├── spree │ │ ├── order_version.rb │ │ ├── payment_version.rb │ │ ├── shipment_version.rb │ │ ├── line_item_version.rb │ │ ├── adjustment_version.rb │ │ ├── order_decorator.rb │ │ ├── payment_decorator.rb │ │ ├── shipment_decorator.rb │ │ ├── line_item_decorator.rb │ │ ├── return_authorization_version.rb │ │ ├── adjustment_decorator.rb │ │ └── return_authorization_decorator.rb │ ├── paper_trail │ │ └── version_decorator.rb │ └── concerns │ │ └── spree │ │ └── versionable.rb ├── controllers │ └── spree │ │ ├── base_controller_decorator.rb │ │ ├── api │ │ └── base_controller_decorator.rb │ │ └── admin │ │ └── orders_controller_decorator.rb ├── overrides │ └── add_order_history_to_order_menu.rb ├── services │ ├── yaml_adapter.rb │ └── versions_adapter.rb └── views │ └── spree │ └── admin │ └── orders │ ├── versions.html.erb │ ├── _object_changes.html.erb │ ├── _order_versions.html.erb │ ├── _adjustment_versions.html.erb │ ├── _line_item_versions.html.erb │ ├── _payment_versions.html.erb │ ├── _shipment_versions.html.erb │ └── _return_authorization_versions.html.erb ├── .rubocop.yml ├── lib ├── solidus_papertrail │ ├── factories.rb │ ├── version.rb │ └── engine.rb ├── solidus_papertrail.rb └── generators │ └── solidus_papertrail │ └── install │ └── install_generator.rb ├── config ├── initializers │ └── paper_trail.rb ├── locales │ ├── es.yml │ └── en.yml └── routes.rb ├── .gem_release.yml ├── Rakefile ├── bin ├── setup ├── rails └── console ├── .gitignore ├── spec ├── controllers │ └── spree │ │ ├── admin │ │ └── base_controller_spec.rb │ │ └── api │ │ └── base_controller_spec.rb ├── support │ └── authentication_helpers.rb ├── spec_helper.rb └── features │ └── admin │ └── order_history_spec.rb ├── .github └── stale.yml ├── .circleci └── config.yml ├── README.md ├── Gemfile ├── solidus_papertrail.gemspec ├── LICENSE ├── db └── migrate │ └── 20160421221937_create_versions.rb └── .rubocop_todo.yml /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /app/assets/javascripts/spree/backend/solidus_papertrail.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/javascripts/spree/frontend/solidus_papertrail.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/stylesheets/spree/backend/solidus_papertrail.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/stylesheets/spree/frontend/solidus_papertrail.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/javascripts/admin/solidus_papertrail.js: -------------------------------------------------------------------------------- 1 | //= require admin/spree_backend 2 | -------------------------------------------------------------------------------- /app/assets/javascripts/store/solidus_papertrail.js: -------------------------------------------------------------------------------- 1 | //= require store/spree_frontend 2 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | require: 2 | - solidus_dev_support/rubocop 3 | 4 | inherit_from: .rubocop_todo.yml 5 | -------------------------------------------------------------------------------- /app/assets/stylesheets/admin/solidus_papertrail.css: -------------------------------------------------------------------------------- 1 | /* 2 | *= require admin/spree_backend 3 | */ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/store/solidus_papertrail.css: -------------------------------------------------------------------------------- 1 | /* 2 | *= require store/spree_frontend 3 | */ 4 | -------------------------------------------------------------------------------- /lib/solidus_papertrail/factories.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | FactoryBot.define do 4 | end 5 | -------------------------------------------------------------------------------- /config/initializers/paper_trail.rb: -------------------------------------------------------------------------------- 1 | PaperTrail.config.enabled = true 2 | PaperTrail.config.track_associations = false 3 | -------------------------------------------------------------------------------- /lib/solidus_papertrail/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module SolidusPapertrail 4 | VERSION = '1.0.0' 5 | end 6 | -------------------------------------------------------------------------------- /.gem_release.yml: -------------------------------------------------------------------------------- 1 | bump: 2 | recurse: false 3 | file: 'lib/solidus_papertrail/version.rb' 4 | message: Bump SolidusPapertrail to %{version} 5 | tag: true 6 | -------------------------------------------------------------------------------- /app/models/spree/order_version.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | class OrderVersion < PaperTrail::Version 3 | self.table_name = :spree_order_versions 4 | end 5 | end -------------------------------------------------------------------------------- /app/models/spree/payment_version.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | class PaymentVersion < PaperTrail::Version 3 | self.table_name = :spree_payment_versions 4 | end 5 | end -------------------------------------------------------------------------------- /app/models/spree/shipment_version.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | class ShipmentVersion < PaperTrail::Version 3 | self.table_name = :spree_shipment_versions 4 | end 5 | end -------------------------------------------------------------------------------- /app/models/spree/line_item_version.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | class LineItemVersion < PaperTrail::Version 3 | self.table_name = :spree_line_item_versions 4 | end 5 | end -------------------------------------------------------------------------------- /config/locales/es.yml: -------------------------------------------------------------------------------- 1 | es: 2 | spree: 3 | payment_history: Historial de Pago 4 | order_history: Historial de la Orden 5 | shipment_history: Historial del Envío -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'solidus_dev_support/rake_tasks' 4 | SolidusDevSupport::RakeTasks.install 5 | 6 | task default: 'extension:specs' 7 | -------------------------------------------------------------------------------- /app/models/spree/adjustment_version.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | class AdjustmentVersion < PaperTrail::Version 3 | self.table_name = :spree_adjustment_versions 4 | end 5 | end -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | gem install bundler --conservative 7 | bundle update 8 | bundle exec rake clobber 9 | -------------------------------------------------------------------------------- /app/models/paper_trail/version_decorator.rb: -------------------------------------------------------------------------------- 1 | module PaperTrail 2 | module VersionDecorator 3 | Version.class_eval do 4 | self.abstract_class = true 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /app/models/spree/order_decorator.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | Order.class_eval do 3 | include Spree::Versionable 4 | has_paper_trail class_name: 'Spree::OrderVersion' 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /app/models/spree/payment_decorator.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | Payment.class_eval do 3 | include Spree::Versionable 4 | has_paper_trail class_name: 'Spree::PaymentVersion' 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /app/models/spree/shipment_decorator.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | Shipment.class_eval do 3 | include Spree::Versionable 4 | has_paper_trail class_name: 'Spree::ShipmentVersion' 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /app/models/spree/line_item_decorator.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | LineItem.class_eval do 3 | include Spree::Versionable 4 | has_paper_trail class_name: 'Spree::LineItemVersion' 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /app/models/spree/return_authorization_version.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | class ReturnAuthorizationVersion < PaperTrail::Version 3 | self.table_name = :spree_return_authorization_versions 4 | end 5 | end -------------------------------------------------------------------------------- /app/models/spree/adjustment_decorator.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | Adjustment.class_eval do 3 | include Spree::Versionable 4 | has_paper_trail class_name: 'Spree::AdjustmentVersion' 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /app/controllers/spree/base_controller_decorator.rb: -------------------------------------------------------------------------------- 1 | Spree::BaseController.class_eval do 2 | def user_for_paper_trail 3 | current_spree_user.nil? ? 'Public User' : current_spree_user.id 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/controllers/spree/api/base_controller_decorator.rb: -------------------------------------------------------------------------------- 1 | Spree::Api::BaseController.class_eval do 2 | def user_for_paper_trail 3 | current_api_user.nil? ? 'Public User' : current_api_user.id 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | \#* 3 | *~ 4 | .#* 5 | .DS_Store 6 | .idea 7 | .project 8 | .sass-cache 9 | coverage 10 | Gemfile.lock 11 | tmp 12 | nbproject 13 | pkg 14 | *.swp 15 | spec/dummy 16 | spec/examples.txt 17 | -------------------------------------------------------------------------------- /app/models/spree/return_authorization_decorator.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | ReturnAuthorization.class_eval do 3 | include Spree::Versionable 4 | has_paper_trail class_name: 'Spree::ReturnAuthorizationVersion' 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /lib/solidus_papertrail.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'solidus_core' 4 | require 'solidus_support' 5 | 6 | require 'solidus_papertrail/version' 7 | require 'solidus_papertrail/engine' 8 | 9 | require 'paper_trail' 10 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Spree::Core::Engine.routes.draw do 2 | # Add your extension routes here 3 | namespace :admin do 4 | resources :orders do 5 | member do 6 | get :versions 7 | end 8 | end 9 | end 10 | 11 | end 12 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # frozen_string_literal: true 4 | 5 | app_root = 'spec/dummy' 6 | 7 | unless File.exist? "#{app_root}/bin/rails" 8 | system "bin/rake", app_root or begin # rubocop:disable Style/AndOr 9 | warn "Automatic creation of the dummy app failed" 10 | exit 1 11 | end 12 | end 13 | 14 | Dir.chdir app_root 15 | exec 'bin/rails', *ARGV 16 | -------------------------------------------------------------------------------- /app/overrides/add_order_history_to_order_menu.rb: -------------------------------------------------------------------------------- 1 | Deface::Override.new( 2 | virtual_path: 'spree/admin/shared/_order_submenu', 3 | name: 'order_history_menu', 4 | insert_bottom: "[data-hook='admin_order_tabs']", 5 | text: "
  • ><%= link_to_with_icon 'icon-shopping-cart', I18n.t('spree.order_history'), versions_admin_order_path(@order) %>
  • " 6 | ) 7 | -------------------------------------------------------------------------------- /app/models/concerns/spree/versionable.rb: -------------------------------------------------------------------------------- 1 | module Spree 2 | module Versionable 3 | 4 | attr_accessor :who, :version_changes, :version_id, :version_event, :version_date 5 | 6 | def who=(user_id) 7 | begin 8 | user = Spree::User.find(user_id) 9 | @who = "#{user.first_name} #{user.last_name}" 10 | rescue 11 | @who = 'Unknown' 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # frozen_string_literal: true 4 | 5 | require "bundler/setup" 6 | require "solidus_papertrail" 7 | 8 | # You can add fixtures and/or initialization code here to make experimenting 9 | # with your gem easier. You can also use a different console, if you like. 10 | $LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"]) 11 | 12 | # (If you use this, don't forget to add pry to your Gemfile!) 13 | # require "pry" 14 | # Pry.start 15 | 16 | require "irb" 17 | IRB.start(__FILE__) 18 | -------------------------------------------------------------------------------- /spec/controllers/spree/admin/base_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Spree::Admin::BaseController, type: :controller do 4 | let(:user) { create(:user) } 5 | stub_authorization! 6 | 7 | context 'as a logged in user' do 8 | before do 9 | sign_in(user) 10 | end 11 | 12 | it 'should return a proper user id' do 13 | expect(controller.user_for_paper_trail).to eq(user.id) 14 | end 15 | end 16 | 17 | context 'without a logged in user' do 18 | it 'should return a proper user id' do 19 | expect(controller.user_for_paper_trail).to match(/public user/i) 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/solidus_papertrail/engine.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spree/core' 4 | 5 | module SolidusPapertrail 6 | class Engine < Rails::Engine 7 | include SolidusSupport::EngineExtensions 8 | 9 | isolate_namespace ::Spree 10 | 11 | engine_name 'solidus_papertrail' 12 | 13 | # use rspec for tests 14 | config.generators do |g| 15 | g.test_framework :rspec 16 | end 17 | 18 | def self.activate 19 | Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c| 20 | Rails.configuration.cache_classes ? require(c) : load(c) 21 | end 22 | end 23 | 24 | config.to_prepare &method(:activate).to_proc 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | activerecord: 3 | models: 4 | spree/adjustmentversion: 5 | one: Adjustment Version 6 | other: Adjustment History 7 | spree/line_item_version: 8 | one: Line Item Version 9 | other: Line Item History 10 | spree/orderversion: 11 | one: Order Version 12 | other: Order History 13 | spree/paymentversion: 14 | one: Payment Version 15 | other: Payment History 16 | spree/return_authorization_version: 17 | one: Return Authorization Version 18 | other: Return Authorization History 19 | spree/shipmentversion: 20 | one: Shipment Version 21 | other: Shipment History 22 | -------------------------------------------------------------------------------- /spec/controllers/spree/api/base_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Spree::Api::BaseController, type: :controller do 4 | let(:user) { create(:user, spree_api_key: SecureRandom.hex) } 5 | stub_authorization! 6 | 7 | context 'as a logged in user' do 8 | before do 9 | allow(controller).to receive_messages(current_api_user: user) 10 | end 11 | 12 | it 'should return a proper user id' do 13 | expect(controller.user_for_paper_trail).to eq(user.id) 14 | end 15 | end 16 | 17 | context 'without a logged in user' do 18 | it 'should return a proper user id' do 19 | expect(controller.user_for_paper_trail).to match(/public user/i) 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /app/services/yaml_adapter.rb: -------------------------------------------------------------------------------- 1 | class YamlAdapter 2 | attr_reader :payload, :klass 3 | 4 | def initialize text, klass 5 | @data = YAML.load(text) 6 | @klass = klass 7 | end 8 | 9 | def deserialize 10 | @klass.new(permitted_data) 11 | end 12 | 13 | private 14 | 15 | # The below two methods prevent papertrail from 16 | # attempting to instantiate models with attributes 17 | # they do not have definitions for or do not have 18 | # the corresponding columns in the database. 19 | # 20 | # Both cases are exceptional, so we filter this here. 21 | def permitted_data 22 | keys = @klass.column_names.to_set 23 | @data.keep_if do |key, _| 24 | keys.include?(key) 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 60 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - security 9 | # Label to use when marking an issue as stale 10 | staleLabel: wontfix 11 | # Comment to post when marking an issue as stale. Set to `false` to disable 12 | markComment: > 13 | This issue has been automatically marked as stale because it has not had 14 | recent activity. It will be closed if no further activity occurs. Thank you 15 | for your contributions. 16 | # Comment to post when closing a stale issue. Set to `false` to disable 17 | closeComment: false -------------------------------------------------------------------------------- /spec/support/authentication_helpers.rb: -------------------------------------------------------------------------------- 1 | module AuthenticationHelpers 2 | def sign_in_as!(user) 3 | visit '/login' 4 | fill_in 'Email', with: user.email 5 | fill_in 'Password', with: 'secret' 6 | click_button 'Login' 7 | end 8 | 9 | def login_as_admin 10 | admin = create(:admin_user, password: 'test123', password_confirmation: 'test123') 11 | visit spree.admin_path 12 | fill_in 'Email', with: admin.email 13 | fill_in 'Password', with: 'test123' 14 | click_button 'Login' 15 | admin 16 | end 17 | end 18 | 19 | RSpec.configure do |config| 20 | config.include AuthenticationHelpers, type: :feature 21 | config.include Devise::Test::ControllerHelpers, type: :controller 22 | config.include Rack::Test::Methods, type: :feature 23 | end 24 | -------------------------------------------------------------------------------- /app/views/spree/admin/orders/versions.html.erb: -------------------------------------------------------------------------------- 1 | <% content_for :page_actions do %> 2 |
  • <%= link_to I18n.t('spree.back'), spree.edit_admin_order_path(@order), :icon => 'icon-arrow-left' %>
  • 3 | <% end %> 4 | 5 | <%= render partial: 'spree/admin/shared/order_tabs', locals: { current: 'Audit Trail'} %> 6 | 7 | <%= render partial: 'order_versions' %> 8 | 9 | <%= render partial: 'line_item_versions' %> 10 | 11 | <%= render partial: 'adjustment_versions' %> 12 | 13 | <%= render partial: 'payment_versions' %> 14 | 15 | <%= render partial: 'shipment_versions' %> 16 | 17 | <%= render partial: 'return_authorization_versions' %> 18 | 19 | 26 | -------------------------------------------------------------------------------- /lib/generators/solidus_papertrail/install/install_generator.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module SolidusPapertrail 4 | module Generators 5 | class InstallGenerator < Rails::Generators::Base 6 | class_option :auto_run_migrations, type: :boolean, default: false 7 | 8 | def add_migrations 9 | run 'bundle exec rake railties:install:migrations FROM=solidus_papertrail' 10 | end 11 | 12 | def run_migrations 13 | run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?( 14 | ask('Would you like to run the migrations now? [Y/n]') 15 | ) 16 | if run_migrations 17 | run 'bundle exec rake db:migrate' 18 | else 19 | puts 'Skipping rake db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /app/services/versions_adapter.rb: -------------------------------------------------------------------------------- 1 | class VersionsAdapter 2 | 3 | def self.create(elements) 4 | collection = [] 5 | elements.each do |element| 6 | if element.respond_to?(:versions) 7 | versions = element.versions.order(:object, created_at: :asc) 8 | versions.each do |version| 9 | prototype = version.object.nil? ? 10 | element.class.new : 11 | YamlAdapter.new(version.object, element.class).deserialize 12 | prototype.who = version.whodunnit 13 | prototype.version_id = version.id 14 | prototype.version_event = version.event 15 | prototype.version_changes = version.object_changes 16 | prototype.version_date = version.created_at 17 | collection << prototype 18 | end 19 | collection << element 20 | end 21 | end 22 | collection 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /app/controllers/spree/admin/orders_controller_decorator.rb: -------------------------------------------------------------------------------- 1 | Spree::Admin::OrdersController.class_eval do 2 | def versions 3 | @order = Spree::Order.find_by_number params[:id] 4 | 5 | @versions = VersionsAdapter.create([@order]) 6 | 7 | payments = @order.payments.order(updated_at: :asc) 8 | @payment_versions = VersionsAdapter.create(payments) 9 | 10 | shipments = @order.shipments.order(updated_at: :desc) 11 | @shipment_versions = VersionsAdapter.create(shipments) 12 | 13 | line_items = @order.line_items.order(updated_at: :desc) 14 | @line_item_versions = VersionsAdapter.create(line_items) 15 | 16 | adjustments = @order.all_adjustments.order(updated_at: :desc) 17 | @adjustment_versions = VersionsAdapter.create(adjustments) 18 | 19 | return_authorizations = @order.return_authorizations.order(updated_at: :desc) 20 | @return_authorization_versions = VersionsAdapter.create(return_authorizations) 21 | end 22 | end -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | orbs: 4 | # Always take the latest version of the orb, this allows us to 5 | # run specs against Solidus supported versions only without the need 6 | # to change this configuration every time a Solidus version is released 7 | # or goes EOL. 8 | solidusio_extensions: solidusio/extensions@volatile 9 | 10 | jobs: 11 | run-specs-with-postgres: 12 | executor: solidusio_extensions/postgres 13 | steps: 14 | - solidusio_extensions/run-tests 15 | run-specs-with-mysql: 16 | executor: solidusio_extensions/mysql 17 | steps: 18 | - solidusio_extensions/run-tests 19 | 20 | workflows: 21 | "Run specs on supported Solidus versions": 22 | jobs: 23 | - run-specs-with-postgres 24 | - run-specs-with-mysql 25 | "Weekly run specs against master": 26 | triggers: 27 | - schedule: 28 | cron: "0 0 * * 4" # every Thursday 29 | filters: 30 | branches: 31 | only: 32 | - master 33 | jobs: 34 | - run-specs-with-postgres 35 | - run-specs-with-mysql 36 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Configure Rails Environment 4 | ENV['RAILS_ENV'] ||= 'test' 5 | 6 | # Run Coverage report 7 | require 'solidus_dev_support/rspec/coverage' 8 | 9 | require File.expand_path('dummy/config/environment.rb', __dir__) 10 | 11 | # Requires factories and other useful helpers defined in spree_core. 12 | require 'solidus_dev_support/rspec/feature_helper' 13 | 14 | # Requires supporting ruby files with custom matchers and macros, etc, 15 | # in spec/support/ and its subdirectories. 16 | Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f } 17 | 18 | # Requires factories defined in lib/solidus_papertrail/factories.rb 19 | require 'solidus_papertrail/factories' 20 | 21 | RSpec.configure do |config| 22 | config.infer_spec_type_from_file_location! 23 | config.raise_errors_for_deprecations! 24 | config.use_transactional_fixtures = false 25 | config.example_status_persistence_file_path = "./spec/examples.txt" 26 | 27 | config.include Spree::TestingSupport::UrlHelpers 28 | config.include Spree::TestingSupport::ControllerRequests, type: :controller 29 | end 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SolidusPapertrail 2 | ================= 3 | 4 | [![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_papertrail.svg?style=svg)](https://circleci.com/gh/solidusio-contrib/solidus_papertrail) 5 | 6 | Introduction goes here. 7 | 8 | Installation 9 | ------------ 10 | 11 | Add solidus_papertrail to your Gemfile: 12 | 13 | ```ruby 14 | gem 'solidus_papertrail' 15 | ``` 16 | 17 | Bundle your dependencies and run the installation generator: 18 | 19 | ```shell 20 | bundle 21 | bundle exec rails g solidus_papertrail:install 22 | ``` 23 | 24 | Testing 25 | ------- 26 | 27 | Be sure to bundle your dependencies and then create a dummy test app for the specs to run against. 28 | 29 | ```shell 30 | bundle 31 | bundle exec rake test_app 32 | bundle exec rspec spec 33 | ``` 34 | 35 | When testing your applications integration with this extension you may use it's factories. 36 | Simply add this require statement to your spec_helper: 37 | 38 | ```ruby 39 | require 'solidus_papertrail/factories' 40 | ``` 41 | 42 | 43 | Copyright (c) 2014 [Acid Labs][acidlabs], released under the New BSD License 44 | 45 | [acidlabs]: https://github.com/acidlabs 46 | -------------------------------------------------------------------------------- /app/views/spree/admin/orders/_object_changes.html.erb: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source 'https://rubygems.org' 4 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 5 | 6 | branch = ENV.fetch('SOLIDUS_BRANCH', 'master') 7 | solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2') 8 | %w[solidusio/solidus solidusio/solidus_frontend] 9 | else 10 | %w[solidusio/solidus] * 2 11 | end 12 | gem 'solidus', github: solidus_git, branch: branch 13 | gem 'solidus_frontend', github: solidus_frontend_git, branch: branch 14 | 15 | # Needed to help Bundler figure out how to resolve dependencies, 16 | # otherwise it takes forever to resolve them. 17 | # See https://github.com/bundler/bundler/issues/6677 18 | gem 'rails', '>0.a' 19 | 20 | # Provides basic authentication functionality for testing parts of your engine 21 | gem 'solidus_auth_devise' 22 | 23 | case ENV['DB'] 24 | when 'mysql' 25 | gem 'mysql2' 26 | when 'postgresql' 27 | gem 'pg' 28 | else 29 | gem 'sqlite3' 30 | end 31 | 32 | gemspec 33 | 34 | # Use a local Gemfile to include development dependencies that might not be 35 | # relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`. 36 | send :eval_gemfile, 'Gemfile-local' if File.exist? 'Gemfile-local' 37 | -------------------------------------------------------------------------------- /solidus_papertrail.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | $:.push File.expand_path('lib', __dir__) 4 | require 'solidus_papertrail/version' 5 | 6 | Gem::Specification.new do |s| 7 | s.platform = Gem::Platform::RUBY 8 | s.name = 'solidus_papertrail' 9 | s.version = SolidusPapertrail::VERSION 10 | s.summary = 'Solidus Papertrail integration' 11 | s.description = 'Views to see Order, Payment and Shipment Papertrail versions' 12 | 13 | s.required_ruby_version = '~> 2.4' 14 | 15 | s.author = 'Acid Labs' 16 | s.email = 'spree@acid.cl' 17 | s.homepage = 'https://github.com/solidusio-contrib/solidus_papertrail' 18 | s.license = 'BSD-3-Clause' 19 | 20 | s.files = Dir.chdir(File.expand_path(__dir__)) do 21 | `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } 22 | end 23 | s.test_files = Dir['spec/**/*'] 24 | s.bindir = "exe" 25 | s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) } 26 | s.require_paths = ["lib"] 27 | 28 | if s.respond_to?(:metadata) 29 | s.metadata["homepage_uri"] = s.homepage if s.homepage 30 | s.metadata["source_code_uri"] = s.homepage if s.homepage 31 | end 32 | 33 | s.add_dependency 'paper_trail', '~> 9.2' 34 | s.add_dependency 'solidus_core', ['>= 1.0', '< 3'] 35 | s.add_dependency 'solidus_support', '~> 0.5' 36 | 37 | s.add_development_dependency 'solidus_dev_support' 38 | end 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Acid Labs and other contributors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name Solidus nor the names of its contributors may be used to 13 | endorse or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /app/views/spree/admin/orders/_order_versions.html.erb: -------------------------------------------------------------------------------- 1 |
    2 | 3 | <%= Spree::OrderVersion.model_name.human %> 4 | 5 |
    6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | <% @versions.each do |order| %> 22 | <% if order.version_id %> 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | <% else %> 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | <% end %> 43 | <% end %> 44 | 45 |
    <%= Spree::OrderVersion.human_attribute_name("version_id") %><%= Spree::OrderVersion.human_attribute_name("status") %><%= Spree::OrderVersion.human_attribute_name("payment_state") %><%= Spree::OrderVersion.human_attribute_name("event") %><%= Spree::OrderVersion.human_attribute_name("changes") %><%= Spree::OrderVersion.human_attribute_name("user") %><%= Spree::OrderVersion.human_attribute_name("created") %>
    <%= order.version_id %><%= order.state %><%= order.payment_state %><%= order.version_event %><%= render partial: 'object_changes', locals: { object: order } %><%= order.who %><%= pretty_time(order.version_date) %>
    <%= order.state %><%= order.payment_state %><%= pretty_time(order.updated_at) %>
    46 | -------------------------------------------------------------------------------- /app/views/spree/admin/orders/_adjustment_versions.html.erb: -------------------------------------------------------------------------------- 1 |
    2 | 3 | <%= Spree::AdjustmentVersion.model_name.human %> 4 | 5 |
    6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | <% @adjustment_versions.each do |adjustment| %> 23 | <% if adjustment.version_id %> 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | <% else %> 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | <% end %> 46 | <% end %> 47 | 48 |
    <%= Spree::AdjustmentVersion.human_attribute_name("version_id") %><%= Spree::AdjustmentVersion.human_attribute_name("id") %><%= Spree::AdjustmentVersion.human_attribute_name("amount") %><%= Spree::AdjustmentVersion.human_attribute_name("label") %><%= Spree::AdjustmentVersion.human_attribute_name("event") %><%= Spree::AdjustmentVersion.human_attribute_name("changes") %><%= Spree::AdjustmentVersion.human_attribute_name("user") %><%= Spree::AdjustmentVersion.human_attribute_name("created") %>
    <%= adjustment.version_id %><%= adjustment.id %><%= number_to_currency adjustment.amount %><%= adjustment.label %><%= adjustment.version_event %><%= render partial: 'object_changes', locals: { object: adjustment } %><%= adjustment.who %><%= pretty_time(adjustment.version_date) %>
    <%= adjustment.id %><%= number_to_currency adjustment.amount %><%= adjustment.label %><%= pretty_time(adjustment.updated_at) %>
    49 | -------------------------------------------------------------------------------- /app/views/spree/admin/orders/_line_item_versions.html.erb: -------------------------------------------------------------------------------- 1 |
    2 | 3 | <%= Spree::LineItemVersion.model_name.human %> 4 | 5 |
    6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | <% @line_item_versions.each do |line_item| %> 24 | <% if line_item.version_id %> 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | <% else %> 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | <% end %> 49 | 50 | <% end %> 51 | 52 |
    <%= Spree::LineItemVersion.human_attribute_name("version_id") %><%= Spree::LineItemVersion.human_attribute_name("id") %><%= Spree::LineItemVersion.human_attribute_name("product") %><%= Spree::LineItemVersion.human_attribute_name("quantity") %><%= Spree::LineItemVersion.human_attribute_name("price") %><%= Spree::LineItemVersion.human_attribute_name("event") %><%= Spree::LineItemVersion.human_attribute_name("changes") %><%= Spree::LineItemVersion.human_attribute_name("user") %><%= Spree::LineItemVersion.human_attribute_name("created") %>
    <%= line_item.version_id %><%= line_item.id %><%= line_item.name if line_item.variant %><%= line_item.quantity %><%= number_to_currency line_item.price %><%= line_item.version_event %><%= render partial: 'object_changes', locals: { object: line_item } %><%= line_item.who %><%= pretty_time(line_item.version_date) %>
    <%= line_item.name if line_item.variant %><%= line_item.quantity %><%= number_to_currency line_item.price %><%= pretty_time(line_item.updated_at) %>
    53 | -------------------------------------------------------------------------------- /app/views/spree/admin/orders/_payment_versions.html.erb: -------------------------------------------------------------------------------- 1 |
    2 | 3 | <%= Spree::PaymentVersion.model_name.human %> 4 | 5 |
    6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | <% @payment_versions.each do |payment| %> 24 | <% if payment.version_id %> 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | <% else %> 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | <% end %> 47 | <% end %> 48 | 49 | 50 | 51 |
    <%= Spree::PaymentVersion.human_attribute_name("version_id") %><%= Spree::PaymentVersion.human_attribute_name("id") %><%= Spree::PaymentVersion.human_attribute_name("amount") %><%= Spree::PaymentVersion.human_attribute_name("payment_state") %><%= Spree::PaymentVersion.human_attribute_name("payment_method") %><%= Spree::PaymentVersion.human_attribute_name("event") %><%= Spree::PaymentVersion.human_attribute_name("changes") %><%= Spree::PaymentVersion.human_attribute_name("user") %><%= Spree::PaymentVersion.human_attribute_name("created") %>
    <%= payment.version_id %><%= payment.id %><%= number_to_currency payment.amount %><%= payment.state if payment.id %><%= payment_method_name(payment) if payment.id %><%= payment.version_event %><%= render partial: 'object_changes', locals: { object: payment } %><%= payment.who %><%= pretty_time(payment.version_date) %>
    <%= payment.id %><%= number_to_currency payment.amount %><%= payment.state if payment.id %><%= payment.payment_method.name if payment.id %><%= pretty_time(payment.updated_at) %>
    52 | -------------------------------------------------------------------------------- /app/views/spree/admin/orders/_shipment_versions.html.erb: -------------------------------------------------------------------------------- 1 |
    2 | 3 | <%= Spree::ShipmentVersion.model_name.human %> 4 | 5 |
    6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | <% @shipment_versions.each do |shipment| %> 24 | <% if shipment.version_id %> 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | <% else %> 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | <% end %> 49 | 50 | <% end %> 51 | 52 |
    <%= Spree::ShipmentVersion.human_attribute_name("version_id") %><%= Spree::ShipmentVersion.human_attribute_name("id") %><%= Spree::ShipmentVersion.human_attribute_name("tracking_number") %><%= Spree::ShipmentVersion.human_attribute_name("shipment_state") %><%= Spree::ShipmentVersion.human_attribute_name("shipping_method") %><%= Spree::ShipmentVersion.human_attribute_name("event") %><%= Spree::ShipmentVersion.human_attribute_name("changes") %><%= Spree::ShipmentVersion.human_attribute_name("user") %><%= Spree::ShipmentVersion.human_attribute_name("created") %>
    <%= shipment.version_id %><%= shipment.id %><%= shipment.tracking %><%= shipment.state %><%= shipment.shipping_method.name if shipment.shipping_method %><%= shipment.version_event %><%= render partial: 'object_changes', locals: { object: shipment } %><%= shipment.who %><%= pretty_time(shipment.version_date) %>
    <%= shipment.id %><%= shipment.tracking %><%= shipment.state %><%= shipment.shipping_method.name if shipment.shipping_method %><%= pretty_time(shipment.updated_at) %>
    53 | -------------------------------------------------------------------------------- /app/views/spree/admin/orders/_return_authorization_versions.html.erb: -------------------------------------------------------------------------------- 1 |
    2 | 3 | <%= Spree::ReturnAuthorizationVersion.model_name.human %> 4 | 5 |
    6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | <% if Spree.solidus_gem_version >= Gem::Version.new('2.4.0') %> 15 | 16 | <% else %> 17 | 18 | <% end %> 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | <% @return_authorization_versions.each do |return_authorization| %> 29 | <% if return_authorization.version_id %> 30 | 31 | 32 | 33 | 34 | 35 | <% if Spree.solidus_gem_version >= Gem::Version.new('2.4.0') %> 36 | 37 | <% else %> 38 | 39 | <% end %> 40 | 41 | 42 | 43 | 44 | 45 | 46 | <% else %> 47 | 48 | 49 | 50 | 51 | 52 | <% if Spree.solidus_gem_version >= Gem::Version.new('2.4.0') %> 53 | 54 | <% else %> 55 | 56 | <% end %> 57 | 58 | 59 | 60 | 61 | 62 | 63 | <% end %> 64 | <% end %> 65 | 66 |
    <%= Spree::ReturnAuthorizationVersion.human_attribute_name("version_id") %><%= Spree::ReturnAuthorizationVersion.human_attribute_name("number") %><%= Spree::ReturnAuthorizationVersion.human_attribute_name("status") %><%= Spree::ReturnAuthorizationVersion.human_attribute_name("total_excluding_vat") %><%= Spree::ReturnAuthorizationVersion.human_attribute_name("pre_tax_total") %><%= Spree::ReturnAuthorizationVersion.human_attribute_name("event") %><%= Spree::ReturnAuthorizationVersion.human_attribute_name("changes") %><%= Spree::ReturnAuthorizationVersion.human_attribute_name("user") %><%= Spree::ReturnAuthorizationVersion.human_attribute_name("created") %>
    <%= return_authorization.version_id %><%= return_authorization.number %><%= return_authorization.state %><%= return_authorization.order && return_authorization.display_total_excluding_vat %><%= return_authorization.order && return_authorization.display_pre_tax_total %><%= return_authorization.version_event %><%= render partial: 'object_changes', locals: { object: return_authorization } %><%= return_authorization.who %><%= pretty_time(return_authorization.version_date) %>
    <%= return_authorization.number %><%= return_authorization.state %><%= return_authorization.order && return_authorization.display_total_excluding_vat %><%= return_authorization.order && return_authorization.display_pre_tax_total %><%= pretty_time(return_authorization.updated_at) %>
    67 | -------------------------------------------------------------------------------- /spec/features/admin/order_history_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # Each entry has a "click to reveal changes" link to display details in a popup 4 | # These tables are nested and contain duplicate information, so it's difficult 5 | # to target cells using anything but row and column numbers 6 | def expect_hidden_details(details, table: nil, row: 0, column: 0) 7 | within(:css, "table#{table}>tbody") do 8 | find(:css, "tr:nth-child(#{row}) td:nth-child(#{column}) a").click 9 | within '.object-changes' do 10 | expect(page).to have_content(details) 11 | end 12 | end 13 | end 14 | 15 | RSpec.feature 'Order History', :type => :feature, js: true do 16 | let!(:order) { create(:order, number: 'R212345678') } 17 | 18 | before :each do 19 | login_as_admin 20 | end 21 | 22 | it "tracks order history" do 23 | visit spree.versions_admin_order_path(order) 24 | expect(page).to have_css("table#order-history>tbody tr", count: 2) 25 | 26 | order.update(email: 'foo@bar.com') 27 | visit(current_path) 28 | 29 | expect(page).to have_css("table#order-history>tbody tr", count: 3) 30 | expect_hidden_details('R212345678', table: '#order-history', row: 1, column: 5) 31 | end 32 | 33 | it "tracks order line item history" do 34 | visit spree.versions_admin_order_path(order) 35 | 36 | expect(page).to have_css("table#line-item-history>tbody tr", count: 0) 37 | 38 | variant = create(:variant) 39 | order.contents.add(variant) 40 | visit(current_path) 41 | 42 | expect(page).to have_css("table#line-item-history>tbody tr", count: 2) 43 | expect_hidden_details(variant.price, table: '#line-item-history', row: 1, column: 7) 44 | end 45 | 46 | it "tracks order adjustment history" do 47 | visit spree.versions_admin_order_path(order) 48 | 49 | expect(page).to have_css("table#adjustment-history>tbody tr", count: 0) 50 | 51 | create(:tax_adjustment, adjustable: order, order: order) 52 | visit(current_path) 53 | 54 | expect(page).to have_css("table#adjustment-history>tbody tr", count: 2) 55 | expect_hidden_details('Spree::TaxRate', table: '#adjustment-history', row: 1, column: 6) 56 | end 57 | 58 | it "tracks order payment history" do 59 | visit spree.versions_admin_order_path(order) 60 | 61 | expect(page).to have_css("table#payment-history>tbody tr", count: 1) 62 | 63 | create(:payment, order: order, response_code: '54321') 64 | visit(current_path) 65 | 66 | expect(page).to have_css("table#payment-history>tbody tr", count: 3) 67 | expect_hidden_details('54321', table: '#payment-history', row: 1, column: 7) 68 | end 69 | 70 | it "tracks order shipment history" do 71 | visit spree.versions_admin_order_path(order) 72 | 73 | expect(page).to have_css("table#shipment-history>tbody tr", count: 0) 74 | 75 | create(:shipment, order: order, stock_location: create(:stock_location, id: 9182736)) 76 | visit(current_path) 77 | 78 | expect(page).to have_css("table#shipment-history>tbody tr", count: 3) 79 | expect_hidden_details('9182736', table: '#shipment-history', row: 1, column: 7) 80 | end 81 | 82 | context 'with shipped order' do 83 | let!(:order) { create(:shipped_order) } 84 | 85 | it "tracks order return authorizations history" do 86 | visit spree.versions_admin_order_path(order) 87 | 88 | expect(page).to have_css("table#returns-history>tbody tr", count: 0) 89 | create(:return_authorization, order: order, memo: 'All wrong.') 90 | visit(current_path) 91 | 92 | expect(page).to have_css("table#returns-history>tbody tr", count: 2) 93 | expect_hidden_details('All wrong.', table: '#returns-history', row: 1, column: 6) 94 | end 95 | end 96 | end 97 | -------------------------------------------------------------------------------- /db/migrate/20160421221937_create_versions.rb: -------------------------------------------------------------------------------- 1 | class CreateVersions < SolidusSupport::Migration[4.2] 2 | # The largest text column available in all supported RDBMS is 3 | # 1024^3 - 1 bytes, roughly one gibibyte. We specify a size 4 | # so that MySQL will use `longtext` instead of `text`. Otherwise, 5 | # when serializing very large objects, `text` might not be big enough. 6 | TEXT_BYTES = 1_073_741_823 7 | 8 | def change 9 | if !table_exists?(:spree_order_versions) 10 | create_table :spree_order_versions do |t| 11 | t.string :item_type, :null => false 12 | t.integer :item_id, :null => false 13 | t.string :event, :null => false 14 | t.string :whodunnit 15 | t.text :object, :limit => TEXT_BYTES 16 | t.text :object_changes, :limit => TEXT_BYTES 17 | t.datetime :created_at 18 | end 19 | add_index :spree_order_versions, [:item_type, :item_id] 20 | end 21 | 22 | if !table_exists?(:spree_payment_versions) 23 | create_table :spree_payment_versions do |t| 24 | t.string :item_type, :null => false 25 | t.integer :item_id, :null => false 26 | t.string :event, :null => false 27 | t.string :whodunnit 28 | t.text :object, :limit => TEXT_BYTES 29 | t.text :object_changes, :limit => TEXT_BYTES 30 | t.datetime :created_at 31 | end 32 | add_index :spree_payment_versions, [:item_type, :item_id] 33 | end 34 | 35 | if !table_exists?(:spree_shipment_versions) 36 | create_table :spree_shipment_versions do |t| 37 | t.string :item_type, :null => false 38 | t.integer :item_id, :null => false 39 | t.string :event, :null => false 40 | t.string :whodunnit 41 | t.text :object, :limit => TEXT_BYTES 42 | t.text :object_changes, :limit => TEXT_BYTES 43 | t.datetime :created_at 44 | end 45 | add_index :spree_shipment_versions, [:item_type, :item_id] 46 | end 47 | 48 | if !table_exists?(:spree_return_authorization_versions) 49 | create_table :spree_return_authorization_versions do |t| 50 | t.string :item_type, :null => false 51 | t.integer :item_id, :null => false 52 | t.string :event, :null => false 53 | t.string :whodunnit 54 | t.text :object, :limit => TEXT_BYTES 55 | t.text :object_changes, :limit => TEXT_BYTES 56 | t.datetime :created_at 57 | end 58 | add_index :spree_return_authorization_versions, [:item_type, :item_id], name: 'spree_return_auth_versions' 59 | end 60 | 61 | if !table_exists?(:spree_line_item_versions) 62 | create_table :spree_line_item_versions do |t| 63 | t.string :item_type, :null => false 64 | t.integer :item_id, :null => false 65 | t.string :event, :null => false 66 | t.string :whodunnit 67 | t.text :object, :limit => TEXT_BYTES 68 | t.text :object_changes, :limit => TEXT_BYTES 69 | t.datetime :created_at 70 | end 71 | add_index :spree_line_item_versions, [:item_type, :item_id] 72 | end 73 | 74 | if !table_exists?(:spree_adjustment_versions) 75 | create_table :spree_adjustment_versions do |t| 76 | t.string :item_type, :null => false 77 | t.integer :item_id, :null => false 78 | t.string :event, :null => false 79 | t.string :whodunnit 80 | t.text :object, :limit => TEXT_BYTES 81 | t.text :object_changes, :limit => TEXT_BYTES 82 | t.datetime :created_at 83 | end 84 | add_index :spree_adjustment_versions, [:item_type, :item_id] 85 | end 86 | end 87 | end 88 | -------------------------------------------------------------------------------- /.rubocop_todo.yml: -------------------------------------------------------------------------------- 1 | # This configuration was generated by 2 | # `rubocop --auto-gen-config` 3 | # on 2020-01-28 09:18:11 +0100 using RuboCop version 0.76.0. 4 | # The point is for the user to remove these configuration records 5 | # one by one as the offenses are removed from the code base. 6 | # Note that changes in the inspected code, or installation of new 7 | # versions of RuboCop, may require this file to be generated again. 8 | 9 | # Offense count: 1 10 | # Cop supports --auto-correct. 11 | # Configuration parameters: EnabledMethods. 12 | Capybara/FeatureMethods: 13 | Exclude: 14 | - 'spec/features/admin/order_history_spec.rb' 15 | 16 | # Offense count: 1 17 | # Cop supports --auto-correct. 18 | # Configuration parameters: EnforcedStyle. 19 | # SupportedStyles: empty_lines, no_empty_lines 20 | Layout/EmptyLinesAroundBlockBody: 21 | Exclude: 22 | - 'config/routes.rb' 23 | 24 | # Offense count: 1 25 | # Cop supports --auto-correct. 26 | # Configuration parameters: EnforcedStyle. 27 | # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only 28 | Layout/EmptyLinesAroundClassBody: 29 | Exclude: 30 | - 'app/services/versions_adapter.rb' 31 | 32 | # Offense count: 1 33 | # Cop supports --auto-correct. 34 | # Configuration parameters: EnforcedStyle. 35 | # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines 36 | Layout/EmptyLinesAroundModuleBody: 37 | Exclude: 38 | - 'app/models/concerns/spree/versionable.rb' 39 | 40 | # Offense count: 12 41 | # Cop supports --auto-correct. 42 | # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. 43 | Layout/ExtraSpacing: 44 | Exclude: 45 | - 'db/migrate/20160421221937_create_versions.rb' 46 | 47 | # Offense count: 7 48 | # Cop supports --auto-correct. 49 | # Configuration parameters: EnforcedStyle. 50 | # SupportedStyles: final_newline, final_blank_line 51 | Layout/TrailingBlankLines: 52 | Exclude: 53 | - 'app/controllers/spree/admin/orders_controller_decorator.rb' 54 | - 'app/models/spree/adjustment_version.rb' 55 | - 'app/models/spree/line_item_version.rb' 56 | - 'app/models/spree/order_version.rb' 57 | - 'app/models/spree/payment_version.rb' 58 | - 'app/models/spree/return_authorization_version.rb' 59 | - 'app/models/spree/shipment_version.rb' 60 | 61 | # Offense count: 11 62 | # Cop supports --auto-correct. 63 | # Configuration parameters: AllowInHeredoc. 64 | Layout/TrailingWhitespace: 65 | Exclude: 66 | - 'app/controllers/spree/admin/orders_controller_decorator.rb' 67 | - 'app/models/spree/adjustment_version.rb' 68 | - 'app/models/spree/line_item_version.rb' 69 | - 'app/models/spree/order_version.rb' 70 | - 'app/models/spree/payment_version.rb' 71 | - 'app/models/spree/return_authorization_version.rb' 72 | - 'app/models/spree/shipment_version.rb' 73 | - 'spec/controllers/spree/admin/base_controller_spec.rb' 74 | - 'spec/controllers/spree/api/base_controller_spec.rb' 75 | 76 | # Offense count: 1 77 | Lint/AmbiguousOperator: 78 | Exclude: 79 | - 'lib/solidus_papertrail/engine.rb' 80 | 81 | # Offense count: 1 82 | Lint/DuplicateMethods: 83 | Exclude: 84 | - 'app/models/concerns/spree/versionable.rb' 85 | 86 | # Offense count: 2 87 | # Configuration parameters: Prefixes. 88 | # Prefixes: when, with, without 89 | RSpec/ContextWording: 90 | Exclude: 91 | - 'spec/controllers/spree/admin/base_controller_spec.rb' 92 | - 'spec/controllers/spree/api/base_controller_spec.rb' 93 | 94 | # Offense count: 2 95 | # Cop supports --auto-correct. 96 | RSpec/EmptyLineAfterFinalLet: 97 | Exclude: 98 | - 'spec/controllers/spree/admin/base_controller_spec.rb' 99 | - 'spec/controllers/spree/api/base_controller_spec.rb' 100 | 101 | # Offense count: 4 102 | # Cop supports --auto-correct. 103 | # Configuration parameters: CustomTransform, IgnoredWords. 104 | RSpec/ExampleWording: 105 | Exclude: 106 | - 'spec/controllers/spree/admin/base_controller_spec.rb' 107 | - 'spec/controllers/spree/api/base_controller_spec.rb' 108 | 109 | # Offense count: 1 110 | # Cop supports --auto-correct. 111 | # Configuration parameters: EnforcedStyle. 112 | # SupportedStyles: implicit, each, example 113 | RSpec/HookArgument: 114 | Exclude: 115 | - 'spec/features/admin/order_history_spec.rb' 116 | 117 | # Offense count: 6 118 | # Configuration parameters: AggregateFailuresByDefault. 119 | RSpec/MultipleExpectations: 120 | Max: 2 121 | 122 | # Offense count: 1 123 | # Cop supports --auto-correct. 124 | # Configuration parameters: Whitelist. 125 | # Whitelist: find_by_sql 126 | Rails/DynamicFindBy: 127 | Exclude: 128 | - 'app/controllers/spree/admin/orders_controller_decorator.rb' 129 | 130 | # Offense count: 1 131 | # Cop supports --auto-correct. 132 | Security/YAMLLoad: 133 | Exclude: 134 | - 'app/services/yaml_adapter.rb' 135 | 136 | # Offense count: 27 137 | # Cop supports --auto-correct. 138 | # Configuration parameters: EnforcedStyle. 139 | # SupportedStyles: always, never 140 | Style/FrozenStringLiteralComment: 141 | Enabled: false 142 | 143 | # Offense count: 1 144 | # Configuration parameters: MinBodyLength. 145 | Style/GuardClause: 146 | Exclude: 147 | - 'db/migrate/20160421221937_create_versions.rb' 148 | 149 | # Offense count: 31 150 | # Cop supports --auto-correct. 151 | # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. 152 | # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys 153 | Style/HashSyntax: 154 | Exclude: 155 | - 'db/migrate/20160421221937_create_versions.rb' 156 | - 'spec/features/admin/order_history_spec.rb' 157 | 158 | # Offense count: 1 159 | # Cop supports --auto-correct. 160 | # Configuration parameters: EnforcedStyle. 161 | # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline 162 | Style/MethodDefParentheses: 163 | Exclude: 164 | - 'app/services/yaml_adapter.rb' 165 | 166 | # Offense count: 1 167 | Style/MultilineTernaryOperator: 168 | Exclude: 169 | - 'app/services/versions_adapter.rb' 170 | 171 | # Offense count: 1 172 | # Cop supports --auto-correct. 173 | # Configuration parameters: EnforcedStyle, MinBodyLength. 174 | # SupportedStyles: skip_modifier_ifs, always 175 | Style/Next: 176 | Exclude: 177 | - 'app/services/versions_adapter.rb' 178 | 179 | # Offense count: 1 180 | # Cop supports --auto-correct. 181 | # Configuration parameters: Strict. 182 | Style/NumericLiterals: 183 | MinDigits: 8 184 | 185 | # Offense count: 1 186 | # Cop supports --auto-correct. 187 | Style/RedundantBegin: 188 | Exclude: 189 | - 'app/models/concerns/spree/versionable.rb' 190 | 191 | # Offense count: 1 192 | # Cop supports --auto-correct. 193 | # Configuration parameters: EnforcedStyle. 194 | # SupportedStyles: implicit, explicit 195 | Style/RescueStandardError: 196 | Exclude: 197 | - 'app/models/concerns/spree/versionable.rb' 198 | 199 | # Offense count: 2 200 | # Cop supports --auto-correct. 201 | # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. 202 | # URISchemes: http, https 203 | Metrics/LineLength: 204 | Max: 186 205 | --------------------------------------------------------------------------------