Skip to content
Snippets Groups Projects
Verified Commit 28736549 authored by Igor Drozdov's avatar Igor Drozdov :two: Committed by GitLab
Browse files

FIx tests related to Rails 7.1 upgrade

parent eba7dc6e
No related branches found
No related tags found
1 merge request!163661FIx tests related to Rails 7.1 upgrade
Showing
with 114 additions and 81 deletions
......@@ -208,7 +208,7 @@
{"name":"gettext","version":"3.4.9","platform":"ruby","checksum":"292864fe6a15c224cee4125a4a72fab426fdbb280e4cff3cfe44935f549b009a"},
{"name":"gettext_i18n_rails","version":"1.12.0","platform":"ruby","checksum":"6ac4817731a9e2ce47e1e83381ac34f9142263bc2911aaaafb2526d2f1afc1be"},
{"name":"git","version":"1.18.0","platform":"ruby","checksum":"c9b80462e4565cd3d7a9ba8440c41d2c52244b17b0dad0bfddb46de70630c465"},
{"name":"gitaly","version":"17.2.1","platform":"ruby","checksum":"8f883bd7ed81d06924704026b43f3e2da55e137e75f9c6ff8b8f6497c61c9d66"},
{"name":"gitaly","version":"17.4.0.pre.rc1","platform":"ruby","checksum":"72c69dfa77871be78dd2e017be3131b9515b396d779df5785f77df291219f7b3"},
{"name":"gitlab","version":"4.19.0","platform":"ruby","checksum":"3f645e3e195dbc24f0834fbf83e8ccfb2056d8e9712b01a640aad418a6949679"},
{"name":"gitlab-chronic","version":"0.10.5","platform":"ruby","checksum":"f80f18dc699b708870a80685243331290bc10cfeedb6b99c92219722f729c875"},
{"name":"gitlab-dangerfiles","version":"4.8.0","platform":"ruby","checksum":"b327d079552ec974a63bf34d749a0308425af6ebf51d01064f1a6ff216a523db"},
......
......@@ -711,7 +711,7 @@ GEM
git (1.18.0)
addressable (~> 2.8)
rchardet (~> 1.8)
gitaly (17.2.1)
gitaly (17.4.0.pre.rc1)
grpc (~> 1.0)
gitlab (4.19.0)
httparty (~> 0.20)
......@@ -2068,7 +2068,7 @@ DEPENDENCIES
gdk-toogle (~> 0.9, >= 0.9.5)
gettext (~> 3.4, >= 3.4.9)
gettext_i18n_rails (~> 1.12.0)
gitaly (~> 17.2.0)
gitaly (~> 17.4.0.pre.rc1)
gitlab-backup-cli!
gitlab-chronic (~> 0.10.5)
gitlab-dangerfiles (~> 4.8.0)
......
......@@ -31,7 +31,7 @@ def partitioned_by(partitioning_key, strategy:, **kwargs)
def _returning_columns_for_insert
auto_populated_columns = []
auto_populated_columns = super if Gitlab.next_rails?
auto_populated_columns.empty? ? Array(primary_key) : auto_populated_columns
auto_populated_columns + Array(primary_key)
end
end
end
......@@ -20,6 +20,7 @@
module Gitlab
class Application < Rails::Application
config.load_defaults 7.0
# This section contains configuration from Rails upgrades to override the new defaults so that we
# keep existing behavior.
#
......@@ -37,7 +38,6 @@ class Application < Rails::Application
config.active_record.automatic_scope_inversing = nil # New default is true
config.active_record.verify_foreign_keys_for_fixtures = nil # New default is true
config.active_record.partial_inserts = true # New default is false
config.active_support.cache_format_version = nil # New default is 7.0
config.active_support.disable_to_s_conversion = false # New default is true
config.active_support.executor_around_test_case = nil # New default is true
config.active_support.isolation_level = nil # New default is thread
......@@ -46,7 +46,6 @@ class Application < Rails::Application
# Rails 6.1
config.action_dispatch.cookies_same_site_protection = nil # New default is :lax
ActiveSupport.utc_to_local_returns_utc_offset_times = false
config.action_view.preload_links_header = false
# Rails 5.2
......@@ -90,6 +89,11 @@ class Application < Rails::Application
require_dependency Rails.root.join('lib/gitlab/patch/old_redis_cache_store')
require_dependency Rails.root.join('lib/gitlab/exceptions_app')
unless ::Gitlab.next_rails?
config.active_support.cache_format_version = nil
ActiveSupport.utc_to_local_returns_utc_offset_times = false
end
config.exceptions_app = Gitlab::ExceptionsApp.new(Gitlab.jh? ? Rails.root.join('jh/public') : Rails.public_path)
# This preload is required to:
......
......@@ -233,6 +233,14 @@
end
end
# This test fails with Rails 7.0.8 + rails-dom-testing 2.2.0
# However it passes with:
# - Rails 7.0.8 + rails-dom-testing 2.0.3
# - Rails 7.1.3 + rails-dom-testing 2.2.0
#
# TODO: Either investigate it on rails-dom-testing gem upgrade or remove this comment after 7.1.3 upgrade
#
# Related to Gitlab.next_rails?
describe '.show_joining_a_project_alert?', feature_category: :onboarding do
where(:cookie_present?, :onboarding?, :user_dismissed_callout?, :expected_result) do
true | true | true | false
......
......@@ -37,7 +37,7 @@
let(:vulnerability_state_transitions) { table(:vulnerability_state_transitions) }
let(:security_scans) { table(:security_scans) }
let(:security_findings) { table(:security_findings, primary_key: :id) }
let(:ci_builds) { table(:p_ci_builds, database: :ci) { |model| model.primary_key = :id } }
let(:ci_builds) { partitioned_table(:p_ci_builds, database: :ci) }
let(:ci_job_artifacts) { table(:ci_job_artifacts, database: :ci) }
let(:ci_pipelines) { table(:ci_pipelines, primary_key: :id, database: :ci) }
......
......@@ -31,7 +31,7 @@
let(:vulnerability_feedback) { table(:vulnerability_feedback) }
let(:security_scans) { table(:security_scans) }
let(:security_findings) { table(:security_findings, primary_key: :id) }
let(:ci_builds) { table(:p_ci_builds, database: :ci) { |model| model.primary_key = :id } }
let(:ci_builds) { partitioned_table(:p_ci_builds, database: :ci) }
let(:ci_pipelines) { table(:ci_pipelines, primary_key: :id, database: :ci) }
let(:ci_job_artifacts) { table(:ci_job_artifacts, database: :ci) }
......
......@@ -29,10 +29,8 @@
metric_type: :gauge_type,
issue: issue
)
duplicate = build_stubbed(:observability_metrics_issues_connection,
metric_name: 'test_metric',
metric_type: :gauge_type,
issue: issue
duplicate = build(:observability_metrics_issues_connection,
metric_name: 'test_metric', metric_type: :gauge_type, issue: issue
)
expect(duplicate).not_to be_valid
expect(duplicate.errors[:metric_name]).to include(_('and metric_type combination must be unique per issue'))
......
......@@ -34,72 +34,72 @@ PATH
gitlab-database-load_balancing (0.1.0)
gitlab-net-dns (~> 0.9.2)
pg (~> 1.5.4)
rails (~> 7.0.8)
rails (>= 7)
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.8)
actionpack (= 7.0.8)
activesupport (= 7.0.8)
actioncable (7.0.8.4)
actionpack (= 7.0.8.4)
activesupport (= 7.0.8.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.8)
actionpack (= 7.0.8)
activejob (= 7.0.8)
activerecord (= 7.0.8)
activestorage (= 7.0.8)
activesupport (= 7.0.8)
actionmailbox (7.0.8.4)
actionpack (= 7.0.8.4)
activejob (= 7.0.8.4)
activerecord (= 7.0.8.4)
activestorage (= 7.0.8.4)
activesupport (= 7.0.8.4)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.8)
actionpack (= 7.0.8)
actionview (= 7.0.8)
activejob (= 7.0.8)
activesupport (= 7.0.8)
actionmailer (7.0.8.4)
actionpack (= 7.0.8.4)
actionview (= 7.0.8.4)
activejob (= 7.0.8.4)
activesupport (= 7.0.8.4)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.8)
actionview (= 7.0.8)
activesupport (= 7.0.8)
actionpack (7.0.8.4)
actionview (= 7.0.8.4)
activesupport (= 7.0.8.4)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.8)
actionpack (= 7.0.8)
activerecord (= 7.0.8)
activestorage (= 7.0.8)
activesupport (= 7.0.8)
actiontext (7.0.8.4)
actionpack (= 7.0.8.4)
activerecord (= 7.0.8.4)
activestorage (= 7.0.8.4)
activesupport (= 7.0.8.4)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.8)
activesupport (= 7.0.8)
actionview (7.0.8.4)
activesupport (= 7.0.8.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.8)
activesupport (= 7.0.8)
activejob (7.0.8.4)
activesupport (= 7.0.8.4)
globalid (>= 0.3.6)
activemodel (7.0.8)
activesupport (= 7.0.8)
activerecord (7.0.8)
activemodel (= 7.0.8)
activesupport (= 7.0.8)
activestorage (7.0.8)
actionpack (= 7.0.8)
activejob (= 7.0.8)
activerecord (= 7.0.8)
activesupport (= 7.0.8)
activemodel (7.0.8.4)
activesupport (= 7.0.8.4)
activerecord (7.0.8.4)
activemodel (= 7.0.8.4)
activesupport (= 7.0.8.4)
activestorage (7.0.8.4)
actionpack (= 7.0.8.4)
activejob (= 7.0.8.4)
activerecord (= 7.0.8.4)
activesupport (= 7.0.8.4)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.8)
activesupport (7.0.8.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
......@@ -172,20 +172,20 @@ GEM
rack (2.2.8)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8)
actioncable (= 7.0.8)
actionmailbox (= 7.0.8)
actionmailer (= 7.0.8)
actionpack (= 7.0.8)
actiontext (= 7.0.8)
actionview (= 7.0.8)
activejob (= 7.0.8)
activemodel (= 7.0.8)
activerecord (= 7.0.8)
activestorage (= 7.0.8)
activesupport (= 7.0.8)
rails (7.0.8.4)
actioncable (= 7.0.8.4)
actionmailbox (= 7.0.8.4)
actionmailer (= 7.0.8.4)
actionpack (= 7.0.8.4)
actiontext (= 7.0.8.4)
actionview (= 7.0.8.4)
activejob (= 7.0.8.4)
activemodel (= 7.0.8.4)
activerecord (= 7.0.8.4)
activestorage (= 7.0.8.4)
activesupport (= 7.0.8.4)
bundler (>= 1.15.0)
railties (= 7.0.8)
railties (= 7.0.8.4)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
......@@ -193,9 +193,9 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.0.8)
actionpack (= 7.0.8)
activesupport (= 7.0.8)
railties (7.0.8.4)
actionpack (= 7.0.8.4)
activesupport (= 7.0.8.4)
method_source
rake (>= 12.2)
thor (~> 1.0)
......
......@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'gitlab-net-dns', '~> 0.9.2'
spec.add_runtime_dependency "pg", '~> 1.5.4'
spec.add_runtime_dependency 'rails', '~> 7.0.8'
spec.add_runtime_dependency 'rails', '>= 7'
spec.add_development_dependency "gitlab-styles", "~> 10.1.0"
spec.add_development_dependency "pg", '~> 1.5.4'
......
......@@ -15,7 +15,7 @@
)
end
let(:audit_events) { table(:audit_events) }
let(:audit_events) { partitioned_table(:audit_events) }
let(:attributes) do
{ author_id: 1,
entity_id: 2,
......
......@@ -3,11 +3,11 @@
require 'spec_helper'
RSpec.describe Gitlab::BackgroundMigration::BackfillNewAuditEventTables, feature_category: :audit_events do
let(:audit_events_table) { table(:audit_events) }
let(:project_audit_events_table) { table(:project_audit_events) }
let(:group_audit_events_table) { table(:group_audit_events) }
let(:user_audit_events_table) { table(:user_audit_events) }
let(:instance_audit_events_table) { table(:instance_audit_events) }
let(:audit_events_table) { partitioned_table(:audit_events) }
let(:project_audit_events_table) { partitioned_table(:project_audit_events) }
let(:group_audit_events_table) { partitioned_table(:group_audit_events) }
let(:user_audit_events_table) { partitioned_table(:user_audit_events) }
let(:instance_audit_events_table) { partitioned_table(:instance_audit_events) }
let!(:project_audit_event) do
audit_events_table.create!(
......
......@@ -550,6 +550,32 @@ def subscribe_events
event = events.first
expect(event).not_to be_nil
expect(event.duration).to be > 0.0
unless ::Gitlab.next_rails?
expect(event.payload).to a_hash_including(
connection: be_a(Gitlab::Database::LoadBalancing::ConnectionProxy)
)
end
end
end
unless ::Gitlab.next_rails?
context 'within an empty transaction block' do
it 'publishes a transaction event' do
events = subscribe_events do
ApplicationRecord.transaction {}
Ci::ApplicationRecord.transaction {}
end
expect(events.length).to be(2)
event = events.first
expect(event).not_to be_nil
expect(event.duration).to be > 0.0
expect(event.payload).to a_hash_including(
connection: be_a(Gitlab::Database::LoadBalancing::ConnectionProxy)
)
end
end
end
......
......@@ -27,14 +27,11 @@
subject(:execute) { service.execute }
def versions
schema_table =
if ::Gitlab.next_rails?
connection.schema_migration
else
ActiveRecord::SchemaMigration
end
schema_table.where(version: version).count
if ::Gitlab.next_rails?
connection.schema_migration.versions.count { |v| v == version.to_s }
else
ActiveRecord::SchemaMigration.where(version: version).count
end
end
it 'marks the migration as successful' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment