Skip to content

Commit

Permalink
Pass User#userid instead of User#id to queue chargeback report
Browse files Browse the repository at this point in the history
The method expects the user's login and not the integer id
https://bugzilla.redhat.com/show_bug.cgi?id=1530952
  • Loading branch information
gtanzillo committed Sep 25, 2018
1 parent a0ce54f commit 8d6a862
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/api/services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def add_provider_vms_resource(type, id, data)

def queue_chargeback_report_resource(_type, id, _data)
service = resource_search(id, :services, Service)
task = service.queue_chargeback_report_generation(:userid => current_user.id)
task = service.queue_chargeback_report_generation(:userid => current_user.userid)
action_result(true, "Queued chargeback report generation for #{service_ident(service)}", :task_id => task.id)
rescue StandardError => err
action_result(false, "Could not queue chargeback report generation - #{err}")
Expand Down
11 changes: 11 additions & 0 deletions spec/requests/services_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1472,5 +1472,16 @@ def expect_svc_with_vms

expect(response).to have_http_status(:forbidden)
end

it 'can queue chargeback report for the current user' do
api_basic_authorize action_identifier(:services, :queue_chargeback_report)

post(api_service_url(nil, svc1), :params => {:action => 'queue_chargeback_report'})

expect(response).to have_http_status(:ok)

q = MiqQueue.where(:class_name => "Service", :method_name => "generate_chargeback_report").take
expect(q.args).to eq([{:userid=>"api_user_id"}])
end
end
end

0 comments on commit 8d6a862

Please sign in to comment.