mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-24 03:43:42 +01:00
Configure elastic search integration with rspec tag (#27882)
This commit is contained in:
parent
297839c10c
commit
e892efbc40
4 changed files with 14 additions and 17 deletions
4
.github/workflows/test-ruby.yml
vendored
4
.github/workflows/test-ruby.yml
vendored
|
@ -227,7 +227,7 @@ jobs:
|
|||
path: tmp/screenshots/
|
||||
|
||||
test-search:
|
||||
name: Testing search
|
||||
name: Elastic Search integration testing
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs:
|
||||
|
@ -314,7 +314,7 @@ jobs:
|
|||
- name: Load database schema
|
||||
run: './bin/rails db:create db:schema:load db:seed'
|
||||
|
||||
- run: bundle exec rake spec:search
|
||||
- run: bin/rspec --tag search
|
||||
|
||||
- name: Archive logs
|
||||
uses: actions/upload-artifact@v3
|
||||
|
|
|
@ -9,13 +9,3 @@ if Rake::Task.task_defined?('spec:system')
|
|||
|
||||
Rake::Task['spec:system'].enhance ['spec:enable_system_specs']
|
||||
end
|
||||
|
||||
if Rake::Task.task_defined?('spec:search')
|
||||
namespace :spec do
|
||||
task :enable_search_specs do # rubocop:disable Rails/RakeEnvironment
|
||||
ENV['RUN_SEARCH_SPECS'] = 'true'
|
||||
end
|
||||
end
|
||||
|
||||
Rake::Task['spec:search'].enhance ['spec:enable_search_specs']
|
||||
end
|
||||
|
|
|
@ -4,7 +4,6 @@ ENV['RAILS_ENV'] ||= 'test'
|
|||
|
||||
# This needs to be defined before Rails is initialized
|
||||
RUN_SYSTEM_SPECS = ENV.fetch('RUN_SYSTEM_SPECS', false)
|
||||
RUN_SEARCH_SPECS = ENV.fetch('RUN_SEARCH_SPECS', false)
|
||||
|
||||
if RUN_SYSTEM_SPECS
|
||||
STREAMING_PORT = ENV.fetch('TEST_STREAMING_PORT', '4020')
|
||||
|
@ -55,20 +54,28 @@ RSpec.configure do |config|
|
|||
case type
|
||||
when :system
|
||||
!RUN_SYSTEM_SPECS
|
||||
when :search
|
||||
!RUN_SEARCH_SPECS
|
||||
end
|
||||
}
|
||||
|
||||
# By default, skip the elastic search integration specs
|
||||
config.filter_run_excluding search: true
|
||||
|
||||
config.fixture_path = Rails.root.join('spec', 'fixtures')
|
||||
config.use_transactional_fixtures = true
|
||||
config.order = 'random'
|
||||
config.infer_spec_type_from_file_location!
|
||||
config.filter_rails_from_backtrace!
|
||||
|
||||
# Set type to `cli` for all CLI specs
|
||||
config.define_derived_metadata(file_path: Regexp.new('spec/lib/mastodon/cli')) do |metadata|
|
||||
metadata[:type] = :cli
|
||||
end
|
||||
|
||||
# Set `search` metadata true for all specs in spec/search/
|
||||
config.define_derived_metadata(file_path: Regexp.new('spec/search/*')) do |metadata|
|
||||
metadata[:search] = true
|
||||
end
|
||||
|
||||
config.include Devise::Test::ControllerHelpers, type: :controller
|
||||
config.include Devise::Test::ControllerHelpers, type: :helper
|
||||
config.include Devise::Test::ControllerHelpers, type: :view
|
||||
|
|
|
@ -60,7 +60,7 @@ RSpec.configure do |config|
|
|||
end
|
||||
end
|
||||
|
||||
config.around :each, type: :search do |example|
|
||||
config.around :each, :search do |example|
|
||||
search_data_manager.populate_indexes
|
||||
example.run
|
||||
search_data_manager.remove_indexes
|
||||
|
@ -73,6 +73,6 @@ RSpec.configure do |config|
|
|||
end
|
||||
|
||||
def search_examples_present?
|
||||
RUN_SEARCH_SPECS
|
||||
RSpec.world.filtered_examples.values.flatten.any? { |example| example.metadata[:search] == true }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue