Merge remote-tracking branch 'parent/main' into kb_migration

This commit is contained in:
KMY 2023-09-06 10:09:07 +09:00
commit fdf1d6df38
41 changed files with 752 additions and 569 deletions

View file

@ -3,17 +3,18 @@
require 'rails_helper'
describe SearchQueryTransformer do
subject { described_class.new.apply(parser, current_account: nil) }
subject { described_class.new.apply(parser, current_account: account) }
let(:account) { Fabricate(:account) }
let(:parser) { SearchQueryParser.new.parse(query) }
context 'with "hello world"' do
let(:query) { 'hello world' }
it 'transforms clauses' do
expect(subject.must_clauses.map(&:term)).to match_array %w(hello world)
expect(subject.must_not_clauses).to be_empty
expect(subject.filter_clauses).to be_empty
expect(subject.send(:must_clauses).map(&:term)).to match_array %w(hello world)
expect(subject.send(:must_not_clauses)).to be_empty
expect(subject.send(:filter_clauses)).to be_empty
end
end
@ -21,9 +22,9 @@ describe SearchQueryTransformer do
let(:query) { 'hello -world' }
it 'transforms clauses' do
expect(subject.must_clauses.map(&:term)).to match_array %w(hello)
expect(subject.must_not_clauses.map(&:term)).to match_array %w(world)
expect(subject.filter_clauses).to be_empty
expect(subject.send(:must_clauses).map(&:term)).to match_array %w(hello)
expect(subject.send(:must_not_clauses).map(&:term)).to match_array %w(world)
expect(subject.send(:filter_clauses)).to be_empty
end
end
@ -31,9 +32,9 @@ describe SearchQueryTransformer do
let(:query) { 'hello is:reply' }
it 'transforms clauses' do
expect(subject.must_clauses.map(&:term)).to match_array %w(hello)
expect(subject.must_not_clauses).to be_empty
expect(subject.filter_clauses.map(&:term)).to match_array %w(reply)
expect(subject.send(:must_clauses).map(&:term)).to match_array %w(hello)
expect(subject.send(:must_not_clauses)).to be_empty
expect(subject.send(:filter_clauses).map(&:term)).to match_array %w(reply)
end
end
@ -41,9 +42,9 @@ describe SearchQueryTransformer do
let(:query) { 'foo: bar' }
it 'transforms clauses' do
expect(subject.must_clauses.map(&:term)).to match_array %w(foo bar)
expect(subject.must_not_clauses).to be_empty
expect(subject.filter_clauses).to be_empty
expect(subject.send(:must_clauses).map(&:term)).to match_array %w(foo bar)
expect(subject.send(:must_not_clauses)).to be_empty
expect(subject.send(:filter_clauses)).to be_empty
end
end
@ -51,9 +52,9 @@ describe SearchQueryTransformer do
let(:query) { 'foo:bar' }
it 'transforms clauses' do
expect(subject.must_clauses.map(&:term)).to contain_exactly('foo bar')
expect(subject.must_not_clauses).to be_empty
expect(subject.filter_clauses).to be_empty
expect(subject.send(:must_clauses).map(&:term)).to contain_exactly('foo bar')
expect(subject.send(:must_not_clauses)).to be_empty
expect(subject.send(:filter_clauses)).to be_empty
end
end
end