mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: don't double request when downloading a file
This commit is contained in:
@ -35,11 +35,8 @@ describe OneboxController do
|
||||
|
||||
url = "http://noodle.com/"
|
||||
|
||||
stub_request(:head, url).
|
||||
to_return(status: 200, body: "", headers: {}).then.to_raise
|
||||
|
||||
stub_request(:get, url)
|
||||
.to_return(status: 200, headers: {}, body: onebox_html).then.to_raise
|
||||
stub_request(:head, url)
|
||||
stub_request(:get, url).to_return(body: onebox_html).then.to_raise
|
||||
|
||||
get :show, params: { url: url, refresh: "true" }, format: :json
|
||||
|
||||
|
@ -59,21 +59,20 @@ describe UploadsController do
|
||||
expect(id).to be
|
||||
end
|
||||
|
||||
it 'is successful with synchronous api' do
|
||||
it 'is successful with api' do
|
||||
SiteSetting.authorized_extensions = "*"
|
||||
controller.stubs(:is_api?).returns(true)
|
||||
|
||||
FinalDestination.stubs(:lookup_ip).returns("1.2.3.4")
|
||||
|
||||
Jobs.expects(:enqueue).with(:create_avatar_thumbnails, anything)
|
||||
|
||||
stub_request(:head, 'http://example.com/image.png')
|
||||
stub_request(:get, "http://example.com/image.png").to_return(body: File.read('spec/fixtures/images/logo.png'))
|
||||
url = "http://example.com/image.png"
|
||||
png = File.read(Rails.root + "spec/fixtures/images/logo.png")
|
||||
|
||||
post :create, params: {
|
||||
url: 'http://example.com/image.png',
|
||||
type: "avatar",
|
||||
synchronous: true,
|
||||
format: :json
|
||||
}
|
||||
stub_request(:get, url).to_return(status: 200, body: png)
|
||||
|
||||
post :create, params: { url: url, type: "avatar", format: :json }
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
|
||||
|
@ -31,7 +31,6 @@ describe UserAvatarsController do
|
||||
SiteSetting.s3_upload_bucket = "test"
|
||||
SiteSetting.s3_cdn_url = "http://cdn.com"
|
||||
|
||||
stub_request(:head, "http://cdn.com/something/else")
|
||||
stub_request(:get, "http://cdn.com/something/else").to_return(body: 'image')
|
||||
|
||||
GlobalSetting.expects(:cdn_url).returns("http://awesome.com/boom")
|
||||
|
Reference in New Issue
Block a user