-
Notifications
You must be signed in to change notification settings - Fork 120
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
Refactoring update_serviceprovision_status method #19
Merged
mkanoor
merged 4 commits into
ManageIQ:master
from
pkomanek:refactoring_update_serviceprovision_status
Jan 27, 2017
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
573e16a
Refactoring Cloud Orchestration update_serviceprovision_status.
pkomanek 111d4a8
Refactoring Ansibletower update_serviceprovision_status.
pkomanek 78ffe23
Refactoring Service update_serviceprovision_status.
pkomanek 236a9df
Removing the old spec.
pkomanek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 0 additions & 102 deletions
102
spec/automation/unit/method_validation/update_service_provision_status_orchestration_spec.rb
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
...isioning/StateMachines/Provision.class/__methods__/update_serviceprovision_status_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
require_domain_file | ||
|
||
describe ManageIQ::Automate::Cloud::Orchestration::Provisioning::StateMachines::UpdateServiceProvisionStatus do | ||
let(:user) { FactoryGirl.create(:user_with_group) } | ||
let(:miq_server) { EvmSpecHelper.local_miq_server } | ||
let(:service_orchestration) { FactoryGirl.create(:service_orchestration) } | ||
|
||
let(:miq_request_task) do | ||
FactoryGirl.create(:miq_request_task, :destination => service_orchestration, | ||
:miq_request => request, :state => 'fred') | ||
end | ||
|
||
let(:request) do | ||
FactoryGirl.create(:service_template_provision_request, :requester => user) | ||
end | ||
|
||
let(:ae_service) do | ||
Spec::Support::MiqAeMockService.new(root_object).tap do |service| | ||
current_object = Spec::Support::MiqAeMockObject.new | ||
current_object.parent = root_object | ||
service.object = current_object | ||
end | ||
end | ||
|
||
let(:svc_model_miq_server) { MiqAeMethodService::MiqAeServiceMiqServer.find(miq_server.id) } | ||
let(:svc_model_miq_request_task) { MiqAeMethodService::MiqAeServiceMiqRequestTask.find(miq_request_task.id) } | ||
let(:svc_model_service) { MiqAeMethodService::MiqAeServiceService.find(service_orchestration.id) } | ||
let(:svc_model_request) do | ||
MiqAeMethodService::MiqAeServiceServiceTemplateProvisionRequest.find(request.id) | ||
end | ||
|
||
context "with a stp request object" do | ||
let(:root_hash) do | ||
{ 'service_template' => MiqAeMethodService::MiqAeServiceService.find(service_orchestration.id) } | ||
end | ||
|
||
let(:root_object) do | ||
obj = Spec::Support::MiqAeMockObject.new(root_hash) | ||
obj["service_template_provision_task"] = svc_model_miq_request_task | ||
obj["miq_server"] = svc_model_miq_server | ||
obj | ||
end | ||
|
||
before do | ||
allow(ae_service).to receive(:inputs) { {'status' => "fred"} } | ||
allow(svc_model_miq_request_task).to receive(:destination) { svc_model_service } | ||
ae_service.root['ae_result'] = 'ok' | ||
end | ||
|
||
it "method succeeds" do | ||
described_class.new(ae_service).main | ||
expect(svc_model_request.reload.status).to eq('Ok') | ||
end | ||
|
||
it "request message set properly" do | ||
described_class.new(ae_service).main | ||
msg = "Server [#{miq_server.name}] Service [#{service_orchestration.name}] Step [] Status [fred] Message [] " | ||
expect(svc_model_request.reload.message).to eq(msg) | ||
end | ||
end | ||
|
||
context "without a stp request object" do | ||
let(:root_hash) { {} } | ||
let(:root_object) { Spec::Support::MiqAeMockObject.new(root_hash) } | ||
|
||
it "method fails" do | ||
expect { described_class.new(ae_service).main }.to raise_error( | ||
"Service Template Provision Task not provided" | ||
) | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pkomanek can this be module ServiceProvisionTemplate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pkomanek I am not sure if thats because of an internal naming issue. We might have to leave it as ServiceProvision_Template. @tinaafitz can you comment on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkanoor @pkomanek It is an internal naming issue, so we have to leave the name as ServiceProvision_Template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/ManageIQ/manageiq/blob/master/app/models/service_template.rb#L262
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/ManageIQ/manageiq/blob/master/app/models/service_template_provision_task.rb#L123