Sha256: 68853fcabcee27c434bbd5e474dce2431b1497aaf34ac2b5324cbf65f9e886a8
Contents?: true
Size: 983 Bytes
Versions: 5
Compression:
Stored size: 983 Bytes
Contents
require 'spec_helper' describe DiscourseApi::API::Uploads do subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") } describe "#upload_file" do before do stub_post("#{host}/uploads").to_return(body: fixture("upload_file.json"), headers: { content_type: "application/json" }) end it "uploads an image via URL" do image = "https://meta-discourse.global.ssl.fastly.net/user_avatar/meta.discourse.org/sam/120/5243.png" args = { url: image } response = subject.upload_file(args) expect(response["url"]).to eq("/uploads/default/original/1X/417e624d2453925e6c68748b9aa67637c284b5aa.jpg") end it "uploads a file" do file = Faraday::UploadIO.new('spec/fixtures/upload_file.json', "application/json") args = { file: file } response = subject.upload_file(args) expect(response["url"]).to eq("/uploads/default/original/1X/417e624d2453925e6c68748b9aa67637c284b5aa.jpg") end end end
Version data entries
5 entries across 5 versions & 1 rubygems