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

Fixes #17526 - Taxonomy.ignore? does not work with "any context" #4070

Merged
merged 1 commit into from Jan 26, 2017

Conversation

dLobatog
Copy link
Member

In this scenario:

  1. User has one organization - "E-Corp" - this organization allows the
    user to see every hostgroup (via selecting "all host groups" when
    editing the organization).

  2. User has a location "Czech republic" that also includes all host
    groups through that checkbox.

  3. User visits /hostgroups with "any context" selected, or "E-Corp/any
    location", or "any organization/Czech republic". The result is that the
    user does not see all host groups even though there's an
    organization/location combination (e-corp/czech republic) that should
    allow the user to see all host groups.


The reason is that when Hostgroup.taxable_ids is called
Organization.ignore? does not realize that there it should look in all
Organizations to see if any of them 'ignores' (has "all host groups"
checked) the resource. The same thing happens with Locations.

The fix is to make ignore? aware the 'Organization.current == nil'
means 'Any organization', not 'No organization'.

@mention-bot
Copy link

@dLobatog, thanks for your PR! By analyzing the history of the files in this pull request, we identified @isratrade, @ares and @abenari to be potential reviewers.

should_not allow_value(' ').for(:name)
# Taxonomy 1 is already used by a fixture
should_not allow_value("#{taxonomy_name} 1").for(:name)
should_not allow_value("#{'a' * 256}").for(:name)

Choose a reason for hiding this comment

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

Prefer to_s over string interpolation.

assert_equal _("is too long (maximum is 0 characters)"), taxonomy.errors[:name].first
end

test 'ignores the taxable_type if current taxonomy ignores it' do
Copy link
Member Author

Choose a reason for hiding this comment

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

These two are the only new tests, the rest of them are just removing the duplication between location_test and organization_test and moving them both to a module

@dLobatog
Copy link
Member Author

Tons of tests broke, setting to WoC

In this scenario:

1. User has one organization - "E-Corp" - this organization allows the
user to see every hostgroup (via selecting "all host groups" when
editing the organization).

2. User has a location "Czech republic" that also includes all host
groups through that checkbox.

3. User visits /hostgroups with "any context" selected, or "E-Corp/any
location", or "any organization/Czech republic". The result is that the
user does not see all host groups even though there's an
organization/location combination (e-corp/czech republic) that should
allow the user to see all host groups.

---

The reason is that when `Hostgroup.taxable_ids` is called
`Organization.ignore?` does not realize that there it should look in all
Organizations to see if any of them 'ignores' (has "all host groups"
    checked) the resource. The same thing happens with Locations.

The fix is to make `ignore?` aware the 'Organization.current == nil'
means 'Any organization', not 'No organization'.
@dLobatog
Copy link
Member Author

dLobatog commented Dec 1, 2016

@theforeman-bot ok to test

@dLobatog
Copy link
Member Author

dLobatog commented Dec 2, 2016

Test failure in Katello is due to https://github.com/Katello/katello/pull/6480/files

@tbrisker tbrisker merged commit 2d9236b into theforeman:develop Jan 26, 2017
@tbrisker
Copy link
Member

Thanks @dLobatog !

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