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

Remove anonymous support due to deprecation. #280

Merged
merged 4 commits into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion lib/gist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ def multi_gist(files, options={})

existing_gist = options[:update].to_s.split("/").last
if options[:anonymous]
access_token = nil
raise 'Anonymous gist support has been removed by Github. ' \
'See: https://blog.github.com/2018-02-18-deprecation-notice-removing-anonymous-gist-creation/'
Copy link
Collaborator

Choose a reason for hiding this comment

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

@estebanz01 Thanks for this — can we make this error explain to the user what to do about it?

raise 'Please log in with `gist --login`. (Github now requires credentials to gist https://bit.ly/2GBBxKw)'

else
access_token = (options[:access_token] || auth_token())
end
Expand Down
11 changes: 10 additions & 1 deletion spec/rawify_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@
end

it "should return the raw file url" do
Gist.gist("Test gist", :output => :raw_url, :anonymous => true).should == "https://gist.github.com/anonymous/XXXXXX/raw"
Gist.gist("Test gist", :output => :raw_url, :anonymous => false).should == "https://gist.github.com/anonymous/XXXXXX/raw"
end

it 'should raise an error when trying to do operations without being logged in' do
error_msg = 'Anonymous gist support has been removed by Github. ' \
'See: https://blog.github.com/2018-02-18-deprecation-notice-removing-anonymous-gist-creation/'

expect do
Gist.gist("Test gist", output: :raw_url, anonymous: true)
end.to raise_error(StandardError, error_msg)
end
end

13 changes: 11 additions & 2 deletions spec/shorten_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@

it "should return a shortened version of the URL when response is 200" do
stub_request(:post, "https://git.io/create").to_return(:status => 200, :body => 'XXXXXX')
Gist.gist("Test gist", :output => :short_url, :anonymous => true).should == "https://git.io/XXXXXX"
Gist.gist("Test gist", :output => :short_url, anonymous: false).should == "https://git.io/XXXXXX"
end

it "should return a shortened version of the URL when response is 201" do
stub_request(:post, "https://git.io/create").to_return(:status => 201, :headers => { 'Location' => 'https://git.io/XXXXXX' })
Gist.gist("Test gist", :output => :short_url, :anonymous => true).should == "https://git.io/XXXXXX"
Gist.gist("Test gist", :output => :short_url, anonymous: false).should == "https://git.io/XXXXXX"
end

it 'should raise an error when trying to get short urls without being logged in' do
error_msg = 'Anonymous gist support has been removed by Github. ' \
'See: https://blog.github.com/2018-02-18-deprecation-notice-removing-anonymous-gist-creation/'

expect do
Gist.gist("Test gist", output: :short_url, anonymous: true)
end.to raise_error(StandardError, error_msg)
end
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
mocks.syntax = :should
end
config.expect_with :rspec do |expectations|
expectations.syntax = :should
expectations.syntax = [:should, :expect]
end
end

Expand Down