Sha256: 2300c8b49c750112ee85c2507a5af13c0fe8fffb95ea7258fa928fd61df07cc4
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
discourse_api-2.0.1 | spec/discourse_api/api/uploads_spec.rb |
discourse_api-2.0.0 | spec/discourse_api/api/uploads_spec.rb |