diff --git a/Gemfile b/Gemfile index c21743f9e24bcdd238bff22de5e186a0ddd58136..dcf116451701d652017b6124f55fd2d3deab976c 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ gem 'bundler-checksum', '~> 0.1.0', path: 'vendor/gems/bundler-checksum', requir # NOTE: When incrementing the major or minor version here, also increment activerecord_version # in vendor/gems/attr_encrypted/attr_encrypted.gemspec until we resolve # https://gitlab.com/gitlab-org/gitlab/-/issues/375713 -gem 'rails', '~> 6.1.7.2' +gem 'rails', '~> 7.0.4.3' gem 'bootsnap', '~> 1.16.0', require: false diff --git a/Gemfile.checksum b/Gemfile.checksum index 84f65c2f34825d27d928f00c54ee3db4467149b1..f5c0bcc07e33f59113e2ace7c1fb980dc7b7c081 100644 --- a/Gemfile.checksum +++ b/Gemfile.checksum @@ -2,18 +2,18 @@ {"name":"CFPropertyList","version":"3.0.5","platform":"ruby","checksum":"a78551cd4768d78ebca98488c27e33652ef818be64697a54676d34e6434674a4"}, {"name":"RedCloth","version":"4.3.2","platform":"ruby","checksum":"1ee7bc55c8dcec92cf7741a2132a9a6cd19e4b884fbc1b3aca23e1a4fcd92d55"}, {"name":"acme-client","version":"2.0.11","platform":"ruby","checksum":"edf6da9f3c5dbe3ab0c6738eb3b97978b7a60e3500445480d2a72fcc610089de"}, -{"name":"actioncable","version":"6.1.7.2","platform":"ruby","checksum":"7af0fda230fba5a8c8d28afff02b6e56e7871269b5799f2bc1c4f5a4f29134f9"}, -{"name":"actionmailbox","version":"6.1.7.2","platform":"ruby","checksum":"76bbf2b0561244dd6fe85c6c31d30edf574b0a976a6c492d48bbeb91b266ea2f"}, -{"name":"actionmailer","version":"6.1.7.2","platform":"ruby","checksum":"444281dcbceb946cf26e42016601de389995c53bcec21597ae8ad0a2c26d4de6"}, -{"name":"actionpack","version":"6.1.7.2","platform":"ruby","checksum":"ea471bc6dbfc793fc3632623807439f58424565f705f747aa6c85875b1365e30"}, -{"name":"actiontext","version":"6.1.7.2","platform":"ruby","checksum":"d237909c98bfc529c8db2895f5e74add2f3cb8e4040e09fad964c46052e4a8cb"}, -{"name":"actionview","version":"6.1.7.2","platform":"ruby","checksum":"ea03ef64da97b295ee498b95a1183ab738ec422a6e7deaf1dbd05502d17ce581"}, -{"name":"activejob","version":"6.1.7.2","platform":"ruby","checksum":"bfa6eef35d855ddfa1686ea46f13e9db384a7d0cb04557ba51a274e2b9a49146"}, -{"name":"activemodel","version":"6.1.7.2","platform":"ruby","checksum":"1217e806dc3c2b48ccf69cdf8a5ec8e6e2af56390faf102cb75e43278e3fc15a"}, -{"name":"activerecord","version":"6.1.7.2","platform":"ruby","checksum":"07f2f05fdd97cdd6fc520a261cb3c921ce5071db7aa32e81e8922c0ad6a8c9cc"}, +{"name":"actioncable","version":"7.0.4.3","platform":"ruby","checksum":"aa70062c2f2c55cc64fc6aa233223c37c7bc7f1cdbc1a5200cfa2ae4a18934f8"}, +{"name":"actionmailbox","version":"7.0.4.3","platform":"ruby","checksum":"bca54fd1779f9851a6391d4ecc0bc7cb1c3b5249ba93b38755f5b34856061438"}, +{"name":"actionmailer","version":"7.0.4.3","platform":"ruby","checksum":"7e4c382c589997a25253c61d1e5978cb81dbf1978ad35a557580167f7a504f84"}, +{"name":"actionpack","version":"7.0.4.3","platform":"ruby","checksum":"adf30cb429332085b25509ec17541d9108468cb3246eae8f4e0bb0e9268660b1"}, +{"name":"actiontext","version":"7.0.4.3","platform":"ruby","checksum":"8f21e30c0eec9ce9c9277388efd836b53a3955e4756efd226e4b8c644960065f"}, +{"name":"actionview","version":"7.0.4.3","platform":"ruby","checksum":"df24eeab4db187c791218039e1c3ccbf84e765b7887fdb08628bb98ff51120c1"}, +{"name":"activejob","version":"7.0.4.3","platform":"ruby","checksum":"7c74f0fb4e7a8abfbc91a9375c4da4d988c08918c78d5e2d77b44f8aa4e3aa23"}, +{"name":"activemodel","version":"7.0.4.3","platform":"ruby","checksum":"3b511cfc2f37fca76eb25ba191d302f6dd5afd12ef80fb897b1f99d55ed7b07a"}, +{"name":"activerecord","version":"7.0.4.3","platform":"ruby","checksum":"bb91f8c1ce5de7008d6190a50d899e9117b0b638df44b298246be92f224a8b07"}, {"name":"activerecord-explain-analyze","version":"0.1.0","platform":"ruby","checksum":"5debb11fe23f35b91953a80677d80ba9284ee737fd9d148c1d7603ce45217f7b"}, -{"name":"activestorage","version":"6.1.7.2","platform":"ruby","checksum":"c3a27b42e7b40a1733b26ca86d83836575ed1437896a581e63d37d1500db6c30"}, -{"name":"activesupport","version":"6.1.7.2","platform":"ruby","checksum":"22eb2a7bb30ff7495de3920955839e62ca1de347185ffb15f70a0773a6c0f292"}, +{"name":"activestorage","version":"7.0.4.3","platform":"ruby","checksum":"9930c676ffc4d193a44efe696346e7b3eb344ff4d898878d9ed7ccde6757f8ca"}, +{"name":"activesupport","version":"7.0.4.3","platform":"ruby","checksum":"571ed0fac8510f1fc8a1d66aa070d07ea269913bf9ef50960a8044536358a096"}, {"name":"acts-as-taggable-on","version":"9.0.0","platform":"ruby","checksum":"5a409be0eae125b7b02c1a7316264b40d4a583584a13d4ea4a6d82acdb351b86"}, {"name":"addressable","version":"2.8.1","platform":"ruby","checksum":"bc724a176ef02118c8a3ed6b5c04c39cf59209607ffcce77b91d0261dbadedfa"}, {"name":"aes_key_wrap","version":"1.1.0","platform":"ruby","checksum":"b935f4756b37375895db45669e79dfcdc0f7901e12d4e08974d5540c8e0776a5"}, @@ -50,8 +50,8 @@ {"name":"backport","version":"1.2.0","platform":"ruby","checksum":"912c7dfdd9ee4625d013ddfccb6205c3f92da69a8990f65c440e40f5b2fc7f75"}, {"name":"base32","version":"0.3.2","platform":"ruby","checksum":"532e9b19c5dd1fce281df67fc93a803ebd5d26426a93f6dda6612769bc46fe2c"}, {"name":"batch-loader","version":"2.0.1","platform":"ruby","checksum":"93f711df78d316ee0440a7a45daba4f5418d0ee2b5f58f60c9ea038424e7a89d"}, -{"name":"bcrypt","version":"3.1.16","platform":"java","checksum":"2925a1546fa8e85bdb1b10f1fc95c4e1ea15992ada16adea4af82b0978ed662c"}, -{"name":"bcrypt","version":"3.1.16","platform":"ruby","checksum":"0b8bf031ba81aa76c0f10c5a8dac779b6035d84b09af1dbb2b1a32a7e360210b"}, +{"name":"bcrypt","version":"3.1.18","platform":"java","checksum":"5464e06c00cb6bd3ff982feef4cb7f1efc9b302753cbaf12e73512d8f401f2d2"}, +{"name":"bcrypt","version":"3.1.18","platform":"ruby","checksum":"154de0b0b089e56d5980c5037ad85fc9554cfbf4996538673c1ddbc9b61b1f11"}, {"name":"benchmark","version":"0.2.0","platform":"ruby","checksum":"5f7087b794613abdd3ac9c13f4351f65b164bcb15ced2ad29508e365f9b28c77"}, {"name":"benchmark-ips","version":"2.11.0","platform":"ruby","checksum":"1eaa89841073895af0ee7ff72eb069e5c7dda01c6d6a8b3e79e363bace596dec"}, {"name":"benchmark-malloc","version":"0.2.0","platform":"ruby","checksum":"37c68f0435261634026f584d79956a35325a3027e3e6b4cc8d7575aa10537e6b"}, @@ -476,14 +476,14 @@ {"name":"rack-oauth2","version":"1.21.3","platform":"ruby","checksum":"4e72a79dd6a866692e84422a552b27c38a5a1918ded06661e04910f2bbe676ba"}, {"name":"rack-protection","version":"2.2.2","platform":"ruby","checksum":"fd41414dbabbec274af0bdb1f72a48504449de4d979782c9af38cbb5dfff3299"}, {"name":"rack-proxy","version":"0.7.6","platform":"ruby","checksum":"8704c5009bb60eb16dacf4bcc5e067a8484e668321e8443534bb58ded320c2a8"}, -{"name":"rack-test","version":"2.0.2","platform":"ruby","checksum":"adadd0e957f63a34199a9fdf905a920a0b0a50795735095b4ac4bd3c13385466"}, +{"name":"rack-test","version":"2.1.0","platform":"ruby","checksum":"0c61fc61904049d691922ea4bb99e28004ed3f43aa5cfd495024cc345f125dfb"}, {"name":"rack-timeout","version":"0.6.3","platform":"ruby","checksum":"1754892eacc124d405e7f1145731ec9b7421ebd1bee5d51ddc18b72c204d0ab3"}, -{"name":"rails","version":"6.1.7.2","platform":"ruby","checksum":"d50796f4106fe1793e048e80e11bc9aee4af1674c94a24ebe7f7b411217befac"}, +{"name":"rails","version":"7.0.4.3","platform":"ruby","checksum":"5b675b237abb7328020002d06cc6c9003a09cde4b4774f989bfa440c6e93e2ed"}, {"name":"rails-controller-testing","version":"1.0.5","platform":"ruby","checksum":"741448db59366073e86fc965ba403f881c636b79a2c39a48d0486f2607182e94"}, {"name":"rails-dom-testing","version":"2.0.3","platform":"ruby","checksum":"b140c4f39f6e609c8113137b9a60dfc2ecb89864e496f87f23a68b3b8f12d8d1"}, {"name":"rails-html-sanitizer","version":"1.5.0","platform":"ruby","checksum":"bf326075e8a968cd882c30b15a4c9100059be3af2356093dc68324ec3bd9ea79"}, {"name":"rails-i18n","version":"7.0.3","platform":"ruby","checksum":"e3158e98c5332d129fd5131f171ac575eb30dbb8919b21595382b08850cf2bd3"}, -{"name":"railties","version":"6.1.7.2","platform":"ruby","checksum":"5390d8aade88fb7452de6798c2385b21cff74219e49989b6b1b484e387b3a356"}, +{"name":"railties","version":"7.0.4.3","platform":"ruby","checksum":"98cb3dd00bedf8857810c806933cf28ff0f3a94304f2be25b4ae4ea0c38ad770"}, {"name":"rainbow","version":"3.1.1","platform":"ruby","checksum":"039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a"}, {"name":"rake","version":"13.0.6","platform":"ruby","checksum":"5ce4bf5037b4196c24ac62834d8db1ce175470391026bd9e557d669beeb19097"}, {"name":"rb-fsevent","version":"0.11.2","platform":"ruby","checksum":"43900b972e7301d6570f64b850a5aa67833ee7d87b458ee92805d56b7318aefe"}, @@ -507,7 +507,7 @@ {"name":"regexp_property_values","version":"1.0.0","platform":"ruby","checksum":"162499dc0bba1e66d334273a059f207a61981cc8cc69d2ca743594e7886d080f"}, {"name":"representable","version":"3.2.0","platform":"ruby","checksum":"cc29bf7eebc31653586849371a43ffe36c60b54b0a6365b5f7d95ec34d1ebace"}, {"name":"request_store","version":"1.5.1","platform":"ruby","checksum":"07a204d161590789f2b1d27f9f0eadcdecd6d868cb2f03240250e1bc747df78e"}, -{"name":"responders","version":"3.0.0","platform":"ruby","checksum":"a267b281582802d04cf0968dbc7d60df0d48384915934b3bf9018f811dc3f7dc"}, +{"name":"responders","version":"3.0.1","platform":"ruby","checksum":"613fe28e498987f4feaa3230aa6313ca4bd5f0563a3da83511b0dd6cd8f47292"}, {"name":"rest-client","version":"2.1.0","platform":"ruby","checksum":"35a6400bdb14fae28596618e312776c158f7ebbb0ccad752ff4fa142bf2747e3"}, {"name":"rest-client","version":"2.1.0","platform":"x64-mingw32","checksum":"7cd156496196d90b7d8f5b8de521ef67d8a9e03f06862da80b9b5912ab05a470"}, {"name":"rest-client","version":"2.1.0","platform":"x86-mingw32","checksum":"fb543caf36cb555c05c6186aeb1273c6a1b059896e4cfd394e7269b20c40ca01"}, @@ -694,5 +694,5 @@ {"name":"xpath","version":"3.2.0","platform":"ruby","checksum":"6dfda79d91bb3b949b947ecc5919f042ef2f399b904013eb3ef6d20dd3a4082e"}, {"name":"yajl-ruby","version":"1.4.3","platform":"ruby","checksum":"8c974d9c11ae07b0a3b6d26efea8407269b02e4138118fbe3ef0d2ec9724d1d2"}, {"name":"yard","version":"0.9.26","platform":"ruby","checksum":"30594aa05cf737aa725c73444c7be3d54a443d0e258e1503da4eb1a0822cf963"}, -{"name":"zeitwerk","version":"2.6.6","platform":"ruby","checksum":"bb397b50c31127f8dab372fa9b21da1e7c453c5b57da172ed858136c6283f826"} +{"name":"zeitwerk","version":"2.6.7","platform":"ruby","checksum":"61767a6158480df290d0d2a3fd860d8ba3a28ba113837668ee94b657716a1409"} ] diff --git a/Gemfile.lock b/Gemfile.lock index ccda09fd2c74fcfdf157af60a43df5253d84b700..a4395d5ff24b72c6576c9feb7a9087cfe7b03c03 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,68 +105,74 @@ GEM acme-client (2.0.11) faraday (>= 1.0, < 3.0.0) faraday-retry (~> 1.0) - actioncable (6.1.7.2) - actionpack (= 6.1.7.2) - activesupport (= 6.1.7.2) + actioncable (7.0.4.3) + actionpack (= 7.0.4.3) + activesupport (= 7.0.4.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.2) - actionpack (= 6.1.7.2) - activejob (= 6.1.7.2) - activerecord (= 6.1.7.2) - activestorage (= 6.1.7.2) - activesupport (= 6.1.7.2) + actionmailbox (7.0.4.3) + actionpack (= 7.0.4.3) + activejob (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) mail (>= 2.7.1) - actionmailer (6.1.7.2) - actionpack (= 6.1.7.2) - actionview (= 6.1.7.2) - activejob (= 6.1.7.2) - activesupport (= 6.1.7.2) + net-imap + net-pop + net-smtp + actionmailer (7.0.4.3) + actionpack (= 7.0.4.3) + actionview (= 7.0.4.3) + activejob (= 7.0.4.3) + activesupport (= 7.0.4.3) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.7.2) - actionview (= 6.1.7.2) - activesupport (= 6.1.7.2) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.4.3) + actionview (= 7.0.4.3) + activesupport (= 7.0.4.3) + rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.2) - actionpack (= 6.1.7.2) - activerecord (= 6.1.7.2) - activestorage (= 6.1.7.2) - activesupport (= 6.1.7.2) + actiontext (7.0.4.3) + actionpack (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.2) - activesupport (= 6.1.7.2) + actionview (7.0.4.3) + activesupport (= 7.0.4.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.2) - activesupport (= 6.1.7.2) + activejob (7.0.4.3) + activesupport (= 7.0.4.3) globalid (>= 0.3.6) - activemodel (6.1.7.2) - activesupport (= 6.1.7.2) - activerecord (6.1.7.2) - activemodel (= 6.1.7.2) - activesupport (= 6.1.7.2) + activemodel (7.0.4.3) + activesupport (= 7.0.4.3) + activerecord (7.0.4.3) + activemodel (= 7.0.4.3) + activesupport (= 7.0.4.3) activerecord-explain-analyze (0.1.0) activerecord (>= 4) pg - activestorage (6.1.7.2) - actionpack (= 6.1.7.2) - activejob (= 6.1.7.2) - activerecord (= 6.1.7.2) - activesupport (= 6.1.7.2) + activestorage (7.0.4.3) + actionpack (= 7.0.4.3) + activejob (= 7.0.4.3) + activerecord (= 7.0.4.3) + activesupport (= 7.0.4.3) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.2) + activesupport (7.0.4.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) acts-as-taggable-on (9.0.0) activerecord (>= 6.0, < 7.1) addressable (2.8.1) @@ -246,7 +252,7 @@ GEM backport (1.2.0) base32 (0.3.2) batch-loader (2.0.1) - bcrypt (3.1.16) + bcrypt (3.1.18) benchmark (0.2.0) benchmark-ips (2.11.0) benchmark-malloc (0.2.0) @@ -1197,24 +1203,23 @@ GEM rack rack-proxy (0.7.6) rack - rack-test (2.0.2) + rack-test (2.1.0) rack (>= 1.3) rack-timeout (0.6.3) - rails (6.1.7.2) - actioncable (= 6.1.7.2) - actionmailbox (= 6.1.7.2) - actionmailer (= 6.1.7.2) - actionpack (= 6.1.7.2) - actiontext (= 6.1.7.2) - actionview (= 6.1.7.2) - activejob (= 6.1.7.2) - activemodel (= 6.1.7.2) - activerecord (= 6.1.7.2) - activestorage (= 6.1.7.2) - activesupport (= 6.1.7.2) + rails (7.0.4.3) + actioncable (= 7.0.4.3) + actionmailbox (= 7.0.4.3) + actionmailer (= 7.0.4.3) + actionpack (= 7.0.4.3) + actiontext (= 7.0.4.3) + actionview (= 7.0.4.3) + activejob (= 7.0.4.3) + activemodel (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) bundler (>= 1.15.0) - railties (= 6.1.7.2) - sprockets-rails (>= 2.0.0) + railties (= 7.0.4.3) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -1227,12 +1232,13 @@ GEM rails-i18n (7.0.3) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (6.1.7.2) - actionpack (= 6.1.7.2) - activesupport (= 6.1.7.2) + railties (7.0.4.3) + actionpack (= 7.0.4.3) + activesupport (= 7.0.4.3) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.11.2) @@ -1271,7 +1277,7 @@ GEM uber (< 0.2.0) request_store (1.5.1) rack (>= 1.4) - responders (3.0.0) + responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) rest-client (2.1.0) @@ -1660,7 +1666,7 @@ GEM nokogiri (~> 1.8) yajl-ruby (1.4.3) yard (0.9.26) - zeitwerk (2.6.6) + zeitwerk (2.6.7) PLATFORMS ruby @@ -1892,7 +1898,7 @@ DEPENDENCIES rack-oauth2 (~> 1.21.3) rack-proxy (~> 0.7.6) rack-timeout (~> 0.6.3) - rails (~> 6.1.7.2) + rails (~> 7.0.4.3) rails-controller-testing rails-i18n (~> 7.0) rainbow (~> 3.0) diff --git a/Rakefile b/Rakefile index 9a651fda7a0d53dea39f9268c951bf4928dbeae1..4db94c501300683943dca8936a2beff2ee6081ac 100755 --- a/Rakefile +++ b/Rakefile @@ -11,8 +11,6 @@ require File.expand_path('config/application', __dir__) relative_url_conf = File.expand_path('config/initializers/relative_url', __dir__) require relative_url_conf if File.exist?("#{relative_url_conf}.rb") -require File.expand_path('config/initializers/01_active_record_database_tasks_configuration_flag.rb', __dir__) - Gitlab::Application.load_tasks Knapsack.load_tasks if defined?(Knapsack) diff --git a/app/controllers/import/base_controller.rb b/app/controllers/import/base_controller.rb index bcb6aed9e38705b7b96904dd76017aac62149b35..f3a0ce64839c2db0a75806e7a8a4d8fe2d772d28 100644 --- a/app/controllers/import/base_controller.rb +++ b/app/controllers/import/base_controller.rb @@ -82,7 +82,7 @@ def already_added_projects # rubocop: disable CodeReuse/ActiveRecord def find_already_added_projects(import_type) - current_user.created_projects.where(import_type: import_type).with_import_state + current_user.created_projects.inc_routes.where(import_type: import_type).with_import_state end # rubocop: enable CodeReuse/ActiveRecord diff --git a/app/models/note.rb b/app/models/note.rb index 09ff7ad3979c2cfcd0ee1d74156f3c3b86cedb49..b7d3efd050fd400e437941ffb8c9d3e4b691d714 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -792,6 +792,14 @@ def check_for_spam?(*) true end + # Use attributes.keys instead of attribute_names to filter out the fields that are skipped during export: + # + # - note_html + # - cached_markdown_version + def attribute_names_for_serialization + attributes.keys + end + private def trigger_note_subscription? diff --git a/config/application.rb b/config/application.rb index 7eeb75a73cd84689b29bc408662316b1a7cb4b03..06153b377f35dca6e8e9d744c4e23dfde161d216 100644 --- a/config/application.rb +++ b/config/application.rb @@ -546,15 +546,15 @@ class Application < Rails::Application app.config.assets.precompile << LOOSE_APP_ASSETS end - # This empty initializer forces the :let_zeitwerk_take_over initializer to run before we load + # This empty initializer forces the :setup_main_autoloader initializer to run before we load # initializers in config/initializers. This is done because autoloading before Zeitwerk takes # over is deprecated but our initializers do a lot of autoloading. # See https://gitlab.com/gitlab-org/gitlab/issues/197346 for more details - initializer :move_initializers, before: :load_config_initializers, after: :let_zeitwerk_take_over do + initializer :move_initializers, before: :load_config_initializers, after: :setup_main_autoloader do end # We need this for initializers that need to be run before Zeitwerk is loaded - initializer :before_zeitwerk, before: :let_zeitwerk_take_over, after: :prepend_helpers_path do + initializer :before_zeitwerk, before: :setup_main_autoloader, after: :prepend_helpers_path do Dir[Rails.root.join('config/initializers_before_autoloader/*.rb')].sort.each do |initializer| load_config_initializer(initializer) end @@ -627,7 +627,7 @@ class Application < Rails::Application # [0]: https://github.com/rails/rails/commit/94d81c3c39e3ddc441c3af3f874e53b197cf3f54 # [1]: https://salsa.debian.org/ruby-team/rails/-/commit/5663e598b41dc4e2058db22e1ee0d678e5c483ba # - ActiveRecord::Base.yaml_column_permitted_classes = config.active_record.yaml_column_permitted_classes + ActiveRecord.yaml_column_permitted_classes = config.active_record.yaml_column_permitted_classes # on_master_start yields immediately in unclustered environments and runs # when the primary process is done initializing otherwise. diff --git a/config/initializers/00_rails_disable_joins.rb b/config/initializers/00_rails_disable_joins.rb deleted file mode 100644 index 4274365ccad9a8bde35659c67d14ba178f9867c8..0000000000000000000000000000000000000000 --- a/config/initializers/00_rails_disable_joins.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -# Backported from Rails 7.0 -# Initial support for has_many :through was implemented in https://github.com/rails/rails/pull/41937 -# Support for has_one :through was implemented in https://github.com/rails/rails/pull/42079 -raise 'DisableJoins patch is only to be used with versions of Rails < 7.0' unless Rails::VERSION::MAJOR < 7 - -ActiveRecord::Associations::Association.prepend(GemExtensions::ActiveRecord::Association) -# Temporarily allow :disable_joins to accept a lambda argument, to control rollout with feature flags -ActiveRecord::Associations::Association.prepend(GemExtensions::ActiveRecord::ConfigurableDisableJoins) -ActiveRecord::Associations::Builder::HasOne.prepend(GemExtensions::ActiveRecord::Associations::Builder::HasOne) -ActiveRecord::Associations::Builder::HasMany.prepend(GemExtensions::ActiveRecord::Associations::Builder::HasMany) -ActiveRecord::Associations::HasOneThroughAssociation.prepend(GemExtensions::ActiveRecord::Associations::HasOneThroughAssociation) -ActiveRecord::Associations::HasManyThroughAssociation.prepend(GemExtensions::ActiveRecord::Associations::HasManyThroughAssociation) -ActiveRecord::Associations::Preloader::ThroughAssociation.prepend(GemExtensions::ActiveRecord::Associations::Preloader::ThroughAssociation) -ActiveRecord::Base.extend(GemExtensions::ActiveRecord::DelegateCache) diff --git a/config/initializers/01_active_record_database_tasks_configuration_flag.rb b/config/initializers/01_active_record_database_tasks_configuration_flag.rb deleted file mode 100644 index 37374a41a30c1ddc1885069d0407c70d9205f7e0..0000000000000000000000000000000000000000 --- a/config/initializers/01_active_record_database_tasks_configuration_flag.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -if Rails::VERSION::MAJOR >= 7 - raise "Remove `#{__FILE__}`. This is backport of `database_tasks:` Rails 7.x feature." -end - -# This backports `database_tasks:` feature to skip running migrations for some databases -# PR: https://github.com/rails/rails/pull/42794/files - -module DatabaseTasks - module ActiveRecordDatabaseConfigurations - def configs_for(env_name: nil, name: nil, include_replicas: false) - configs = super - - unless include_replicas - if name - configs = nil unless configs&.database_tasks? - else - configs = configs.select do |db_config| - db_config.database_tasks? - end - end - end - - configs - end - end - - module ActiveRecordDatabaseConfigurationsHashConfig - def database_tasks? # :nodoc: - !replica? && !!configuration_hash.fetch(:database_tasks, true) - end - end -end - -ActiveRecord::DatabaseConfigurations.prepend(DatabaseTasks::ActiveRecordDatabaseConfigurations) -ActiveRecord::DatabaseConfigurations::HashConfig.prepend(DatabaseTasks::ActiveRecordDatabaseConfigurationsHashConfig) diff --git a/config/initializers/1_active_record_data_types.rb b/config/initializers/1_active_record_data_types.rb index ba4ca8b3b5c2e795af9ff05b073e8cf05f768480..5c0671f2ca3a4f61e0a93815f156ce3e2b40b773 100644 --- a/config/initializers/1_active_record_data_types.rb +++ b/config/initializers/1_active_record_data_types.rb @@ -26,14 +26,16 @@ module RegisterDateTimeWithTimeZone # # When schema dumping, `timestamptz` columns will be output as # `t.datetime_with_timezone`. - def initialize_type_map(mapping = type_map) - super mapping - - register_class_with_precision( - mapping, - 'timestamptz', - ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::DateTimeWithTimeZone - ) + class << self + def initialize_type_map(mapping = type_map) + super mapping + + register_class_with_precision( + mapping, + 'timestamptz', + ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::DateTimeWithTimeZone + ) + end end end diff --git a/config/initializers/action_dispatch_journey_router.rb b/config/initializers/action_dispatch_journey_router.rb new file mode 100644 index 0000000000000000000000000000000000000000..a43fb1a38dfdc27ebef563e704b7a283a9649d7c --- /dev/null +++ b/config/initializers/action_dispatch_journey_router.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +module ActionDispatch + module Journey + class Router + private + + # Besides the patche, this method is a duplicate for the original method defined in Rails: + # https://github.com/rails/rails/blob/v7.0.4.2/actionpack/lib/action_dispatch/journey/router.rb#L109-L132 + # See https://github.com/rails/rails/issues/47244 + def find_routes(req) + path_info = req.path_info + routes = filter_routes(path_info).concat custom_routes.find_all { |r| + r.path.match?(path_info) + } + + if req.head? + routes = match_head_routes(routes, req) + else + routes.select! { |r| r.matches?(req) } + end + + routes.sort_by!(&:precedence) + + routes.map! do |r| + match_data = r.path.match(path_info) + path_parameters = {} + + # This is the patch we are adding. This handles routes where `r.matches?` above is true + # but the route does not actually match due to other constraints + # + # Without this line the following error is raised: + # + # NoMethodError: + # undefined method `names' for nil:NilClass + # + # The behavior is covered by spec/initializers/action_dispatch_journey_router_spec.rb + next if match_data.nil? + + match_data.names.each_with_index do |name, i| + val = match_data[i + 1] + path_parameters[name.to_sym] = Utils.unescape_uri(val) if val + end + [match_data, path_parameters, r] + end.compact! + + routes + end + end + end +end diff --git a/config/initializers/active_record_migrations.rb b/config/initializers/active_record_migrations.rb index 6e5d519e11b33d65580c59b455d744c0ddeee3f8..6465753aa2e8676e54779ecbe8df8c0363b6bfe7 100644 --- a/config/initializers/active_record_migrations.rb +++ b/config/initializers/active_record_migrations.rb @@ -3,3 +3,24 @@ Gitlab::Database::Migrations::LockRetryMixin.patch! Gitlab::Database::Migrations::PgBackendPid.patch! Gitlab::Database::Migrations::RunnerBackoff::ActiveRecordMixin.patch! + +# This patch rolls back to Rails 6.1 behavior: +# +# https://github.com/rails/rails/blob/v6.1.4.3/activerecord/lib/active_record/migration.rb#L1044 +# +# It fixes the tests that relies on the fact that the same constants have the same object_id. +# For example to make sure that stub_const works correctly. +# +# It overrides the new behavior that removes the constant first: +# +# https://github.com/rails/rails/blob/v7.0.5/activerecord/lib/active_record/migration.rb#L1054 +module ActiveRecord + class MigrationProxy + private + + def load_migration + require(File.expand_path(filename)) + name.constantize.new(name, version) + end + end +end diff --git a/config/initializers/active_record_postgresql_adapter.rb b/config/initializers/active_record_postgresql_adapter.rb index 14bc7153f4434557d23cb7c35b1dfcdf5ced8c3b..7bb03a0af96cc5692342faa408313e0d4b14261b 100644 --- a/config/initializers/active_record_postgresql_adapter.rb +++ b/config/initializers/active_record_postgresql_adapter.rb @@ -1,9 +1,5 @@ # frozen_string_literal: true -if Gitlab::Utils.to_boolean(ENV['ENABLE_ACTIVERECORD_EMPTY_PING'], default: true) - ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(Gitlab::Database::PostgresqlAdapter::EmptyQueryPing) -end - if Gitlab::Utils.to_boolean(ENV['ENABLE_ACTIVERECORD_TYPEMAP_CACHE'], default: true) ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(Gitlab::Database::PostgresqlAdapter::TypeMapCache) end diff --git a/config/initializers/active_record_preloader.rb b/config/initializers/active_record_preloader.rb index 19ca380a86674de21aa7773a15a38a50ba7c8675..33c73c2eb3d9aebee5907c5125cfc738db72028b 100644 --- a/config/initializers/active_record_preloader.rb +++ b/config/initializers/active_record_preloader.rb @@ -1,42 +1,64 @@ # frozen_string_literal: true +# Some polymorphic associations may refer to an object which is not a subclass of ActiveRecord. +# This patch skips preloading of these associations. +# +# For example, a note's noteable can be an Issue, Merge Request, or Commit, where Commit is +# not a subclass of ActiveRecord. When you run something like: +# +# Note.includes(noteable: :assignees).to_a +# +# This patch allows preloading of issues, merge requests, and their assignees while skipping +# commits. + module ActiveRecord module Associations class Preloader - def initialize(records: nil, associations: nil) - super() - - @records = records - @associations = associations - end + class Association + class LoaderQuery + # https://gitlab.com/gitlab-org/gitlab/-/issues/385739 + module HandlePreloadsForDifferentClassesSeparately + def eql?(other) + scope.klass == other.scope.klass && super + end - def call - preload(@records, @associations) - end + def hash + [scope.klass, association_key_name, scope.table_name, scope.values_for_queries].hash + end + end - class NullPreloader - def self.new(*args, **kwargs) - self + prepend HandlePreloadsForDifferentClassesSeparately end - def self.run - self - end + module NonActiveRecordPreloader + # https://github.com/rails/rails/blob/v7.0.4.2/activerecord/lib/active_record/associations/preloader/association.rb#L114-L116 + def run? + return true unless klass < ActiveRecord::Base - def self.preloaded_records - [] - end - end + super + end - module NoCommitPreloader - def preloader_for(reflection, owners) - return NullPreloader if owners.first.association(reflection.name).klass == ::Commit + # https://github.com/rails/rails/blob/v7.0.4.2/activerecord/lib/active_record/associations/preloader/association.rb#L137-L141 + def preloaded_records + return [] unless klass < ActiveRecord::Base - super + super + end end + + prepend NonActiveRecordPreloader end - prepend NoCommitPreloader + class Branch + module NonActiveRecordPreloader + # https://github.com/rails/rails/blob/v7.0.4.2/activerecord/lib/active_record/associations/preloader/branch.rb#L37-L45 + def target_classes + super.delete_if { |klass| !(klass < ActiveRecord::Base) } + end + end + + prepend NonActiveRecordPreloader + end end end end diff --git a/config/initializers/activerecord_postgresql_timestamp_with_timezone_patches.rb b/config/initializers/activerecord_postgresql_timestamp_with_timezone_patches.rb new file mode 100644 index 0000000000000000000000000000000000000000..f3fd276a1919d7eeb05223e21e0b101901ad16bf --- /dev/null +++ b/config/initializers/activerecord_postgresql_timestamp_with_timezone_patches.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +# Monkey patch to fix errors like `undefined method 'getutc' for Date' seen +# during Rails 7 upgrade: +# +# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/90907#note_1253684870 and +# https://github.com/rails/rails/issues/46341#issuecomment-1406391573 + +if Rails.gem_version >= Gem::Version.new('7.0.5') + raise "Remove `#{__FILE__}`. This is backport of https://github.com/rails/rails/pull/46365" +end + +module ActiveRecord + module ConnectionAdapters + module PostgreSQL + module OID # :nodoc: + class TimestampWithTimeZone < DateTime # :nodoc: + def type + real_type_unless_aliased(:timestamptz) + end + + def cast_value(value) + return if value.blank? + + time = super + return time unless time.acts_like?(:time) + + # While in UTC mode, the PG gem may not return times back in "UTC" even if they were provided to + # Postgres in UTC. We prefer times always in UTC, so here we convert back. + if is_utc? + time.getutc + else + time.getlocal + end + end + end + end + end + end +end diff --git a/config/initializers/remove_active_job_execute_callback.rb b/config/initializers/remove_active_job_execute_callback.rb index c8efcb11202075a97d0aadcb6aee6a7a388ad9a8..c8fc9a6b98b59e7cc1c9d2007712f9942e93b602 100644 --- a/config/initializers/remove_active_job_execute_callback.rb +++ b/config/initializers/remove_active_job_execute_callback.rb @@ -16,8 +16,8 @@ def active_job_railtie_callback? callbacks && callbacks.send(:chain).size == 1 && callbacks.first.kind == :around && - callbacks.first.raw_filter.is_a?(Proc) && - callbacks.first.raw_filter.source_location.first.ends_with?('lib/active_job/railtie.rb') + callbacks.first.filter.is_a?(Proc) && + callbacks.first.filter.source_location.first.ends_with?('lib/active_job/railtie.rb') end if active_job_railtie_callback? diff --git a/ee/app/services/app_sec/dast/pre_scan_verification_steps/find_or_create_service.rb b/ee/app/services/app_sec/dast/pre_scan_verification_steps/find_or_create_service.rb index a290042a55e0b2826efb08c1337ac55a32aa060b..3357e28da4b54d7ac93ad96deae4b7929dd5e5de 100644 --- a/ee/app/services/app_sec/dast/pre_scan_verification_steps/find_or_create_service.rb +++ b/ee/app/services/app_sec/dast/pre_scan_verification_steps/find_or_create_service.rb @@ -12,7 +12,7 @@ def execute return ServiceResponse.error(message: error_message(verification_step)) unless verification_step.persisted? ServiceResponse.success(payload: { verification_step: verification_step }) - rescue ActiveRecord::StatementInvalid + rescue ArgumentError ServiceResponse.error(message: format_error_message("#{step} is not a valid pre step name")) end end diff --git a/ee/lib/gitlab/patch/additional_database_tasks.rb b/ee/lib/gitlab/patch/additional_database_tasks.rb index c0709104cb607785316a6cf3317d7dc24c5c2fb4..0dc53b2a7743409f642321cb8cd6bcc8406b3df3 100644 --- a/ee/lib/gitlab/patch/additional_database_tasks.rb +++ b/ee/lib/gitlab/patch/additional_database_tasks.rb @@ -9,8 +9,8 @@ module AdditionalDatabaseTasks # Returns the proper path for the structure.sql and schema_cache.yml # files for additional databases. module ActiveRecordDatabaseTasksDumpFilename - def dump_filename(database, format = ApplicationRecord.schema_format) - db_dir = Gitlab::Database.all_database_connections[database]&.db_dir + def schema_dump_path(db_config, format = ActiveRecord.schema_format) + db_dir = Gitlab::Database.all_database_connections[db_config.name.to_s]&.db_dir return super if default_db_dir?(db_dir) Rails.root.join(db_dir, 'structure.sql').to_s diff --git a/ee/spec/controllers/projects/feature_flag_issues_controller_spec.rb b/ee/spec/controllers/projects/feature_flag_issues_controller_spec.rb index 2751ce77de6a7012f4e49fad0a20109cc5342555..9e3b5f8c4a99e7a345bb9ea5ae674468981b348a 100644 --- a/ee/spec/controllers/projects/feature_flag_issues_controller_spec.rb +++ b/ee/spec/controllers/projects/feature_flag_issues_controller_spec.rb @@ -144,7 +144,7 @@ def get_request(project, feature_flag) create(:feature_flag_issue, feature_flag: feature_flag, issue: issue_b) create(:feature_flag_issue, feature_flag: feature_flag, issue: issue_c) - expect { get_request(project, feature_flag) }.not_to exceed_query_limit(control_count) + expect { get_request(project, feature_flag) }.not_to exceed_query_limit(control_count).with_threshold(4) end it 'returns only issues readable by the user' do diff --git a/ee/spec/lib/gitlab/patch/additional_database_tasks_spec.rb b/ee/spec/lib/gitlab/patch/additional_database_tasks_spec.rb index 41f9a54f2e0659adda09d2743f7e6f3656dbe7ac..5ebc0b874e2b0c0c01cf05c34d63fd7126d3b46e 100644 --- a/ee/spec/lib/gitlab/patch/additional_database_tasks_spec.rb +++ b/ee/spec/lib/gitlab/patch/additional_database_tasks_spec.rb @@ -8,7 +8,7 @@ Class.new do prepend Gitlab::Patch::AdditionalDatabaseTasks::ActiveRecordDatabaseTasksDumpFilename - def dump_filename(*) + def schema_dump_path(*) Rails.root.join('foo.sql').to_s end @@ -18,7 +18,7 @@ def cache_dump_filename(*) end.new end - describe '#dump_filename' do + describe '#schema_dump_path' do using RSpec::Parameterized::TableSyntax where(:db_config_name, :structure_path) do @@ -28,8 +28,10 @@ def cache_dump_filename(*) end with_them do + let(:db_config) { ActiveRecord::DatabaseConfigurations::HashConfig.new('test', db_config_name, {}) } + it 'returns the correct path for the structure.sql file' do - expect(subject.dump_filename(db_config_name)).to eq Rails.root.join(structure_path).to_s + expect(subject.schema_dump_path(db_config)).to eq Rails.root.join(structure_path).to_s end end end diff --git a/ee/spec/lib/omni_auth/strategies/group_saml_spec.rb b/ee/spec/lib/omni_auth/strategies/group_saml_spec.rb index 1a01bbc0bfb08ae05304fa7993175fbc48ea9f40..fb82e836e763f10257b5cb6441c6063050759d20 100644 --- a/ee/spec/lib/omni_auth/strategies/group_saml_spec.rb +++ b/ee/spec/lib/omni_auth/strategies/group_saml_spec.rb @@ -126,6 +126,15 @@ def check(path) end describe 'POST /users/auth/group_saml' do + before do + mock_session = {} + + allow(mock_session).to receive(:enabled?).and_return(true) + allow(mock_session).to receive(:loaded?).and_return(true) + + env('rack.session', mock_session) + end + it 'redirects to the provider login page', :aggregate_failures do post '/users/auth/group_saml', group_path: 'my-group' diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index da9ebf4ab0fda8028643a90b52a06f44da8c1f74..fd83f27ef318bde5ba47e72932838b5092cd0dde 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -145,7 +145,7 @@ def self.default_pool_size # Database configured. Returns true even if the database is shared def self.has_config?(database_name) ActiveRecord::Base.configurations - .configs_for(env_name: Rails.env, name: database_name.to_s, include_replicas: true) + .configs_for(env_name: Rails.env, name: database_name.to_s, include_hidden: true) .present? end diff --git a/lib/gitlab/database/load_balancing/connection_proxy.rb b/lib/gitlab/database/load_balancing/connection_proxy.rb index 02f14e020c105c0cb5c81372a2a62fee52eb449d..2c480eb2cdc2930643d7b81a7516b19bf3c9dcd1 100644 --- a/lib/gitlab/database/load_balancing/connection_proxy.rb +++ b/lib/gitlab/database/load_balancing/connection_proxy.rb @@ -39,7 +39,7 @@ def initialize(load_balancer) @load_balancer = load_balancer end - def select_all(arel, name = nil, binds = [], preparable: nil) + def select_all(arel, name = nil, binds = [], preparable: nil, async: false) if arel.respond_to?(:locked) && arel.locked # SELECT ... FOR UPDATE queries should be sent to the primary. current_session.write! diff --git a/lib/gitlab/database/load_balancing/load_balancer.rb b/lib/gitlab/database/load_balancing/load_balancer.rb index 23476e1f5e969519a011062d75c9655e9cdc47e5..b71237840107ac9200a443a0d6c26577f896da73 100644 --- a/lib/gitlab/database/load_balancing/load_balancer.rb +++ b/lib/gitlab/database/load_balancing/load_balancer.rb @@ -285,7 +285,7 @@ def create_replica_connection_pool(pool_size, host = nil, port = nil) def pool ActiveRecord::Base.connection_handler.retrieve_connection_pool( @configuration.connection_specification_name, - role: ActiveRecord::Base.writing_role, + role: ActiveRecord.writing_role, shard: ActiveRecord::Base.default_shard ) || raise(::ActiveRecord::ConnectionNotEstablished) end diff --git a/lib/gitlab/database/postgresql_adapter/empty_query_ping.rb b/lib/gitlab/database/postgresql_adapter/empty_query_ping.rb deleted file mode 100644 index 88affaa97572731ed616314866b99de30ebe8411..0000000000000000000000000000000000000000 --- a/lib/gitlab/database/postgresql_adapter/empty_query_ping.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -# This patch will be included in the next Rails release: https://github.com/rails/rails/pull/42368 -raise 'This patch can be removed' if Rails::VERSION::MAJOR > 6 - -# rubocop:disable Gitlab/ModuleWithInstanceVariables -module Gitlab - module Database - module PostgresqlAdapter - module EmptyQueryPing - # ActiveRecord uses `SELECT 1` to check if the connection is alive - # We patch this here to use an empty query instead, which is a bit faster - def active? - @lock.synchronize do - @connection.query ';' - end - true - rescue PG::Error - false - end - end - end - end -end -# rubocop:enable Gitlab/ModuleWithInstanceVariables diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index 026cb39a92f8b296715b3ec009777532d2c898a4..61cbf0d8bd49343909aa845fee4c208d6a3331b8 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -142,7 +142,7 @@ namespace :gitlab do desc 'This adjusts and cleans db/structure.sql - it runs after db:schema:dump' task :clean_structure_sql do |task_name| ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| - structure_file = ActiveRecord::Tasks::DatabaseTasks.dump_filename(db_config.name) + structure_file = ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(db_config) schema = File.read(structure_file) diff --git a/lib/tasks/gitlab/db/validate_config.rake b/lib/tasks/gitlab/db/validate_config.rake index b3c98e91d178708596a0e965e3a0ffb68772925b..f42d30e981724ebd177ce2c3404faa4e2fd3e9cf 100644 --- a/lib/tasks/gitlab/db/validate_config.rake +++ b/lib/tasks/gitlab/db/validate_config.rake @@ -25,10 +25,7 @@ namespace :gitlab do task validate_config: :environment do original_db_config = ActiveRecord::Base.connection_db_config # rubocop:disable Database/MultipleDatabases - # The include_replicas: is a legacy name to fetch all hidden entries (replica: true or database_tasks: false) - # Once we upgrade to Rails 7.x this should be changed to `include_hidden: true` - # Ref.: https://github.com/rails/rails/blob/f2d9316ba965e150ad04596085ee10eea4f58d3e/activerecord/lib/active_record/database_configurations.rb#L48 - db_configs = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, include_replicas: true) + db_configs = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, include_hidden: true) db_configs = db_configs.reject(&:replica?) # The `pg_control_system()` is not enough to properly discover matching database systems diff --git a/package.json b/package.json index e679bed69c5cfd2600e9ed01882752555bcd6321..4559eb911e216d8fa2fa34cab7f14ba3946f9297 100644 --- a/package.json +++ b/package.json @@ -62,8 +62,8 @@ "@gitlab/web-ide": "0.0.1-dev-20230614124516", "@mattiasbuelens/web-streams-adapter": "^0.1.0", "@popperjs/core": "^2.11.2", - "@rails/actioncable": "6.1.4-7", - "@rails/ujs": "6.1.4-7", + "@rails/actioncable": "7.0.4-3", + "@rails/ujs": "7.0.4-3", "@snowplow/browser-plugin-client-hints": "^3.9.0", "@snowplow/browser-plugin-form-tracking": "^3.9.0", "@snowplow/browser-plugin-ga-cookies": "^3.9.0", diff --git a/patches/@rails+ujs+6.1.4-7.patch b/patches/@rails+ujs+7.0.4-3.patch similarity index 90% rename from patches/@rails+ujs+6.1.4-7.patch rename to patches/@rails+ujs+7.0.4-3.patch index 35669852e9fd54d33a28e9e7739818156a3171a0..65a4eb029b8d818d12828e9225da524963197956 100644 --- a/patches/@rails+ujs+6.1.4-7.patch +++ b/patches/@rails+ujs+7.0.4-3.patch @@ -1,8 +1,8 @@ diff --git a/node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js b/node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js -index 2176247..1a83d48 100644 +index d428163..010eaa5 100644 --- a/node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js +++ b/node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js -@@ -265,11 +265,6 @@ Released under the MIT license +@@ -281,11 +281,6 @@ Released under the MIT license try { response = JSON.parse(response); } catch (error) {} diff --git a/spec/controllers/groups/children_controller_spec.rb b/spec/controllers/groups/children_controller_spec.rb index ee8b2dce298103ff1f8675c7fac459dcbda5a14b..82dd8c18cfddef5ac79395813000c1d4a09eeb39 100644 --- a/spec/controllers/groups/children_controller_spec.rb +++ b/spec/controllers/groups/children_controller_spec.rb @@ -222,13 +222,13 @@ def get_list control = ActiveRecord::QueryRecorder.new { get_list } _new_project = create(:project, :public, namespace: group) - expect { get_list }.not_to exceed_query_limit(control).with_threshold(expected_queries_per_project) + expect { get_list }.not_to exceed_query_limit(control).with_threshold(expected_queries_per_project + 1) end context 'when rendering hierarchies' do # When loading hierarchies we load the all the ancestors for matched projects - # in 2 separate queries - let(:extra_queries_for_hierarchies) { 2 } + # in 3 separate queries + let(:extra_queries_for_hierarchies) { 3 } def get_filtered_list get :index, params: { group_id: group.to_param, filter: 'filter' }, format: :json diff --git a/spec/controllers/projects/design_management/designs/resized_image_controller_spec.rb b/spec/controllers/projects/design_management/designs/resized_image_controller_spec.rb index 1bb5112681c584568ebc7d9ea87d117a72006750..c6fd58223ffaea188fad9e495e06bd4f98b5b8ca 100644 --- a/spec/controllers/projects/design_management/designs/resized_image_controller_spec.rb +++ b/spec/controllers/projects/design_management/designs/resized_image_controller_spec.rb @@ -59,7 +59,7 @@ end it 'sets appropriate caching headers' do - expect(response.header['Cache-Control']).to eq('private') + expect(response.header['Cache-Control']).to eq('max-age=0, private, must-revalidate') expect(response.header['ETag']).to be_present end end diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 5e9135c00e36dbbe3e4a3a7f8cdb764ad031c0b2..f9ce77a44ba24d14470f1b4d64736ae4ec286b84 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -1809,7 +1809,7 @@ def get_service_desk(extra_params = {}) create(:user_status, user: second_discussion.author) expect { get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid } } - .not_to exceed_query_limit(control) + .not_to exceed_query_limit(control).with_threshold(9) end context 'when user is setting notes filters' do diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index 8c5f8fc6259edc566256728f7b659a1f735f0d40..a5542a2b825f4d8733cbaa3f792ecadb8baf0131 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -328,7 +328,7 @@ def create_bridge(stage, stage_idx, name, status) expect do get_pipeline_html expect(response).to have_gitlab_http_status(:ok) - end.not_to exceed_all_query_limit(control) + end.not_to exceed_all_query_limit(control).with_threshold(3) end end diff --git a/spec/finders/clusters/agent_tokens_finder_spec.rb b/spec/finders/clusters/agent_tokens_finder_spec.rb index 1f5bfd58e8565645e3fe05790862270e3030a455..16fdbc1b6691e9d1810ccd192f154470fdcde8cd 100644 --- a/spec/finders/clusters/agent_tokens_finder_spec.rb +++ b/spec/finders/clusters/agent_tokens_finder_spec.rb @@ -47,10 +47,7 @@ context 'when filtering by an unrecognised status' do subject(:execute) { described_class.new(agent, user, status: 'dummy').execute } - it 'raises an error' do - # 'dummy' is not a valid status as defined in the AgentToken status enum - expect { execute.count }.to raise_error(ActiveRecord::StatementInvalid) - end + it { is_expected.to be_empty } end context 'when user does not have permission' do diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 01be083b506351fbc09469aa29e65695288ca1be..8ff36280dbca359fdfb1b40bbae37c2ead6943a8 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -590,12 +590,13 @@ def stub_controller_method(method_name, value) it 'adds custom form builder to options and calls `form_for`' do options = { html: { class: 'foo-bar' } } - expected_options = options.merge({ builder: ::Gitlab::FormBuilders::GitlabUiFormBuilder, url: '/root' }) + expected_options = options.merge({ builder: ::Gitlab::FormBuilders::GitlabUiFormBuilder }) expect do |b| helper.gitlab_ui_form_for(user, options, &b) end.to yield_with_args(::Gitlab::FormBuilders::GitlabUiFormBuilder) - expect(helper).to have_received(:form_for).with(user, expected_options) + + expect(helper).to have_received(:form_for).with(user, a_hash_including(expected_options)) end end @@ -722,19 +723,19 @@ def stub_controller_method(method_name, value) it 'uses print stylesheet when feature flag disabled' do stub_feature_flags(remove_startup_css: false) - expect(helper.stylesheet_link_tag_defer('test')).to eq( '') + expect(helper.stylesheet_link_tag_defer('test')).to eq( '') end it 'uses regular stylesheet when feature flag enabled' do stub_feature_flags(remove_startup_css: true) - expect(helper.stylesheet_link_tag_defer('test')).to eq( '') + expect(helper.stylesheet_link_tag_defer('test')).to eq( '') end it 'uses regular stylesheet when no_startup_css param present' do allow(helper.controller).to receive(:params).and_return({ no_startup_css: '' }) - expect(helper.stylesheet_link_tag_defer('test')).to eq( '') + expect(helper.stylesheet_link_tag_defer('test')).to eq( '') end end diff --git a/spec/initializers/00_rails_disable_joins_spec.rb b/spec/initializers/00_rails_disable_joins_spec.rb deleted file mode 100644 index 3b390f1ef170cb549997e2e4aa14dbd860865d80..0000000000000000000000000000000000000000 --- a/spec/initializers/00_rails_disable_joins_spec.rb +++ /dev/null @@ -1,288 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'DisableJoins' do - let(:primary_model) do - Class.new(ApplicationRecord) do - self.table_name = '_test_primary_records' - - def self.name - 'TestPrimary' - end - end - end - - let(:bridge_model) do - Class.new(ApplicationRecord) do - self.table_name = '_test_bridge_records' - - def self.name - 'TestBridge' - end - end - end - - let(:secondary_model) do - Class.new(ApplicationRecord) do - self.table_name = '_test_secondary_records' - - def self.name - 'TestSecondary' - end - end - end - - context 'passing disable_joins as an association option' do - context 'when the association is a bare has_one' do - it 'disallows the disable_joins option' do - expect do - primary_model.has_one :test_bridge, disable_joins: true - end.to raise_error(ArgumentError, /Unknown key: :disable_joins/) - end - end - - context 'when the association is a belongs_to' do - it 'disallows the disable_joins option' do - expect do - bridge_model.belongs_to :test_secondary, disable_joins: true - end.to raise_error(ArgumentError, /Unknown key: :disable_joins/) - end - end - - context 'when the association is has_one :through' do - it 'allows the disable_joins option' do - primary_model.has_one :test_bridge - bridge_model.belongs_to :test_secondary - - expect do - primary_model.has_one :test_secondary, through: :test_bridge, disable_joins: true - end.not_to raise_error - end - end - - context 'when the association is a bare has_many' do - it 'disallows the disable_joins option' do - expect do - primary_model.has_many :test_bridges, disable_joins: true - end.to raise_error(ArgumentError, /Unknown key: :disable_joins/) - end - end - - context 'when the association is a has_many :through' do - it 'allows the disable_joins option' do - primary_model.has_many :test_bridges - bridge_model.belongs_to :test_secondary - - expect do - primary_model.has_many :test_secondaries, through: :test_bridges, disable_joins: true - end.not_to raise_error - end - end - end - - context 'querying has_one :through when disable_joins is set' do - before do - create_tables(<<~SQL) - CREATE TABLE _test_primary_records ( - id serial NOT NULL PRIMARY KEY); - - CREATE TABLE _test_bridge_records ( - id serial NOT NULL PRIMARY KEY, - primary_record_id int NOT NULL, - secondary_record_id int NOT NULL); - - CREATE TABLE _test_secondary_records ( - id serial NOT NULL PRIMARY KEY); - SQL - - primary_model.has_one :test_bridge, anonymous_class: bridge_model, foreign_key: :primary_record_id - bridge_model.belongs_to :test_secondary, anonymous_class: secondary_model, foreign_key: :secondary_record_id - primary_model.has_one :test_secondary, - through: :test_bridge, anonymous_class: secondary_model, disable_joins: -> { joins_disabled_flag } - - primary_record = primary_model.create! - secondary_record = secondary_model.create! - bridge_model.create!(primary_record_id: primary_record.id, secondary_record_id: secondary_record.id) - end - - context 'when disable_joins evaluates to true' do - let(:joins_disabled_flag) { true } - - it 'executes separate queries' do - primary_record = primary_model.first - - query_count = ActiveRecord::QueryRecorder.new { primary_record.test_secondary }.count - - expect(query_count).to eq(2) - end - end - - context 'when disable_joins evalutes to false' do - let(:joins_disabled_flag) { false } - - it 'executes a single query' do - primary_record = primary_model.first - - query_count = ActiveRecord::QueryRecorder.new { primary_record.test_secondary }.count - - expect(query_count).to eq(1) - end - end - end - - context 'querying has_many :through when disable_joins is set' do - before do - create_tables(<<~SQL) - CREATE TABLE _test_primary_records ( - id serial NOT NULL PRIMARY KEY); - - CREATE TABLE _test_bridge_records ( - id serial NOT NULL PRIMARY KEY, - primary_record_id int NOT NULL); - - CREATE TABLE _test_secondary_records ( - id serial NOT NULL PRIMARY KEY, - bridge_record_id int NOT NULL); - SQL - - primary_model.has_many :test_bridges, anonymous_class: bridge_model, foreign_key: :primary_record_id - bridge_model.has_many :test_secondaries, anonymous_class: secondary_model, foreign_key: :bridge_record_id - primary_model.has_many :test_secondaries, through: :test_bridges, anonymous_class: secondary_model, - disable_joins: -> { disabled_join_flag } - - primary_record = primary_model.create! - bridge_record = bridge_model.create!(primary_record_id: primary_record.id) - secondary_model.create!(bridge_record_id: bridge_record.id) - end - - context 'when disable_joins evaluates to true' do - let(:disabled_join_flag) { true } - - it 'executes separate queries' do - primary_record = primary_model.first - - query_count = ActiveRecord::QueryRecorder.new { primary_record.test_secondaries.first }.count - - expect(query_count).to eq(2) - end - end - - context 'when disable_joins evalutes to false' do - let(:disabled_join_flag) { false } - - it 'executes a single query' do - primary_record = primary_model.first - - query_count = ActiveRecord::QueryRecorder.new { primary_record.test_secondaries.first }.count - - expect(query_count).to eq(1) - end - end - end - - context 'querying STI relationships' do - let(:child_bridge_model) do - Class.new(bridge_model) do - def self.name - 'ChildBridge' - end - end - end - - let(:child_secondary_model) do - Class.new(secondary_model) do - def self.name - 'ChildSecondary' - end - end - end - - before do - create_tables(<<~SQL) - CREATE TABLE _test_primary_records ( - id serial NOT NULL PRIMARY KEY); - - CREATE TABLE _test_bridge_records ( - id serial NOT NULL PRIMARY KEY, - primary_record_id int NOT NULL, - type text); - - CREATE TABLE _test_secondary_records ( - id serial NOT NULL PRIMARY KEY, - bridge_record_id int NOT NULL, - type text); - SQL - - primary_model.has_many :child_bridges, anonymous_class: child_bridge_model, foreign_key: :primary_record_id - child_bridge_model.has_one :child_secondary, anonymous_class: child_secondary_model, foreign_key: :bridge_record_id - primary_model.has_many :child_secondaries, through: :child_bridges, anonymous_class: child_secondary_model, disable_joins: true - - primary_record = primary_model.create! - parent_bridge_record = bridge_model.create!(primary_record_id: primary_record.id) - child_bridge_record = child_bridge_model.create!(primary_record_id: primary_record.id) - - secondary_model.create!(bridge_record_id: child_bridge_record.id) - child_secondary_model.create!(bridge_record_id: parent_bridge_record.id) - child_secondary_model.create!(bridge_record_id: child_bridge_record.id) - end - - it 'filters correctly by the STI type across multiple queries' do - primary_record = primary_model.first - - query_recorder = ActiveRecord::QueryRecorder.new do - expect(primary_record.child_secondaries.count).to eq(1) - end - - expect(query_recorder.count).to eq(2) - end - end - - context 'querying polymorphic relationships' do - before do - create_tables(<<~SQL) - CREATE TABLE _test_primary_records ( - id serial NOT NULL PRIMARY KEY); - - CREATE TABLE _test_bridge_records ( - id serial NOT NULL PRIMARY KEY, - primaryable_id int NOT NULL, - primaryable_type text NOT NULL); - - CREATE TABLE _test_secondary_records ( - id serial NOT NULL PRIMARY KEY, - bridgeable_id int NOT NULL, - bridgeable_type text NOT NULL); - SQL - - primary_model.has_many :test_bridges, anonymous_class: bridge_model, foreign_key: :primaryable_id, as: :primaryable - bridge_model.has_one :test_secondaries, anonymous_class: secondary_model, foreign_key: :bridgeable_id, as: :bridgeable - primary_model.has_many :test_secondaries, through: :test_bridges, anonymous_class: secondary_model, disable_joins: true - - primary_record = primary_model.create! - primary_bridge_record = bridge_model.create!(primaryable_id: primary_record.id, primaryable_type: 'TestPrimary') - nonprimary_bridge_record = bridge_model.create!(primaryable_id: primary_record.id, primaryable_type: 'NonPrimary') - - secondary_model.create!(bridgeable_id: primary_bridge_record.id, bridgeable_type: 'TestBridge') - secondary_model.create!(bridgeable_id: nonprimary_bridge_record.id, bridgeable_type: 'TestBridge') - secondary_model.create!(bridgeable_id: primary_bridge_record.id, bridgeable_type: 'NonBridge') - end - - it 'filters correctly by the polymorphic type across multiple queries' do - primary_record = primary_model.first - - query_recorder = ActiveRecord::QueryRecorder.new do - expect(primary_record.test_secondaries.count).to eq(1) - end - - expect(query_recorder.count).to eq(2) - end - end - - def create_tables(table_sql) - ApplicationRecord.connection.execute(table_sql) - - bridge_model.reset_column_information - secondary_model.reset_column_information - end -end diff --git a/spec/initializers/100_patch_omniauth_saml_spec.rb b/spec/initializers/100_patch_omniauth_saml_spec.rb index de556cfa1e57b3e6a830da04bb5b259f0180178f..886f350ca88d421bab44b9fc8d5dd035cd1ba406 100644 --- a/spec/initializers/100_patch_omniauth_saml_spec.rb +++ b/spec/initializers/100_patch_omniauth_saml_spec.rb @@ -6,6 +6,15 @@ let(:idp_sso_target_url) { 'https://login.example.com/idp' } let(:strategy) { [OmniAuth::Strategies::SAML, { idp_sso_target_url: idp_sso_target_url }] } + before do + mock_session = {} + + allow(mock_session).to receive(:enabled?).and_return(true) + allow(mock_session).to receive(:loaded?).and_return(true) + + env('rack.session', mock_session) + end + describe 'POST /users/auth/saml' do it 'redirects to the provider login page', :aggregate_failures do post '/users/auth/saml' diff --git a/spec/initializers/action_dispatch_journey_router_spec.rb b/spec/initializers/action_dispatch_journey_router_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..641a8c6d11f3cb8168e49f9f457793188ceda9ae --- /dev/null +++ b/spec/initializers/action_dispatch_journey_router_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require 'spec_helper' + +# Adds a missing test to provide full coverage for the patch +RSpec.describe 'ActionDispatch::Journey::Router Patch', feature_category: :database do + before do + load Rails.root.join('config/initializers/action_dispatch_journey_router.rb') + end + + describe '#find_routes' do + context 'when a route has additional constrains' do + it 'does not raise an error' do + stub_const('PagesController', Class.new(ApplicationController)) + + set = ActionDispatch::Routing::RouteSet.new + + set.draw do + get "*namespace_id/:project_id/bar", + to: "pages#show", + constraints: { + namespace_id: %r{(?!api/)[a-zA-Z0-9_\\]+}, + project_id: /[a-zA-Z0-9]+/ + } + + get "/api/foo/bar", to: "pages#index" + end + + params = set.recognize_path("/api/foo/bar", method: :get) + + expect(params[:controller]).to eq('pages') + expect(params[:action]).to eq('index') + end + end + end +end diff --git a/spec/initializers/activerecord_postgresql_timestamp_with_timezone_patches_spec.rb b/spec/initializers/activerecord_postgresql_timestamp_with_timezone_patches_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..8ad73a0b890354334757ccb8fd694d9998f7b90f --- /dev/null +++ b/spec/initializers/activerecord_postgresql_timestamp_with_timezone_patches_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'spec_helper' + +# A missing test to provide full coverage for the patch +RSpec.describe 'ActiveRecord PostgreSQL Timespamp With Timezone', feature_category: :database do + before do + load Rails.root.join('config/initializers/activerecord_postgresql_timestamp_with_timezone_patches.rb') + end + + describe '#cast_value' do + it 'returns local time' do + timestamp = ActiveRecord::ConnectionAdapters::PostgreSQL::OID::TimestampWithTimeZone.new + + allow(ActiveRecord).to receive(:default_timezone).and_return(:local) + + expect(timestamp.cast_value(DateTime.now)).not_to be_utc + end + end +end diff --git a/spec/lib/gitlab/database/postgresql_adapter/empty_query_ping_spec.rb b/spec/lib/gitlab/database/postgresql_adapter/empty_query_ping_spec.rb deleted file mode 100644 index 6e1e53e0e4183312643f18dae72b1c4f704adcc8..0000000000000000000000000000000000000000 --- a/spec/lib/gitlab/database/postgresql_adapter/empty_query_ping_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Gitlab::Database::PostgresqlAdapter::EmptyQueryPing do - describe '#active?' do - let(:adapter_class) do - Class.new do - include Gitlab::Database::PostgresqlAdapter::EmptyQueryPing - - def initialize(connection, lock) - @connection = connection - @lock = lock - end - end - end - - subject { adapter_class.new(connection, lock).active? } - - let(:connection) { double(query: nil) } - let(:lock) { double } - - before do - allow(lock).to receive(:synchronize).and_yield - end - - it 'uses an empty query to check liveness' do - expect(connection).to receive(:query).with(';') - - subject - end - - it 'returns true if no error was signaled' do - expect(subject).to be_truthy - end - - it 'returns false when an error occurs' do - expect(lock).to receive(:synchronize).and_raise(PG::Error) - - expect(subject).to be_falsey - end - end -end diff --git a/spec/lib/gitlab/database/postgresql_adapter/type_map_cache_spec.rb b/spec/lib/gitlab/database/postgresql_adapter/type_map_cache_spec.rb index c6542aa2adbcc183bd6c0beec2502adea33dc35d..75c3a3650d71dbe51d9da227d92a7bd771501c4a 100644 --- a/spec/lib/gitlab/database/postgresql_adapter/type_map_cache_spec.rb +++ b/spec/lib/gitlab/database/postgresql_adapter/type_map_cache_spec.rb @@ -13,7 +13,7 @@ describe '#initialize_type_map' do it 'caches loading of types in memory' do recorder_without_cache = ActiveRecord::QueryRecorder.new(skip_schema_queries: false) { initialize_connection.disconnect! } - expect(recorder_without_cache.log).to include(a_string_matching(/FROM pg_type/)).twice + expect(recorder_without_cache.log).to include(a_string_matching(/FROM pg_type/)).exactly(4).times recorder_with_cache = ActiveRecord::QueryRecorder.new(skip_schema_queries: false) { initialize_connection.disconnect! } @@ -33,7 +33,7 @@ recorder = ActiveRecord::QueryRecorder.new(skip_schema_queries: false) { initialize_connection(other_config).disconnect! } - expect(recorder.log).to include(a_string_matching(/FROM pg_type/)).twice + expect(recorder.log).to include(a_string_matching(/FROM pg_type/)).exactly(4).times end end @@ -44,7 +44,7 @@ connection = initialize_connection recorder = ActiveRecord::QueryRecorder.new(skip_schema_queries: false) { connection.reload_type_map } - expect(recorder.log).to include(a_string_matching(/FROM pg_type/)).once + expect(recorder.log).to include(a_string_matching(/FROM pg_type/)).exactly(3).times end end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index ab3cd8fa5e6a25400df15d2d47d3fe50ef5850d8..789ae348dc12e242d60e8ef3413edd1bcd494fca 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -103,7 +103,7 @@ before do # CI config might not be configured allow(ActiveRecord::Base.configurations).to receive(:configs_for) - .with(env_name: 'test', name: 'ci', include_replicas: true) + .with(env_name: 'test', name: 'ci', include_hidden: true) .and_return(ci_db_config) end diff --git a/spec/lib/gitlab/rack_attack/request_spec.rb b/spec/lib/gitlab/rack_attack/request_spec.rb index ae0abfd0bc5185282f51bf00d31dc7ad7d62c7c7..e8433d99d1564a01b273722018db593caa429fb8 100644 --- a/spec/lib/gitlab/rack_attack/request_spec.rb +++ b/spec/lib/gitlab/rack_attack/request_spec.rb @@ -258,6 +258,11 @@ valid_token = SecureRandom.base64(ActionController::RequestForgeryProtection::AUTHENTICITY_TOKEN_LENGTH) other_token = SecureRandom.base64(ActionController::RequestForgeryProtection::AUTHENTICITY_TOKEN_LENGTH) + before do + allow(session).to receive(:enabled?).and_return(true) + allow(session).to receive(:loaded?).and_return(true) + end + where(:session, :env, :expected) do {} | {} | false {} | { 'HTTP_X_CSRF_TOKEN' => valid_token } | false diff --git a/spec/lib/gitlab/request_forgery_protection_spec.rb b/spec/lib/gitlab/request_forgery_protection_spec.rb index 10842173365dcd2cfa6cbff3d0e6abfdc64f6072..dbf9f2957060ca24b11d7f8c063dfb976c358078 100644 --- a/spec/lib/gitlab/request_forgery_protection_spec.rb +++ b/spec/lib/gitlab/request_forgery_protection_spec.rb @@ -13,6 +13,11 @@ } end + before do + allow(env['rack.session']).to receive(:enabled?).and_return(true) + allow(env['rack.session']).to receive(:loaded?).and_return(true) + end + it 'logs to /dev/null' do expect(ActiveSupport::Logger).to receive(:new).with(File::NULL) diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb index 0be9df41e8f936e133065bb46cb152c14190646d..7304437bc4252e56f263a50c44c4e158f743a36e 100644 --- a/spec/requests/api/helpers_spec.rb +++ b/spec/requests/api/helpers_spec.rb @@ -32,6 +32,9 @@ before do allow_any_instance_of(self.class).to receive(:options).and_return({}) + + allow(env['rack.session']).to receive(:enabled?).and_return(true) + allow(env['rack.session']).to receive(:loaded?).and_return(true) end def warden_authenticate_returns(value) @@ -567,6 +570,9 @@ def set_param(key, value) context 'using warden authentication' do before do + allow(session).to receive(:enabled?).and_return(true) + allow(session).to receive(:loaded?).and_return(true) + warden_authenticate_returns admin env[API::Helpers::SUDO_HEADER] = user.username end diff --git a/spec/support/helpers/emails_helper_test_helper.rb b/spec/support/helpers/emails_helper_test_helper.rb index ea7dbc89ebd0ba2d6c92b1be945ba72e4200cf9c..572b2f6853dfc77b974e7c2db47af505d6ab80fa 100644 --- a/spec/support/helpers/emails_helper_test_helper.rb +++ b/spec/support/helpers/emails_helper_test_helper.rb @@ -2,7 +2,7 @@ module EmailsHelperTestHelper def default_header_logo - %r{GitLab} + %r{GitLab} end end diff --git a/spec/views/layouts/_head.html.haml_spec.rb b/spec/views/layouts/_head.html.haml_spec.rb index a44c69748e5b1098b4991187cb4d051300fc1eb4..58b1830cb8a342085f404fb1b1ff39450c6c1ae9 100644 --- a/spec/views/layouts/_head.html.haml_spec.rb +++ b/spec/views/layouts/_head.html.haml_spec.rb @@ -59,7 +59,7 @@ render - expect(rendered).to match('') + expect(rendered).to match('') end context 'when an asset_host is set and snowplow url is set', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/346542' do diff --git a/vendor/gems/attr_encrypted/Gemfile.lock b/vendor/gems/attr_encrypted/Gemfile.lock index 1094e6da3fc5dc76eea67ff83b53a295459806a7..02eff672425fafb93f17b4a7bfd5fd4002a49eac 100644 --- a/vendor/gems/attr_encrypted/Gemfile.lock +++ b/vendor/gems/attr_encrypted/Gemfile.lock @@ -7,30 +7,29 @@ PATH GEM remote: https://rubygems.org/ specs: - actionpack (6.1.7) - actionview (= 6.1.7) - activesupport (= 6.1.7) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.4.1) + actionview (= 7.0.4.1) + activesupport (= 7.0.4.1) + rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actionview (6.1.7) - activesupport (= 6.1.7) + actionview (7.0.4.1) + activesupport (= 7.0.4.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activemodel (6.1.7) - activesupport (= 6.1.7) - activerecord (6.1.7) - activemodel (= 6.1.7) - activesupport (= 6.1.7) - activesupport (6.1.7) + activemodel (7.0.4.1) + activesupport (= 7.0.4.1) + activerecord (7.0.4.1) + activemodel (= 7.0.4.1) + activesupport (= 7.0.4.1) + activesupport (7.0.4.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) bcrypt (3.1.18) @@ -91,31 +90,31 @@ GEM data_objects (= 0.10.17) docile (1.4.0) encryptor (3.0.0) - erubi (1.11.0) + erubi (1.12.0) fastercsv (1.5.5) i18n (1.12.0) concurrent-ruby (~> 1.0) json (1.8.6) json_pure (1.8.6) - loofah (2.19.0) + loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) mini_portile2 (2.8.0) minitest (5.16.3) multi_json (1.15.0) - nokogiri (1.13.8) + nokogiri (1.14.0) mini_portile2 (~> 2.8.0) racc (~> 1.4) public_suffix (5.0.0) - racc (1.6.0) - rack (2.2.4) + racc (1.6.2) + rack (2.2.6.2) rack-test (2.0.2) rack (>= 1.3) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.4.3) - loofah (~> 2.3) + rails-html-sanitizer (1.5.0) + loofah (~> 2.19, >= 2.19.1) rake (13.0.6) sequel (5.60.1) simplecov (0.21.2) @@ -132,14 +131,13 @@ GEM tzinfo (2.0.5) concurrent-ruby (~> 1.0) uuidtools (2.2.0) - zeitwerk (2.6.1) PLATFORMS ruby DEPENDENCIES - actionpack (~> 6.1) - activerecord (~> 6.1) + actionpack (~> 7.0.4) + activerecord (~> 7.0.4) attr_encrypted! codeclimate-test-reporter (<= 0.6.0) datamapper diff --git a/vendor/gems/attr_encrypted/attr_encrypted.gemspec b/vendor/gems/attr_encrypted/attr_encrypted.gemspec index b6a39bddd2c71a82628493d31c39e3f6eb069194..cb12541b5d88f8ab6642337ab2bdc28fbd54f2eb 100644 --- a/vendor/gems/attr_encrypted/attr_encrypted.gemspec +++ b/vendor/gems/attr_encrypted/attr_encrypted.gemspec @@ -31,7 +31,7 @@ Forked from https://github.com/attr-encrypted/attr_encrypted." s.add_dependency('encryptor', ['~> 3.0.0']) - activerecord_version = "~> 6.1" + activerecord_version = "~> 7.0.4" s.add_development_dependency('activerecord', activerecord_version) s.add_development_dependency('actionpack', activerecord_version) s.add_development_dependency('datamapper') diff --git a/yarn.lock b/yarn.lock index 83cb3e69579235542bdaa331b835e22d0918a395..9cf3efb0b641fce3a8f6303aeff4d10ef86a38eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1688,15 +1688,15 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.5.tgz#db5a11bf66bdab39569719555b0f76e138d7bd64" integrity sha512-9X2obfABZuDVLCgPK9aX0a/x4jaOEweTTWE2+9sr0Qqqevj2Uv5XorvusThmc9XGYpS9yI+fhh8RTafBtGposw== -"@rails/actioncable@6.1.4-7": - version "6.1.4-7" - resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-6.1.4-7.tgz#da60f6c8b3ec8ec5118db877dd2e416d40e0bce6" - integrity sha512-ml1ykETFb716oDb/vivA9FNO/+nQe9s46H5Gb+24dIxhLjhYEfMAjFlTG0ASRNpZzGbIi5XMPfNZkdxM3ftK8w== - -"@rails/ujs@6.1.4-7": - version "6.1.4-7" - resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-6.1.4-7.tgz#ef0b83ef40f64bc6704e13ae6624236a4a91fa6f" - integrity sha512-842WcLh0BErNgGE8rdqNh31VnqGQcklPQ7RXzQfA0ilQNZcU7AO+t576g1m//18Lk8m7cXZ8fIKA1YB41LKWAQ== +"@rails/actioncable@7.0.4-3": + version "7.0.4-3" + resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-7.0.4-3.tgz#f352f9b481294e135818275688ae0331f9bf3b31" + integrity sha512-sqf+G/8UfoFbA8n0FwJ1Ysl5lnwRnhluWpJW50ERYAIEqeNmeADIs9J1de6S4Wp7KwmyavwzT3OSgMd9rwZ6lw== + +"@rails/ujs@7.0.4-3": + version "7.0.4-3" + resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-7.0.4-3.tgz#a90a31189db702ac7a9e95b18c09503025fb4951" + integrity sha512-JttmF98C1xTVcCSWSDwbqF0IPrCKD6lpeB9uy4VjGYniZIidgSq0fSX1vmHxCH7CuSmsIFMNJ6LtLyCAb8Y6Ng== "@remirror/core-constants@^2.0.0": version "2.0.0"