Skip to content
Snippets Groups Projects
Commit d2f2fd59 authored by Aleksei Lipniagov's avatar Aleksei Lipniagov Committed by Rémy Coutable
Browse files

Fix various kwargs issues

Will extract into `master`.

Changelog: other
parent b32447be
No related branches found
No related tags found
No related merge requests found
Showing
with 69 additions and 48 deletions
Loading
Loading
@@ -72,7 +72,7 @@ def stub_last_request_id(id)
audit_event_service = instance_double(AuditEventService)
 
allow(AuditEventService).to receive(:new).and_call_original
expect(AuditEventService).to receive(:new).with(user, group, with: provider)
expect(AuditEventService).to receive(:new).with(user, group, { with: provider })
.and_return(audit_event_service)
expect(audit_event_service).to receive_message_chain(:for_authentication, :security_event)
 
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@
 
context 'when all requirements are met' do
it 'calls the finder with the restrictive scope' do
expect(SnippetsFinder).to receive(:new).with(user, authorized_and_user_personal: true).and_call_original
expect(SnippetsFinder).to receive(:new).with(user, { authorized_and_user_personal: true }).and_call_original
 
subject
end
Loading
Loading
Loading
Loading
@@ -10,9 +10,11 @@
proxy = Elastic::Latest::ProjectInstanceProxy.new(project)
 
expect(proxy.client).to receive(:index).with(
index: 'gitlab-test',
id: 'project_1',
body: proxy.as_indexed_json
{
index: 'gitlab-test',
id: 'project_1',
body: proxy.as_indexed_json
}
)
 
proxy.index_document
Loading
Loading
Loading
Loading
@@ -56,7 +56,7 @@
it 'logs the error' do
expect(Gitlab::ErrorTracking).to receive(:log_exception).with(
instance_of(Gitlab::Ci::Limit::LimitExceededError),
project_id: project.id, plan: namespace.actual_plan_name
{ project_id: project.id, plan: namespace.actual_plan_name }
)
 
subject
Loading
Loading
Loading
Loading
@@ -58,7 +58,7 @@
it 'logs the error' do
expect(Gitlab::ErrorTracking).to receive(:log_exception).with(
instance_of(Gitlab::Ci::Limit::LimitExceededError),
project_id: project.id, plan: namespace.actual_plan_name
{ project_id: project.id, plan: namespace.actual_plan_name }
)
 
subject
Loading
Loading
Loading
Loading
@@ -70,9 +70,11 @@
it 'logs the error' do
expect(Gitlab::ErrorTracking).to receive(:log_exception).with(
instance_of(Gitlab::Ci::Limit::LimitExceededError),
jobs_count: pipeline.statuses.count,
project_id: project.id, plan: namespace.actual_plan_name,
project_full_path: project.full_path, pipeline_source: pipeline.source
{
jobs_count: pipeline.statuses.count,
project_id: project.id, plan: namespace.actual_plan_name,
project_full_path: project.full_path, pipeline_source: pipeline.source
}
)
 
subject
Loading
Loading
@@ -153,9 +155,11 @@
it 'logs the pipeline' do
expect(Gitlab::ErrorTracking).to receive(:log_exception).with(
instance_of(Gitlab::Ci::Limit::LimitExceededError),
jobs_count: pipeline.statuses.count,
project_id: project.id, plan: namespace.actual_plan_name,
project_full_path: project.full_path, pipeline_source: pipeline.source
{
jobs_count: pipeline.statuses.count,
project_id: project.id, plan: namespace.actual_plan_name,
project_full_path: project.full_path, pipeline_source: pipeline.source
}
)
 
subject
Loading
Loading
Loading
Loading
@@ -27,10 +27,13 @@
it 'logs with the correct caller class' do
stub_const("Gitlab::Geo::LogCursor::Logger::PID", 111)
 
expect(::Gitlab::Logger).to receive(:debug).with(pid: 111,
class: 'Gitlab::Geo::LogCursor::Lease',
host: "localhost",
message: 'Lease renewed.')
expect(::Gitlab::Logger).to receive(:debug).with(
{
pid: 111,
class: 'Gitlab::Geo::LogCursor::Lease',
host: "localhost",
message: 'Lease renewed.'
})
 
