mirror of
https://github.com/discourse/discourse.git
synced 2024-12-18 20:35:58 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
44 lines
1.1 KiB
Ruby
44 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe Jobs::CreateRecentPostSearchIndexes do
|
|
subject { described_class.new }
|
|
|
|
fab!(:post) do
|
|
SearchIndexer.enable
|
|
Fabricate(:post)
|
|
end
|
|
|
|
fab!(:post_2) do
|
|
SearchIndexer.enable
|
|
Fabricate(:post)
|
|
end
|
|
|
|
before do
|
|
SearchIndexer.enable
|
|
end
|
|
|
|
describe '#execute' do
|
|
it 'should not create the index if requried posts size has not been reached' do
|
|
SiteSetting.search_recent_posts_size = 1
|
|
SiteSetting.search_enable_recent_regular_posts_offset_size = 3
|
|
|
|
expect do
|
|
subject.execute({})
|
|
end.to_not change { SiteSetting.search_recent_regular_posts_offset_post_id }
|
|
end
|
|
|
|
it 'should create the right index' do
|
|
SiteSetting.search_recent_posts_size = 1
|
|
SiteSetting.search_enable_recent_regular_posts_offset_size = 1
|
|
|
|
subject.execute({})
|
|
|
|
expect(SiteSetting.search_recent_regular_posts_offset_post_id).to eq(post_2.id)
|
|
|
|
expect(DB.query_single(<<~SQL).first).to eq(1)
|
|
SELECT 1 FROM pg_indexes WHERE indexname = '#{described_class::REGULAR_POST_SEARCH_DATA_INDEX_NAME}'
|
|
SQL
|
|
end
|
|
end
|
|
end
|