s3_relay 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/controllers/s3_relay/uploads_controller.rb +8 -2
  4. data/app/models/s3_relay/upload.rb +1 -1
  5. data/lib/s3_relay/private_url.rb +1 -1
  6. data/lib/s3_relay/version.rb +1 -1
  7. data/test/controllers/s3_relay/uploads_controller_test.rb +17 -11
  8. data/test/dummy/{README.rdoc → README.md} +1 -5
  9. data/test/dummy/Rakefile +1 -1
  10. data/test/dummy/app/assets/config/manifest.js +3 -0
  11. data/test/dummy/app/assets/javascripts/application.js +6 -4
  12. data/test/dummy/app/assets/javascripts/cable.js +13 -0
  13. data/test/dummy/app/assets/stylesheets/application.css +5 -5
  14. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  15. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  16. data/test/dummy/app/controllers/application_controller.rb +0 -2
  17. data/test/dummy/app/jobs/application_job.rb +2 -0
  18. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  19. data/test/dummy/app/models/application_record.rb +3 -0
  20. data/test/dummy/app/models/product.rb +1 -1
  21. data/test/dummy/app/views/layouts/application.html.erb +9 -9
  22. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  23. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  24. data/test/dummy/bin/rails +6 -1
  25. data/test/dummy/bin/rake +5 -0
  26. data/test/dummy/bin/setup +38 -0
  27. data/test/dummy/bin/spring +17 -0
  28. data/test/dummy/bin/update +29 -0
  29. data/test/dummy/bin/yarn +11 -0
  30. data/test/dummy/config/application.rb +7 -11
  31. data/test/dummy/config/boot.rb +2 -4
  32. data/test/dummy/config/cable.yml +10 -0
  33. data/test/dummy/config/environment.rb +1 -1
  34. data/test/dummy/config/environments/development.rb +24 -7
  35. data/test/dummy/config/environments/production.rb +35 -22
  36. data/test/dummy/config/environments/test.rb +6 -3
  37. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  38. data/test/dummy/config/initializers/assets.rb +8 -2
  39. data/test/dummy/config/initializers/cookies_serializer.rb +3 -1
  40. data/test/dummy/config/initializers/wrap_parameters.rb +2 -2
  41. data/test/dummy/config/locales/en.yml +10 -0
  42. data/test/dummy/config/puma.rb +56 -0
  43. data/test/dummy/config/secrets.yml +15 -5
  44. data/test/dummy/config/spring.rb +6 -0
  45. data/test/dummy/config.ru +2 -1
  46. data/test/dummy/db/seeds.rb +7 -0
  47. data/test/dummy/package.json +5 -0
  48. data/test/dummy/public/404.html +6 -6
  49. data/test/dummy/public/422.html +6 -6
  50. data/test/dummy/public/500.html +6 -6
  51. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  52. data/test/dummy/public/apple-touch-icon.png +0 -0
  53. data/test/dummy/public/robots.txt +1 -0
  54. data/test/dummy/test/application_system_test_case.rb +5 -0
  55. data/test/dummy/test/test_helper.rb +9 -0
  56. data/test/factories/uploads.rb +10 -3
  57. data/test/helpers/s3_relay/uploads_helper_test.rb +3 -3
  58. data/test/models/s3_relay/upload_test.rb +6 -5
  59. data/test/test_helper.rb +1 -0
  60. metadata +89 -33
  61. data/test/dummy/config/initializers/session_store.rb +0 -3
  62. data/test/dummy/log/development.log +0 -26
  63. data/test/dummy/log/test.log +0 -988
@@ -14,13 +14,14 @@ Rails.application.configure do
14
14
  config.consider_all_requests_local = false
15
15
  config.action_controller.perform_caching = true
16
16
 
17
- # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
- # Add `rack-cache` to your Gemfile before enabling this.
19
- # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
- # config.action_dispatch.rack_cache = true
17
+ # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
18
+ # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
19
+ # `config/secrets.yml.key`.
20
+ config.read_encrypted_secrets = true
21
21
 
22
- # Disable Rails's static asset server (Apache or nginx will already do this).
23
- config.serve_static_assets = false
22
+ # Disable serving static files from the `/public` folder by default since
23
+ # Apache or NGINX already handles this.
24
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
24
25
 
25
26
  # Compress JavaScripts and CSS.
26
27
  config.assets.js_compressor = :uglifier
@@ -29,32 +30,37 @@ Rails.application.configure do
29
30
  # Do not fallback to assets pipeline if a precompiled asset is missed.
30
31
  config.assets.compile = false
31
32
 
32
- # Generate digests for assets URLs.
33
- config.assets.digest = true
34
-
35
33
  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
36
34
 
35
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
36
+ # config.action_controller.asset_host = 'http://assets.example.com'
37
+
37
38
  # Specifies the header that your server uses for sending files.
38
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
39
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
39
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
40
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
41
+
42
+ # Mount Action Cable outside main process or domain
43
+ # config.action_cable.mount_path = nil
44
+ # config.action_cable.url = 'wss://example.com/cable'
45
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
40
46
 
41
47
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
42
48
  # config.force_ssl = true
43
49
 
44
- # Set to :debug to see everything in the log.
45
- config.log_level = :info
50
+ # Use the lowest log level to ensure availability of diagnostic information
51
+ # when problems arise.
52
+ config.log_level = :debug
46
53
 
47
54
  # Prepend all log lines with the following tags.
48
- # config.log_tags = [ :subdomain, :uuid ]
49
-
50
- # Use a different logger for distributed setups.
51
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
55
+ config.log_tags = [ :request_id ]
52
56
 
53
57
  # Use a different cache store in production.
54
58
  # config.cache_store = :mem_cache_store
55
59
 
56
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
57
- # config.action_controller.asset_host = "http://assets.example.com"
60
+ # Use a real queuing backend for Active Job (and separate queues per environment)
61
+ # config.active_job.queue_adapter = :resque
62
+ # config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
63
+ config.action_mailer.perform_caching = false
58
64
 
59
65
  # Ignore bad email addresses and do not raise email delivery errors.
60
66
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
@@ -67,12 +73,19 @@ Rails.application.configure do
67
73
  # Send deprecation notices to registered listeners.
68
74
  config.active_support.deprecation = :notify
69
75
 
70
- # Disable automatic flushing of the log to improve performance.
71
- # config.autoflush_log = false
72
-
73
76
  # Use default logging formatter so that PID and timestamp are not suppressed.
74
77
  config.log_formatter = ::Logger::Formatter.new
75
78
 
79
+ # Use a different logger for distributed setups.
80
+ # require 'syslog/logger'
81
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
82
+
83
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
84
+ logger = ActiveSupport::Logger.new(STDOUT)
85
+ logger.formatter = config.log_formatter
86
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
87
+ end
88
+
76
89
  # Do not dump schema after migrations.
77
90
  config.active_record.dump_schema_after_migration = false
78
91
  end
@@ -12,9 +12,11 @@ Rails.application.configure do
12
12
  # preloads Rails for running tests, you may have to set it to true.
13
13
  config.eager_load = false
14
14
 
15
- # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
17
- config.static_cache_control = 'public, max-age=3600'
15
+ # Configure public file server for tests with Cache-Control for performance.
16
+ config.public_file_server.enabled = true
17
+ config.public_file_server.headers = {
18
+ 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
19
+ }
18
20
 
19
21
  # Show full error reports and disable caching.
20
22
  config.consider_all_requests_local = true
@@ -25,6 +27,7 @@ Rails.application.configure do
25
27
 
26
28
  # Disable request forgery protection in test environment.
27
29
  config.action_controller.allow_forgery_protection = false
30
+ config.action_mailer.perform_caching = false
28
31
 
29
32
  # Tell Action Mailer not to deliver emails to the real world.
30
33
  # The :test delivery method accumulates sent emails in the
@@ -0,0 +1,6 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # ApplicationController.renderer.defaults.merge!(
4
+ # http_host: 'example.org',
5
+ # https: false
6
+ # )
@@ -3,6 +3,12 @@
3
3
  # Version of your assets, change this if you want to expire all your assets.
4
4
  Rails.application.config.assets.version = '1.0'
5
5
 
6
+ # Add additional assets to the asset load path.
7
+ # Rails.application.config.assets.paths << Emoji.images_path
8
+ # Add Yarn node_modules folder to the asset load path.
9
+ Rails.application.config.assets.paths << Rails.root.join('node_modules')
10
+
6
11
  # Precompile additional assets.
