Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Have other rights appear in groupless #5

Merged
merged 7 commits into from
Jul 6, 2016
Merged

Conversation

mnoack
Copy link
Contributor

@mnoack mnoack commented Jul 4, 2016

No description provided.

@coveralls
Copy link

coveralls commented Jul 4, 2016

Coverage Status

Coverage increased (+0.2%) to 85.475% when pulling 921c670 on groupless_rights into e7bdb41 on master.

@@ -34,6 +34,9 @@ def by_groups
rights = []
rights += regular_rights_with_group
rights += restricted_rights_with_group
other_rights = Right.all - rights
other_rights.each { |right| right.group = 'Groupless' }
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just append the groupless rights to the end of the resulting array instead of introducing a hardcoded group 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.

I think we can.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe even clearer if we add a new method that just return the "groupless" rights.

@coveralls
Copy link

coveralls commented Jul 5, 2016

Coverage Status

Coverage decreased (-0.5%) to 84.706% when pulling 15fbfd3 on groupless_rights into e7bdb41 on master.

@coveralls
Copy link

coveralls commented Jul 6, 2016

Coverage Status

Coverage increased (+0.2%) to 85.475% when pulling 921c670 on groupless_rights into e7bdb41 on master.

rights += regular_rights_with_group
rights += restricted_rights_with_group
rights = regular_rights_with_group + restricted_rights_with_group
rights += (Right.all - rights)
Copy link
Contributor

@alxberardi alxberardi Jul 6, 2016

Choose a reason for hiding this comment

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

Maybe I'm reading this wrong, but wouldn't this end up assigning all rights to the rights variable?
It reads like

a = [1,2,3]
b = [4,5,6]
all = [1,2,3,4,5,6,7,8,9]
sum = a + b
sum = sum + all - sum # => all

Or are the regular_rights_with_group and restricted_rights_with_group somehow decorated?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, I see the decoration happening below, with the assignment of the group. That answers the above question.

Copy link

@akilmadan akilmadan Jul 6, 2016

Choose a reason for hiding this comment

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

Optional suggestion. Maybe something like...

rights_with_groups = regular_rights_with_group + restricted_rights_with_group
other_rights = Rights.all - rights_with_groups
rights = rights_with_groups + other_rights

It's an extra line but does make it easier to understand the logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alxberardi Shall I make it like the above and merge?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm happy how it is now. If you want to implement @vgmaster21 's suggestion feel free to. I just didn't immediately notice the assignment of the groups to the rights.

@alxberardi
Copy link
Contributor

👍 (though this gem could use some more nice refactoring)

@alxberardi alxberardi merged commit cbe67d3 into master Jul 6, 2016
@alxberardi alxberardi deleted the groupless_rights branch July 6, 2016 00:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants