2010-03-18 18:29:41 -04:00
|
|
|
ENV["RAILS_ENV"] = "test"
|
2010-08-18 18:42:33 -04:00
|
|
|
|
2013-06-05 18:37:33 -04:00
|
|
|
if ENV["SIMPLECOV"]
|
|
|
|
require 'simplecov'
|
|
|
|
SimpleCov.start 'rails' do
|
2017-02-04 22:28:33 -05:00
|
|
|
add_group "Libraries", ["app/logical", "lib"]
|
|
|
|
add_group "Presenters", "app/presenters"
|
2013-06-05 18:37:33 -04:00
|
|
|
end
|
|
|
|
end
|
2010-12-05 22:27:45 -05:00
|
|
|
|
2010-08-18 18:42:33 -04:00
|
|
|
require File.expand_path('../../config/environment', __FILE__)
|
2010-02-04 15:08:49 -05:00
|
|
|
require 'rails/test_help'
|
2015-05-28 16:32:36 -04:00
|
|
|
require 'cache'
|
2017-06-29 19:05:01 -04:00
|
|
|
require 'webmock/minitest'
|
2010-02-04 15:08:49 -05:00
|
|
|
|
2010-02-06 16:48:40 -05:00
|
|
|
Dir[File.expand_path(File.dirname(__FILE__) + "/factories/*.rb")].each {|file| require file}
|
2017-06-21 12:02:33 -04:00
|
|
|
Dir[File.expand_path(File.dirname(__FILE__) + "/helpers/*.rb")].each {|file| require file}
|
2010-02-04 15:08:49 -05:00
|
|
|
|
2017-02-04 22:27:59 -05:00
|
|
|
Shoulda::Matchers.configure do |config|
|
|
|
|
config.integrate do |with|
|
|
|
|
with.library :rails
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-13 20:21:05 -05:00
|
|
|
class ActiveSupport::TestCase
|
|
|
|
include PostArchiveTestHelper
|
2017-06-21 12:02:33 -04:00
|
|
|
include ReportbooruHelper
|
|
|
|
include DownloadTestHelper
|
|
|
|
|
|
|
|
setup do
|
|
|
|
mock_popular_search_service!
|
|
|
|
mock_missed_search_service!
|
2017-07-01 12:49:08 -04:00
|
|
|
WebMock.allow_net_connect!
|
2017-06-21 12:02:33 -04:00
|
|
|
end
|
2017-04-15 22:51:56 -04:00
|
|
|
|
|
|
|
teardown do
|
|
|
|
Cache.clear
|
|
|
|
end
|
2017-01-13 20:21:05 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
class ActionController::TestCase
|
|
|
|
include PostArchiveTestHelper
|
|
|
|
|
|
|
|
def assert_authentication_passes(action, http_method, role, params, session)
|
|
|
|
__send__(http_method, action, params, session.merge(:user_id => @users[role].id))
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
def assert_authentication_fails(action, http_method, role)
|
|
|
|
__send__(http_method, action, params, session.merge(:user_id => @users[role].id))
|
|
|
|
assert_redirected_to(new_sessions_path)
|
|
|
|
end
|
2017-04-15 22:51:56 -04:00
|
|
|
|
2017-11-20 19:29:59 -05:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
User.any_instance.stubs(:validate_sock_puppets).returns(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
super
|
2017-04-15 22:51:56 -04:00
|
|
|
Cache.clear
|
|
|
|
end
|
2017-01-13 20:21:05 -05:00
|
|
|
end
|
|
|
|
|
2017-02-03 18:24:10 -05:00
|
|
|
Delayed::Worker.delay_jobs = false
|
2017-06-14 21:02:32 -04:00
|
|
|
TestAfterCommit.enabled = false
|
2017-12-21 12:56:12 -05:00
|
|
|
|
|
|
|
Rails.application.load_seed
|