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

Manager name not updated on foreman provider edit #5

Merged

Conversation

lgalis
Copy link
Contributor

@lgalis lgalis commented Jun 21, 2017

Manager name not updated on foreman provider edit

https://bugzilla.redhat.com/show_bug.cgi?id=1450457

@lgalis
Copy link
Contributor Author

lgalis commented Jun 21, 2017

@bdunne - please review

@lgalis lgalis closed this Jun 21, 2017
@lgalis lgalis reopened this Jun 21, 2017
describe "#save" do
it "will update the name for the manager" do
provider = FactoryGirl.create(:provider_foreman, :zone => FactoryGirl.create(:zone), :name => 'Old Name')
provider.save
Copy link
Member

Choose a reason for hiding this comment

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

The save isn't needed since you used create above.

it "will update the name for the manager" do
provider = FactoryGirl.create(:provider_foreman, :zone => FactoryGirl.create(:zone), :name => 'Old Name')
provider.save
expect(provider.configuration_manager.name).to eq('Old Name Configuration Manager')
Copy link
Member

Choose a reason for hiding this comment

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

It feels a little strange to me that we're doing this, but since we are, shouldn't we test that all managers are updated?


provider.name = 'New Name'
provider.save
expect(provider.configuration_manager.name).to eq('New Name Configuration Manager')
Copy link
Member

Choose a reason for hiding this comment

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

Same question

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bdunne - not sure if the provisioning manager name is used in the UI - I have added a test for that as well.

@lgalis lgalis force-pushed the manager_name_not_updated_on_provider_edit branch from d1db59b to fff521d Compare June 23, 2017 14:02
@@ -20,7 +20,7 @@ class ManageIQ::Providers::Foreman::Provider < ::Provider

delegate :api_cached?, :ensure_api_cached, :to => :connect

before_create :ensure_managers
before_validation :ensure_managers
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be before_save, right? Otherwise we could wind up updating the name on the managers before running the validations on the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bdunne - I think it should be before_validation, in order for the validation to run with the new names.

Copy link
Member

Choose a reason for hiding this comment

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

I see, we're using :autosave => true on these relations.

@lgalis
Copy link
Contributor Author

lgalis commented Jun 26, 2017

@miq-bot assign @gmcculloug

expect(provider.configuration_manager.name).to eq('Old Name Configuration Manager')

provider.name = 'New Name'
provider.save
Copy link
Member

Choose a reason for hiding this comment

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

These two lines

provider.name = 'New Name'
provider.save

can be combined into one call:

provider.update_attributes(:name => 'New Name')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to update that replaces update_attributes in newer rails.

@lgalis lgalis force-pushed the manager_name_not_updated_on_provider_edit branch from fff521d to 7cb3b44 Compare June 27, 2017 12:29
@lgalis lgalis force-pushed the manager_name_not_updated_on_provider_edit branch from 7cb3b44 to 0a84fe3 Compare June 27, 2017 13:21
@miq-bot
Copy link
Member

miq-bot commented Jun 27, 2017

Checked commits lgalis/manageiq-providers-foreman@13b7149~...0a84fe3 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 👍

@lgalis
Copy link
Contributor Author

lgalis commented Jun 28, 2017

the travis errors are not related to the changes in this PR

@gmcculloug
Copy link
Member

@bdunne Is this an apipie-bindings gem issue? We are on version 0.0.15 - September 21, 2015 and the latest is 0.2.0 - April 24, 2017. Is it possible to upgrade?

@gmcculloug
Copy link
Member

Agreed that the failing tests are unrelated to this PR. I will merge this and open a git issue to resolve the failing tests. Thanks.

@simaishi
Copy link

simaishi commented Aug 4, 2017

Fine backport (to manageiq repo) details:

$ git log -1
commit 184525028ead68829ec64d5a111e9571088eb5bd
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Wed Jul 5 08:59:19 2017 -0400

    Merge pull request #5 from lgalis/manager_name_not_updated_on_provider_edit
    
    Manager name not updated on foreman provider edit
    (cherry picked from commit 1fd7717a6fb1dacd703371d9b5715e46675bb480)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1478513

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

5 participants