described_class.renew!
end
Loading
Loading
Loading
Loading
@@ -32,11 +32,15 @@
 
describe '.event_info' do
it 'logs an info event' do
expect(::Gitlab::Logger).to receive(:info).with(pid: 111,
class: "LoggerSpec",
host: 'localhost',
message: 'Test',
cursor_delay_s: 0.0)
expect(::Gitlab::Logger).to receive(:info).with(
{
pid: 111,
class: "LoggerSpec",
host: 'localhost',
message: 'Test',
cursor_delay_s: 0.0
}
)
 
logger.event_info(Time.now, 'Test')
end
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@
 
context 'when the job artifact exists' do
before do
expect(::Ci::JobArtifact).to receive(:find_by).with(id: job_artifact.id).and_return(job_artifact)
expect(::Ci::JobArtifact).to receive(:find_by).with({ id: job_artifact.id }).and_return(job_artifact)
end
 
context 'when the job artifact is an archive file_type and has a file' do
Loading
Loading
@@ -37,7 +37,7 @@
end
 
it 'logs the missing file' do
expect(retriever).to receive(:log_error).with("Could not upload job artifact because it does not have a file", id: job_artifact.id)
expect(retriever).to receive(:log_error).with("Could not upload job artifact because it does not have a file", { id: job_artifact.id })
 
subject
end
Loading
Loading
Loading
Loading
@@ -14,9 +14,9 @@
expanded_key = "geo:#{key}:#{Gitlab::VERSION}:#{Rails.version}"
 
expect(Gitlab::ProcessMemoryCache.cache_backend).to receive(:write)
.with(expanded_key, an_instance_of(String), expires_in: expected_l1_expiry).and_call_original
.with(expanded_key, an_instance_of(String), { expires_in: expected_l1_expiry }).and_call_original
expect(Rails.cache).to receive(:write)
.with(expanded_key, an_instance_of(String), expires_in: expected_l2_expiry)
.with(expanded_key, an_instance_of(String), { expires_in: expected_l2_expiry })
 
described_class.public_send(method)
end
Loading
Loading
Loading
Loading
@@ -75,9 +75,9 @@
 
describe '#fail' do
it 'calls halt with failed: true' do
expect(record).to receive(:halt).with(failed: true, foo: :bar)
expect(record).to receive(:halt).with({ failed: true, foo: :bar })
 
record.fail(foo: :bar)
record.fail({ foo: :bar })
end
end
 
Loading
Loading
Loading
Loading
@@ -169,11 +169,11 @@
# Creating a confirmed user also creates an email corresponding to the user primary email
expect(::AuditEventService).to(
receive(:new)
.with(instance_of(User), instance_of(User), action: :create).and_call_original)
.with(instance_of(User), instance_of(User), { action: :create }).and_call_original)
 
expect(::AuditEventService).to(
receive(:new)
.with(instance_of(User), instance_of(User), with: auth_method, ip_address: '127.0.0.1')
.with(instance_of(User), instance_of(User), { with: auth_method, ip_address: '127.0.0.1' })
.and_return(audit_event_service))
expect(audit_event_service).to receive_message_chain(:for_authentication, :security_event)
 
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@
 
expect(MarkupHelper)
.to receive(:markdown_field)
.with(object, field, issue_iid: issue_iid, post_process_pipeline: ::Gitlab::StatusPage::Pipeline::PostProcessPipeline)
.with(object, field, { issue_iid: issue_iid, post_process_pipeline: ::Gitlab::StatusPage::Pipeline::PostProcessPipeline })
 
described_class.markdown(object, field, issue_iid: issue_iid)
end
Loading
Loading
Loading
Loading
@@ -34,7 +34,7 @@
milestone = create(:milestone, title: 'milestone', group: group)
original_issue.update!(milestone: milestone)
 
expect(new_epic).to receive(:update).with(labels: [])
expect(new_epic).to receive(:update).with({ labels: [] })
 
subject.execute
end
Loading
Loading
Loading
Loading
@@ -48,10 +48,12 @@
 
