diff --git a/.gitignore b/.gitignore index 708260f..035b384 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,4 @@ # rspec failure tracking .rspec_status -Gemfile.lock - log diff --git a/.travis.yml b/.travis.yml index 36ba317..4d695eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,52 @@ language: ruby -matrix: + +os: linux +dist: xenial + +jobs: fast_finish: true include: - - rvm: 2.4 - rvm: 2.5 - rvm: 2.6 + - rvm: 2.7 - rvm: ruby-head allow_failures: - rvm: ruby-head -sudo: false -cache: bundler + services: - postgresql + addons: - postgresql: 9.6 -before_install: gem install bundler + postgresql: 12 + apt: + packages: + - postgresql-12 + - postgresql-client-12 + - postgresql-server-dev-12 + - postgresql-client-common + - postgresql-common + +env: + global: + - PGPORT=5433 + +cache: bundler + +before_install: +- gem install bundler +- sudo cp /etc/postgresql/9.6/main/pg_hba.conf /etc/postgresql/12/main/pg_hba.conf +- sudo service postgresql restart 12 +- sleep 1 + +install: bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle} + before_script: - psql -c 'create database sequel_plugins;' -U postgres + script: - bundle exec rspec - bundle exec rubocop + deploy: provider: rubygems api_key: @@ -28,3 +55,4 @@ deploy: on: repo: umbrellio/umbrellio-sequel-plugins branch: master + rvm: 2.7 diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..deb4cf6 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,117 @@ +PATH + remote: . + specs: + umbrellio-sequel-plugins (0.4.0) + sequel + symbiont-ruby (>= 0.6) + +GEM + remote: https://rubygems.org/ + specs: + activesupport (6.0.2.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.2) + ast (2.4.0) + coderay (1.1.2) + concurrent-ruby (1.1.6) + coveralls (0.8.23) + json (>= 1.8, < 3) + simplecov (~> 0.16.1) + term-ansicolor (~> 1.3) + thor (>= 0.19.4, < 2.0) + tins (~> 1.6) + diff-lcs (1.3) + docile (1.3.2) + i18n (1.8.2) + concurrent-ruby (~> 1.0) + jaro_winkler (1.5.4) + json (2.3.0) + method_source (1.0.0) + minitest (5.14.0) + money (6.13.7) + i18n (>= 0.6.4, <= 2) + parallel (1.19.1) + parser (2.7.1.0) + ast (~> 2.4.0) + pg (1.2.3) + pry (0.13.0) + coderay (~> 1.1) + method_source (~> 1.0) + rack (2.2.2) + rainbow (3.0.0) + rake (13.0.1) + rexml (3.2.4) + rspec (3.9.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-core (3.9.1) + rspec-support (~> 3.9.1) + rspec-expectations (3.9.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.2) + rubocop (0.81.0) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.7.0.1) + rainbow (>= 2.2.2, < 4.0) + rexml + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-config-umbrellio (0.81.0.78) + rubocop (= 0.81.0) + rubocop-performance (= 1.5.2) + rubocop-rails (= 2.5.0) + rubocop-rspec (= 1.38.1) + rubocop-performance (1.5.2) + rubocop (>= 0.71.0) + rubocop-rails (2.5.0) + activesupport + rack (>= 1.1) + rubocop (>= 0.72.0) + rubocop-rspec (1.38.1) + rubocop (>= 0.68.1) + ruby-progressbar (1.10.1) + sequel (5.31.0) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) + symbiont-ruby (0.6.0) + sync (0.5.0) + term-ansicolor (1.7.1) + tins (~> 1.0) + thor (1.0.1) + thread_safe (0.3.6) + tins (1.24.1) + sync + tzinfo (1.2.7) + thread_safe (~> 0.1) + unicode-display_width (1.7.0) + zeitwerk (2.3.0) + +PLATFORMS + ruby + +DEPENDENCIES + bundler + coveralls (>= 0.8) + money + pg + pry + rake + rspec + rubocop-config-umbrellio + simplecov + umbrellio-sequel-plugins! + +BUNDLED WITH + 2.1.4 diff --git a/lib/sequel/plugins/money_accessors.rb b/lib/sequel/plugins/money_accessors.rb index 50cac7c..b2c3d7e 100644 --- a/lib/sequel/plugins/money_accessors.rb +++ b/lib/sequel/plugins/money_accessors.rb @@ -2,6 +2,8 @@ require "money" +Money.rounding_mode = BigDecimal::ROUND_HALF_UP + # Creates accessors for money values module Sequel::Plugins::MoneyAccessors MoneyClassRequired = Class.new(StandardError) diff --git a/lib/sequel/plugins/upsert.rb b/lib/sequel/plugins/upsert.rb index 441d60b..1069ff1 100644 --- a/lib/sequel/plugins/upsert.rb +++ b/lib/sequel/plugins/upsert.rb @@ -39,7 +39,7 @@ def upsert(row, **options) # @see #upsert_dataset def multi_upsert(rows, **options) rows = rows.map { |row| sequel_values(row) } - upsert_dataset(options).multi_insert(rows) + upsert_dataset(**options).multi_insert(rows) end # Returns formatted row values diff --git a/spec/extensions/currency_rates_spec.rb b/spec/extensions/currency_rates_spec.rb index 36bde3d..d700a90 100644 --- a/spec/extensions/currency_rates_spec.rb +++ b/spec/extensions/currency_rates_spec.rb @@ -32,10 +32,10 @@ RSpec.describe "currency_rates" do let(:items) do - DB[:items].with_rates(*args).select(Sequel[:price].in_usd.as(:price)).order(:price) + DB[:items].with_rates(**options).select(Sequel[:price].in_usd.as(:price)).order(:price) end - let(:args) { [] } + let(:options) { Hash[] } specify do expect(items.first).to eq(price: 15) @@ -43,7 +43,7 @@ end context "with symbol in time_column param" do - let(:args) { [time_column: :updated_at] } + let(:options) { Hash[time_column: :updated_at] } specify do expect(items.first).to eq(price: 15) @@ -52,7 +52,7 @@ end context "with expression in time_column param" do - let(:args) { [time_column: Sequel[:items][:updated_at]] } + let(:options) { Hash[time_column: Sequel[:items][:updated_at]] } specify do expect(items.first).to eq(price: 15) diff --git a/spec/plugins/with_lock_spec.rb b/spec/plugins/with_lock_spec.rb index 0d37cfb..56b6e54 100644 --- a/spec/plugins/with_lock_spec.rb +++ b/spec/plugins/with_lock_spec.rb @@ -20,10 +20,13 @@ def locks_count it "updates the field" do count_before = locks_count + model.with_lock do - expect(locks_count).to eq(count_before + 1) + expect(locks_count).to eq(count_before + 2) model.update(count: 1) end + expect(locks_count).to eq(count_before) + expect(model.count).to eq(1) end end diff --git a/umbrellio-sequel-plugins.gemspec b/umbrellio-sequel-plugins.gemspec index b843779..d52909f 100644 --- a/umbrellio-sequel-plugins.gemspec +++ b/umbrellio-sequel-plugins.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "symbiont-ruby", ">= 0.6" spec.add_development_dependency "bundler" - spec.add_development_dependency "coveralls" + spec.add_development_dependency "coveralls", ">= 0.8" spec.add_development_dependency "money" spec.add_development_dependency "pg" spec.add_development_dependency "pry"