Created
July 1, 2023 12:37
-
-
Save kyanagi/6ed7f6d562cacfd0844128d13a6c5301 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "rails", github: "rails/rails", branch: "main" | |
gem "rack", "~> 2.0" | |
gem "sqlite3" | |
end | |
require "active_record/railtie" | |
require "active_storage/engine" | |
require "tmpdir" | |
class TestApp < Rails::Application | |
config.root = __dir__ | |
config.hosts << "example.org" | |
config.eager_load = false | |
config.session_store :cookie_store, key: "cookie_store_key" | |
config.secret_key_base = "secret_key_base" | |
config.logger = Logger.new($stdout) | |
Rails.logger = config.logger | |
config.active_storage.service = :local | |
config.active_storage.service_configurations = { | |
local: { | |
root: Dir.tmpdir, | |
service: "Disk" | |
} | |
} | |
config.active_job.queue_adapter = :inline | |
end | |
ENV["DATABASE_URL"] = "sqlite3::memory:" | |
Rails.application.initialize! | |
require ActiveStorage::Engine.root.join("db/migrate/20170806125915_create_active_storage_tables.rb").to_s | |
ActiveRecord::Schema.define do | |
CreateActiveStorageTables.new.change | |
create_table :uploaded_files, force: true | |
end | |
class UploadedFile < ActiveRecord::Base | |
has_one_attached :file | |
end | |
require "minitest/autorun" | |
class BugTest < Minitest::Test | |
def test_current | |
ActiveStorage::Current.url_options = { protocol: "http://", host: "example.com", port: 3000 } | |
assert ActiveStorage::Current.url_options | |
UploadedFile.create!(file: Rack::Test::UploadedFile.new("example.jpg", "image/jpeg")) | |
assert ActiveStorage::Current.url_options | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment