Commit f9bd2d7a authored by Mike Kozono's avatar Mike Kozono

Geo: Alternate redownload and normal design sync attempts

Changelog: changed
EE: true
parent bc6c2a5c
...@@ -120,6 +120,6 @@ class Geo::DesignRegistry < Geo::BaseRegistry ...@@ -120,6 +120,6 @@ class Geo::DesignRegistry < Geo::BaseRegistry
def should_be_redownloaded? def should_be_redownloaded?
return true if force_to_redownload return true if force_to_redownload
retry_count > RETRIES_BEFORE_REDOWNLOAD retry_count.present? && retry_count > RETRIES_BEFORE_REDOWNLOAD && retry_count.odd?
end end
end end
...@@ -4,6 +4,7 @@ require 'spec_helper' ...@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Geo::DesignRegistry, :geo do RSpec.describe Geo::DesignRegistry, :geo do
include ::EE::GeoHelpers include ::EE::GeoHelpers
using RSpec::Parameterized::TableSyntax
it_behaves_like 'a BulkInsertSafe model', Geo::DesignRegistry do it_behaves_like 'a BulkInsertSafe model', Geo::DesignRegistry do
let(:valid_items_for_bulk_insertion) do let(:valid_items_for_bulk_insertion) do
...@@ -266,25 +267,27 @@ RSpec.describe Geo::DesignRegistry, :geo do ...@@ -266,25 +267,27 @@ RSpec.describe Geo::DesignRegistry, :geo do
end end
describe '#should_be_redownloaded?' do describe '#should_be_redownloaded?' do
let_it_be(:design_registry) { create(:geo_design_registry) } where(:force_to_redownload, :retry_count, :expected) do
false | nil | false
context 'when force_to_redownload is false' do false | 0 | false
it 'returns false' do false | 1 | false
expect(design_registry.should_be_redownloaded?).to be false false | 10 | false
end false | 11 | true
false | 12 | false
it 'returns true when limit is exceeded' do false | 13 | true
design_registry.retry_count = Geo::DesignRegistry::RETRIES_BEFORE_REDOWNLOAD + 1 false | 14 | false
false | 101 | true
expect(design_registry.should_be_redownloaded?).to be true false | 102 | false
end true | nil | true
end true | 0 | true
true | 11 | true
context 'when force_to_redownload is true' do end
it 'resets the state of the sync' do
design_registry.force_to_redownload = true with_them do
it "returns the expected boolean" do
expect(design_registry.should_be_redownloaded?).to be true registry = build(:geo_design_registry, retry_count: retry_count, force_to_redownload: force_to_redownload)
expect(registry.should_be_redownloaded?).to eq(expected)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment