aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/test_helper.rb
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2018-07-07 23:25:33 -0400
committerGitHub <noreply@github.com>2018-07-07 23:25:33 -0400
commite8682c5bf051517b0b265e446aa1a7eccfd47bf7 (patch)
treecc04c8a28113bc0fa3748fdc6035d487e3e16af7 /activestorage/test/test_helper.rb
parent0b534cd1c814a4db2d0aa283981f1d55e5e62d25 (diff)
downloadrails-e8682c5bf051517b0b265e446aa1a7eccfd47bf7.tar.gz
rails-e8682c5bf051517b0b265e446aa1a7eccfd47bf7.tar.bz2
rails-e8682c5bf051517b0b265e446aa1a7eccfd47bf7.zip
Store newly-uploaded files on save rather than assignment
Diffstat (limited to 'activestorage/test/test_helper.rb')
-rw-r--r--activestorage/test/test_helper.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activestorage/test/test_helper.rb b/activestorage/test/test_helper.rb
index 9985a76832..7b7926ac79 100644
--- a/activestorage/test/test_helper.rb
+++ b/activestorage/test/test_helper.rb
@@ -79,6 +79,10 @@ class ActiveSupport::TestCase
def extract_metadata_from(blob)
blob.tap(&:analyze).metadata
end
+
+ def fixture_file_upload(filename)
+ Rack::Test::UploadedFile.new file_fixture(filename).to_s
+ end
end
require "global_id"
@@ -86,6 +90,8 @@ GlobalID.app = "ActiveStorageExampleApp"
ActiveRecord::Base.send :include, GlobalID::Identification
class User < ActiveRecord::Base
+ validates :name, presence: true
+
has_one_attached :avatar
has_one_attached :cover_photo, dependent: false