7
- # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
8
- # Rails.application.config.assets.precompile += %w( search.js )
12
+ # application.js, application.css, and all non-JS/CSS in the app/assets
13
+ # folder are already added.
14
+ # Rails.application.config.assets.precompile += %w( admin.js admin.css )
@@ -1,3 +1,5 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- Rails.application.config.action_dispatch.cookies_serializer = :json
3
+ # Specify a serializer for the signed and encrypted cookie jars.
4
+ # Valid options are :json, :marshal, and :hybrid.
5
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -5,10 +5,10 @@
5
5
 
6
6
  # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
7
  ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
8
+ wrap_parameters format: [:json]
9
9
  end
10
10
 
11
11
  # To enable root element in JSON for ActiveRecord objects.
12
12
  # ActiveSupport.on_load(:active_record) do
13
- # self.include_root_in_json = true
13
+ # self.include_root_in_json = true
14
14
  # end
@@ -16,6 +16,16 @@
16
16
  #
17
17
  # This would use the information in config/locales/es.yml.
18
18
  #
19
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # 'true': 'foo'
28
+ #
19
29
  # To learn more, please read the Rails Internationalization guide
20
30
  # available at http://guides.rubyonrails.org/i18n.html.
21
31
 
@@ -0,0 +1,56 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers: a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum; this matches the default thread size of Active Record.
6
+ #
7
+ threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8
+ threads threads_count, threads_count
9
+
10
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11
+ #
12
+ port ENV.fetch("PORT") { 3000 }
13
+
14
+ # Specifies the `environment` that Puma will run in.
15
+ #
16
+ environment ENV.fetch("RAILS_ENV") { "development" }
17
+
18
+ # Specifies the number of `workers` to boot in clustered mode.
19
+ # Workers are forked webserver processes. If using threads and workers together
20
+ # the concurrency of the application would be max `threads` * `workers`.
21
+ # Workers do not work on JRuby or Windows (both of which do not support
22
+ # processes).
23
+ #
24
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25
+
26
+ # Use the `preload_app!` method when specifying a `workers` number.
27
+ # This directive tells Puma to first boot the application and load code
28
+ # before forking the application. This takes advantage of Copy On Write
29
+ # process behavior so workers use less memory. If you use this option
30
+ # you need to make sure to reconnect any threads in the `on_worker_boot`
31
+ # block.
32
+ #
33
+ # preload_app!
34
+
35
+ # If you are preloading your application and using Active Record, it's
36
+ # recommended that you close any connections to the database before workers
37
+ # are forked to prevent connection leakage.
38
+ #
39
+ # before_fork do
40
+ # ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
41
+ # end
42
+
43
+ # The code in the `on_worker_boot` will be called if you are using
44
+ # clustered mode by specifying a number of `workers`. After each worker
45
+ # process is booted, this block will be run. If you are using the `preload_app!`
46
+ # option, you will want to use this block to reconnect to any threads
47
+ # or connections that may have been created at application boot, as Ruby
48
+ # cannot share connections between processes.
49
+ #
50
+ # on_worker_boot do
51
+ # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
52
+ # end
53
+ #
54
+
55
+ # Allow puma to be restarted by `rails restart` command.
56
+ plugin :tmp_restart
@@ -5,18 +5,28 @@
5
5
 
6
6
  # Make sure the secret is at least 30 characters and all random,
7
7
  # no regular words or you'll be exposed to dictionary attacks.
8
- # You can use `rake secret` to generate a secure secret key.
8
+ # You can use `rails secret` to generate a secure secret key.
9
9
 
10
10
  # Make sure the secrets in this file are kept private
11
11
  # if you're sharing your code publicly.
12
12
 
13
+ # Shared secrets are available across all environments.
14
+
15
+ # shared:
16
+ # api_key: a1B2c3D4e5F6
17
+
18
+ # Environmental secrets are only available for that specific environment.
19
+
13
20
  development:
