-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make Scopes#+ and #& work against a non-Scopes object #868
Conversation
end | ||
|
||
it 'can get intersection with an array' do | ||
scopes = Scopes.from_string('public admin') & %w(write admin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
lib/doorkeeper/oauth/scopes.rb
Outdated
|
||
private | ||
|
||
def other_array(other) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename it to something like to_array
? I think other_array
is not descriptive name for this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Hi @knu . Can you please give an attention to the comments above ? (Hound CI and mine). Also can you please add a changelog to the NEWS.md file and rebase commits to squash them? Thanks for your work! |
OK, but as for Hound CI I'm a bit at a loss because I just followed the styles of existing code. |
end | ||
|
||
it 'can get intersection with an array' do | ||
scopes = Scopes.from_string('public admin') & %w(write admin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
expect(origin.to_s).to eq('public admin') | ||
end | ||
|
||
it 'can get intersection with an array' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
it 'does not change the existing object' do | ||
origin = Scopes.from_string('public admin') | ||
origin & Scopes.from_string('write admin') | ||
expect(origin.to_s).to eq('public admin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
|
||
it 'does not change the existing object' do | ||
origin = Scopes.from_string('public admin') | ||
origin & Scopes.from_string('write admin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end | ||
|
||
it 'does not change the existing object' do | ||
origin = Scopes.from_string('public admin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
it 'raises an error if cannot handle addition' do | ||
expect do | ||
Scopes.from_string('public') + 'admin' | ||
end.to raise_error(NoMethodError) | ||
end | ||
end | ||
|
||
describe '#&' do | ||
it 'can get intersection with another scope object' do | ||
scopes = Scopes.from_string('public admin') & Scopes.from_string('write admin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Line is too long. [87/80]
it 'raises an error if cannot handle addition' do | ||
expect do | ||
Scopes.from_string('public') + 'admin' | ||
end.to raise_error(NoMethodError) | ||
end | ||
end | ||
|
||
describe '#&' do | ||
it 'can get intersection with another scope object' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
it 'raises an error if cannot handle addition' do | ||
expect do | ||
Scopes.from_string('public') + 'admin' | ||
end.to raise_error(NoMethodError) | ||
end | ||
end | ||
|
||
describe '#&' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -70,13 +70,36 @@ module Doorkeeper::OAuth | |||
expect(origin.to_s).to eq('public') | |||
end | |||
|
|||
it 'can add an array to a scope object' do | |||
scopes = Scopes.from_string('public') + ['admin'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -70,13 +70,36 @@ module Doorkeeper::OAuth | |||
expect(origin.to_s).to eq('public') | |||
end | |||
|
|||
it 'can add an array to a scope object' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@knu, ok, not a big deal. Can you please add a changelog entry tyo NEWS.md and rebase your commits to squash them? Thanx! |
Thanks, I will! |
One more moment - can you squash your 2 last commits into 1 please? 🙏 |
Done. |
Thank you @knu! 🙇 |
The intention of
Scopes#+
calling super is unclear to me, but I believe it is useful for the operators like+
and&
to work against an array, or any object that is convertible to Array.