diff --git a/CHANGELOG.md b/CHANGELOG.md index 607c9f0..2a3dc57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog All notable changes to this project will be documented in this file. +## [6.0.4] - 2022-02-05 +### Fixed + +- `Debouncer` calculates proper `next_sync_time` + ## [6.0.3] - 2021-12-09 ### Fixed Fixed bug when routing key is nil. @@ -45,7 +50,7 @@ Separate classes for publishing, object data, Rabbit params, debounce, serializa 6. Changed ORMAdapters. -7. Destroyed objects are initialized. +7. Destroyed objects are initialized. Now custom attributes for destruction will be called on instances. - Obj.table_sync_destroy_attributes() -> Obj#attributes_for_destroy diff --git a/Gemfile.lock b/Gemfile.lock index 2c51ab9..5b32ad4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - table_sync (6.0.3) + table_sync (6.0.4) memery rabbit_messaging rails @@ -10,60 +10,60 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (6.1.4.1) - actionpack (= 6.1.4.1) - activesupport (= 6.1.4.1) + actioncable (6.1.4.4) + actionpack (= 6.1.4.4) + activesupport (= 6.1.4.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - 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) + actionmailbox (6.1.4.4) + actionpack (= 6.1.4.4) + activejob (= 6.1.4.4) + activerecord (= 6.1.4.4) + activestorage (= 6.1.4.4) + activesupport (= 6.1.4.4) 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) + actionmailer (6.1.4.4) + actionpack (= 6.1.4.4) + actionview (= 6.1.4.4) + activejob (= 6.1.4.4) + activesupport (= 6.1.4.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.4.1) - actionview (= 6.1.4.1) - activesupport (= 6.1.4.1) + actionpack (6.1.4.4) + actionview (= 6.1.4.4) + activesupport (= 6.1.4.4) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) 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) + actiontext (6.1.4.4) + actionpack (= 6.1.4.4) + activerecord (= 6.1.4.4) + activestorage (= 6.1.4.4) + activesupport (= 6.1.4.4) nokogiri (>= 1.8.5) - actionview (6.1.4.1) - activesupport (= 6.1.4.1) + actionview (6.1.4.4) + activesupport (= 6.1.4.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.4.1) - activesupport (= 6.1.4.1) + activejob (6.1.4.4) + activesupport (= 6.1.4.4) globalid (>= 0.3.6) - 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) + activemodel (6.1.4.4) + activesupport (= 6.1.4.4) + activerecord (6.1.4.4) + activemodel (= 6.1.4.4) + activesupport (= 6.1.4.4) + activestorage (6.1.4.4) + actionpack (= 6.1.4.4) + activejob (= 6.1.4.4) + activerecord (= 6.1.4.4) + activesupport (= 6.1.4.4) marcel (~> 1.0.0) mini_mime (>= 1.1.0) - activesupport (6.1.4.1) + activesupport (6.1.4.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -84,16 +84,13 @@ GEM diff-lcs (1.4.4) docile (1.3.5) erubi (1.10.0) - exception_notification (4.4.3) - actionmailer (>= 4.0, < 7) - activesupport (>= 4.0, < 7) - globalid (0.5.2) + globalid (1.0.0) activesupport (>= 5.0) - i18n (1.8.10) + i18n (1.9.1) concurrent-ruby (~> 1.0) - lamian (1.4.0) + lamian (1.5.0) rails (>= 4.2) - loofah (2.12.0) + loofah (2.13.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -104,7 +101,7 @@ GEM method_source (1.0.0) mini_mime (1.1.2) mini_portile2 (2.6.1) - minitest (5.14.4) + minitest (5.15.0) nio4r (2.5.8) nokogiri (1.12.5) mini_portile2 (~> 2.6.1) @@ -116,9 +113,8 @@ GEM pry (0.14.0) coderay (~> 1.1) method_source (~> 1.0) - rabbit_messaging (0.12.0) + rabbit_messaging (0.12.1) bunny (~> 2.0) - exception_notification lamian rails (>= 5.2) sneakers (~> 2.0) @@ -127,35 +123,35 @@ GEM rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) - 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) + rails (6.1.4.4) + actioncable (= 6.1.4.4) + actionmailbox (= 6.1.4.4) + actionmailer (= 6.1.4.4) + actionpack (= 6.1.4.4) + actiontext (= 6.1.4.4) + actionview (= 6.1.4.4) + activejob (= 6.1.4.4) + activemodel (= 6.1.4.4) + activerecord (= 6.1.4.4) + activestorage (= 6.1.4.4) + activesupport (= 6.1.4.4) bundler (>= 1.15.0) - railties (= 6.1.4.1) + railties (= 6.1.4.4) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.2) loofah (~> 2.3) - railties (6.1.4.1) - actionpack (= 6.1.4.1) - activesupport (= 6.1.4.1) + railties (6.1.4.4) + actionpack (= 6.1.4.4) + activesupport (= 6.1.4.4) method_source rake (>= 0.13) thor (~> 1.0) rainbow (3.0.0) rake (13.0.6) - rbtree (0.4.4) + rbtree (0.4.5) regexp_parser (2.1.1) rexml (3.2.5) rspec (3.10.0) @@ -230,13 +226,13 @@ GEM sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.4.1) + sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) tainbox (2.1.2) activesupport - thor (1.1.0) + thor (1.2.1) timecop (0.9.4) tzinfo (2.0.4) concurrent-ruby (~> 1.0) @@ -244,7 +240,7 @@ GEM websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.4.2) + zeitwerk (2.5.4) PLATFORMS ruby diff --git a/lib/table_sync/publishing/helpers/debounce.rb b/lib/table_sync/publishing/helpers/debounce.rb index f480a80..bcab2ff 100644 --- a/lib/table_sync/publishing/helpers/debounce.rb +++ b/lib/table_sync/publishing/helpers/debounce.rb @@ -63,7 +63,7 @@ def initialize(object_class:, needle:, event:, debounce_time: nil) end def skip? - true if sync_in_the_future? && upsert_event? # case 3.1 + sync_in_the_future? && upsert_event? # case 3.1 end memoize def next_sync_time @@ -87,16 +87,16 @@ def sync_in_the_past? end def debounce_time_passed? - cached_sync_time + debounce_time.seconds >= current_time + cached_sync_time + debounce_time.seconds <= current_time end def debounce_time_not_passed? - cached_sync_time + debounce_time.seconds < current_time + cached_sync_time + debounce_time.seconds > current_time end # CASE 3 def sync_in_the_future? - cached_sync_time && (cached_sync_time > current_time) + !!cached_sync_time && (cached_sync_time > current_time) end def destroy_event? diff --git a/lib/table_sync/version.rb b/lib/table_sync/version.rb index ebd41c8..d670da7 100644 --- a/lib/table_sync/version.rb +++ b/lib/table_sync/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module TableSync - VERSION = "6.0.3" + VERSION = "6.0.4" end diff --git a/spec/publishing/helpers/debounce_spec.rb b/spec/publishing/helpers/debounce_spec.rb index c064377..db6db02 100644 --- a/spec/publishing/helpers/debounce_spec.rb +++ b/spec/publishing/helpers/debounce_spec.rb @@ -47,35 +47,35 @@ def set_cached_sync_time(time) let(:debounce_time) { 0 } let(:expected_time) { current_time } - include_examples "skip? returns", nil + include_examples "skip? returns", false include_examples "returns correct next_sync_time" end context "case 1: cached sync time is empty" do let(:expected_time) { current_time } - include_examples "skip? returns", nil + include_examples "skip? returns", false include_examples "returns correct next_sync_time" end context "case 2: cached sync time in the past" do context "case 2.1: debounce time passed" do let(:expected_time) { current_time } - let(:cached_time) { current_time - debounce_time.seconds + 10.seconds } + let(:cached_time) { current_time - 30.seconds } before { set_cached_sync_time(cached_time) } - include_examples "skip? returns", nil + include_examples "skip? returns", false include_examples "returns correct next_sync_time" end context "case 2.2: debounce time not passed yet" do - let(:expected_time) { cached_time + debounce_time.seconds } - let(:cached_time) { current_time - debounce_time.seconds - 10.seconds } + let(:expected_time) { cached_time + 30.seconds } + let(:cached_time) { current_time } before { set_cached_sync_time(cached_time) } - include_examples "skip? returns", nil + include_examples "skip? returns", false include_examples "returns correct next_sync_time" end end @@ -94,9 +94,9 @@ def set_cached_sync_time(time) context "case 3.2: event destroy" do let(:event) { :destroy } - let(:expected_time) { cached_time + debounce_time.seconds } + let(:expected_time) { cached_time + 30.seconds } - include_examples "skip? returns", nil + include_examples "skip? returns", false include_examples "returns correct next_sync_time" end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 098806c..4d1daaa 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -40,6 +40,7 @@ config.filter_run_when_matching :focus config.default_formatter = "doc" if config.files_to_run.one? config.expose_dsl_globally = true + config.profile_examples = 10 config.expect_with(:rspec) do |expectations| expectations.syntax = :expect