blob: 8c038b93fbc8009b0153c66d9ba69eeb6372acc9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# frozen_string_literal: true
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
require 'rails/test_help'
require 'vcr'
require 'webmock/minitest'
ActiveRecord::Base.logger.level = 0
WebMock.disable_net_connect!(allow_localhost: true)
VCR.configure do |c|
c.ignore_localhost = true
c.ignore_hosts 'elasticsearch'
c.cassette_library_dir = "#{::Rails.root}/test/fixtures/cassettes"
c.hook_into :webmock # or :fakeweb
end
class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
include FactoryBot::Syntax::Methods
fixtures :filters
def self.prepare
[Post, Tag, Comment, Gallery, Filter, ForumPost, Report].each do |m|
m.index_name "test_#{m.model_name.plural}"
m.__elasticsearch__.tap do |es|
es.create_index!(force: true)
es.import
es.refresh_index!
end
end
end
def refresh_index(model)
model.__elasticsearch__.refresh_index!
end
def setup_test_users
@user = create(:user)
@dupe_assistant = create(:dupe_assistant)
@image_assistant = create(:image_assistant)
@comment_assistant = create(:comment_assistant)
@tag_assistant = create(:tag_assistant)
@admin = create(:admin)
@moderator = create(:moderator)
end
end
class ActionController::TestCase
include Devise::Test::ControllerHelpers
end
ActiveSupport::TestCase.prepare
|