Upload media to mastodon

This commit is contained in:
2023-02-04 13:37:48 +11:00
parent 084ee53b3e
commit 9619227b0e
7 changed files with 37 additions and 12 deletions

View File

@@ -12,11 +12,11 @@ RSpec.describe Adamantium::Commands::Media::Upload do
}
result = subject.call(file: file)
expected_path = "media/#{Time.now.strftime("%m-%Y")}/foo.txt"
expected_path = /media\/#{Time.now.strftime("%m-%Y")}\/[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}.txt/
expect(result).to be_success
expect(result.value!).to eq "http://localhost/#{expected_path}"
File.read("public/#{expected_path}")
File.delete("public/#{expected_path}")
expect(result.value!).to match expected_path
File.read("public/#{result.value!.gsub("http://localhost/", "")}")
File.delete("public/#{result.value!.gsub("http://localhost/", "")}")
end
it "returns a Failure if the file couldn't be saved" do

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
RSpec.describe "Post creation", type: [:request, :db] do
RSpec.describe "Post creation", :db, :requests do
let(:post_repo) { Adamantium::Repos::PostRepo.new }
context "posts" do

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
RSpec.describe "Root", type: :request do
RSpec.describe "Root", :requests do
it "is successful" do
get "/"

View File

@@ -9,14 +9,14 @@ RSpec.configure do |config|
DatabaseCleaner[:sequel].clean_with :truncation
end
config.prepend_before :each, type: :db do |example|
config.prepend_before :each, :db do |example|
strategy = example.metadata[:js] ? :truncation : :transaction
DatabaseCleaner[:sequel].strategy = strategy
DatabaseCleaner[:sequel].start
end
config.append_after :each, type: :db do
config.append_after :each, :db do
DatabaseCleaner[:sequel].clean
end
end

View File

@@ -1,3 +1,4 @@
# require_with_metadata: true
# frozen_string_literal: true
require "rack/test"
@@ -7,6 +8,6 @@ RSpec.shared_context "Hanami app" do
end
RSpec.configure do |config|
config.include Rack::Test::Methods, type: :request
config.include_context "Hanami app", type: :request
config.include Rack::Test::Methods, :requests
config.include_context "Hanami app", :requests
end

View File

@@ -13,7 +13,9 @@ RSpec.describe Adamantium::Syndication::Mastodon do
slug: "my-post",
category: ["ruby", "rspec"],
published_at: Time.now,
post_type: "post"
post_type: "post",
syndicate_to: [],
photos: []
)
}