Skip to content

Instantly share code, notes, and snippets.

@shawndeprey
Last active January 22, 2021 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawndeprey/9dd2b93ad4e76e28158cc2810dff2b39 to your computer and use it in GitHub Desktop.
Save shawndeprey/9dd2b93ad4e76e28158cc2810dff2b39 to your computer and use it in GitHub Desktop.
require "test_helper"
class AttachmentTest < ActiveSupport::TestCase
test "attachment_with_image" do
attachment = Attachment.new({file: fixture_file_upload('/files/tracer1.jpg', 'image/jpg')})
assert attachment.save
assert_match(/^http:\/\/test.host\/rails\/active_storage\/blobs\/.+tracer1\.jpg$/i, attachment.url)
end
test "attachment_with_image_variation" do
attachment = Attachment.new({file: Rack::Test::UploadedFile.new("#{Rails.root}/test/fixtures/files/tracer1.jpg", 'tracer1.jpg')})
assert attachment.save
assert_match(/^http:\/\/test.host\/rails\/active_storage\/blobs\/.+tracer1\.jpg$/i, attachment.url)
end
test "attachment_with_image_manual_attach" do
attachment = Attachment.new
attachment.file.attach(io: File.open(Rails.root + 'test/fixtures/files/tracer1.jpg'), filename: 'tracer1.jpg', content_type: 'image/jpg')
assert attachment.save
assert_match(/^http:\/\/test.host\/rails\/active_storage\/blobs\/.+tracer1\.jpg$/i, attachment.url)
end
end
source 'https://rubygems.org'
ruby '2.5.6'
gem 'strip_attributes'
gem 'bundler', '= 1.17.3'
gem 'rails', '~> 6'
gem 'pg', '~> 1.1.4'
gem 'puma', '~> 4.1'
gem 'puma_worker_killer', '~> 0.1.1'
gem 'will_paginate', '~> 3.2.1'
gem 'redcarpet', '~> 3.5.0'
gem 'bcrypt', '~> 3.1.7'
gem 'rack-cors', '~> 1'
gem 'rack', '= 2.2.3'
gem 'pwned', '= 2.0.0'
gem 'sanitize', '~> 5'
gem 'active_model_serializers', '~> 0.10.10'
gem 'gibbon', '~> 3.3.3'
gem 'order_as_specified', '~> 1.6'
# ElasticSearch
gem 'elasticsearch-model', '~> 7'
gem 'elasticsearch-rails', '~> 7'
gem 'elasticsearch-transport', '~> 7'
# Sidekiq
gem 'sidekiq', '~> 6'
gem 'sidekiq-failures', '= 1.0.0'
# gem 'sidekiq-throttler', '= 0.5.1'
gem 'sidekiq-status', '= 1.1.4'
gem 'sidekiq-unique-jobs', '~> 6'
# ActiveStorage
gem 'aws-sdk-s3', '~> 1'
gem 'image_processing', '~> 1'
# Security
gem 'rotp', '~> 5'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false
group :development, :test do
gem 'factory_bot_rails', '~> 5.1.1'
gem 'm', '= 1.3.4'
gem 'minitest-rails', ' ~> 6.0.0'
gem 'database_cleaner', '~> 1.7.0'
gem 'faker', '~> 2.7.0'
end
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', '~> 1.2019.3'
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.3.4)
actionpack (= 6.0.3.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.4)
actionpack (= 6.0.3.4)
activejob (= 6.0.3.4)
activerecord (= 6.0.3.4)
activestorage (= 6.0.3.4)
activesupport (= 6.0.3.4)
mail (>= 2.7.1)
actionmailer (6.0.3.4)
actionpack (= 6.0.3.4)
actionview (= 6.0.3.4)
activejob (= 6.0.3.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.3.4)
actionview (= 6.0.3.4)
activesupport (= 6.0.3.4)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.4)
actionpack (= 6.0.3.4)
activerecord (= 6.0.3.4)
activestorage (= 6.0.3.4)
activesupport (= 6.0.3.4)
nokogiri (>= 1.8.5)
actionview (6.0.3.4)
activesupport (= 6.0.3.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_model_serializers (0.10.12)
actionpack (>= 4.1, < 6.2)
activemodel (>= 4.1, < 6.2)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (6.0.3.4)
activesupport (= 6.0.3.4)
globalid (>= 0.3.6)
activemodel (6.0.3.4)
activesupport (= 6.0.3.4)
activerecord (6.0.3.4)
activemodel (= 6.0.3.4)
activesupport (= 6.0.3.4)
activestorage (6.0.3.4)
actionpack (= 6.0.3.4)
activejob (= 6.0.3.4)
activerecord (= 6.0.3.4)
marcel (~> 0.3.1)
activesupport (6.0.3.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
aws-eventstream (1.1.0)
aws-partitions (1.417.0)
aws-sdk-core (3.111.2)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.41.0)
aws-sdk-core (~> 3, >= 3.109.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.87.0)
aws-sdk-core (~> 3, >= 3.109.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.2.2)
aws-eventstream (~> 1, >= 1.0.2)
bcrypt (3.1.16)
bootsnap (1.5.1)
msgpack (~> 1.0)
builder (3.2.4)
case_transform (0.2)
activesupport
chronic_duration (0.10.6)
numerizer (~> 0.1.1)
concurrent-ruby (1.1.8)
connection_pool (2.2.3)
crass (1.0.6)
database_cleaner (1.7.0)
elasticsearch (7.10.1)
elasticsearch-api (= 7.10.1)
elasticsearch-transport (= 7.10.1)
elasticsearch-api (7.10.1)
multi_json
elasticsearch-model (7.1.1)
activesupport (> 3)
elasticsearch (> 1)
hashie
elasticsearch-rails (7.1.1)
elasticsearch-transport (7.10.1)
faraday (~> 1)
multi_json
erubi (1.10.0)
factory_bot (5.1.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.1.1)
factory_bot (~> 5.1.0)
railties (>= 4.2.0)
faker (2.7.0)
i18n (>= 1.6, < 1.8)
faraday (1.3.0)
faraday-net_http (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords
faraday-net_http (1.0.1)
ffi (1.14.2)
get_process_mem (0.2.7)
ffi (~> 1.0)
gibbon (3.3.4)
faraday (>= 0.16.0)
multi_json (>= 1.11.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
hashie (4.1.0)
i18n (1.7.1)
concurrent-ruby (~> 1.0)
image_processing (1.12.1)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
jmespath (1.4.0)
jsonapi-renderer (0.2.2)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.9.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
m (1.3.4)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (1.0.0)
mimemagic (0.3.5)
mini_magick (4.11.0)
mini_mime (1.0.2)
minitest (5.14.3)
minitest-rails (6.0.1)
minitest (~> 5.10)
railties (~> 6.0.0)
msgpack (1.3.3)
multi_json (1.15.0)
multipart-post (2.1.1)
nio4r (2.5.4)
nokogiri (1.11.1-x86_64-linux)
racc (~> 1.4)
nokogumbo (2.0.4)
nokogiri (~> 1.8, >= 1.8.4)
numerizer (0.1.1)
order_as_specified (1.6)
activerecord (>= 5.0.0)
pg (1.1.4)
public_suffix (4.0.6)
puma (4.3.7)
nio4r (~> 2.0)
puma_worker_killer (0.1.1)
get_process_mem (~> 0.2)
puma (>= 2.7, < 5)
pwned (2.0.0)
racc (1.5.2)
rack (2.2.3)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.3.4)
actioncable (= 6.0.3.4)
actionmailbox (= 6.0.3.4)
actionmailer (= 6.0.3.4)
actionpack (= 6.0.3.4)
actiontext (= 6.0.3.4)
actionview (= 6.0.3.4)
activejob (= 6.0.3.4)
activemodel (= 6.0.3.4)
activerecord (= 6.0.3.4)
activestorage (= 6.0.3.4)
activesupport (= 6.0.3.4)
bundler (>= 1.3.0)
railties (= 6.0.3.4)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.3.4)
actionpack (= 6.0.3.4)
activesupport (= 6.0.3.4)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (13.0.3)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
redcarpet (3.5.1)
redis (4.2.5)
rotp (5.1.0)
addressable (~> 2.5)
ruby-vips (2.0.17)
ffi (~> 1.9)
ruby2_keywords (0.0.4)
ruby_dep (1.5.0)
sanitize (5.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.8.0)
nokogumbo (~> 2.0)
sidekiq (6.1.3)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
sidekiq-failures (1.0.0)
sidekiq (>= 4.0.0)
sidekiq-status (1.1.4)
chronic_duration
sidekiq (>= 3.0)
sidekiq-unique-jobs (6.0.25)
concurrent-ruby (~> 1.0, >= 1.0.5)
sidekiq (>= 4.0, < 7.0)
thor (>= 0.20, < 2.0)
spring (2.1.1)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
strip_attributes (1.11.0)
activemodel (>= 3.0, < 7.0)
thor (1.1.0)
thread_safe (0.3.6)
tzinfo (1.2.9)
thread_safe (~> 0.1)
tzinfo-data (1.2019.3)
tzinfo (>= 1.0.0)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
will_paginate (3.2.1)
zeitwerk (2.4.2)
PLATFORMS
ruby
DEPENDENCIES
active_model_serializers (~> 0.10.10)
aws-sdk-s3 (~> 1)
bcrypt (~> 3.1.7)
bootsnap (>= 1.4.2)
bundler (= 1.17.3)
database_cleaner (~> 1.7.0)
elasticsearch-model (~> 7)
elasticsearch-rails (~> 7)
elasticsearch-transport (~> 7)
factory_bot_rails (~> 5.1.1)
faker (~> 2.7.0)
gibbon (~> 3.3.3)
image_processing (~> 1)
listen (>= 3.0.5, < 3.2)
m (= 1.3.4)
minitest-rails (~> 6.0.0)
order_as_specified (~> 1.6)
pg (~> 1.1.4)
puma (~> 4.1)
puma_worker_killer (~> 0.1.1)
pwned (= 2.0.0)
rack (= 2.2.3)
rack-cors (~> 1)
rails (~> 6)
redcarpet (~> 3.5.0)
rotp (~> 5)
sanitize (~> 5)
sidekiq (~> 6)
sidekiq-failures (= 1.0.0)
sidekiq-status (= 1.1.4)
sidekiq-unique-jobs (~> 6)
spring
spring-watcher-listen (~> 2.0.0)
strip_attributes
tzinfo-data (~> 1.2019.3)
will_paginate (~> 3.2.1)
RUBY VERSION
ruby 2.5.6p201
BUNDLED WITH
1.17.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment