OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Do not cache HTTPX session object in tests.
Pavel Balashoudf36334e8baa
diff --git a/lib/open_project.rb b/lib/open_project.rbindex 9fd814bacee..4f1119991de 100644--- a/lib/open_project.rb+++ b/lib/open_project.rb@@ -47,23 +47,32 @@ module OpenProjectenddef self.httpx- Thread.current[:httpx_session] ||= begin- session = HTTPX- .plugin(:oauth)- .plugin(:persistent)- .plugin(:basic_auth)- .plugin(:webdav)- .with(- timeout: {- connect_timeout: OpenProject::Configuration.httpx_connect_timeout,- operation_timeout: OpenProject::Configuration.httpx_operation_timeout,- request_timeout: OpenProject::Configuration.httpx_request_timeout,- write_timeout: OpenProject::Configuration.httpx_write_timeout,- read_timeout: OpenProject::Configuration.httpx_read_timeout,- keep_alive_timeout: OpenProject::Configuration.httpx_keep_alive_timeout- }- )- OpenProject::Appsignal.enabled? ? session.plugin(HttpxAppsignal) : session+ # In tests it is not advisible to cache httpx session object,+ # because, for example, stubs made for this object in one test case can+ # easy interfere with other test cases using the same session object.+ if Rails.env.test?+ httpx_session+ else+ Thread.current[:httpx_session] ||= httpx_sessionendend++ private_class_method def self.httpx_session+ session = HTTPX+ .plugin(:oauth)+ .plugin(:persistent)+ .plugin(:basic_auth)+ .plugin(:webdav)+ .with(+ timeout: {+ connect_timeout: OpenProject::Configuration.httpx_connect_timeout,+ operation_timeout: OpenProject::Configuration.httpx_operation_timeout,+ request_timeout: OpenProject::Configuration.httpx_request_timeout,+ write_timeout: OpenProject::Configuration.httpx_write_timeout,+ read_timeout: OpenProject::Configuration.httpx_read_timeout,+ keep_alive_timeout: OpenProject::Configuration.httpx_keep_alive_timeout+ }+ )+ OpenProject::Appsignal.enabled? ? session.plugin(HttpxAppsignal) : session+ endend