card 1.19.3 → 1.19.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/VERSION +1 -1
- data/card.gemspec +1 -3
- data/db/migrate_core_cards/20160914132636_fix_mod_files.rb +25 -0
- data/lib/card.rb +0 -2
- data/lib/card/content/diff.rb +3 -4
- data/lib/card/format/error.rb +1 -1
- data/mod/admin/set/self/admin.rb +2 -2
- data/mod/admin/set/self/trash.rb +9 -3
- data/mod/basic_types/set/type/html.rb +1 -1
- data/mod/bootstrap/set/all/bootstrap/layout.rb +58 -0
- data/mod/bootstrap/spec/set/all/bootstrap/layout_spec.rb +32 -0
- data/mod/carrierwave/lib/carrier_wave/cardmount.rb +0 -2
- data/mod/carrierwave/set/abstract/attachment/upload_cache.rb +2 -1
- data/mod/core/set/all/stages.rb +6 -4
- data/mod/history/lib/card/act.rb +8 -7
- data/mod/history/set/all/history.rb +10 -8
- data/mod/machines/set/abstract/script.rb +1 -1
- data/mod/machines/set/type/css.rb +1 -1
- data/mod/pointer/set/abstract/01_pointer.rb +1 -1
- data/mod/standard/file/credit_image/image-icon.png +0 -0
- data/mod/standard/file/credit_image/image-large.png +0 -0
- data/mod/standard/file/credit_image/image-medium.png +0 -0
- data/mod/standard/file/credit_image/image-small.png +0 -0
- data/mod/standard/file/favicon/image-icon.png +0 -0
- data/mod/standard/file/favicon/image-large.png +0 -0
- data/mod/standard/file/favicon/image-medium.png +0 -0
- data/mod/standard/file/favicon/image-small.png +0 -0
- data/mod/standard/file/logo/image-icon.png +0 -0
- data/mod/standard/file/logo/image-large.png +0 -0
- data/mod/standard/file/logo/image-medium.png +0 -0
- data/mod/standard/file/logo/image-small.png +0 -0
- data/mod/standard/set/self/recent.rb +2 -2
- data/spec/lib/card/diff_spec.rb +9 -9
- metadata +19 -156
- data/vendor/carrierwave/.gitignore +0 -19
- data/vendor/carrierwave/.rubocop.yml +0 -262
- data/vendor/carrierwave/.travis.yml +0 -58
- data/vendor/carrierwave/CHANGELOG.md +0 -81
- data/vendor/carrierwave/CONTRIBUTING.md +0 -37
- data/vendor/carrierwave/Gemfile +0 -5
- data/vendor/carrierwave/README.md +0 -995
- data/vendor/carrierwave/Rakefile +0 -26
- data/vendor/carrierwave/carrierwave.gemspec +0 -45
- data/vendor/carrierwave/cucumber.yml +0 -2
- data/vendor/carrierwave/features/caching.feature +0 -28
- data/vendor/carrierwave/features/download.feature +0 -20
- data/vendor/carrierwave/features/file_storage.feature +0 -37
- data/vendor/carrierwave/features/file_storage_overridden_filename.feature +0 -38
- data/vendor/carrierwave/features/file_storage_overridden_store_dir.feature +0 -38
- data/vendor/carrierwave/features/file_storage_reversing_processor.feature +0 -43
- data/vendor/carrierwave/features/fixtures/bork.txt +0 -1
- data/vendor/carrierwave/features/fixtures/monkey.txt +0 -1
- data/vendor/carrierwave/features/fixtures/upcased_bork.txt +0 -1
- data/vendor/carrierwave/features/mount_activerecord.feature +0 -46
- data/vendor/carrierwave/features/step_definitions/activerecord_steps.rb +0 -20
- data/vendor/carrierwave/features/step_definitions/caching_steps.rb +0 -12
- data/vendor/carrierwave/features/step_definitions/datamapper_steps.rb +0 -27
- data/vendor/carrierwave/features/step_definitions/download_steps.rb +0 -8
- data/vendor/carrierwave/features/step_definitions/file_steps.rb +0 -51
- data/vendor/carrierwave/features/step_definitions/general_steps.rb +0 -102
- data/vendor/carrierwave/features/step_definitions/mount_steps.rb +0 -17
- data/vendor/carrierwave/features/step_definitions/store_steps.rb +0 -16
- data/vendor/carrierwave/features/support/activerecord.rb +0 -18
- data/vendor/carrierwave/features/support/env.rb +0 -19
- data/vendor/carrierwave/features/versions_basics.feature +0 -50
- data/vendor/carrierwave/features/versions_caching_from_versions.feature +0 -32
- data/vendor/carrierwave/features/versions_nested_versions.feature +0 -70
- data/vendor/carrierwave/features/versions_overridden_filename.feature +0 -51
- data/vendor/carrierwave/features/versions_overriden_store_dir.feature +0 -41
- data/vendor/carrierwave/gemfiles/rails-4-0-stable.gemfile +0 -5
- data/vendor/carrierwave/gemfiles/rails-4-1-stable.gemfile +0 -5
- data/vendor/carrierwave/gemfiles/rails-4-2-stable.gemfile +0 -5
- data/vendor/carrierwave/gemfiles/rails-master.gemfile +0 -11
- data/vendor/carrierwave/lib/carrierwave.rb +0 -93
- data/vendor/carrierwave/lib/carrierwave/compatibility/paperclip.rb +0 -103
- data/vendor/carrierwave/lib/carrierwave/error.rb +0 -8
- data/vendor/carrierwave/lib/carrierwave/locale/cs.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/de.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/el.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/en.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/es.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/fr-CA.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/fr.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/id.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/ja.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/nb.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/nl.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/pl.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/pt-BR.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/pt-PT.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/ru.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/sk.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/tr.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/zh-CN.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/locale/zh-TW.yml +0 -14
- data/vendor/carrierwave/lib/carrierwave/mount.rb +0 -444
- data/vendor/carrierwave/lib/carrierwave/mounter.rb +0 -163
- data/vendor/carrierwave/lib/carrierwave/orm/activerecord.rb +0 -103
- data/vendor/carrierwave/lib/carrierwave/processing.rb +0 -2
- data/vendor/carrierwave/lib/carrierwave/processing/mini_magick.rb +0 -328
- data/vendor/carrierwave/lib/carrierwave/processing/rmagick.rb +0 -379
- data/vendor/carrierwave/lib/carrierwave/sanitized_file.rb +0 -348
- data/vendor/carrierwave/lib/carrierwave/storage.rb +0 -2
- data/vendor/carrierwave/lib/carrierwave/storage/abstract.rb +0 -43
- data/vendor/carrierwave/lib/carrierwave/storage/file.rb +0 -118
- data/vendor/carrierwave/lib/carrierwave/storage/fog.rb +0 -462
- data/vendor/carrierwave/lib/carrierwave/test/matchers.rb +0 -394
- data/vendor/carrierwave/lib/carrierwave/uploader.rb +0 -67
- data/vendor/carrierwave/lib/carrierwave/uploader/cache.rb +0 -207
- data/vendor/carrierwave/lib/carrierwave/uploader/callbacks.rb +0 -33
- data/vendor/carrierwave/lib/carrierwave/uploader/configuration.rb +0 -203
- data/vendor/carrierwave/lib/carrierwave/uploader/content_type_blacklist.rb +0 -48
- data/vendor/carrierwave/lib/carrierwave/uploader/content_type_whitelist.rb +0 -48
- data/vendor/carrierwave/lib/carrierwave/uploader/default_url.rb +0 -17
- data/vendor/carrierwave/lib/carrierwave/uploader/download.rb +0 -92
- data/vendor/carrierwave/lib/carrierwave/uploader/extension_blacklist.rb +0 -51
- data/vendor/carrierwave/lib/carrierwave/uploader/extension_whitelist.rb +0 -51
- data/vendor/carrierwave/lib/carrierwave/uploader/file_size.rb +0 -41
- data/vendor/carrierwave/lib/carrierwave/uploader/magic_mime_blacklist.rb +0 -94
- data/vendor/carrierwave/lib/carrierwave/uploader/magic_mime_whitelist.rb +0 -94
- data/vendor/carrierwave/lib/carrierwave/uploader/mountable.rb +0 -38
- data/vendor/carrierwave/lib/carrierwave/uploader/processing.rb +0 -88
- data/vendor/carrierwave/lib/carrierwave/uploader/proxy.rb +0 -86
- data/vendor/carrierwave/lib/carrierwave/uploader/remove.rb +0 -21
- data/vendor/carrierwave/lib/carrierwave/uploader/serialization.rb +0 -28
- data/vendor/carrierwave/lib/carrierwave/uploader/store.rb +0 -93
- data/vendor/carrierwave/lib/carrierwave/uploader/url.rb +0 -41
- data/vendor/carrierwave/lib/carrierwave/uploader/versions.rb +0 -295
- data/vendor/carrierwave/lib/carrierwave/utilities.rb +0 -6
- data/vendor/carrierwave/lib/carrierwave/utilities/uri.rb +0 -21
- data/vendor/carrierwave/lib/carrierwave/validations/active_model.rb +0 -78
- data/vendor/carrierwave/lib/carrierwave/version.rb +0 -3
- data/vendor/carrierwave/lib/generators/templates/uploader.rb +0 -49
- data/vendor/carrierwave/lib/generators/uploader_generator.rb +0 -7
- data/vendor/carrierwave/script/console +0 -10
- data/vendor/carrierwave/script/destroy +0 -14
- data/vendor/carrierwave/script/generate +0 -14
- data/vendor/carrierwave/spec/compatibility/paperclip_spec.rb +0 -138
- data/vendor/carrierwave/spec/fixtures/Uppercase.jpg +0 -1
- data/vendor/carrierwave/spec/fixtures/bork.ttxt +0 -1
- data/vendor/carrierwave/spec/fixtures/bork.txt +0 -1
- data/vendor/carrierwave/spec/fixtures/bork.txtt +0 -1
- data/vendor/carrierwave/spec/fixtures/case.JPG +0 -1
- data/vendor/carrierwave/spec/fixtures/landscape.jpg +0 -0
- data/vendor/carrierwave/spec/fixtures/multi_page.pdf +0 -0
- data/vendor/carrierwave/spec/fixtures/new.jpeg +0 -1
- data/vendor/carrierwave/spec/fixtures/new.txt +0 -1
- data/vendor/carrierwave/spec/fixtures/old.jpeg +0 -1
- data/vendor/carrierwave/spec/fixtures/old.txt +0 -1
- data/vendor/carrierwave/spec/fixtures/portrait.jpg +0 -0
- data/vendor/carrierwave/spec/fixtures/ruby.gif +0 -0
- data/vendor/carrierwave/spec/fixtures/sponsored.doc +0 -1
- data/vendor/carrierwave/spec/fixtures/test+.jpg +0 -1
- data/vendor/carrierwave/spec/fixtures/test.jpeg +0 -1
- data/vendor/carrierwave/spec/fixtures/test.jpg +0 -1
- data/vendor/carrierwave/spec/generators/uploader_generator_spec.rb +0 -19
- data/vendor/carrierwave/spec/mount_multiple_spec.rb +0 -913
- data/vendor/carrierwave/spec/mount_single_spec.rb +0 -793
- data/vendor/carrierwave/spec/orm/activerecord_spec.rb +0 -1556
- data/vendor/carrierwave/spec/processing/mini_magick_spec.rb +0 -210
- data/vendor/carrierwave/spec/processing/rmagick_spec.rb +0 -250
- data/vendor/carrierwave/spec/sanitized_file_spec.rb +0 -805
- data/vendor/carrierwave/spec/spec_helper.rb +0 -105
- data/vendor/carrierwave/spec/storage/file_spec.rb +0 -82
- data/vendor/carrierwave/spec/storage/fog_credentials.rb +0 -46
- data/vendor/carrierwave/spec/storage/fog_helper.rb +0 -428
- data/vendor/carrierwave/spec/storage/fog_spec.rb +0 -48
- data/vendor/carrierwave/spec/support/activerecord.rb +0 -31
- data/vendor/carrierwave/spec/support/file_utils_helper.rb +0 -15
- data/vendor/carrierwave/spec/uploader/cache_spec.rb +0 -324
- data/vendor/carrierwave/spec/uploader/callback_spec.rb +0 -30
- data/vendor/carrierwave/spec/uploader/configuration_spec.rb +0 -133
- data/vendor/carrierwave/spec/uploader/content_type_blacklist_spec.rb +0 -61
- data/vendor/carrierwave/spec/uploader/content_type_whitelist_spec.rb +0 -63
- data/vendor/carrierwave/spec/uploader/default_url_spec.rb +0 -77
- data/vendor/carrierwave/spec/uploader/download_spec.rb +0 -204
- data/vendor/carrierwave/spec/uploader/extension_blacklist_spec.rb +0 -112
- data/vendor/carrierwave/spec/uploader/extension_whitelist_spec.rb +0 -102
- data/vendor/carrierwave/spec/uploader/file_size_spec.rb +0 -52
- data/vendor/carrierwave/spec/uploader/mountable_spec.rb +0 -26
- data/vendor/carrierwave/spec/uploader/overrides_spec.rb +0 -71
- data/vendor/carrierwave/spec/uploader/paths_spec.rb +0 -18
- data/vendor/carrierwave/spec/uploader/processing_spec.rb +0 -159
- data/vendor/carrierwave/spec/uploader/proxy_spec.rb +0 -79
- data/vendor/carrierwave/spec/uploader/remove_spec.rb +0 -71
- data/vendor/carrierwave/spec/uploader/store_spec.rb +0 -400
- data/vendor/carrierwave/spec/uploader/url_spec.rb +0 -273
- data/vendor/carrierwave/spec/uploader/versions_spec.rb +0 -633
@@ -1,21 +0,0 @@
|
|
1
|
-
module CarrierWave
|
2
|
-
module Utilities
|
3
|
-
module Uri
|
4
|
-
# based on Ruby < 2.0's URI.encode
|
5
|
-
SAFE_STRING = URI::REGEXP::PATTERN::UNRESERVED + '\/'
|
6
|
-
UNSAFE = Regexp.new("[^#{SAFE_STRING}]", false)
|
7
|
-
|
8
|
-
private
|
9
|
-
def encode_path(path)
|
10
|
-
path.to_s.gsub(UNSAFE) do
|
11
|
-
us = $&
|
12
|
-
tmp = ''
|
13
|
-
us.each_byte do |uc|
|
14
|
-
tmp << sprintf('%%%02X', uc)
|
15
|
-
end
|
16
|
-
tmp
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end # Uri
|
20
|
-
end # Utilities
|
21
|
-
end # CarrierWave
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'active_model/validator'
|
2
|
-
require 'active_support/concern'
|
3
|
-
|
4
|
-
module CarrierWave
|
5
|
-
|
6
|
-
# == Active Model Presence Validator
|
7
|
-
module Validations
|
8
|
-
module ActiveModel
|
9
|
-
extend ActiveSupport::Concern
|
10
|
-
|
11
|
-
class ProcessingValidator < ::ActiveModel::EachValidator
|
12
|
-
|
13
|
-
def validate_each(record, attribute, value)
|
14
|
-
if e = record.send("#{attribute}_processing_error")
|
15
|
-
message = (e.message == e.class.to_s) ? :carrierwave_processing_error : e.message
|
16
|
-
record.errors.add(attribute, message)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class IntegrityValidator < ::ActiveModel::EachValidator
|
22
|
-
|
23
|
-
def validate_each(record, attribute, value)
|
24
|
-
if e = record.send("#{attribute}_integrity_error")
|
25
|
-
message = (e.message == e.class.to_s) ? :carrierwave_integrity_error : e.message
|
26
|
-
record.errors.add(attribute, message)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
class DownloadValidator < ::ActiveModel::EachValidator
|
32
|
-
|
33
|
-
def validate_each(record, attribute, value)
|
34
|
-
if e = record.send("#{attribute}_download_error")
|
35
|
-
message = (e.message == e.class.to_s) ? :carrierwave_download_error : e.message
|
36
|
-
record.errors.add(attribute, message)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
module HelperMethods
|
42
|
-
|
43
|
-
##
|
44
|
-
# Makes the record invalid if the file couldn't be uploaded due to an integrity error
|
45
|
-
#
|
46
|
-
# Accepts the usual parameters for validations in Rails (:if, :unless, etc...)
|
47
|
-
#
|
48
|
-
def validates_integrity_of(*attr_names)
|
49
|
-
validates_with IntegrityValidator, _merge_attributes(attr_names)
|
50
|
-
end
|
51
|
-
|
52
|
-
##
|
53
|
-
# Makes the record invalid if the file couldn't be processed (assuming the process failed
|
54
|
-
# with a CarrierWave::ProcessingError)
|
55
|
-
#
|
56
|
-
# Accepts the usual parameters for validations in Rails (:if, :unless, etc...)
|
57
|
-
#
|
58
|
-
def validates_processing_of(*attr_names)
|
59
|
-
validates_with ProcessingValidator, _merge_attributes(attr_names)
|
60
|
-
end
|
61
|
-
#
|
62
|
-
##
|
63
|
-
# Makes the record invalid if the remote file couldn't be downloaded
|
64
|
-
#
|
65
|
-
# Accepts the usual parameters for validations in Rails (:if, :unless, etc...)
|
66
|
-
#
|
67
|
-
def validates_download_of(*attr_names)
|
68
|
-
validates_with DownloadValidator, _merge_attributes(attr_names)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
included do
|
73
|
-
extend HelperMethods
|
74
|
-
include HelperMethods
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
class <%= class_name %>Uploader < CarrierWave::Uploader::Base
|
2
|
-
|
3
|
-
# Include RMagick or MiniMagick support:
|
4
|
-
# include CarrierWave::RMagick
|
5
|
-
# include CarrierWave::MiniMagick
|
6
|
-
|
7
|
-
# Choose what kind of storage to use for this uploader:
|
8
|
-
storage :file
|
9
|
-
# storage :fog
|
10
|
-
|
11
|
-
# Override the directory where uploaded files will be stored.
|
12
|
-
# This is a sensible default for uploaders that are meant to be mounted:
|
13
|
-
def store_dir
|
14
|
-
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
15
|
-
end
|
16
|
-
|
17
|
-
# Provide a default URL as a default if there hasn't been a file uploaded:
|
18
|
-
# def default_url
|
19
|
-
# # For Rails 3.1+ asset pipeline compatibility:
|
20
|
-
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
21
|
-
#
|
22
|
-
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
23
|
-
# end
|
24
|
-
|
25
|
-
# Process files as they are uploaded:
|
26
|
-
# process scale: [200, 300]
|
27
|
-
#
|
28
|
-
# def scale(width, height)
|
29
|
-
# # do something
|
30
|
-
# end
|
31
|
-
|
32
|
-
# Create different versions of your uploaded files:
|
33
|
-
# version :thumb do
|
34
|
-
# process resize_to_fit: [50, 50]
|
35
|
-
# end
|
36
|
-
|
37
|
-
# Add a white list of extensions which are allowed to be uploaded.
|
38
|
-
# For images you might use something like this:
|
39
|
-
# def extension_whitelist
|
40
|
-
# %w(jpg jpeg gif png)
|
41
|
-
# end
|
42
|
-
|
43
|
-
# Override the filename of the uploaded files:
|
44
|
-
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
45
|
-
# def filename
|
46
|
-
# "something.jpg" if original_filename
|
47
|
-
# end
|
48
|
-
|
49
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# File: script/console
|
3
|
-
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
-
|
5
|
-
libs = " -r irb/completion"
|
6
|
-
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
-
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
-
libs << " -r #{File.dirname(__FILE__) + '/../lib/carrierwave.rb'}"
|
9
|
-
puts "Loading carrierwave gem"
|
10
|
-
exec "#{irb} #{libs} --simple-prompt"
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/destroy'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/generate'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Generate.new.run(ARGV)
|
@@ -1,138 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'carrierwave/orm/activerecord'
|
3
|
-
|
4
|
-
module Rails; end unless defined?(Rails)
|
5
|
-
|
6
|
-
describe CarrierWave::Compatibility::Paperclip do
|
7
|
-
let(:uploader_class) do
|
8
|
-
Class.new(CarrierWave::Uploader::Base) do
|
9
|
-
include CarrierWave::Compatibility::Paperclip
|
10
|
-
|
11
|
-
version :thumb
|
12
|
-
version :list
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:model) { double('model') }
|
17
|
-
|
18
|
-
let(:uploader) { uploader_class.new(model, :monkey) }
|
19
|
-
|
20
|
-
before do
|
21
|
-
allow(Rails).to receive(:root).and_return('/rails/root')
|
22
|
-
allow(Rails).to receive(:env).and_return('test')
|
23
|
-
allow(model).to receive(:id).and_return(23)
|
24
|
-
allow(model).to receive(:ook).and_return('eek')
|
25
|
-
allow(model).to receive(:money).and_return('monkey.png')
|
26
|
-
end
|
27
|
-
|
28
|
-
after { FileUtils.rm_rf(public_path) }
|
29
|
-
|
30
|
-
describe '#store_path' do
|
31
|
-
subject { uploader.store_path("monkey.png") }
|
32
|
-
|
33
|
-
it "mimics paperclip default" do
|
34
|
-
is_expected.to eq("/rails/root/public/system/monkeys/23/original/monkey.png")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "interpolates the root path" do
|
38
|
-
allow(uploader).to receive(:paperclip_path).and_return(":rails_root/foo/bar")
|
39
|
-
is_expected.to eq(Rails.root + "/foo/bar")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "interpolates the attachment" do
|
43
|
-
allow(uploader).to receive(:paperclip_path).and_return("/foo/:attachment/bar")
|
44
|
-
is_expected.to eq("/foo/monkeys/bar")
|
45
|
-
end
|
46
|
-
|
47
|
-
it "interpolates the id" do
|
48
|
-
allow(uploader).to receive(:paperclip_path).and_return("/foo/:id/bar")
|
49
|
-
is_expected.to eq("/foo/23/bar")
|
50
|
-
end
|
51
|
-
|
52
|
-
it "interpolates the id partition" do
|
53
|
-
allow(uploader).to receive(:paperclip_path).and_return("/foo/:id_partition/bar")
|
54
|
-
is_expected.to eq("/foo/000/000/023/bar")
|
55
|
-
end
|
56
|
-
|
57
|
-
it "interpolates the basename" do
|
58
|
-
allow(uploader).to receive(:paperclip_path).and_return("/foo/:basename/bar")
|
59
|
-
is_expected.to eq("/foo/monkey/bar")
|
60
|
-
end
|
61
|
-
|
62
|
-
it "interpolates the extension" do
|
63
|
-
allow(uploader).to receive(:paperclip_path).and_return("/foo/:extension/bar")
|
64
|
-
is_expected.to eq("/foo/png/bar")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '.interpolate' do
|
69
|
-
subject { uploader.store_path("monkey.png") }
|
70
|
-
|
71
|
-
before do
|
72
|
-
uploader_class.interpolate :ook do |custom, style|
|
73
|
-
custom.model.ook
|
74
|
-
end
|
75
|
-
|
76
|
-
uploader_class.interpolate :aak do |model, style|
|
77
|
-
style
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'allows you to add custom interpolations' do
|
82
|
-
allow(uploader).to receive(:paperclip_path).and_return("/foo/:id/:ook")
|
83
|
-
is_expected.to eq('/foo/23/eek')
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'mimics paperclips arguments' do
|
87
|
-
allow(uploader).to receive(:paperclip_path).and_return("/foo/:aak")
|
88
|
-
is_expected.to eq('/foo/original')
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'when multiple uploaders include the compatibility module' do
|
92
|
-
let(:uploader) { uploader_class_other.new(model, :monkey) }
|
93
|
-
let(:uploader_class_other) do
|
94
|
-
Class.new(CarrierWave::Uploader::Base) do
|
95
|
-
include CarrierWave::Compatibility::Paperclip
|
96
|
-
|
97
|
-
version :thumb
|
98
|
-
version :list
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
before { allow(uploader).to receive(:paperclip_path).and_return("/foo/:id/:ook") }
|
103
|
-
|
104
|
-
it "doesn't share custom interpolations" do
|
105
|
-
is_expected.to eq('/foo/23/:ook')
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'when there are multiple versions' do
|
110
|
-
let(:complex_uploader_class) do
|
111
|
-
Class.new(CarrierWave::Uploader::Base) do
|
112
|
-
include CarrierWave::Compatibility::Paperclip
|
113
|
-
|
114
|
-
interpolate :ook do |model, style|
|
115
|
-
'eek'
|
116
|
-
end
|
117
|
-
|
118
|
-
version :thumb
|
119
|
-
version :list
|
120
|
-
|
121
|
-
def paperclip_path
|
122
|
-
"#{public_path}/foo/:ook/:id/:style"
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
let(:uploader) { complex_uploader_class.new(model, :monkey) }
|
128
|
-
let!(:file) { File.open(file_path('test.jpg')) }
|
129
|
-
|
130
|
-
before { uploader.store!(file) }
|
131
|
-
|
132
|
-
it 'interpolates for all versions correctly' do
|
133
|
-
expect(uploader.thumb.path).to eq("#{public_path}/foo/eek/23/thumb")
|
134
|
-
expect(uploader.list.path).to eq("#{public_path}/foo/eek/23/list")
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
this is stuff
|
@@ -1 +0,0 @@
|
|
1
|
-
bork bork bork Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
@@ -1 +0,0 @@
|
|
1
|
-
bork bork bork Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
@@ -1 +0,0 @@
|
|
1
|
-
bork bork bork Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
@@ -1 +0,0 @@
|
|
1
|
-
this is stuff
|
Binary file
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
this is stuff
|
@@ -1 +0,0 @@
|
|
1
|
-
bork bork bork Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
@@ -1 +0,0 @@
|
|
1
|
-
this is stuff
|
@@ -1 +0,0 @@
|
|
1
|
-
bork bork bork Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
Binary file
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
Hi there
|
@@ -1 +0,0 @@
|
|
1
|
-
this is stuff
|
@@ -1 +0,0 @@
|
|
1
|
-
this is stuff
|
@@ -1 +0,0 @@
|
|
1
|
-
this is stuff
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'generator_spec'
|
3
|
-
require 'generators/uploader_generator'
|
4
|
-
|
5
|
-
describe UploaderGenerator, :type => :generator do
|
6
|
-
destination(File.expand_path("../../tmp", __FILE__))
|
7
|
-
|
8
|
-
before { prepare_destination }
|
9
|
-
|
10
|
-
it "creates uploader file" do
|
11
|
-
run_generator %w(Avatar)
|
12
|
-
assert_file 'app/uploaders/avatar_uploader.rb', /class AvatarUploader < CarrierWave::Uploader::Base/
|
13
|
-
end
|
14
|
-
|
15
|
-
it "creates namespaced uploader file" do
|
16
|
-
run_generator %w(MyModule::Avatar)
|
17
|
-
assert_file 'app/uploaders/my_module/avatar_uploader.rb', /class MyModule::AvatarUploader < CarrierWave::Uploader::Base/
|
18
|
-
end
|
19
|
-
end
|
@@ -1,913 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe CarrierWave::Mount do
|
4
|
-
let(:klass) { Class.new.send(:extend, CarrierWave::Mount) }
|
5
|
-
let(:uploader) { Class.new(CarrierWave::Uploader::Base) }
|
6
|
-
let(:instance) { klass.new }
|
7
|
-
let(:test_file_name) { 'test.jpg' }
|
8
|
-
let(:new_file_name) { 'new.jpeg' }
|
9
|
-
let(:test_file_stub) { stub_file(test_file_name) }
|
10
|
-
let(:new_file_stub) { stub_file(new_file_name) }
|
11
|
-
|
12
|
-
after { FileUtils.rm_rf(public_path) }
|
13
|
-
|
14
|
-
describe '.mount_uploaders' do
|
15
|
-
before { klass.mount_uploaders(:images, uploader) }
|
16
|
-
|
17
|
-
describe "super behavior" do
|
18
|
-
before do
|
19
|
-
klass.class_eval do
|
20
|
-
def images_uploader
|
21
|
-
super
|
22
|
-
end
|
23
|
-
|
24
|
-
def images=(val)
|
25
|
-
super
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
instance.images = [stub_file(test_file_name)]
|
30
|
-
end
|
31
|
-
|
32
|
-
it "maintains the ability to super" do
|
33
|
-
expect(instance.images[0]).to be_an_instance_of(uploader)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "upload inheritance" do
|
38
|
-
let(:subclass) { Class.new(klass) }
|
39
|
-
let(:subclass_instance) { subclass.new }
|
40
|
-
|
41
|
-
before { subclass_instance.images = [test_file_stub, new_file_stub] }
|
42
|
-
|
43
|
-
it "inherits uploaders to subclasses" do
|
44
|
-
expect(subclass_instance.images[0]).to be_an_instance_of(uploader)
|
45
|
-
expect(subclass_instance.images[1]).to be_an_instance_of(uploader)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "upload marshalling" do
|
50
|
-
before do
|
51
|
-
Object.const_set("MyClass#{klass.object_id}".gsub('-', '_'), klass)
|
52
|
-
Object.const_set("Uploader#{uploader.object_id}".gsub('-', '_'), uploader)
|
53
|
-
|
54
|
-
uploader.class_eval do
|
55
|
-
def rotate
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
uploader.version :thumb do
|
60
|
-
process :rotate
|
61
|
-
end
|
62
|
-
|
63
|
-
instance.images = [test_file_stub]
|
64
|
-
end
|
65
|
-
|
66
|
-
it "allows marshalling uploaders and versions" do
|
67
|
-
expect { Marshal.dump(instance.images) }.not_to raise_error
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe "behavior of subclassed uploaders" do
|
72
|
-
let(:uploader_1) do
|
73
|
-
Class.new(CarrierWave::Uploader::Base) do
|
74
|
-
[:rotate, :compress, :encrypt, :shrink].each { |m| define_method(m) {} }
|
75
|
-
end.tap do |uploader|
|
76
|
-
uploader.process :rotate
|
77
|
-
uploader.version :thumb do
|
78
|
-
process :compress
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
let(:uploader_2) do
|
84
|
-
Class.new(uploader_1).tap do |uploader|
|
85
|
-
uploader.process :shrink
|
86
|
-
uploader.version :secret do
|
87
|
-
process :encrypt
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
let(:instance) do
|
93
|
-
klass.new.tap do |instance|
|
94
|
-
instance.images1 = [test_file_stub]
|
95
|
-
instance.images2 = [test_file_stub]
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
before do
|
100
|
-
klass.mount_uploaders(:images1, uploader_1)
|
101
|
-
klass.mount_uploaders(:images2, uploader_2)
|
102
|
-
end
|
103
|
-
|
104
|
-
context "defined version inheritance works" do
|
105
|
-
it { expect(instance.images1[0]).to respond_to(:thumb) }
|
106
|
-
|
107
|
-
it { expect(instance.images2[0]).to respond_to(:thumb) }
|
108
|
-
end
|
109
|
-
|
110
|
-
context "version inheritance defined in subclasses works" do
|
111
|
-
it { expect(instance.images1[0]).not_to respond_to(:secret) }
|
112
|
-
|
113
|
-
it { expect(instance.images2[0]).to respond_to(:secret) }
|
114
|
-
end
|
115
|
-
|
116
|
-
context "defined processors inheritance works" do
|
117
|
-
it { expect(uploader_1.processors).to eq([[:rotate, [], nil]]) }
|
118
|
-
|
119
|
-
it { expect(uploader_2.processors).to eq([[:rotate, [], nil], [:shrink, [], nil]]) }
|
120
|
-
|
121
|
-
it { expect(uploader_1.versions[:thumb].processors).to eq([[:compress, [], nil]]) }
|
122
|
-
|
123
|
-
it { expect(uploader_2.versions[:thumb].processors).to eq([[:compress, [], nil]]) }
|
124
|
-
|
125
|
-
it { expect(uploader_2.versions[:secret].processors).to eq([[:encrypt, [], nil]]) }
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe '#images' do
|
130
|
-
context "return an empty array when nothing has been assigned" do
|
131
|
-
before do
|
132
|
-
allow(instance).to receive(:read_uploader).with(:images).and_return(nil)
|
133
|
-
end
|
134
|
-
|
135
|
-
it { expect(instance.images).to eq [] }
|
136
|
-
end
|
137
|
-
|
138
|
-
context "returns an empty array when an empty string has been assigned" do
|
139
|
-
before do
|
140
|
-
allow(instance).to receive(:read_uploader).with(:images).and_return('')
|
141
|
-
end
|
142
|
-
|
143
|
-
it { expect(instance.images).to eq [] }
|
144
|
-
end
|
145
|
-
|
146
|
-
context "retrieves a file from the storage if a value is stored in the database" do
|
147
|
-
subject(:images) { instance.images }
|
148
|
-
|
149
|
-
before do
|
150
|
-
allow(instance).to receive(:read_uploader).with(:images).at_least(:once).and_return([test_file_name, new_file_name])
|
151
|
-
end
|
152
|
-
|
153
|
-
it { expect(images[0]).to be_an_instance_of(uploader) }
|
154
|
-
it { expect(images[1]).to be_an_instance_of(uploader) }
|
155
|
-
end
|
156
|
-
|
157
|
-
context "sets the path to the store dir" do
|
158
|
-
subject(:image) { instance.images.first }
|
159
|
-
|
160
|
-
before do
|
161
|
-
allow(instance).to receive(:read_uploader).with(:images).at_least(:once).and_return(test_file_name)
|
162
|
-
end
|
163
|
-
|
164
|
-
it { expect(image.current_path).to eq(public_path("uploads/#{test_file_name}")) }
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe '#images=' do
|
169
|
-
let(:old_image_stub) { stub_file('old.jpeg') }
|
170
|
-
let(:text_file_stub) { stub_file('bork.txt') }
|
171
|
-
|
172
|
-
context "caching images" do
|
173
|
-
before do
|
174
|
-
instance.images = [test_file_stub, old_image_stub]
|
175
|
-
end
|
176
|
-
|
177
|
-
it { expect(instance.images[0]).to be_an_instance_of(uploader) }
|
178
|
-
|
179
|
-
it { expect(instance.images[1]).to be_an_instance_of(uploader) }
|
180
|
-
|
181
|
-
it "copies files into the cache directory" do
|
182
|
-
expect(instance.images[0].current_path).to match(/^#{public_path('uploads/tmp')}/)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
it "does nothing when nil is assigned" do
|
187
|
-
expect(instance).not_to receive(:write_uploader)
|
188
|
-
instance.images = nil
|
189
|
-
end
|
190
|
-
|
191
|
-
it "does nothing when an empty string is assigned" do
|
192
|
-
expect(instance).not_to receive(:write_uploader)
|
193
|
-
|
194
|
-
instance.images = [test_file_stub]
|
195
|
-
end
|
196
|
-
|
197
|
-
context "fails silently if the images fails a white list integrity check" do
|
198
|
-
before do
|
199
|
-
uploader.class_eval do
|
200
|
-
def extension_whitelist
|
201
|
-
%w(txt)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
instance.images = [text_file_stub, test_file_stub]
|
206
|
-
end
|
207
|
-
|
208
|
-
it { expect(instance.images).to be_empty }
|
209
|
-
end
|
210
|
-
|
211
|
-
describe "fails silently if the images fails a black list integrity check" do
|
212
|
-
before do
|
213
|
-
uploader.class_eval do
|
214
|
-
def extension_blacklist
|
215
|
-
%w(jpg)
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
instance.images = [text_file_stub, test_file_stub]
|
220
|
-
end
|
221
|
-
|
222
|
-
it { expect(instance.images).to be_empty }
|
223
|
-
end
|
224
|
-
|
225
|
-
describe "fails silently if the images fails to be processed" do
|
226
|
-
before do
|
227
|
-
uploader.class_eval do
|
228
|
-
process :monkey
|
229
|
-
def monkey
|
230
|
-
raise CarrierWave::ProcessingError, "Ohh noez!"
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
instance.images = [test_file_stub]
|
235
|
-
end
|
236
|
-
|
237
|
-
it { expect(instance.images).to be_empty }
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
describe '#images?' do
|
242
|
-
subject { instance.images? }
|
243
|
-
|
244
|
-
context "false when nothing has been assigned" do
|
245
|
-
before { instance.images = nil }
|
246
|
-
|
247
|
-
it { is_expected.to be_falsey }
|
248
|
-
end
|
249
|
-
|
250
|
-
context "false when an empty string has been assigned" do
|
251
|
-
before { instance.images = '' }
|
252
|
-
|
253
|
-
it { is_expected.to be_falsey }
|
254
|
-
end
|
255
|
-
|
256
|
-
context "true when a file has been cached" do
|
257
|
-
before { instance.images = [test_file_stub] }
|
258
|
-
|
259
|
-
it { is_expected.to be_truthy }
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
describe '#images_urls' do
|
264
|
-
subject(:images_urls) { instance.images_urls }
|
265
|
-
|
266
|
-
describe "returns nil when nothing has been assigned" do
|
267
|
-
before do
|
268
|
-
allow(instance).to receive(:read_uploader).with(:images).and_return(nil)
|
269
|
-
end
|
270
|
-
|
271
|
-
it { is_expected.to be_empty }
|
272
|
-
end
|
273
|
-
|
274
|
-
describe "should return nil when an empty string has been assigned" do
|
275
|
-
before do
|
276
|
-
allow(instance).to receive(:read_uploader).with(:images).and_return('')
|
277
|
-
end
|
278
|
-
|
279
|
-
it { is_expected.to be_empty }
|
280
|
-
end
|
281
|
-
|
282
|
-
describe "gets the url from a retrieved file" do
|
283
|
-
before do
|
284
|
-
allow(instance).to receive(:read_uploader).at_least(:once).with(:images).and_return(test_file_name)
|
285
|
-
end
|
286
|
-
|
287
|
-
it { expect(images_urls.first).to eq("/uploads/#{test_file_name}") }
|
288
|
-
end
|
289
|
-
|
290
|
-
describe "gets the url from a cached file" do
|
291
|
-
before { instance.images = [test_file_stub] }
|
292
|
-
|
293
|
-
it { expect(images_urls[0]).to match(%r{uploads/tmp/[\d\-]+/test.jpg}) }
|
294
|
-
end
|
295
|
-
|
296
|
-
describe "gets the url from a cached file's version" do
|
297
|
-
before do
|
298
|
-
uploader.version(:thumb)
|
299
|
-
instance.images = [test_file_stub]
|
300
|
-
end
|
301
|
-
|
302
|
-
it { expect(instance.images_urls(:thumb)[0]).to match(%r{uploads/tmp/[\d\-]+/thumb_test.jpg}) }
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
describe '#images_cache' do
|
307
|
-
before do
|
308
|
-
allow(instance).to receive(:write_uploader)
|
309
|
-
allow(instance).to receive(:read_uploader).and_return(nil)
|
310
|
-
end
|
311
|
-
|
312
|
-
context "when nothing has been assigned" do
|
313
|
-
it { expect(instance.images_cache).to be_nil }
|
314
|
-
end
|
315
|
-
|
316
|
-
context "when a file has been stored" do
|
317
|
-
before do
|
318
|
-
instance.images = [test_file_stub]
|
319
|
-
instance.store_images!
|
320
|
-
end
|
321
|
-
|
322
|
-
it { expect(instance.images_cache).to be_nil }
|
323
|
-
end
|
324
|
-
|
325
|
-
context "when a file has been cached" do
|
326
|
-
let(:json_response) { JSON.parse(instance.images_cache) }
|
327
|
-
|
328
|
-
before do
|
329
|
-
instance.images = [test_file_stub, stub_file('old.jpeg')]
|
330
|
-
end
|
331
|
-
|
332
|
-
it { expect(json_response[0]).to match(%r(^[\d]+\-[\d]+\-[\d]{4}\-[\d]{4}/test\.jpg$)) }
|
333
|
-
|
334
|
-
it { expect(json_response[1]).to match(%r(^[\d]+\-[\d]+\-[\d]{4}\-[\d]{4}/old\.jpeg$)) }
|
335
|
-
end
|
336
|
-
end
|
337
|
-
|
338
|
-
describe '#images_cache=' do
|
339
|
-
before do
|
340
|
-
allow(instance).to receive(:write_uploader)
|
341
|
-
allow(instance).to receive(:read_uploader).and_return(nil)
|
342
|
-
CarrierWave::SanitizedFile.new(test_file_stub).copy_to(public_path('uploads/tmp/1369894322-123-0123-1234/test.jpg'))
|
343
|
-
end
|
344
|
-
|
345
|
-
before { instance.images_cache = images_cache }
|
346
|
-
|
347
|
-
context "does nothing when nil is assigned" do
|
348
|
-
let(:images_cache) { nil }
|
349
|
-
|
350
|
-
it { expect(instance.images).to be_empty }
|
351
|
-
end
|
352
|
-
|
353
|
-
context "does nothing when an empty string is assigned" do
|
354
|
-
let(:images_cache) { '' }
|
355
|
-
|
356
|
-
it { expect(instance.images).to be_empty }
|
357
|
-
end
|
358
|
-
|
359
|
-
context "retrieve from cache when a cache name is assigned" do
|
360
|
-
let(:images_cache) { ['1369894322-123-0123-1234/test.jpg'].to_json }
|
361
|
-
|
362
|
-
it { expect(instance.images[0].current_path).to eq(public_path('uploads/tmp/1369894322-123-0123-1234/test.jpg')) }
|
363
|
-
end
|
364
|
-
|
365
|
-
context "doesn't write over a previously assigned file" do
|
366
|
-
let(:images_cache) { ['1369894322-123-0123-1234/monkey.jpg'].to_json }
|
367
|
-
|
368
|
-
before { instance.images = [test_file_stub] }
|
369
|
-
|
370
|
-
it { expect(instance.images[0].current_path).to match(/test.jpg$/) }
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
|
-
describe "#remote_images_urls" do
|
375
|
-
subject { instance.remote_images_urls }
|
376
|
-
|
377
|
-
before { stub_request(:get, "www.example.com/#{test_file_name}").to_return(body: File.read(test_file_stub)) }
|
378
|
-
|
379
|
-
context "returns nil" do
|
380
|
-
it { is_expected.to be_nil }
|
381
|
-
end
|
382
|
-
|
383
|
-
context "returns previously cached URL" do
|
384
|
-
before { instance.remote_images_urls = ["http://www.example.com/test.jpg"] }
|
385
|
-
|
386
|
-
it { is_expected.to eq(["http://www.example.com/test.jpg"]) }
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
describe "#remote_images_urls=" do
|
391
|
-
subject(:images) { instance.images }
|
392
|
-
|
393
|
-
before do
|
394
|
-
stub_request(:get, "www.example.com/#{test_file_name}").to_return(body: File.read(test_file_stub))
|
395
|
-
instance.remote_images_urls = remote_images_url
|
396
|
-
end
|
397
|
-
|
398
|
-
context "does nothing when nil is assigned" do
|
399
|
-
let(:remote_images_url) { nil }
|
400
|
-
|
401
|
-
it { is_expected.to be_empty }
|
402
|
-
end
|
403
|
-
|
404
|
-
context "does nothing when an empty string is assigned" do
|
405
|
-
let(:remote_images_url) { '' }
|
406
|
-
|
407
|
-
it { is_expected.to be_empty }
|
408
|
-
end
|
409
|
-
|
410
|
-
context "retrieves from cache when a cache name is assigned" do
|
411
|
-
subject { images[0].current_path }
|
412
|
-
|
413
|
-
let(:remote_images_url) { ["http://www.example.com/test.jpg"] }
|
414
|
-
|
415
|
-
it { is_expected.to match(/test.jpg$/) }
|
416
|
-
end
|
417
|
-
|
418
|
-
context "writes over a previously assigned file" do
|
419
|
-
subject { images[0].current_path }
|
420
|
-
|
421
|
-
let(:remote_images_url) { ["http://www.example.com/test.jpg"] }
|
422
|
-
|
423
|
-
before do
|
424
|
-
instance.images = [stub_file("portrait.jpg")]
|
425
|
-
instance.remote_images_urls = remote_images_url
|
426
|
-
end
|
427
|
-
|
428
|
-
it { is_expected.to match(/test.jpg$/) }
|
429
|
-
end
|
430
|
-
end
|
431
|
-
|
432
|
-
describe '#store_images!' do
|
433
|
-
before do
|
434
|
-
allow(instance).to receive(:write_uploader)
|
435
|
-
allow(instance).to receive(:read_uploader).and_return(nil)
|
436
|
-
end
|
437
|
-
|
438
|
-
context "does nothing when no file has been uploaded" do
|
439
|
-
before { instance.store_images! }
|
440
|
-
|
441
|
-
it { expect(instance.images).to be_empty }
|
442
|
-
end
|
443
|
-
|
444
|
-
context "stores an assigned file" do
|
445
|
-
let(:images) { [test_file_stub] }
|
446
|
-
|
447
|
-
before do
|
448
|
-
instance.images = images
|
449
|
-
instance.store_images!
|
450
|
-
end
|
451
|
-
|
452
|
-
it { expect(instance.images[0].current_path).to eq(public_path("uploads/#{test_file_name}")) }
|
453
|
-
end
|
454
|
-
|
455
|
-
context "removes an uploaded file when remove_images is true" do
|
456
|
-
let(:images) { [test_file_stub] }
|
457
|
-
|
458
|
-
before do
|
459
|
-
instance.images = images
|
460
|
-
@image_path = instance.images[0].current_path.dup
|
461
|
-
instance.remove_images = true
|
462
|
-
instance.store_images!
|
463
|
-
end
|
464
|
-
|
465
|
-
it { expect(instance.images).to be_empty }
|
466
|
-
|
467
|
-
it { expect(File.exist?(@image_path)).to be_falsey }
|
468
|
-
end
|
469
|
-
end
|
470
|
-
|
471
|
-
describe '#remove_images!' do
|
472
|
-
before do
|
473
|
-
allow(instance).to receive(:write_uploader)
|
474
|
-
allow(instance).to receive(:read_uploader).and_return(nil)
|
475
|
-
end
|
476
|
-
|
477
|
-
context "does nothing when no file has been uploaded" do
|
478
|
-
before { instance.remove_images! }
|
479
|
-
|
480
|
-
it { expect(instance.images).to be_empty }
|
481
|
-
end
|
482
|
-
|
483
|
-
context "removes an uploaded file" do
|
484
|
-
before do
|
485
|
-
instance.images = [test_file_stub]
|
486
|
-
@image_path = instance.images[0].current_path
|
487
|
-
instance.remove_images!
|
488
|
-
end
|
489
|
-
|
490
|
-
it { expect(instance.images).to be_empty }
|
491
|
-
|
492
|
-
it { expect(File.exist?(@image_path)).to be_falsey }
|
493
|
-
end
|
494
|
-
end
|
495
|
-
|
496
|
-
describe '#remove_images' do
|
497
|
-
before { instance.remove_images = true }
|
498
|
-
|
499
|
-
it "stores a value" do
|
500
|
-
expect(instance.remove_images).to be_truthy
|
501
|
-
end
|
502
|
-
end
|
503
|
-
|
504
|
-
describe '#remove_images?' do
|
505
|
-
subject { instance.remove_images? }
|
506
|
-
|
507
|
-
let(:remove_images) { true }
|
508
|
-
|
509
|
-
before { instance.remove_images = remove_images }
|
510
|
-
|
511
|
-
it "when value is true" do
|
512
|
-
is_expected.to be_truthy
|
513
|
-
end
|
514
|
-
|
515
|
-
context "when value is false" do
|
516
|
-
let(:remove_images) { false }
|
517
|
-
|
518
|
-
it { is_expected.to be_falsey }
|
519
|
-
end
|
520
|
-
|
521
|
-
context "when value is ''" do
|
522
|
-
let(:remove_images) { '' }
|
523
|
-
|
524
|
-
it { is_expected.to be_falsey }
|
525
|
-
end
|
526
|
-
|
527
|
-
context "when value is 0" do
|
528
|
-
let(:remove_images) { "0" }
|
529
|
-
|
530
|
-
it { is_expected.to be_falsey }
|
531
|
-
end
|
532
|
-
|
533
|
-
context "when value is false" do
|
534
|
-
let(:remove_images) { 'false' }
|
535
|
-
|
536
|
-
it { is_expected.to be_falsey }
|
537
|
-
end
|
538
|
-
end
|
539
|
-
|
540
|
-
describe '#images_integrity_error' do
|
541
|
-
subject(:images_integrity_error) { instance.images_integrity_error }
|
542
|
-
|
543
|
-
describe "default behaviour" do
|
544
|
-
it { is_expected.to be_nil }
|
545
|
-
end
|
546
|
-
|
547
|
-
context "when a file is cached" do
|
548
|
-
before { instance.images = test_file_stub }
|
549
|
-
|
550
|
-
it { is_expected.to be_nil }
|
551
|
-
end
|
552
|
-
|
553
|
-
describe "when an integrity check fails" do
|
554
|
-
before do
|
555
|
-
uploader.class_eval do
|
556
|
-
def extension_whitelist
|
557
|
-
%w(txt)
|
558
|
-
end
|
559
|
-
end
|
560
|
-
end
|
561
|
-
|
562
|
-
context "when file is cached" do
|
563
|
-
before { instance.images = [test_file_stub] }
|
564
|
-
|
565
|
-
it { is_expected.to be_an_instance_of(CarrierWave::IntegrityError) }
|
566
|
-
|
567
|
-
it "has an error message" do
|
568
|
-
expect(images_integrity_error.message.lines.grep(/^You are not allowed to upload/)).to be_truthy
|
569
|
-
end
|
570
|
-
end
|
571
|
-
|
572
|
-
context "when file was downloaded" do
|
573
|
-
before do
|
574
|
-
stub_request(:get, "www.example.com/#{test_file_name}").to_return(body: File.read(test_file_stub))
|
575
|
-
instance.remote_images_urls = ["http://www.example.com/#{test_file_name}"]
|
576
|
-
end
|
577
|
-
|
578
|
-
it { is_expected.to be_an_instance_of(CarrierWave::IntegrityError) }
|
579
|
-
|
580
|
-
it "has an error message" do
|
581
|
-
expect(images_integrity_error.message.lines.grep(/^You are not allowed to upload/)).to be_truthy
|
582
|
-
end
|
583
|
-
end
|
584
|
-
|
585
|
-
context "when file is assigned and remote_iamges_url is blank" do
|
586
|
-
before do
|
587
|
-
instance.images = [test_file_stub]
|
588
|
-
instance.remote_images_urls = ""
|
589
|
-
end
|
590
|
-
|
591
|
-
it { is_expected.to be_an_instance_of(CarrierWave::IntegrityError) }
|
592
|
-
|
593
|
-
it "has an error message" do
|
594
|
-
expect(images_integrity_error.message.lines.grep(/^You are not allowed to upload/)).to be_truthy
|
595
|
-
end
|
596
|
-
end
|
597
|
-
end
|
598
|
-
end
|
599
|
-
|
600
|
-
describe '#images_processing_error' do
|
601
|
-
subject(:images_processing_error) { instance.images_processing_error }
|
602
|
-
|
603
|
-
describe "default behavior" do
|
604
|
-
it { is_expected.to be_nil }
|
605
|
-
end
|
606
|
-
|
607
|
-
context "when file is cached" do
|
608
|
-
before { instance.images = [test_file_stub] }
|
609
|
-
|
610
|
-
it { is_expected.to be_nil }
|
611
|
-
end
|
612
|
-
|
613
|
-
describe "when an processing error occurs" do
|
614
|
-
before do
|
615
|
-
uploader.class_eval do
|
616
|
-
process :monkey
|
617
|
-
def monkey
|
618
|
-
raise CarrierWave::ProcessingError, "Ohh noez!"
|
619
|
-
end
|
620
|
-
end
|
621
|
-
end
|
622
|
-
|
623
|
-
context "when file is cached" do
|
624
|
-
before { instance.images = [test_file_stub] }
|
625
|
-
|
626
|
-
it { is_expected.to be_an_instance_of(CarrierWave::ProcessingError) }
|
627
|
-
end
|
628
|
-
|
629
|
-
context "when file was downloaded" do
|
630
|
-
before do
|
631
|
-
stub_request(:get, "www.example.com/#{test_file_name}").to_return(body: File.read(test_file_stub))
|
632
|
-
instance.remote_images_urls = ["http://www.example.com/#{test_file_name}"]
|
633
|
-
end
|
634
|
-
|
635
|
-
it { is_expected.to be_an_instance_of(CarrierWave::ProcessingError) }
|
636
|
-
end
|
637
|
-
end
|
638
|
-
end
|
639
|
-
|
640
|
-
describe '#images_download_error' do
|
641
|
-
subject(:images_download_error) { instance.images_download_error }
|
642
|
-
|
643
|
-
before do
|
644
|
-
stub_request(:get, "www.example.com/#{test_file_name}").to_return(body: File.read(test_file_stub))
|
645
|
-
stub_request(:get, "www.example.com/missing.jpg").to_return(status: 404)
|
646
|
-
end
|
647
|
-
|
648
|
-
describe "default behaviour" do
|
649
|
-
it { expect(instance.images_download_error).to be_nil }
|
650
|
-
end
|
651
|
-
|
652
|
-
context "when file download was successful" do
|
653
|
-
before { instance.remote_images_urls = ["http://www.example.com/#{test_file_name}"] }
|
654
|
-
|
655
|
-
it { is_expected.to be_nil }
|
656
|
-
end
|
657
|
-
|
658
|
-
context "when file couldn't be found" do
|
659
|
-
before { instance.remote_images_urls = ["http://www.example.com/missing.jpg"] }
|
660
|
-
|
661
|
-
it { is_expected.to be_an_instance_of(CarrierWave::DownloadError) }
|
662
|
-
end
|
663
|
-
end
|
664
|
-
|
665
|
-
describe '#write_images_identifier' do
|
666
|
-
after { instance.write_images_identifier }
|
667
|
-
|
668
|
-
it "writes to the column" do
|
669
|
-
expect(instance).to receive(:write_uploader).with(:images, [test_file_name]).at_least(:once)
|
670
|
-
instance.images = [test_file_stub]
|
671
|
-
instance.write_images_identifier
|
672
|
-
end
|
673
|
-
|
674
|
-
context "when remove_images is true" do
|
675
|
-
before do
|
676
|
-
instance.images = [test_file_name]
|
677
|
-
instance.store_images!
|
678
|
-
instance.remove_images = true
|
679
|
-
end
|
680
|
-
|
681
|
-
it "removes from the column when remove_images is true" do
|
682
|
-
expect(instance).to receive(:write_uploader).with(:images, nil)
|
683
|
-
end
|
684
|
-
end
|
685
|
-
end
|
686
|
-
|
687
|
-
describe '#images_identifiers' do
|
688
|
-
it "returns the identifier from the mounted column" do
|
689
|
-
expect(instance).to receive(:read_uploader).with(:images).and_return(test_file_name)
|
690
|
-
expect(instance.images_identifiers).to eq([test_file_name])
|
691
|
-
end
|
692
|
-
end
|
693
|
-
end
|
694
|
-
|
695
|
-
describe '#mount_uploaders without an uploader' do
|
696
|
-
let(:klass) do
|
697
|
-
Class.new.tap do |k|
|
698
|
-
k.send(:extend, CarrierWave::Mount)
|
699
|
-
k.mount_uploaders(:images)
|
700
|
-
end
|
701
|
-
end
|
702
|
-
|
703
|
-
let(:instance) { klass.new }
|
704
|
-
|
705
|
-
describe '#images' do
|
706
|
-
before do
|
707
|
-
allow(instance).to receive(:read_uploader).and_return(test_file_name)
|
708
|
-
end
|
709
|
-
|
710
|
-
it "returns an instance of a subclass of CarrierWave::Uploader::Base" do
|
711
|
-
expect(instance.images[0]).to be_a(CarrierWave::Uploader::Base)
|
712
|
-
end
|
713
|
-
|
714
|
-
it "sets the path to the store dir" do
|
715
|
-
expect(instance.images[0].current_path).to eq(public_path("uploads/#{test_file_name}"))
|
716
|
-
end
|
717
|
-
end
|
718
|
-
end
|
719
|
-
|
720
|
-
describe '#mount_uploaders with a block' do
|
721
|
-
describe 'and no uploader given' do
|
722
|
-
subject(:last_image) { instance.images[0] }
|
723
|
-
|
724
|
-
let(:klass) do
|
725
|
-
Class.new do |k|
|
726
|
-
k.send(:extend, CarrierWave::Mount)
|
727
|
-
k.mount_uploaders(:images) do
|
728
|
-
def monkey
|
729
|
-
'blah'
|
730
|
-
end
|
731
|
-
end
|
732
|
-
end
|
733
|
-
end
|
734
|
-
|
735
|
-
before { instance.images = [test_file_stub] }
|
736
|
-
|
737
|
-
it "returns an instance of a subclass of CarrierWave::Uploader::Base" do
|
738
|
-
is_expected.to be_a(CarrierWave::Uploader::Base)
|
739
|
-
end
|
740
|
-
|
741
|
-
it "applies any custom modifications" do
|
742
|
-
expect(last_image.monkey).to eq("blah")
|
743
|
-
end
|
744
|
-
end
|
745
|
-
|
746
|
-
describe 'and an uploader given' do
|
747
|
-
let!(:uploader) do
|
748
|
-
Class.new(CarrierWave::Uploader::Base).tap do |u|
|
749
|
-
u.version :thumb do
|
750
|
-
version :mini
|
751
|
-
version :maxi
|
752
|
-
end
|
753
|
-
end
|
754
|
-
end
|
755
|
-
|
756
|
-
let(:klass) do
|
757
|
-
Class.new.tap do |k|
|
758
|
-
k.send(:extend, CarrierWave::Mount)
|
759
|
-
k.mount_uploaders(:images, uploader) do
|
760
|
-
def fish
|
761
|
-
'blub'
|
762
|
-
end
|
763
|
-
end
|
764
|
-
end
|
765
|
-
end
|
766
|
-
|
767
|
-
let(:first_image) { instance.images[0] }
|
768
|
-
|
769
|
-
before { instance.images = [test_file_stub] }
|
770
|
-
|
771
|
-
it "returns an instance of the uploader specified" do
|
772
|
-
expect(first_image).to be_a_kind_of(uploader)
|
773
|
-
end
|
774
|
-
|
775
|
-
it "applies any custom modifications to the instance" do
|
776
|
-
expect(first_image.fish).to eq("blub")
|
777
|
-
end
|
778
|
-
|
779
|
-
it "applies any custom modifications to all defined versions" do
|
780
|
-
expect(first_image.thumb.fish).to eq("blub")
|
781
|
-
expect(first_image.thumb.mini.fish).to eq("blub")
|
782
|
-
expect(first_image.thumb.maxi.fish).to eq("blub")
|
783
|
-
end
|
784
|
-
|
785
|
-
it "applies any custom modifications to the uploader class" do
|
786
|
-
expect(uploader.new).not_to respond_to(:fish)
|
787
|
-
end
|
788
|
-
end
|
789
|
-
end
|
790
|
-
|
791
|
-
describe '#mount_uploaders with :ignore_integrity_errors => false' do
|
792
|
-
let(:klass) do
|
793
|
-
Class.new.tap do |k|
|
794
|
-
k.send(:extend, CarrierWave::Mount)
|
795
|
-
k.mount_uploaders(:images, uploader, :ignore_integrity_errors => false)
|
796
|
-
end
|
797
|
-
end
|
798
|
-
|
799
|
-
let(:uploader) do
|
800
|
-
Class.new(CarrierWave::Uploader::Base).tap do |u|
|
801
|
-
u.class_eval do
|
802
|
-
def extension_whitelist
|
803
|
-
%w(txt)
|
804
|
-
end
|
805
|
-
end
|
806
|
-
end
|
807
|
-
end
|
808
|
-
|
809
|
-
context "when a cached image fails an integrity check" do
|
810
|
-
it { expect(running { instance.images = [test_file_stub] }).to raise_error(CarrierWave::IntegrityError) }
|
811
|
-
end
|
812
|
-
|
813
|
-
context "when a downloaded image fails an integity check" do
|
814
|
-
before do
|
815
|
-
stub_request(:get, "www.example.com/#{test_file_name}").to_return(body: test_file_stub)
|
816
|
-
end
|
817
|
-
|
818
|
-
it { expect(running {instance.remote_images_urls = ["http://www.example.com/#{test_file_name}"]}).to raise_error(CarrierWave::IntegrityError) }
|
819
|
-
end
|
820
|
-
end
|
821
|
-
|
822
|
-
describe '#mount_uploaders with :ignore_processing_errors => false' do
|
823
|
-
let(:klass) do
|
824
|
-
Class.new.tap do |k|
|
825
|
-
k.send(:extend, CarrierWave::Mount)
|
826
|
-
k.mount_uploaders(:images, uploader, :ignore_processing_errors => false)
|
827
|
-
end
|
828
|
-
end
|
829
|
-
|
830
|
-
let(:uploader) do
|
831
|
-
Class.new(CarrierWave::Uploader::Base).tap do |u|
|
832
|
-
u.class_eval do
|
833
|
-
process :monkey
|
834
|
-
def monkey
|
835
|
-
raise CarrierWave::ProcessingError, "Ohh noez!"
|
836
|
-
end
|
837
|
-
end
|
838
|
-
end
|
839
|
-
end
|
840
|
-
|
841
|
-
context "when a cached image fails an integrity check" do
|
842
|
-
it { expect(running { instance.images = [test_file_stub] }).to raise_error(CarrierWave::ProcessingError) }
|
843
|
-
end
|
844
|
-
|
845
|
-
context "when a downloaded image fails an integity check" do
|
846
|
-
before do
|
847
|
-
stub_request(:get, "www.example.com/#{test_file_name}").to_return(body: test_file_stub)
|
848
|
-
end
|
849
|
-
|
850
|
-
it { expect(running {instance.remote_images_urls = ["http://www.example.com/#{test_file_name}"]}).to raise_error(CarrierWave::ProcessingError) }
|
851
|
-
end
|
852
|
-
end
|
853
|
-
|
854
|
-
describe '#mount_uploaders with :ignore_download_errors => false' do
|
855
|
-
let(:klass) do
|
856
|
-
Class.new.tap do |k|
|
857
|
-
k.send(:extend, CarrierWave::Mount)
|
858
|
-
k.mount_uploaders(:images, uploader, ignore_download_errors: false)
|
859
|
-
end
|
860
|
-
end
|
861
|
-
|
862
|
-
let(:uploader) { Class.new(CarrierWave::Uploader::Base) }
|
863
|
-
|
864
|
-
before do
|
865
|
-
uploader.class_eval do
|
866
|
-
def download! uri
|
867
|
-
raise CarrierWave::DownloadError
|
868
|
-
end
|
869
|
-
end
|
870
|
-
end
|
871
|
-
|
872
|
-
context "when the image fail to be processed" do
|
873
|
-
it { expect(running {instance.remote_images_urls = ["http://www.example.com/#{test_file_name}"]}).to raise_error(CarrierWave::DownloadError) }
|
874
|
-
end
|
875
|
-
end
|
876
|
-
|
877
|
-
describe '#mount_uploaders with :mount_on => :monkey' do
|
878
|
-
let(:klass) do
|
879
|
-
Class.new.tap do |k|
|
880
|
-
k.send(:extend, CarrierWave::Mount)
|
881
|
-
k.mount_uploaders(:images, uploader, mount_on: :monkey)
|
882
|
-
end
|
883
|
-
end
|
884
|
-
|
885
|
-
let(:uploader) { Class.new(CarrierWave::Uploader::Base) }
|
886
|
-
|
887
|
-
describe '#images' do
|
888
|
-
context "when a value is store in the database" do
|
889
|
-
it "retrieves a file from the storage" do
|
890
|
-
expect(instance).to receive(:read_uploader).at_least(:once).with(:monkey).and_return([test_file_name])
|
891
|
-
expect(instance.images[0]).to be_an_instance_of(uploader)
|
892
|
-
expect(instance.images[0].current_path).to eq(public_path("uploads/#{test_file_name}"))
|
893
|
-
end
|
894
|
-
end
|
895
|
-
end
|
896
|
-
|
897
|
-
describe '#write_images_identifier' do
|
898
|
-
it "writes to the given column" do
|
899
|
-
expect(instance).to receive(:write_uploader).with(:monkey, [test_file_name])
|
900
|
-
instance.images = [test_file_stub]
|
901
|
-
instance.write_images_identifier
|
902
|
-
end
|
903
|
-
|
904
|
-
it "removes from the given column when remove_images is true" do
|
905
|
-
instance.images = [test_file_stub]
|
906
|
-
instance.store_images!
|
907
|
-
instance.remove_images = true
|
908
|
-
expect(instance).to receive(:write_uploader).with(:monkey, nil)
|
909
|
-
instance.write_images_identifier
|
910
|
-
end
|
911
|
-
end
|
912
|
-
end
|
913
|
-
end
|