Skip to content

Commit

Permalink
Merged in r2-3127-offline-action-broken (pull request #6998)
Browse files Browse the repository at this point in the history
R2-3127 - Mark for Offline action broken
  • Loading branch information
dhernandez-quoin authored and pnabutovsky committed Dec 4, 2024
2 parents 4acd27a + 3bd0b65 commit 7d690a1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
9 changes: 9 additions & 0 deletions app/controllers/application_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@ def model_class
end

def record_id
return unless params[:id].is_a?(String)

params[:id]
end

def metadata_record_ids
return [] unless params[:id].present?
return [params[:id]] if params[:id].is_a?(String)

params[:id].values
end

def authorize_all!(permission, records)
records.each do |record|
authorize!(permission, record)
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/concerns/audit_log_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def default_metadata_audit_params
remote_ip: LogUtils.remote_ip(request),
agency_id: current_user.try(:agency_id),
role_id: current_user.try(:role_id),
http_method: request.method
http_method: request.method,
record_ids: metadata_record_ids
}
end

Expand Down
2 changes: 1 addition & 1 deletion spec/requests/api/v2/children_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@
user_id: fake_user_id, # This is technically wrong, but an artifact of the way we do tests
resource_url: request.url,
metadata: { user_name: fake_user_name, remote_ip: '127.0.0.1', agency_id: nil, role_id: nil,
http_method: 'GET' })
http_method: 'GET', record_ids: [@case1.id] })
end

it 'obfuscates the case name when hidden' do
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/api/v2/flags_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
user_id: fake_user_id, # This is technically wrong, but an artifact of the way we do tests
resource_url: request.url,
metadata: { user_name: fake_user_name, remote_ip: '127.0.0.1', agency_id: nil, role_id: nil,
http_method: 'POST' })
http_method: 'POST', record_ids: [] })
end
end

Expand Down
3 changes: 2 additions & 1 deletion spec/requests/api/v2/tokens_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

it 'enqueues an audit log job that records the login attempt' do
metadata = {
user_name: @user.user_name, remote_ip: '127.0.0.1', agency_id: nil, role_id: nil, http_method: 'POST'
user_name: @user.user_name, remote_ip: '127.0.0.1', agency_id: nil, role_id: nil, http_method: 'POST',
record_ids: []
}
post '/api/v2/tokens', params: @params
expect(AuditLogJob).to have_been_enqueued
Expand Down

0 comments on commit 7d690a1

Please sign in to comment.