Commit 18724b07 authored by Stan Hu's avatar Stan Hu

Merge branch 'id-extract-rails-6-1-commits' into 'master'

Provide changes that fix tests for Rails 6.1

See merge request gitlab-org/gitlab!61447
parents 70d40db5 4808039c
...@@ -17,7 +17,7 @@ class UpdateHighestRoleWorker ...@@ -17,7 +17,7 @@ class UpdateHighestRoleWorker
return unless user.present? return unless user.present?
if user.active? && user.user_type.nil? && !user.internal? if user.active? && user.human? && !user.internal?
Users::UpdateHighestMemberRoleService.new(user).execute Users::UpdateHighestMemberRoleService.new(user).execute
else else
UserHighestRole.where(user_id: user_id).delete_all UserHighestRole.where(user_id: user_id).delete_all
......
# This file is created only to be able to run `derailed exec perf:mem` task
# This task loads the whole Rails application using its own initializers
...@@ -30,7 +30,7 @@ module EE ...@@ -30,7 +30,7 @@ module EE
result[project_id] = { result[project_id] = {
average_coverage: average_coverage, average_coverage: average_coverage,
coverage_count: coverage_count, coverage_count: coverage_count,
last_updated_on: date last_updated_on: Date.parse(date.to_s)
} }
end end
end end
......
...@@ -154,7 +154,7 @@ RSpec.describe EpicIssues::CreateService do ...@@ -154,7 +154,7 @@ RSpec.describe EpicIssues::CreateService do
# and we insert 5 issues instead of 1 which we do for control count # and we insert 5 issues instead of 1 which we do for control count
expect { described_class.new(epic, user, params).execute } expect { described_class.new(epic, user, params).execute }
.not_to exceed_query_limit(control_count) .not_to exceed_query_limit(control_count)
.with_threshold(28) .with_threshold(29)
end end
end end
......
...@@ -16,7 +16,7 @@ module AfterCommitQueue ...@@ -16,7 +16,7 @@ module AfterCommitQueue
def run_after_commit_or_now(&block) def run_after_commit_or_now(&block)
if Gitlab::Database.inside_transaction? if Gitlab::Database.inside_transaction?
if ActiveRecord::Base.connection.current_transaction.records.include?(self) if ActiveRecord::Base.connection.current_transaction.records&.include?(self)
run_after_commit(&block) run_after_commit(&block)
else else
# If the current transaction does not include this record, we can run # If the current transaction does not include this record, we can run
......
...@@ -19,6 +19,8 @@ module Gitlab ...@@ -19,6 +19,8 @@ module Gitlab
# polluted with other unrelated errors (e.g. state machine) # polluted with other unrelated errors (e.g. state machine)
# https://gitlab.com/gitlab-org/gitlab/-/issues/220823 # https://gitlab.com/gitlab-org/gitlab/-/issues/220823
pipeline.errors.add(:base, message) pipeline.errors.add(:base, message)
pipeline.errors.full_messages
end end
def warning(message) def warning(message)
......
...@@ -607,7 +607,7 @@ module Gitlab ...@@ -607,7 +607,7 @@ module Gitlab
unique_users_all_imports: unique_users_all_imports(time_period), unique_users_all_imports: unique_users_all_imports(time_period),
bulk_imports: { bulk_imports: {
gitlab: DEPRECATED_VALUE, gitlab: DEPRECATED_VALUE,
gitlab_v1: count(::BulkImport.where(time_period, source_type: :gitlab)) gitlab_v1: count(::BulkImport.where(**time_period, source_type: :gitlab))
}, },
project_imports: project_imports(time_period), project_imports: project_imports(time_period),
issue_imports: issue_imports(time_period), issue_imports: issue_imports(time_period),
......
...@@ -100,7 +100,8 @@ RSpec.describe InternalId do ...@@ -100,7 +100,8 @@ RSpec.describe InternalId do
context 'when executed outside of transaction' do context 'when executed outside of transaction' do
it 'increments counter with in_transaction: "false"' do it 'increments counter with in_transaction: "false"' do
expect(ActiveRecord::Base.connection).to receive(:transaction_open?) { false } allow(ActiveRecord::Base.connection).to receive(:transaction_open?) { false }
expect(InternalId::InternalIdGenerator.internal_id_transactions_total).to receive(:increment) expect(InternalId::InternalIdGenerator.internal_id_transactions_total).to receive(:increment)
.with(operation: :generate, usage: 'issues', in_transaction: 'false').and_call_original .with(operation: :generate, usage: 'issues', in_transaction: 'false').and_call_original
...@@ -158,7 +159,8 @@ RSpec.describe InternalId do ...@@ -158,7 +159,8 @@ RSpec.describe InternalId do
let(:value) { 2 } let(:value) { 2 }
it 'increments counter with in_transaction: "false"' do it 'increments counter with in_transaction: "false"' do
expect(ActiveRecord::Base.connection).to receive(:transaction_open?) { false } allow(ActiveRecord::Base.connection).to receive(:transaction_open?) { false }
expect(InternalId::InternalIdGenerator.internal_id_transactions_total).to receive(:increment) expect(InternalId::InternalIdGenerator.internal_id_transactions_total).to receive(:increment)
.with(operation: :reset, usage: 'issues', in_transaction: 'false').and_call_original .with(operation: :reset, usage: 'issues', in_transaction: 'false').and_call_original
...@@ -228,7 +230,8 @@ RSpec.describe InternalId do ...@@ -228,7 +230,8 @@ RSpec.describe InternalId do
context 'when executed outside of transaction' do context 'when executed outside of transaction' do
it 'increments counter with in_transaction: "false"' do it 'increments counter with in_transaction: "false"' do
expect(ActiveRecord::Base.connection).to receive(:transaction_open?) { false } allow(ActiveRecord::Base.connection).to receive(:transaction_open?) { false }
expect(InternalId::InternalIdGenerator.internal_id_transactions_total).to receive(:increment) expect(InternalId::InternalIdGenerator.internal_id_transactions_total).to receive(:increment)
.with(operation: :track_greatest, usage: 'issues', in_transaction: 'false').and_call_original .with(operation: :track_greatest, usage: 'issues', in_transaction: 'false').and_call_original
......
...@@ -179,7 +179,7 @@ RSpec.describe Users::BuildService do ...@@ -179,7 +179,7 @@ RSpec.describe Users::BuildService do
params.merge!({ user_type: :project_bot }) params.merge!({ user_type: :project_bot })
end end
it { expect(user.project_bot?).to be true} it { expect(user.project_bot?).to be true }
end end
context 'when not a project_bot' do context 'when not a project_bot' do
...@@ -187,7 +187,7 @@ RSpec.describe Users::BuildService do ...@@ -187,7 +187,7 @@ RSpec.describe Users::BuildService do
params.merge!({ user_type: :alert_bot }) params.merge!({ user_type: :alert_bot })
end end
it { expect(user.user_type).to be nil } it { expect(user).to be_human }
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment