diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d03460a..8b782fa 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,8 +15,9 @@ jobs: - '2.6' - '2.7' activerecord: - - '5.2' + - '6.1' - '6.0' + - '5.2' services: postgres: image: postgres:12 diff --git a/.rspec b/.rspec index 53607ea..18ed8e1 100644 --- a/.rspec +++ b/.rspec @@ -1 +1 @@ ---colour +--force-color diff --git a/amountable.gemspec b/amountable.gemspec index c85d573..92b9b76 100644 --- a/amountable.gemspec +++ b/amountable.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |gem| gem.require_paths = ['lib'] gem.required_ruby_version = '>= 2.6' - gem.add_dependency 'activerecord', '>= 5.2', '< 6.1' + gem.add_dependency 'activerecord', '>= 5.2', '< 7' gem.add_dependency 'activerecord-import', '>= 0.19.1' gem.add_dependency 'money-rails', '>=1.7.0' gem.add_dependency 'monetize' diff --git a/gemfiles/activerecord_6.1.gemfile b/gemfiles/activerecord_6.1.gemfile new file mode 100644 index 0000000..540fb14 --- /dev/null +++ b/gemfiles/activerecord_6.1.gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gemspec path: "../" + +gem "activerecord", "~> 6.1.0" diff --git a/lib/amountable/amount.rb b/lib/amountable/amount.rb index 1ed4f49..c37c7a6 100644 --- a/lib/amountable/amount.rb +++ b/lib/amountable/amount.rb @@ -2,20 +2,6 @@ module Amountable class Amount < ActiveRecord::Base - class_attribute :columns - self.columns = [] - - def self.column(name, sql_type = nil, default = nil, null = true) - type = "ActiveRecord::Type::#{sql_type.to_s.camelize}".constantize.new - columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, type, null) - end - - column :amountable_type, :string, nil, false - column :amountable_id, :integer, nil, false - column :value_currency, :string, nil, true - column :value_cents, :integer, 0, false - column :name, :string, nil, false - include Amountable::Operations belongs_to :amountable, polymorphic: true @@ -31,6 +17,5 @@ def save raise StandardError.new("Can't persist amount to database") if persistable == false super end - end -end \ No newline at end of file +end diff --git a/spec/amountable/amountable_spec.rb b/spec/amountable/amountable_spec.rb index 76e0997..ae4f66b 100644 --- a/spec/amountable/amountable_spec.rb +++ b/spec/amountable/amountable_spec.rb @@ -23,7 +23,7 @@ expect(amount.persisted?).to be true end expect do - expect(order.update_attributes(sub_total: Money.new(200))) + expect(order.update(sub_total: Money.new(200))) end.not_to change { Amountable::Amount.count } end @@ -80,7 +80,7 @@ expect { subscription.save }.not_to change { Amountable::Amount.count } expect(amount.persisted?).to be false end - subscription.update_attributes(sub_total: Money.new(200)) + subscription.update(sub_total: Money.new(200)) expect(subscription.sub_total).to eq(Money.new(200)) expect(subscription.total).to eq(Money.new(200)) subscription.sub_total = Money.zero diff --git a/spec/support/database.rb b/spec/support/database.rb index 06e4fd7..47c64ca 100644 --- a/spec/support/database.rb +++ b/spec/support/database.rb @@ -10,7 +10,7 @@ ActiveRecord::Base.default_timezone = :utc ActiveRecord::Base.configurations = YAML.load_file(database_yml) ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), '../debug.log')) -ActiveRecord::Base.logger.level = ENV['TRAVIS'] ? ::Logger::ERROR : ::Logger::DEBUG +ActiveRecord::Base.logger.level = ENV['CI'] ? ::Logger::ERROR : ::Logger::DEBUG config = ActiveRecord::Base.configurations[db_name] begin