it 'logs the approval in application logs' do
expect(Gitlab::AppLogger).to receive(:info).with(
message: "Group member access approved",
group: group.id,
member: member.id,
approved_by: current_user.id
{
message: "Group member access approved",
group: group.id,
member: member.id,
approved_by: current_user.id
}
)
 
execute
Loading
Loading
@@ -163,9 +165,11 @@
 
it 'logs the approval in application logs' do
expect(Gitlab::AppLogger).to receive(:info).with(
message: "Approved all pending group members",
group: group.id,
approved_by: current_user.id
{
message: "Approved all pending group members",
group: group.id,
approved_by: current_user.id
}
)
 
execute
Loading
Loading
Loading
Loading
@@ -148,7 +148,8 @@
 
it 'parses variables from the action and applies them in configuration service' do
expect_next_instance_of(::Security::SecurityOrchestrationPolicies::CiConfigurationService) do |ci_configuration_service|
expect(ci_configuration_service).to receive(:execute).once.with(action, 'SAST_DISABLED' => nil, 'SAST_EXCLUDED_ANALYZERS' => 'semgrep').and_call_original
expect(ci_configuration_service).to receive(:execute).once
.with(action, { 'SAST_DISABLED' => nil, 'SAST_EXCLUDED_ANALYZERS' => 'semgrep' }).and_call_original
end
 
subject
Loading
Loading
Loading
Loading
@@ -37,7 +37,8 @@
 
it 'parses variables from the action and applies them in configuration service' do
expect_next_instance_of(::Security::SecurityOrchestrationPolicies::CiConfigurationService) do |ci_configuration_service|
expect(ci_configuration_service).to receive(:execute).once.with(actions.first, 'SAST_DISABLED' => nil, 'SAST_EXCLUDED_ANALYZERS' => 'semgrep').and_call_original
expect(ci_configuration_service).to receive(:execute).once
.with(actions.first, { 'SAST_DISABLED' => nil, 'SAST_EXCLUDED_ANALYZERS' => 'semgrep' }).and_call_original
end
 
subject
Loading
Loading
Loading
Loading
@@ -16,9 +16,11 @@
 
it 'passes the correct arguments' do
expect(Event).to receive(:create!).with(
group_id: group.id,
action: :created,
author_id: user.id
{
group_id: group.id,
action: :created,
author_id: user.id
}
)
 
worker.perform(group.id, user.id, :created)
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@
allow(Gitlab::GitalyClient).to receive(:call).and_call_original
allow(Gitlab::GitalyClient).to receive(:call).with(anything, :commit_service, :count_commits, anything, anything).and_raise(e = StandardError.new('_message_'))
 
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(e, caller_info: :identifiable)
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(e, { caller_info: :identifiable })
 
expect(subject).to eq(42)
end
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@
value = 'secure value'
 
expect_next_instance_of(ActionDispatch::Cookies::EncryptedKeyRotatingCookieJar) do |instance|
expect(instance).to receive(:[]=).with(key, httponly: true, secure: true, expires: expiration, value: value)
expect(instance).to receive(:[]=).with(key, { httponly: true, secure: true, expires: expiration, value: value })
end
 
helper.set_secure_cookie(key, value, httponly: true, expires: expiration, type: CookiesHelper::COOKIE_TYPE_ENCRYPTED)
Loading
Loading
@@ -22,7 +22,7 @@
value = 'permanent value'
 
expect_next_instance_of(ActionDispatch::Cookies::PermanentCookieJar) do |instance|
expect(instance).to receive(:[]=).with(key, httponly: false, secure: false, expires: nil, value: value)
expect(instance).to receive(:[]=).with(key, { httponly: false, secure: false, expires: nil, value: value })
end
 
helper.set_secure_cookie(key, value, type: CookiesHelper::COOKIE_TYPE_PERMANENT)
Loading
Loading
@@ -33,7 +33,7 @@
value = 'regular value'
 
expect_next_instance_of(ActionDispatch::Cookies::CookieJar) do |instance|
expect(instance).to receive(:[]=).with(key, httponly: false, secure: false, expires: nil, value: value)
expect(instance).to receive(:[]=).with(key, { httponly: false, secure: false, expires: nil, value: value })
end
 
helper.set_secure_cookie(key, value)
Loading
Loading
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