Skip to content

Fix test failures of spec/models/user_spec.rb and jh/spec/features/users/signup_spec.rb

张泽华请求将fix/user-spec合并到main-jh

1. spec/models/user_spec.rb

These tests failed because we removed search term length limits on JH side, so I skipped them.

Failures:
  1) User.search name matching returns users with a exact matching name shorter than 3 chars
     Failure/Error: expect(described_class.search(user3.name)).to eq([user3])
       expected: [#<User id:347 @se>]
            got: #<ActiveRecord::Relation [#<User id:347 @se>, #<User id:345 @usern>, #<User id:346 @username>]>
       (compared using ==)
       Diff:
       @@ -1 +1 @@
       -[#<User id:347 @se>]
       +[#<User id:347 @se>, #<User id:345 @usern>, #<User id:346 @username>]
     # ./spec/models/user_spec.rb:2670:in `block (4 levels) in <top (required)>'
     # ./spec/spec_helper.rb:423:in `block (3 levels) in <top (required)>'
     # ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
     # ./spec/spec_helper.rb:414:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
     # ./lib/gitlab/application_context.rb:45:in `with_raw_context'
     # ./spec/spec_helper.rb:410:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:267:in `block (2 levels) in <top (required)>'
     # ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/support/flaky_tests.rb:27:in `block (2 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (3 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <top (required)>'
     # ./jh/spec/spec_helper.rb:15:in `block (2 levels) in <top (required)>'
  2) User.search name matching returns users with a exact matching name shorter than 3 chars regardless of the casing
     Failure/Error: expect(described_class.search(user3.name.upcase)).to eq([user3])
       expected: [#<User id:347 @se>]
            got: #<ActiveRecord::Relation [#<User id:347 @se>, #<User id:345 @usern>, #<User id:346 @username>]>
       (compared using ==)
       Diff:
       @@ -1 +1 @@
       -[#<User id:347 @se>]
       +[#<User id:347 @se>, #<User id:345 @usern>, #<User id:346 @username>]
     # ./spec/models/user_spec.rb:2674:in `block (4 levels) in <top (required)>'
     # ./spec/spec_helper.rb:423:in `block (3 levels) in <top (required)>'
     # ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
     # ./spec/spec_helper.rb:414:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
     # ./lib/gitlab/application_context.rb:45:in `with_raw_context'
     # ./spec/spec_helper.rb:410:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:267:in `block (2 levels) in <top (required)>'
     # ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/support/flaky_tests.rb:27:in `block (2 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (3 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <top (required)>'
     # ./jh/spec/spec_helper.rb:15:in `block (2 levels) in <top (required)>'
  3) User.search username matching returns users with a exact matching username shorter than 3 chars
     Failure/Error: expect(described_class.search(user3.username)).to eq([user3])
       expected: [#<User id:347 @se>]
            got: #<ActiveRecord::Relation [#<User id:347 @se>, #<User id:345 @usern>, #<User id:346 @username>]>
       (compared using ==)
       Diff:
       @@ -1 +1 @@
       -[#<User id:347 @se>]
       +[#<User id:347 @se>, #<User id:345 @usern>, #<User id:346 @username>]
     # ./spec/models/user_spec.rb:2735:in `block (4 levels) in <top (required)>'
     # ./spec/spec_helper.rb:423:in `block (3 levels) in <top (required)>'
     # ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
     # ./spec/spec_helper.rb:414:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
     # ./lib/gitlab/application_context.rb:45:in `with_raw_context'
     # ./spec/spec_helper.rb:410:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:267:in `block (2 levels) in <top (required)>'
     # ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/support/flaky_tests.rb:27:in `block (2 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (3 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <top (required)>'
     # ./jh/spec/spec_helper.rb:15:in `block (2 levels) in <top (required)>'
  4) User.search username matching returns users with a exact matching username shorter than 3 chars regardless of the casing
     Failure/Error: expect(described_class.search(user3.username.upcase)).to eq([user3])
       expected: [#<User id:347 @se>]
            got: #<ActiveRecord::Relation [#<User id:347 @se>, #<User id:345 @usern>, #<User id:346 @username>]>
       (compared using ==)
       Diff:
       @@ -1 +1 @@
       -[#<User id:347 @se>]
       +[#<User id:347 @se>, #<User id:345 @usern>, #<User id:346 @username>]
     # ./spec/models/user_spec.rb:2739:in `block (4 levels) in <top (required)>'
     # ./spec/spec_helper.rb:423:in `block (3 levels) in <top (required)>'
     # ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
     # ./spec/spec_helper.rb:414:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
     # ./lib/gitlab/application_context.rb:45:in `with_raw_context'
     # ./spec/spec_helper.rb:410:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:267:in `block (2 levels) in <top (required)>'
     # ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/support/flaky_tests.rb:27:in `block (2 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (3 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <top (required)>'
     # ./jh/spec/spec_helper.rb:15:in `block (2 levels) in <top (required)>'
  5) User.user_search_minimum_char_limit returns true
     Failure/Error: expect(described_class.user_search_minimum_char_limit).to be(true)
       expected true
            got false
     # ./spec/models/user_spec.rb:2760:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:423:in `block (3 levels) in <top (required)>'
     # ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
     # ./spec/spec_helper.rb:414:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
     # ./lib/gitlab/application_context.rb:45:in `with_raw_context'
     # ./spec/spec_helper.rb:410:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:267:in `block (2 levels) in <top (required)>'
     # ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
     # ./spec/support/flaky_tests.rb:27:in `block (2 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (3 levels) in <top (required)>'
     # ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <top (required)>'
     # ./jh/spec/spec_helper.rb:15:in `block (2 levels) in <top (required)>'
Finished in 18 minutes 23 seconds (files took 47.9 seconds to load)
4565 examples, 5 failures, 30 pending
Failed examples:
rspec ./spec/models/user_spec.rb:2669 # User.search name matching returns users with a exact matching name shorter than 3 chars
rspec ./spec/models/user_spec.rb:2673 # User.search name matching returns users with a exact matching name shorter than 3 chars regardless of the casing
rspec ./spec/models/user_spec.rb:2734 # User.search username matching returns users with a exact matching username shorter than 3 chars
rspec ./spec/models/user_spec.rb:2738 # User.search username matching returns users with a exact matching username shorter than 3 chars regardless of the casing
rspec ./spec/models/user_spec.rb:2759 # User.user_search_minimum_char_limit returns true

2. jh/spec/features/users/signup_spec.rb

This test failure is due to the user registration, the phone number of the inserted into the database is encrypted, and database limit is less than 50 characters, used in the test method let(:phone_number) { FFaker::PhoneNumber.phone_number} can sometimes generate longer phone number, after the encryption will be longer than 50 characters, cause the failure of the test, so I change the method to let(:phone_number) { FFaker::PhoneNumber.short_phone_number}

Failures:

  1) Users::Signup #form_validation when it is JH COM when matching password complexity returns that user signed up
     Failure/Error: connection.send(...)

     ActiveRecord::StatementInvalid:
       PG::CheckViolation: ERROR:  new row for relation "user_details" violates check constraint "check_a73b398c60"
       DETAIL:  Failing row contains (19, , , null, null, null, null, null, null, LPujOtTdOK3+dsbdRZPYW697nR2iuCJiH39sFwoSTWlMRnpboFI=, f).
     # ./lib/gitlab/database/load_balancing/connection_proxy.rb:126:in `block in write_using_load_balancer'
     # ./lib/gitlab/database/load_balancing/load_balancer.rb:112:in `block in read_write'
     # ./lib/gitlab/database/load_balancing/load_balancer.rb:172:in `retry_with_backoff'
     # ./lib/gitlab/database/load_balancing/load_balancer.rb:110:in `read_write'
     # ./lib/gitlab/database/load_balancing/connection_proxy.rb:125:in `write_using_load_balancer'
     # ./lib/gitlab/database/load_balancing/connection_proxy.rb:67:in `block (2 levels) in <class:ConnectionProxy>'
     # ./lib/gitlab/database/load_balancing/connection_proxy.rb:126:in `block in write_using_load_balancer'
     # ./lib/gitlab/database/load_balancing/load_balancer.rb:112:in `block in read_write'
     # ./lib/gitlab/database/load_balancing/load_balancer.rb:172:in `retry_with_backoff'
     # ./lib/gitlab/database/load_balancing/load_balancer.rb:110:in `read_write'
     # ./lib/gitlab/database/load_balancing/connection_proxy.rb:125:in `write_using_load_balancer'
     # ./lib/gitlab/database/load_balancing/connection_proxy.rb:77:in `transaction'
     # ./lib/gitlab/database/load_balancing/connection_proxy.rb:126:in `block in write_using_load_balancer'
     # ./lib/gitlab/database/load_balancing/load_balancer.rb:112:in `block in read_write'
     # ./lib/gitlab/database/load_balancing/load_balancer.rb:172:in `retry_with_backoff'
     # ./lib/gitlab/database/load_balancing/load_balancer.rb:110:in `read_write'
     # ./lib/gitlab/database/load_balancing/connection_proxy.rb:125:in `write_using_load_balancer'
     # ./lib/gitlab/database/load_balancing/connection_proxy.rb:77:in `transaction'
     # ./app/controllers/registrations_controller.rb:34:in `create'
     # ./ee/lib/gitlab/ip_address_state.rb:10:in `with'
     # ./ee/app/controllers/ee/application_controller.rb:45:in `set_current_ip_address'
     # ./app/controllers/application_controller.rb:500:in `set_current_admin'
     # ./lib/gitlab/session.rb:11:in `with_session'
     # ./app/controllers/application_controller.rb:490:in `set_session_storage'
     # ./lib/gitlab/i18n.rb:105:in `with_locale'
     # ./lib/gitlab/i18n.rb:111:in `with_user_locale'
     # ./app/controllers/application_controller.rb:484:in `set_locale'
     # ./app/controllers/application_controller.rb:478:in `set_current_context'
     # ./lib/gitlab/middleware/memory_report.rb:13:in `call'
     # ./lib/gitlab/middleware/speedscope.rb:13:in `call'
     # ./lib/gitlab/request_profiler/middleware.rb:17:in `call'
     # ./lib/gitlab/query_limiting/middleware.rb:17:in `block in call'
     # ./lib/gitlab/query_limiting/transaction.rb:40:in `run'
     # ./lib/gitlab/query_limiting/middleware.rb:16:in `call'
     # ./lib/gitlab/database/load_balancing/rack_middleware.rb:23:in `call'
     # ./lib/gitlab/jira/middleware.rb:19:in `call'
     # ./lib/gitlab/middleware/go.rb:20:in `call'
     # ./lib/gitlab/etag_caching/middleware.rb:21:in `call'
     # ./lib/gitlab/middleware/query_analyzer.rb:11:in `block in call'
     # ./lib/gitlab/database/query_analyzer.rb:40:in `within'
     # ./lib/gitlab/middleware/query_analyzer.rb:11:in `call'
     # ./lib/gitlab/middleware/multipart.rb:173:in `call'
     # ./lib/gitlab/middleware/read_only/controller.rb:50:in `call'
     # ./lib/gitlab/middleware/read_only.rb:18:in `call'
     # ./lib/gitlab/middleware/same_site_cookies.rb:27:in `call'
     # ./lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'
     # ./lib/gitlab/middleware/basic_health_check.rb:25:in `call'
     # ./lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'
     # ./lib/gitlab/middleware/request_context.rb:21:in `call'
     # ./lib/gitlab/middleware/webhook_recursion_detection.rb:15:in `call'
     # ./config/initializers/fix_local_cache_middleware.rb:11:in `call'
     # ./lib/gitlab/middleware/compressed_json.rb:26:in `call'
     # ./lib/gitlab/middleware/static.rb:11:in `call'
     # ./lib/gitlab/testing/clear_process_memory_cache_middleware.rb:13:in `call'
     # ./lib/gitlab/testing/request_inspector_middleware.rb:35:in `call'
     # ./lib/gitlab/testing/robots_blocker_middleware.rb:30:in `call'
     # ./lib/gitlab/testing/request_blocker_middleware.rb:47:in `call'
     # ./lib/gitlab/middleware/rack_multipart_tempfile_factory.rb:19:in `call'
     # ./lib/gitlab/middleware/sidekiq_web_static.rb:20:in `call'
     # ./lib/gitlab/metrics/requests_rack_middleware.rb:77:in `call'
     # ./jh/spec/features/users/signup_spec.rb:100:in `block (5 levels) in <top (required)>'
     # ./spec/spec_helper.rb:423:in `block (3 levels) in <top (required)>'
     # ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
     # ./spec/spec_helper.rb:414:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:410:in `block (3 levels) in <top (required)>'
     # ./lib/gitlab/application_context.rb:45:in `with_raw_context'
     # ./spec/spec_helper.rb:410:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:267:in `block (2 levels) in <top (required)>'
     # ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (3 levels) in <main>'
     # ./spec/support/database/prevent_cross_joins.rb:60:in `with_cross_joins_prevented'
     # ./spec/support/database/prevent_cross_joins.rb:106:in `block (2 levels) in <main>'
     # ./jh/spec/spec_helper.rb:15:in `block (2 levels) in <main>'
     # ------------------
     # --- Caused by: ---
     # PG::CheckViolation:
     #   ERROR:  new row for relation "user_details" violates check constraint "check_a73b398c60"
     #   DETAIL:  Failing row contains (19, , , null, null, null, null, null, null, LPujOtTdOK3+dsbdRZPYW697nR2iuCJiH39sFwoSTWlMRnpboFI=, f).
     #   ./lib/gitlab/database/load_balancing/connection_proxy.rb:126:in `block in write_using_load_balancer'

image

张泽华 编辑于

合并请求报告

加载中