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

Force a lookup in EmsFolder #11632

Merged
merged 2 commits into from
Oct 5, 2016

Conversation

syncrou
Copy link
Contributor

@syncrou syncrou commented Sep 30, 2016

If anything comes back in :placement_folder_name we always do a find_by as opposed
to assuming that the data passed back is always good.

This resolves an issue where we might return a false positive.

Links

@syncrou
Copy link
Contributor Author

syncrou commented Sep 30, 2016

@miq_bot add_label providers/vmware/infra, provisioning

@syncrou
Copy link
Contributor Author

syncrou commented Sep 30, 2016

@miq-bot assign @gmcculloug

@syncrou
Copy link
Contributor Author

syncrou commented Sep 30, 2016

cc - @agrare

@agrare
Copy link
Member

agrare commented Oct 3, 2016

Nice, can you add a test case for this? Maybe pass in -1 for the ID and make sure it returns the default folder.

folder_id = get_option(:placement_folder_name)
return EmsFolder.find_by(:id => folder_id) if folder_id
ems_folder = EmsFolder.find_by(:id => get_option(:placement_folder_name))
return ems_folder unless ems_folder.nil?
Copy link
Member

Choose a reason for hiding this comment

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

Suggest using: return ems_folder if ems_folder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@agrare
Copy link
Member

agrare commented Oct 3, 2016

Would this be caused by passing an invalid folder ID?

@syncrou
Copy link
Contributor Author

syncrou commented Oct 3, 2016

@agrare - Yes - (although there isn't definite proof yet that it has happened.)

In that case a nil would be returned with no more processing on the folder lookup.

@syncrou syncrou force-pushed the find_folder_only_if_it_is_real branch 3 times, most recently from ea4707c to 6e4c880 Compare October 5, 2016 13:57
@@ -0,0 +1,51 @@
describe ManageIQ::Providers::Vmware::InfraManager::Provision::Cloning do
context "#dest_folder" do
before(:each) do
Copy link
Member

Choose a reason for hiding this comment

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

Drop the (:each) as that is the default.

describe ManageIQ::Providers::Vmware::InfraManager::Provision::Cloning do
context "#dest_folder" do
before(:each) do
@os = OperatingSystem.new(:product_name => 'Microsoft Windows')
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason you are not using FactoryGirl here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't know about that factory. Fixed.

If anything comes back in :placement_folder_name we always do a find_by as opposed
to assuming that the data passed back is always good.
This resolves us from returning false positives

https://www.pivotaltracker.com/story/show/131473779
@miq-bot
Copy link
Member

miq-bot commented Oct 5, 2016

Checked commits syncrou/manageiq@88b41aa~...000e316 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
2 files checked, 2 offenses detected

spec/models/manageiq/providers/vmware/infra_manager/provision/cloning_spec.rb

@gmcculloug gmcculloug added this to the Sprint 48 Ending Oct 24, 2016 milestone Oct 5, 2016
@gmcculloug gmcculloug merged commit fc9a588 into ManageIQ:master Oct 5, 2016
chessbyte pushed a commit that referenced this pull request Oct 13, 2016
Force a lookup in EmsFolder
(cherry picked from commit fc9a588)
@chessbyte
Copy link
Member

Euwe Backport details:

$ git log
commit 3dd9feed520606c48d1f56af734a15ae50f28e84
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Wed Oct 5 15:48:58 2016 -0400

    Merge pull request #11632 from syncrou/find_folder_only_if_it_is_real

    Force a lookup in EmsFolder
    (cherry picked from commit fc9a588dc65a768f83ac2af4e7dd3f16267403df)

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.

None yet

6 participants