Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show affected servers on PhysicalServerProvisionRequest details #5461

Merged
merged 1 commit into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,9 @@ def prov_set_show_vars
if (service_id = @miq_request.options[:src_ids].first) && (service = Service.find_by(:id => service_id)) && Rbac.filtered_object(service)
@view, @pages = get_view(Vm, :parent => service, :view_suffix => 'OrchestrationStackRetireRequest')
end
elsif @miq_request.resource_type == 'PhysicalServerProvisionRequest'
@selected_ids = @miq_request.options[:src_ids]
@view, @pages = get_view(PhysicalServer, :view_suffix => 'PhysicalServerProvisionRequest')
else
@options = @miq_request.options
@options[:memory], @options[:mem_typ] = reconfigure_calculations(@options[:vm_memory][0]) if @options[:vm_memory]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#main_div
%h3
= _("Affected Physical Servers")
- if @view
- @embedded = true
- @gtl_type = "list"
= render :partial => "layouts/gtl", :locals => {:view => @view, :no_flash_div => true}
2 changes: 2 additions & 0 deletions app/views/miq_request/_request.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
= render :partial => "service_retire_show"
- elsif @miq_request.type == "AutomationRequest"
= render :partial => "ae_prov_show"
- elsif @miq_request.type == "PhysicalServerProvisionRequest"
= render :partial => "physical_server_provision_show"
- else
= render :partial => "reconfigure_show"

50 changes: 50 additions & 0 deletions spec/controllers/miq_request_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,56 @@
end
end

context 'showing details of a physical server provisioning task' do
before do
@user = stub_admin
EvmSpecHelper.create_guid_miq_server_zone
end

let(:server1) { FactoryBot.create(:physical_server) }
let(:server2) { FactoryBot.create(:physical_server) } # not part of request
let(:request) do
FactoryBot.create(:physical_server_provision_request,
:type => 'PhysicalServerProvisionRequest',
:requester => @user,
:options => {:src_ids => [server1.id]})
end

let(:payload) { { :model_name => 'PhysicalServer', additional_key => additional_val } }
let(:additional_val) do
{
:model => 'PhysicalServer',
:view_suffix => 'PhysicalServerProvisionRequest',
:display => 'main',
:gtl_type => 'list'
}
end

context 'angular for grid with affected PhysicalServers is properly initialized' do
let(:additional_key) { :report_data_additional_options }
it do
expect(controller).to receive(:prov_set_show_vars).once.and_call_original

# Verify Rails correctly initializes Angular which will then perform POST /report_data to fetch the PhysicalServers.
expect_any_instance_of(GtlHelper).to receive(:render_gtl).with match_gtl_options(**payload)

get :show, :params => {:id => request.id}
expect(response.status).to eq(200)
end
end

context 'angular for grid with affected PhysicalServers gets the correct objects with XHR call' do
let(:additional_key) { :additional_options }
it do
post :report_data, :params => payload.merge(:records => [server1.id])
expect(response.status).to eq(200)

# Verify Angular got correct PhysicalServers when sending the payload as set by previous test.
expect(JSON.parse(response.body).dig('data', 'rows').map { |row| row['id'] }).to eq([server1.id.to_s])
end
end
end

context "#edit_button" do
before do
stub_user(:features => :all)
Expand Down