14
- secret_key_base: b7e1648a8e124ff4a982a471d4b9472773f802ca7178afed271c731bfe7bd182a86688600c585c351f03e299957988f15ed3b8b86d7788486c4d78b41bdae470
21
+ secret_key_base: 19e610b06a453d05b6e62ef4ed269ed3d02714be49111f3003bb3a0afcb0bf4876765658e31d6e9a8ca3b7317c5455ef36c1c19f57342c3865f63cb8a04737b8
15
22
 
16
23
  test:
17
- secret_key_base: 4bba0b43791e5a1f22817205ea18549108b654c125920d6a1d076cd3e7b93743dbaa88127093f8bd423d9660df56ab85900999a0f2052073c843e883af0ec34f
24
+ secret_key_base: dd79062a967665de1536193b1e40f9816ba53ca659dd8227f0aa96675e1fbd951b519d6b431147102b9aca9df6ee335463617f57c9d58434071b4f9e1117cb59
25
+
26
+ # Do not keep production secrets in the unencrypted secrets file.
27
+ # Instead, either read values from the environment.
28
+ # Or, use `bin/rails secrets:setup` to configure encrypted secrets
29
+ # and move the `production:` environment over there.
18
30
 
19
- # Do not keep production secrets in the repository,
20
- # instead read values from the environment.
21
31
  production:
22
32
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,6 @@
1
+ %w(
2
+ .ruby-version
3
+ .rbenv-vars
4
+ tmp/restart.txt
5
+ tmp/caching-dev.txt
6
+ ).each { |path| Spring.watch(path) }
data/test/dummy/config.ru CHANGED
@@ -1,4 +1,5 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require_relative 'config/environment'
4
+
4
5
  run Rails.application
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7
+ # Character.create(name: 'Luke', movie: movies.first)
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "dummy",
3
+ "private": true,
4
+ "dependencies": {}
5
+ }
@@ -4,7 +4,7 @@
4
4
  <title>The page you were looking for doesn't exist (404)</title>
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
6
  <style>
