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

Refactoring service retirement start_retirement method. #538

Conversation

billfitzgerald0120
Copy link
Contributor

Refactoring Service/Retirement/StateMachines/Methods.class/methods/start_retirement.rb method with spec. This PR is based on the issue below.

#8

@miq-bot add_label refactoring

@coveralls
Copy link

coveralls commented May 21, 2019

Pull Request Test Coverage Report for Build 3260

  • 23 of 26 (88.46%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.08%) to 96.859%

Changes Missing Coverage Covered Lines Changed/Added Lines %
content/automate/ManageIQ/Service/Retirement/StateMachines/Methods.class/methods/start_retirement.rb 23 26 88.46%
Totals Coverage Status
Change from base Build 3235: -0.08%
Covered Lines: 2960
Relevant Lines: 3056

💛 - Coveralls

MiqAeMethodService::MiqAeServiceServiceRetireRequest.find(request.id)
end

it "#start_retirement is nil and service is retiring" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make this more descriptive.

expect(service.retired?).to be_truthy
end

it "starts retirement" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not test anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to test the good condition. Retirement_state is nil and then I start retirement and the retirement_state is equal to retiring.

def service
@service ||= @handle.root["service"].tap do |service|
if service.nil?
@handle.log(:error, 'Service Object not found')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems perfect places to use ManageIQ::Automate::System::CommonMethods::Utils::LogObject.log_and_raise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to do this in a followup PR

Refactoring Service/Retirement/StateMachines/Methods.class/methods/start_retirement.rb method with spec. This PR is based on the issue below.

ManageIQ#8

@miq-bot add_label refactoring
Made labels more descriptive and removed some useless tests as requested
@billfitzgerald0120 billfitzgerald0120 force-pushed the service_start_retirement_refactor branch from fa47176 to 5559748 Compare June 27, 2019 18:22
@billfitzgerald0120 billfitzgerald0120 changed the title [WIP] Refactoring service retirement start_retirement method. Refactoring service retirement start_retirement method. Jun 27, 2019
@miq-bot miq-bot removed the wip label Jul 2, 2019
@miq-bot
Copy link
Member

miq-bot commented Jul 2, 2019

Checked commits billfitzgerald0120/manageiq-content@5559748~...b5c57e5 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

end

it "starts retirement" do
allow(ae_service).to receive(:create_notification)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a test, then it should be expect instead of allow. Otherwise this is not testing anything.

@billfitzgerald0120
Copy link
Contributor Author

Closing this PR, github.com//pull/601 replaces this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants