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

Fix for <Choose> found as option in drop down service dialogs #15456

Merged
merged 1 commit into from
Jul 3, 2017

Conversation

eclarizio
Copy link
Member

For all static fields, if the default value is not chosen, the first item in the list will be a 'nil' option with a description of either <None> or <Choose>, depending on if the field is required or not. However, if a default value is chosen, this doesn't really make sense for required fields because a default value is already selected and there is no reason someone should go back to a nil value. For non-required fields, however, it makes sense to continue to have the <None> option even if a default value is already set.

This PR enhances the logic of when and when not to add a 'nil' option for sorted item fields.

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

@miq-bot add_label bug, fine/yes, euwe/yes
@miq-bot assign @gmcculloug

/cc @dclarizio Since you assigned this BZ to me I wanted to tag you for visibility.

@syncrou Can you review for me? I'm not super convinced that the way I handled the nil_option logic is optimal, but I feel like it's at least contained in a small enough method that it will be easier to make changes to if we need to down the road.

@miq-bot
Copy link
Member

miq-bot commented Jun 27, 2017

This pull request is not mergeable. Please rebase and repush.


context "when the field is not required" do
it "returns the values with a nil 'None' option" do
expect(dialog_field.values).to eq([[nil, "<None>"], %w(test test), %w(abc abc)])
Copy link
Contributor

Choose a reason for hiding this comment

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

@eclarizio - I'm assuming this part ( that the [nil, '<None>'] as the first option is the bit that resolves the main description of BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1462375

context "when there is a default value that matches a value in the values list" do
let(:default_value) { "2" }
let(:values) { [%w(1 1), %w(2 2), %w(3 3)] }
it "returns the values with the first option being a nil 'None' option" do
Copy link
Contributor

Choose a reason for hiding this comment

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

@eclarizio - same here - I like that the title makes note that it is the first option.

if !required?
initial_values.flatten
elsif default_value.blank? || !default_value_included?(self[:values])
[nil, "<Choose>"]
Copy link
Contributor

Choose a reason for hiding this comment

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

@eclarizio - For consistency - possibly move this out into a method like initial_values - Or bring both back into nil_option

@miq-bot
Copy link
Member

miq-bot commented Jul 3, 2017

Checked commit eclarizio@b42c110 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks fine. 🍰

Copy link
Contributor

@syncrou syncrou left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@gmcculloug gmcculloug merged commit 0cbb33d into ManageIQ:master Jul 3, 2017
@gmcculloug gmcculloug added this to the Sprint 64 Ending Jul 3, 2017 milestone Jul 3, 2017
simaishi pushed a commit that referenced this pull request Jul 25, 2017
Fix for <Choose> found as option in drop down service dialogs
(cherry picked from commit 0cbb33d)

https://bugzilla.redhat.com/show_bug.cgi?id=1472806
@simaishi
Copy link
Contributor

Euwe backport details:

$ git log -1
commit 53e5e173cdfbbedbac15037313495db8c308833b
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Mon Jul 3 13:57:08 2017 -0400

    Merge pull request #15456 from eclarizio/BZ1462375
    
    Fix for <Choose> found as option in drop down service dialogs
    (cherry picked from commit 0cbb33deb054ac05f7107677323e9d0bbee008c0)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1472806

@simaishi
Copy link
Contributor

@eclarizio Travis is failing in Euwe branch now. Can you take a look and see if backport of this PR is causing the failure?

https://travis-ci.org/ManageIQ/manageiq/jobs/257482451

@eclarizio
Copy link
Member Author

Yes, it does appear to be because of the backport. It is safe to simply remove the [nil, "<Choose>"] option that the tests are expecting, since all of the offending dialogs have set a default value and are required, so it doesn't make sense to include that value.

It will also fail on spec/services/orchestration_template_dialog_service_spec.rb:149 for the same reason, but it's not getting there because it fails in a different spot first, so that needs to be fixed as well.

I'll email you a patch file.

@simaishi
Copy link
Contributor

Can you please create a PR?

simaishi pushed a commit that referenced this pull request Aug 4, 2017
Fix for <Choose> found as option in drop down service dialogs
(cherry picked from commit 0cbb33d)

https://bugzilla.redhat.com/show_bug.cgi?id=1478435
@simaishi
Copy link
Contributor

simaishi commented Aug 4, 2017

Fine backport details:

$ git log -1
commit f038283ea05e9f3eeea294433a7f0b94507f3499
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Mon Jul 3 13:57:08 2017 -0400

    Merge pull request #15456 from eclarizio/BZ1462375
    
    Fix for <Choose> found as option in drop down service dialogs
    (cherry picked from commit 0cbb33deb054ac05f7107677323e9d0bbee008c0)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1478435

@simaishi
Copy link
Contributor

simaishi commented Aug 4, 2017

@eclarizio Looks like this is causing Travis failure in Fine branch too: https://travis-ci.org/ManageIQ/manageiq-ui-classic/jobs/261064934

Can you please create a PR to fix it?

@eclarizio
Copy link
Member Author

Sure, here it is: ManageIQ/manageiq-ui-classic#1837

d-m-u pushed a commit to d-m-u/manageiq that referenced this pull request Jun 6, 2018
Fix for <Choose> found as option in drop down service dialogs
(cherry picked from commit 0cbb33d)

https://bugzilla.redhat.com/show_bug.cgi?id=1478435
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