mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 09:51:24 +00:00
Fix search operators sometimes getting lost (#35190)
This commit is contained in:
parent
a9f2ec45da
commit
2e0a00ab46
|
@ -35,7 +35,7 @@ class SearchQueryTransformer < Parslet::Transform
|
||||||
private
|
private
|
||||||
|
|
||||||
def clauses_by_operator
|
def clauses_by_operator
|
||||||
@clauses_by_operator ||= @clauses.compact.chunk(&:operator).to_h
|
@clauses_by_operator ||= @clauses.compact.group_by(&:operator)
|
||||||
end
|
end
|
||||||
|
|
||||||
def flags_from_clauses!
|
def flags_from_clauses!
|
||||||
|
|
|
@ -129,4 +129,24 @@ RSpec.describe SearchQueryTransformer do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with multiple prefix clauses before a search term' do
|
||||||
|
let(:query) { 'from:me has:media foo' }
|
||||||
|
|
||||||
|
it 'transforms clauses' do
|
||||||
|
expect(subject.send(:must_clauses).map(&:term)).to contain_exactly('foo')
|
||||||
|
expect(subject.send(:must_not_clauses)).to be_empty
|
||||||
|
expect(subject.send(:filter_clauses).map(&:prefix)).to contain_exactly('from', 'has')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a search term between two prefix clauses' do
|
||||||
|
let(:query) { 'from:me foo has:media' }
|
||||||
|
|
||||||
|
it 'transforms clauses' do
|
||||||
|
expect(subject.send(:must_clauses).map(&:term)).to contain_exactly('foo')
|
||||||
|
expect(subject.send(:must_not_clauses)).to be_empty
|
||||||
|
expect(subject.send(:filter_clauses).map(&:prefix)).to contain_exactly('from', 'has')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user