7
- body {
7
+ .rails-default-error-page {
8
8
  background-color: #EFEFEF;
9
9
  color: #2E2F30;
10
10
  text-align: center;
@@ -12,13 +12,13 @@
12
12
  margin: 0;
13
13
  }
14
14
 
15
- div.dialog {
15
+ .rails-default-error-page div.dialog {
16
16
  width: 95%;
17
17
  max-width: 33em;
18
18
  margin: 4em auto 0;
19
19
  }
20
20
 
21
- div.dialog > div {
21
+ .rails-default-error-page div.dialog > div {
22
22
  border: 1px solid #CCC;
23
23
  border-right-color: #999;
24
24
  border-left-color: #999;
@@ -31,13 +31,13 @@
31
31
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
32
  }
33
33
 
34
- h1 {
34
+ .rails-default-error-page h1 {
35
35
  font-size: 100%;
36
36
  color: #730E15;
37
37
  line-height: 1.5em;
38
38
  }
39
39
 
40
- div.dialog > p {
40
+ .rails-default-error-page div.dialog > p {
41
41
  margin: 0 0 1em;
42
42
  padding: 1em;
43
43
  background-color: #F7F7F7;
@@ -54,7 +54,7 @@
54
54
  </style>
55
55
  </head>
56
56
 
57
- <body>
57
+ <body class="rails-default-error-page">
58
58
  <!-- This file lives in public/404.html -->
59
59
  <div class="dialog">
60
60
  <div>
@@ -4,7 +4,7 @@
4
4
  <title>The change you wanted was rejected (422)</title>
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
6
  <style>
7
- body {
7
+ .rails-default-error-page {
8
8
  background-color: #EFEFEF;
9
9
  color: #2E2F30;
10
10
  text-align: center;
@@ -12,13 +12,13 @@
12
12
  margin: 0;
13
13
  }
14
14
 
15
- div.dialog {
15
+ .rails-default-error-page div.dialog {
16
16
  width: 95%;
17
17
  max-width: 33em;
18
18
  margin: 4em auto 0;
19
19
  }
20
20
 
21
- div.dialog > div {
21
+ .rails-default-error-page div.dialog > div {
22
22
  border: 1px solid #CCC;
23
23
  border-right-color: #999;
24
24
  border-left-color: #999;
@@ -31,13 +31,13 @@
31
31
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
32
  }
33
33
 
34
- h1 {
34
+ .rails-default-error-page h1 {
35
35
  font-size: 100%;
36
36
  color: #730E15;
37
37
  line-height: 1.5em;
38
38
  }
39
39
 
40
- div.dialog > p {
40
+ .rails-default-error-page div.dialog > p {
41
41
  margin: 0 0 1em;
42
42
  padding: 1em;
43
43
  background-color: #F7F7F7;
@@ -54,7 +54,7 @@
54
54
  </style>
55
55
  </head>
56
56
 
57
- <body>
57
+ <body class="rails-default-error-page">
58
58
  <!-- This file lives in public/422.html -->
59
59
  <div class="dialog">
60
60
  <div>
@@ -4,7 +4,7 @@
4
4
  <title>We're sorry, but something went wrong (500)</title>
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
6
  <style>
7
- body {
7
+ .rails-default-error-page {
8
8
  background-color: #EFEFEF;
9
9
  color: #2E2F30;
10
10
  text-align: center;
@@ -12,13 +12,13 @@
12
12
  margin: 0;
13
13
  }
14
14
 
15
- div.dialog {
15
+ .rails-default-error-page div.dialog {
16
16
  width: 95%;
17
17
  max-width: 33em;
18
18
  margin: 4em auto 0;
19
19
  }
20
20
 
21
- div.dialog > div {
21
+ .rails-default-error-page div.dialog > div {
22
22
  border: 1px solid #CCC;
23
23
  border-right-color: #999;
24
24
  border-left-color: #999;
@@ -31,13 +31,13 @@
31
31
  box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
32
  }
33
33
 
34
- h1 {
34
+ .rails-default-error-page h1 {
35
35
  font-size: 100%;
36
36
  color: #730E15;
37
37
  line-height: 1.5em;
38
38
  }
39
39
 
40
- div.dialog > p {
40
+ .rails-default-error-page div.dialog > p {
41
41
  margin: 0 0 1em;
42
42
  padding: 1em;
43
43
  background-color: #F7F7F7;
@@ -54,7 +54,7 @@
54
54
  </style>
55
55
  </head>
56
56
 
57
- <body>
57
+ <body class="rails-default-error-page">
58
58
  <!-- This file lives in public/500.html -->
59
59
  <div class="dialog">
60
60
  <div>
File without changes
@@ -0,0 +1 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
@@ -0,0 +1,5 @@
1
+ require "test_helper"
2
+
3
+ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
4
+ driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
5
+ end
@@ -0,0 +1,9 @@
1
+ require File.expand_path('../../config/environment', __FILE__)
2
+ require 'rails/test_help'
3
+
4
+ class ActiveSupport::TestCase
5
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
6
+ fixtures :all
7
+
8
+ # Add more helper methods to be used by all tests here...
9
+ end
@@ -1,16 +1,23 @@
1
1
  FactoryGirl.define do
2
2
  factory :upload, class: "S3Relay::Upload" do
3
- uuid SecureRandom.uuid
3
+ uuid { SecureRandom.uuid }
4
+ end
5
+
6
+ factory :file_upload, parent: :upload do
4
7
  filename "cat.png"
5
8
  content_type "image/png"
6
9
  upload_type "FileUpload"
7
10
  end
8
11
 
9
12
  factory :icon_upload, parent: :upload do
10
- upload_type "IconUpload"
13
+ filename "cat.png"
14
+ content_type "image/png"
15
+ upload_type "IconUpload"
11
16
  end
12
17
 
13
18
  factory :photo_upload, parent: :upload do
14
- upload_type "PhotoUpload"
19
+ filename "cat.png"
20
+ content_type "image/png"
21
+ upload_type "PhotoUpload"
15
22
  end
16
23
  end
@@ -7,21 +7,21 @@ describe S3Relay::UploadsHelper do
7
7
  describe "without options" do
8
8
  it do
9
9
  s3_relay_field(@product, :photo_uploads)
10
- .must_equal %Q{<div class="s3r-container" data-association="photo_uploads" data-disposition=\"inline\" data-parent-id="#{@product.id}" data-parent-type="product"><input class="s3r-field" id="file" name="file" type="file" /><table class="s3r-upload-list"></table></div>}
10
+ .must_equal %Q{<div class="s3r-container" data-parent-type="product" data-parent-id="#{@product.id}" data-association="photo_uploads" data-disposition=\"inline\"><input type="file" name="file" id="file" class="s3r-field" /><table class="s3r-upload-list"></table></div>}
11
11
  end
12
12
  end
13
13
 
14
14
  describe "with multiple: true" do
15
15
  it do
16
16
  s3_relay_field(@product, :photo_uploads, multiple: true)
17
- .must_equal %Q{<div class="s3r-container" data-association="photo_uploads" data-disposition=\"inline\" data-parent-id="#{@product.id}" data-parent-type="product"><input class="s3r-field" id="file" multiple="multiple" name="file" type="file" /><table class="s3r-upload-list"></table></div>}
17
+ .must_equal %Q{<div class="s3r-container" data-parent-type="product" data-parent-id="#{@product.id}" data-association="photo_uploads" data-disposition=\"inline\"><input type="file" name="file" id="file" multiple="multiple" class="s3r-field" /><table class="s3r-upload-list"></table></div>}
18
18
  end
19
19
  end
20
20
 
21
21
  describe "with disposition: attachment" do
22
22
  it do
23
23
  s3_relay_field(@product, :photo_uploads, disposition: :attachment)
24
- .must_equal %Q{<div class="s3r-container" data-association="photo_uploads" data-disposition=\"attachment\" data-parent-id="#{@product.id}" data-parent-type="product"><input class="s3r-field" disposition=\"attachment\" id="file" name="file" type="file" /><table class="s3r-upload-list"></table></div>}
24
+ .must_equal %Q{<div class="s3r-container" data-parent-type="product" data-parent-id="#{@product.id}" data-association="photo_uploads" data-disposition=\"attachment\"><input type="file" name="file" id="file" disposition=\"attachment\" class="s3r-field" /><table class="s3r-upload-list"></table></div>}
25
25
  end
26
26
  end
27
27
  end
@@ -2,7 +2,7 @@ require "test_helper"
2
2
 
3
3
  describe S3Relay::Upload do
4
4
  before do
5
- @upload = S3Relay::Upload.new
5
+ @upload = FactoryGirl.build(:upload)
6
6
  end
7
7
 
8
8
  describe "associations" do
@@ -17,12 +17,13 @@ describe S3Relay::Upload do
17
17
  describe "validations" do
18
18
  describe "uuid" do
19
19
  it "validates presence" do
20
+ @upload.uuid = nil
20
21
  @upload.valid?
21
22
  @upload.errors[:uuid].must_include("can't be blank")
22
23
  end
23
24
 
24
25
  it "validates uniqueness" do
25
- S3Relay::Upload.new(uuid: @upload.uuid).save!(validate: false)
26
+ FactoryGirl.create(:file_upload, uuid: @upload.uuid)
26
27
  @upload.valid?
27
28
  @upload.errors[:uuid].must_include("has already been taken")
28
29
  end
@@ -60,9 +61,9 @@ describe S3Relay::Upload do
60
61
 
61
62
  describe "scopes" do
62
63
  before do
63
- @pending = S3Relay::Upload.new
64
+ @pending = FactoryGirl.build(:file_upload)
64
65
  .tap { |u| u.save(validate: false) }
65
- @imported = S3Relay::Upload.new(state: "imported")
66
+ @imported = FactoryGirl.build(:upload, state: "imported")
66
67
  .tap { |u| u.save(validate: false) }
67
68
  end
68
69
 
@@ -110,7 +111,7 @@ describe S3Relay::Upload do
110
111
  end
111
112
 
112
113
  describe "#notify_parent" do
113
- before { @upload = FactoryGirl.build(:upload) }
114
+ before { @upload = FactoryGirl.build(:file_upload) }
114
115
 
115
116
  describe "when the parent is associated" do
116
117
  it do
data/test/test_helper.rb CHANGED
@@ -24,5 +24,6 @@ require "rails/generators"
24
24
  require "rails/test_help"
25
25
  require "minitest/rails"
26
26
  require "minitest/pride"
27
+ require "mocha/mini_test"
27
28
 
28
29
  Dir[File.join("./test/support/*.rb")].sort.each { |f| require f }