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

Expand scope of report definitions that visible to a user #16716

Merged
merged 1 commit into from
Jan 4, 2018

Conversation

gtanzillo
Copy link
Member

This change expands the existing scope of the current user's group to the current user's tenant
allowing visibility to all reports created by users within the tenant.

The scope was changed in #15472 but was too restrictive

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

@gtanzillo
Copy link
Member Author

@carbonin I cleaned up the tests as best I could and took care of the rubocops. Please take another look when you get a chance.

it "returns reports created by me or anyone in a group in my tenant" do
my_report
report_in_my_tenant
report_in_another_tenant
Copy link
Member

Choose a reason for hiding this comment

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

If we change these to be let! we can remove these calls to instantiate the reports.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice, done 👍

expect(described_class.for_user(my_user)).to match_array([my_report, report_in_my_tenant])
end

it "does not return reports created by a group in another tenant" do
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 you can just remove this spec.

By asserting that the array only contains my_report and report_in_my_tenant in the first spec you're also asserting that report_in_another_tenant was not returned even though you created it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also done 👍

This change expands the existing scope of the current user's group to the current user's tenant
allowing visibility to all reports created by users within the tenant.

The scope was changed in ManageIQ#15472 but was too restrictive

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1526058
@miq-bot
Copy link
Member

miq-bot commented Jan 4, 2018

Checked commit gtanzillo@5978047 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍰

let!(:report_in_another_tenant) { FactoryGirl.create(:miq_report, :miq_group => group_in_other_tenant, :rpt_type => "Custom") }

it "returns reports created by me or anyone in a group in my tenant" do
User.current_user = my_user
Copy link
Member

Choose a reason for hiding this comment

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

Not sure what happened in the specs, but maybe it's not safe to set User.current_user as that sets a thread variable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Weird, I had that line there when the tests were passing. I'm gonna restart and hope it succeeds.

@carbonin carbonin self-assigned this Jan 4, 2018
@carbonin carbonin merged commit eff2583 into ManageIQ:master Jan 4, 2018
@carbonin carbonin added this to the Sprint 77 Ending Jan 15, 2018 milestone Jan 4, 2018
simaishi pushed a commit that referenced this pull request Jan 4, 2018
Expand scope of report definitions that visible to a user
(cherry picked from commit eff2583)

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

simaishi commented Jan 4, 2018

Gaprindashvili backport details:

$ git log -1
commit c1a45faf9d792c3003688df01d62f6751703aaee
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Thu Jan 4 17:20:22 2018 -0500

    Merge pull request #16716 from gtanzillo/custom-reports-tenant-level
    
    Expand scope of report definitions that visible to a user
    (cherry picked from commit eff25835d09506967a352eca720c2d5027b9173f)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1531301

@himdel
Copy link
Contributor

himdel commented Jan 5, 2018

This PR introduced a travis spec failure in ui-classic - fixed by ManageIQ/manageiq-ui-classic#3171 :)

detail

(backport to fine together with that PR please)

simaishi pushed a commit that referenced this pull request Jan 10, 2018
Expand scope of report definitions that visible to a user
(cherry picked from commit eff2583)

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

Fine backport details:

$ git log -1
commit 0f944c1152d75a60f1a52e07653a85866c8399ce
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Thu Jan 4 17:20:22 2018 -0500

    Merge pull request #16716 from gtanzillo/custom-reports-tenant-level
    
    Expand scope of report definitions that visible to a user
    (cherry picked from commit eff25835d09506967a352eca720c2d5027b9173f)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1532857

d-m-u pushed a commit to d-m-u/manageiq that referenced this pull request Jun 6, 2018
…t-level

Expand scope of report definitions that visible to a user
(cherry picked from commit eff2583)

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