Skip to content

Commit

Permalink
Compatibility with redis 4.7.x gem
Browse files Browse the repository at this point in the history
It's not clear why this complexity was added in rpush#32 but it was unnecessary and breaks the test suite with redis 4.7.1. Removing it continues with tests passing on 4.6.0 and fixes the tests with 4.7.1.

Compatibility with redis 4.8.x will come in rpush#35.

See rpush#36.
  • Loading branch information
benlangfeld committed Jan 18, 2023
1 parent 8b6fa91 commit 2864b10
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PATH
activesupport (>= 5.2)
connection_pool (>= 2)
msgpack (>= 0.5)
redis (>= 3.0, < 4.7)
redis (>= 3.0, < 4.8)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -43,7 +43,7 @@ GEM
ast (~> 2.4.1)
rainbow (3.0.0)
rake (13.0.1)
redis (4.6.0)
redis (4.7.1)
rexml (3.2.5)
rspec (3.9.0)
rspec-core (~> 3.9.0)
Expand Down
2 changes: 1 addition & 1 deletion modis.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |gem|

gem.add_runtime_dependency 'activemodel', '>= 5.2'
gem.add_runtime_dependency 'activesupport', '>= 5.2'
gem.add_runtime_dependency 'redis', '>= 3.0', '< 4.7'
gem.add_runtime_dependency 'redis', '>= 3.0', '< 4.8'
gem.add_runtime_dependency 'connection_pool', '>= 2'

if defined? JRUBY_VERSION
Expand Down
18 changes: 4 additions & 14 deletions spec/persistence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,8 @@ class MockModelNoAllIndex < MockModel

it 'does not track the ID if the underlying Redis command failed' do
redis = double(hmset: double(value: nil), sadd: nil)
if Gem::Version.new(Redis::VERSION) > Gem::Version.new('4.6.0')
expect(model.class).to receive(:transaction).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline::Multi.new(redis)))
expect(redis).to receive(:pipelined).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline.new(redis)))
else
expect(model.class).to receive(:transaction).and_yield(redis)
expect(redis).to receive(:pipelined).and_yield(redis)
end
expect(model.class).to receive(:transaction).and_yield(redis)
expect(redis).to receive(:pipelined).and_yield(redis)
model.save
expect { model.class.find(model.id) }.to raise_error(Modis::RecordNotFound)
end
Expand All @@ -140,13 +135,8 @@ class MockModelNoAllIndex < MockModel
model.age = 11
redis = double
expect(redis).to receive(:hmset).with("modis:persistence_spec:mock_model:1", ["age", "\v"]).and_return(double(value: 'OK'))
if Gem::Version.new(Redis::VERSION) > Gem::Version.new('4.6.0')
expect(model.class).to receive(:transaction).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline::Multi.new(redis)))
expect(redis).to receive(:pipelined).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline.new(redis)))
else
expect(model.class).to receive(:transaction).and_yield(redis)
expect(redis).to receive(:pipelined).and_yield(redis)
end
expect(model.class).to receive(:transaction).and_yield(redis)
expect(redis).to receive(:pipelined).and_yield(redis)
model.save!
expect(model.age).to eq(11)
end
Expand Down

0 comments on commit 2864b10

Please sign in to comment.