Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/omniauth/strategies/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def emails
end

def email_access_allowed?
options['scope'] && !(options['scope'] == 'public')
options['scope'] =~ /user/
end

end
Expand Down
18 changes: 9 additions & 9 deletions spec/omniauth/strategies/github_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@
subject.should_not be_email_access_allowed
end

it "should not allow email if scope is 'public'" do
subject.options['scope'] = 'public'
subject.should_not be_email_access_allowed
end

it "should allow email if scope is user" do
subject.options['scope'] = 'user'
subject.should be_email_access_allowed
end

it "should allow email if scope is scope is a bunch of stuff" do
subject.options['scope'] = 'user,public_repo,repo,delete_repo,gist'
it "should allow email if scope is a bunch of stuff including user" do
subject.options['scope'] = 'public_repo,user,repo,delete_repo,gist'
subject.should be_email_access_allowed
end

it "should assume email access allowed if scope is scope is something currently not documented " do
it "should not allow email if scope is other than user" do
subject.options['scope'] = 'repo'
subject.should_not be_email_access_allowed
end

it "should assume email access not allowed if scope is something currently not documented " do
subject.options['scope'] = 'currently_not_documented'
subject.should be_email_access_allowed
subject.should_not be_email_access_allowed
end
end

Expand Down