Skip to content

Commit

Permalink
fix attachment downloading from url
Browse files Browse the repository at this point in the history
test plan:
* use the content migrations api to import
 content from a course using a url
* it should work as expected

closes #CNVS-26233:

Change-Id: I66ef4a7d445cfb40209b46386179395de58e59f2
Reviewed-on: https://gerrit.instructure.com/70005
Reviewed-by: Simon Williams <[email protected]>
Tested-by: Jenkins
QA-Review: Clare Strong <[email protected]>
Product-Review: James Williams  <[email protected]>
  • Loading branch information
maneframe authored and simonista committed Jan 10, 2016
1 parent cf3aa8c commit 42c15f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gems/canvas_http/lib/canvas_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ def initialize(code)
end
class RelativeUriError < ArgumentError; end

def self.put(*args)
CanvasHttp.request(Net::HTTP::Put, *args)
def self.put(*args, &block)
CanvasHttp.request(Net::HTTP::Put, *args, &block)
end

def self.delete(*args)
CanvasHttp.request(Net::HTTP::Delete, *args)
def self.delete(*args, &block)
CanvasHttp.request(Net::HTTP::Delete, *args, &block)
end

def self.get(*args)
CanvasHttp.request(Net::HTTP::Get, *args)
def self.get(*args, &block)
CanvasHttp.request(Net::HTTP::Get, *args, &block)
end

# Use this helper method to do HTTP GET requests. It knows how to handle
Expand Down
12 changes: 12 additions & 0 deletions gems/canvas_http/spec/canvas_http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@
to_return(status: 301, headers: { 'Location' => 'http://www.example3.com/a'})
expect { CanvasHttp.get("http://www.example.com/a", {}, 2) }.to raise_error(CanvasHttp::TooManyRedirectsError)
end

it "should yield requests to blocks" do
res = nil
stub_request(:get, "http://www.example.com/a/b").
to_return(body: "Hello", headers: { 'Content-Length' => 5 })
CanvasHttp.get("http://www.example.com/a/b") do |yielded_res|
res = yielded_res
end
res.should be_a Net::HTTPOK
res.body.should == "Hello"
end

end

describe ".tempfile_for_url" do
Expand Down

0 comments on commit 42c15f8

Please sign in to comment.