Sha256: 98454679f9596c2753824cc183e7e90fbc8da539a2ba2ca09a58e1d1d61e1957

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 KB

Contents

# encoding: utf-8
#
require 'spec_helper'

# Shows that realime update data can be ignored if they are
# already in the index.
#
describe 'ignoring updates' do
  
  normal_index = Picky::Index.new :normal do
    category :title
  end
  
  symbol_keys_index = Picky::Index.new :symbol do
    symbol_keys
    
    category :title
  end
  
  static_index = Picky::Index.new :static do
    static
    
    category :title
  end
  
  [normal_index, symbol_keys_index, static_index].each do |index|
    it 'does not update the index if the added data stayed the same' do
      thing = Struct.new :id, :title
      index.add thing.new(1, 'some title')
      index.add thing.new(2, 'some title')
    
      try = Picky::Search.new index
    
      try.search('some').ids.should == [2, 1]
    
      index.add thing.new(1, 'some title'), force_update: true
    
      # Expected behavior.
      try.search('some').ids.should == [1, 2]
    
      index.add thing.new(2, 'some title') # force_update: false is the default.
    
      # Not updated, since it was the exact same data everywhere.
      try.search('some').ids.should == [1, 2]
    
      index.add thing.new(2, 'some title'), force_update: false
    
      # Not updated, since it was the exact same data everywhere.
      try.search('some').ids.should == [1, 2]
    end
  
    it 'does always update the index if replace is used' do
      index = Picky::Index.new :books do
        category :title
      end

      thing = Struct.new :id, :title
      index.add thing.new(1, 'some title')
      index.add thing.new(2, 'some title')
    
      try = Picky::Search.new index
    
      try.search('some').ids.should == [2, 1]
    
      index.replace thing.new(1, 'some title')
    
      # Expected behavior.
      try.search('some').ids.should == [1, 2]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
picky-4.31.3 spec/functional/realtime_force_update_spec.rb
picky-4.31.2 spec/functional/realtime_force_update_spec.rb
picky-4.31.1 spec/functional/realtime_force_update_spec.rb
picky-4.31.0 spec/functional/realtime_force_update_spec.rb