Created
May 7, 2021 01:12
-
-
Save stefannibrasil/ce7dfbfd616bb4da6711588f3c18a299 to your computer and use it in GitHub Desktop.
This file contains 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
Error: | |
BugTest#test_active_storage_url_does_not_raise: | |
NoMethodError: undefined method `rails_disk_service_url' for #<Module:0x000056214bf78498> | |
Did you mean? rails_info_properties_url | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activestorage-6.1.3.1/lib/active_storage/service/disk_service.rb:129:in `generate_url' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activestorage-6.1.3.1/lib/active_storage/service/disk_service.rb:107:in `private_url' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activestorage-6.1.3.1/lib/active_storage/service.rb:118:in `block in url' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3.1/lib/active_support/notifications.rb:203:in `block in instrument' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3.1/lib/active_support/notifications.rb:203:in `instrument' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activestorage-6.1.3.1/lib/active_storage/service.rb:155:in `instrument' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activestorage-6.1.3.1/lib/active_storage/service.rb:113:in `url' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activestorage-6.1.3.1/app/models/active_storage/blob.rb:199:in `url' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3.1/lib/active_support/core_ext/module/delegation.rb:310:in `public_send' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3.1/lib/active_support/core_ext/module/delegation.rb:310:in `method_missing' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3.1/lib/active_support/core_ext/module/delegation.rb:310:in `public_send' | |
/home/steff/.asdf/installs/ruby/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3.1/lib/active_support/core_ext/module/delegation.rb:310:in `method_missing' | |
rails_app_active_storage_error.rb:72:in `test_active_storage_url_does_not_raise' |
This file contains 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 "rails", "6.1.3.1" | |
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" | |
secrets.secret_key_base = "secret_key_base" | |
# !! Don't draw routes for API only service | |
config.active_storage.draw_routes = false | |
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" | |
} | |
} | |
end | |
ENV["DATABASE_URL"] = "sqlite3::memory:" | |
Rails.application.initialize! | |
Rails.application.routes.draw do | |
scope ActiveStorage.routes_prefix do | |
get "/disk/:encoded_key/*filename" => "active_storage/disk#show", as: :rails_disk_service | |
put "/disk/:encoded_token" => "active_storage/disk#update", as: :update_rails_disk_service | |
end | |
end | |
require ActiveStorage::Engine.root.join("db/migrate/20170806125915_create_active_storage_tables.rb").to_s | |
ActiveRecord::Schema.define do | |
CreateActiveStorageTables.new.change | |
create_table :users, force: true | |
end | |
class User < ActiveRecord::Base | |
has_one_attached :profile | |
end | |
require "minitest/autorun" | |
ActiveStorage::Current.host = "http://example.org" | |
class BugTest < Minitest::Test | |
def test_active_storage_url_does_not_raise | |
user = User.create!( | |
profile: { | |
content_type: "text/jpeg", | |
filename: "dummy.jpg", | |
io: Rack::Test::UploadedFile.new("blank.jpg", "image/jpeg"), | |
} | |
) | |
# fails | |
assert(user.profile.url) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment