fix issue locomotivecms/wagon#273: with_scope with tags field type works like AND operator instead of OR
did
committed Nov 27, 2015
commit 89915c6c024942ef8d9f9a26ca7ab54785c82da0
Showing 2
changed files with
11 additions
and 3 deletions
locomotive/steam/adapters/memory/condition.rb b/lib/locomotive/steam/adapters/memory/condition.rb
+2
-2
| @@ | @@ -41,7 +41,7 @@ module Locomotive::Steam |
| end | |
| def inspect | |
| - | "#{field}.#{operator} #{value}" |
| + | "#{field}#{operator != :== ? '.' : ' '}#{operator} #{value}" |
| end | |
| protected | |
| @@ | @@ -92,7 +92,7 @@ module Locomotive::Steam |
| if target.size == 0 | |
| source.size == 0 | |
| else | |
| - | source & target == target |
| + | (source & target).size != 0 |
| end | |
| end | |
spec/unit/adapters/memory/condition_spec.rb
+9
-1
| @@ | @@ -90,7 +90,15 @@ describe Locomotive::Steam::Adapters::Memory::Condition do |
| describe '#array_contains?' do | |
| let(:source) { [1, 2, 3, 4] } | |
| let(:target) { [1, 2, 3] } | |
| - | context 'with target contains in source' do |
| + | context 'target contains the source' do |
| + | specify('should be true') do |
| + | expect(subject.send(:array_contains?, source, target)).to eq true |
| + | end |
| + | end |
| + | |
| + | context 'target contains at least one element' do |
| + | let(:source) { [1] } |
| + | let(:target) { [1, 2, 3] } |
| specify('should be true') do | |
| expect(subject.send(:array_contains?, source, target)).to eq true | |
| end | |