From 90657be68085cb8e6b674664151efe6ebbb6db24 Mon Sep 17 00:00:00 2001 From: David Paluy Date: Wed, 10 Nov 2021 12:33:39 -0600 Subject: [PATCH 1/2] fix rails6 rspec upgraded test fix --- Gemfile.lock | 219 +++++++++++--------- app/models/debitcredit/account.rb | 22 +- debitcredit.gemspec | 4 +- spec/models/debitcredit/account_spec.rb | 2 +- spec/test_app/app/assets/config/manifest.js | 1 + spec/test_app/config/environments/test.rb | 2 +- spec/test_app/db/schema.rb | 12 +- 7 files changed, 141 insertions(+), 121 deletions(-) create mode 100644 spec/test_app/app/assets/config/manifest.js diff --git a/Gemfile.lock b/Gemfile.lock index 5b850b7..d1108b5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,139 +3,158 @@ PATH specs: debitcredit (1.0.0.pre.pre.1) docile - rails (~> 5.2) + rails (>= 5.2) GEM remote: https://rubygems.org/ specs: - actioncable (5.2.2) - actionpack (= 5.2.2) + actioncable (6.1.4.1) + actionpack (= 6.1.4.1) + activesupport (= 6.1.4.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.2) - actionpack (= 5.2.2) - actionview (= 5.2.2) - activejob (= 5.2.2) + actionmailbox (6.1.4.1) + actionpack (= 6.1.4.1) + activejob (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) + mail (>= 2.7.1) + actionmailer (6.1.4.1) + actionpack (= 6.1.4.1) + actionview (= 6.1.4.1) + activejob (= 6.1.4.1) + activesupport (= 6.1.4.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.2) - actionview (= 5.2.2) - activesupport (= 5.2.2) - rack (~> 2.0) + actionpack (6.1.4.1) + actionview (= 6.1.4.1) + activesupport (= 6.1.4.1) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.2) - activesupport (= 5.2.2) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.4.1) + actionpack (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) + nokogiri (>= 1.8.5) + actionview (6.1.4.1) + activesupport (= 6.1.4.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.2) - activesupport (= 5.2.2) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.4.1) + activesupport (= 6.1.4.1) globalid (>= 0.3.6) - activemodel (5.2.2) - activesupport (= 5.2.2) - activerecord (5.2.2) - activemodel (= 5.2.2) - activesupport (= 5.2.2) - arel (>= 9.0) - activestorage (5.2.2) - actionpack (= 5.2.2) - activerecord (= 5.2.2) - marcel (~> 0.3.1) - activesupport (5.2.2) + activemodel (6.1.4.1) + activesupport (= 6.1.4.1) + activerecord (6.1.4.1) + activemodel (= 6.1.4.1) + activesupport (= 6.1.4.1) + activestorage (6.1.4.1) + actionpack (= 6.1.4.1) + activejob (= 6.1.4.1) + activerecord (= 6.1.4.1) + activesupport (= 6.1.4.1) + marcel (~> 1.0.0) + mini_mime (>= 1.1.0) + activesupport (6.1.4.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - arel (9.0.0) - builder (3.2.3) - byebug (11.0.0) - concurrent-ruby (1.1.4) - crass (1.0.4) - diff-lcs (1.3) - docile (1.3.1) - erubi (1.8.0) - globalid (0.4.2) - activesupport (>= 4.2.0) - i18n (1.5.3) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + builder (3.2.4) + byebug (11.1.3) + concurrent-ruby (1.1.9) + crass (1.0.6) + diff-lcs (1.4.4) + docile (1.4.0) + erubi (1.10.0) + globalid (0.5.2) + activesupport (>= 5.0) + i18n (1.8.11) concurrent-ruby (~> 1.0) - loofah (2.2.3) + loofah (2.12.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) - method_source (0.9.2) - mimemagic (0.3.3) - mini_mime (1.0.1) - mini_portile2 (2.4.0) - minitest (5.11.3) - nio4r (2.3.1) - nokogiri (1.10.1) - mini_portile2 (~> 2.4.0) - rack (2.0.6) + marcel (1.0.2) + method_source (1.0.0) + mini_mime (1.1.2) + mini_portile2 (2.6.1) + minitest (5.14.4) + nio4r (2.5.8) + nokogiri (1.12.5) + mini_portile2 (~> 2.6.1) + racc (~> 1.4) + racc (1.6.0) + rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.2) - actioncable (= 5.2.2) - actionmailer (= 5.2.2) - actionpack (= 5.2.2) - actionview (= 5.2.2) - activejob (= 5.2.2) - activemodel (= 5.2.2) - activerecord (= 5.2.2) - activestorage (= 5.2.2) - activesupport (= 5.2.2) - bundler (>= 1.3.0) - railties (= 5.2.2) + rails (6.1.4.1) + actioncable (= 6.1.4.1) + actionmailbox (= 6.1.4.1) + actionmailer (= 6.1.4.1) + actionpack (= 6.1.4.1) + actiontext (= 6.1.4.1) + actionview (= 6.1.4.1) + activejob (= 6.1.4.1) + activemodel (= 6.1.4.1) + activerecord (= 6.1.4.1) + activestorage (= 6.1.4.1) + activesupport (= 6.1.4.1) + bundler (>= 1.15.0) + railties (= 6.1.4.1) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) - railties (5.2.2) - actionpack (= 5.2.2) - activesupport (= 5.2.2) + rails-html-sanitizer (1.4.2) + loofah (~> 2.3) + railties (6.1.4.1) + actionpack (= 6.1.4.1) + activesupport (= 6.1.4.1) method_source - rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) - rake (12.3.2) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) + rake (>= 0.13) + thor (~> 1.0) + rake (13.0.6) + rspec-core (3.10.1) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) + rspec-support (~> 3.10.0) + rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-rails (3.7.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - sprockets (3.7.2) + rspec-support (~> 3.10.0) + rspec-rails (5.0.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + railties (>= 5.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.10.3) + sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.4.0) - thor (0.20.3) - thread_safe (0.3.6) - tzinfo (1.2.5) - thread_safe (~> 0.1) - websocket-driver (0.7.0) + sqlite3 (1.4.2) + thor (1.1.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) + websocket-extensions (0.1.5) + zeitwerk (2.5.1) PLATFORMS ruby @@ -143,8 +162,8 @@ PLATFORMS DEPENDENCIES byebug debitcredit! - rspec-rails (~> 3.7.2) + rspec-rails (>= 3.7.2) sqlite3 BUNDLED WITH - 1.17.3 + 2.2.15 diff --git a/app/models/debitcredit/account.rb b/app/models/debitcredit/account.rb index 49a8246..ae8112d 100644 --- a/app/models/debitcredit/account.rb +++ b/app/models/debitcredit/account.rb @@ -7,23 +7,22 @@ class Account < ApplicationRecord validates :name, :balance, presence: true validate :prevent_overdraft, unless: :overdraft_enabled? - scope :asset, ->{where(type: AssetAccount.name)} - scope :equity, ->{where(type: EquityAccount.name)} - scope :liability, ->{where(type: LiabilityAccount.name)} - scope :expense, ->{where(type: ExpenseAccount.name)} - scope :income, ->{where(type: IncomeAccount.name)} + scope :asset, -> { where(type: AssetAccount.name) } + scope :equity, -> { where(type: EquityAccount.name) } + scope :liability, -> { where(type: LiabilityAccount.name) } + scope :expense, -> { where(type: ExpenseAccount.name) } + scope :income, -> { where(type: IncomeAccount.name) } - scope :by_id, ->{order(:id)} + scope :by_id, -> { order(:id) } class NotFound < StandardError; end class BadKind < StandardError; end class << self - def by_kind kind + def by_kind(kind) Debitcredit.const_get "#{kind.to_s.capitalize}Account" end def find_or_create(name, kind = nil, overdraft = false) - unless account = find_by(name: name) # Note: reference is automatically provided by association # when running through an association, e.g. @user.accounts[ .... ] @@ -38,11 +37,12 @@ def find_or_create(name, kind = nil, overdraft = false) raise BadKind if kind && by_kind(kind) != account.class if overdraft != account.overdraft_enabled? - account.update_attributes! overdraft_enabled: overdraft + account.update_attribute(:overdraft_enabled, overdraft) end - return account + account end + alias :[] :find_or_create def total_balance @@ -77,7 +77,7 @@ def overdraft? def prevent_overdraft return unless balance_changed? return unless check_overdraft - return unless balance < 0 + return unless overdraft? return unless balance_was > balance errors.add(:balance, :overdraft) diff --git a/debitcredit.gemspec b/debitcredit.gemspec index e066564..16d06f9 100644 --- a/debitcredit.gemspec +++ b/debitcredit.gemspec @@ -16,9 +16,9 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] - s.add_dependency "rails", "~> 5.2" + s.add_dependency "rails", ">= 5.2" s.add_dependency "docile" s.add_development_dependency "sqlite3" - s.add_development_dependency "rspec-rails", "~> 3.7.2" + s.add_development_dependency "rspec-rails", ">= 3.7.2" end diff --git a/spec/models/debitcredit/account_spec.rb b/spec/models/debitcredit/account_spec.rb index e52b006..41a0dbc 100644 --- a/spec/models/debitcredit/account_spec.rb +++ b/spec/models/debitcredit/account_spec.rb @@ -1,7 +1,7 @@ module Debitcredit RSpec.describe Account do def described_class; Debitcredit::AssetAccount; end - def valid_attrs; {name: 'foo'} end + def valid_attrs; { name: 'foo' } end describe '.by_kind' do it 'should find account class by kind' do diff --git a/spec/test_app/app/assets/config/manifest.js b/spec/test_app/app/assets/config/manifest.js new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/spec/test_app/app/assets/config/manifest.js @@ -0,0 +1 @@ +{} diff --git a/spec/test_app/config/environments/test.rb b/spec/test_app/config/environments/test.rb index 6fd7f98..36c3748 100644 --- a/spec/test_app/config/environments/test.rb +++ b/spec/test_app/config/environments/test.rb @@ -15,7 +15,7 @@ # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" + 'Cache-Control' => "public, max-age=3600" } # Show full error reports and disable caching. diff --git a/spec/test_app/db/schema.rb b/spec/test_app/db/schema.rb index 3f1e6e9..27f067d 100644 --- a/spec/test_app/db/schema.rb +++ b/spec/test_app/db/schema.rb @@ -2,15 +2,15 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150106165647) do +ActiveRecord::Schema.define(version: 2015_01_06_165647) do create_table "debitcredit_accounts", force: :cascade do |t| t.string "name", limit: 32, null: false From 25789644537bca14e93875dd08fd3f3b711c0d37 Mon Sep 17 00:00:00 2001 From: David Paluy Date: Wed, 10 Nov 2021 21:32:21 -0600 Subject: [PATCH 2/2] update version --- Gemfile.lock | 2 +- lib/debitcredit/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d1108b5..ce04540 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - debitcredit (1.0.0.pre.pre.1) + debitcredit (1.1.6) docile rails (>= 5.2) diff --git a/lib/debitcredit/version.rb b/lib/debitcredit/version.rb index 6becff9..a7922f0 100644 --- a/lib/debitcredit/version.rb +++ b/lib/debitcredit/version.rb @@ -1,3 +1,3 @@ module Debitcredit - VERSION = '1.0.0-pre.1' + VERSION = '1.1.6' end