kt-paperclip 7.2.2 → 8.0.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.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +24 -56
- data/lib/generators/paperclip/paperclip_generator.rb +3 -1
- data/lib/kt-paperclip.rb +2 -0
- data/lib/paperclip/attachment.rb +49 -30
- data/lib/paperclip/attachment_registry.rb +2 -0
- data/lib/paperclip/callbacks.rb +7 -4
- data/lib/paperclip/commands/imagemagick/geometry_parser.rb +63 -0
- data/lib/paperclip/commands/imagemagick/version_detector.rb +41 -0
- data/lib/paperclip/commands/imagemagick.rb +44 -0
- data/lib/paperclip/commands/runner.rb +38 -0
- data/lib/paperclip/commands/unix_file.rb +28 -0
- data/lib/paperclip/content_type_detector.rb +31 -32
- data/lib/paperclip/errors.rb +2 -0
- data/lib/paperclip/file_command_content_type_detector.rb +11 -12
- data/lib/paperclip/filename_cleaner.rb +2 -0
- data/lib/paperclip/geometry.rb +22 -7
- data/lib/paperclip/geometry_detector_factory.rb +11 -31
- data/lib/paperclip/geometry_parser_factory.rb +13 -17
- data/lib/paperclip/glue.rb +2 -0
- data/lib/paperclip/has_attached_file.rb +2 -0
- data/lib/paperclip/helpers.rb +5 -25
- data/lib/paperclip/interpolations/plural_cache.rb +2 -0
- data/lib/paperclip/interpolations.rb +2 -0
- data/lib/paperclip/io_adapters/abstract_adapter.rb +3 -1
- data/lib/paperclip/io_adapters/attachment_adapter.rb +11 -0
- data/lib/paperclip/io_adapters/data_uri_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/empty_string_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/file_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/identity_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/nil_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/registry.rb +2 -0
- data/lib/paperclip/io_adapters/stringio_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/uri_adapter.rb +5 -13
- data/lib/paperclip/locales/fr.yml +18 -0
- data/lib/paperclip/locales/gd.yml +1 -1
- data/lib/paperclip/logger.rb +2 -0
- data/lib/paperclip/matchers/have_attached_file_matcher.rb +2 -0
- data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +5 -3
- data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +2 -0
- data/lib/paperclip/matchers/validate_attachment_size_matcher.rb +2 -0
- data/lib/paperclip/matchers.rb +2 -0
- data/lib/paperclip/media_type_spoof_detector.rb +3 -10
- data/lib/paperclip/missing_attachment_styles.rb +2 -0
- data/lib/paperclip/processor.rb +6 -19
- data/lib/paperclip/processor_helpers.rb +2 -0
- data/lib/paperclip/rails_environment.rb +2 -0
- data/lib/paperclip/railtie.rb +2 -0
- data/lib/paperclip/schema.rb +6 -4
- data/lib/paperclip/storage/filesystem.rb +2 -0
- data/lib/paperclip/storage/fog.rb +13 -4
- data/lib/paperclip/storage/s3.rb +27 -5
- data/lib/paperclip/storage.rb +2 -0
- data/lib/paperclip/style.rb +2 -0
- data/lib/paperclip/tempfile.rb +2 -0
- data/lib/paperclip/tempfile_factory.rb +2 -0
- data/lib/paperclip/thumbnail.rb +9 -10
- data/lib/paperclip/url_generator.rb +2 -0
- data/lib/paperclip/validators/attachment_content_type_validator.rb +2 -0
- data/lib/paperclip/validators/attachment_file_name_validator.rb +2 -0
- data/lib/paperclip/validators/attachment_file_type_ignorance_validator.rb +2 -0
- data/lib/paperclip/validators/attachment_presence_validator.rb +2 -0
- data/lib/paperclip/validators/attachment_size_validator.rb +2 -0
- data/lib/paperclip/validators/media_type_spoof_detection_validator.rb +2 -0
- data/lib/paperclip/validators.rb +2 -0
- data/lib/paperclip/version.rb +3 -1
- data/lib/paperclip.rb +25 -4
- data/lib/tasks/paperclip.rake +9 -4
- data/shoulda_macros/paperclip.rb +2 -0
- metadata +19 -538
- data/.codeclimate.yml +0 -17
- data/.github/FUNDING.yml +0 -3
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- data/.github/ISSUE_TEMPLATE/custom.md +0 -10
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.gitignore +0 -19
- data/.hound.yml +0 -3
- data/.rubocop.yml +0 -1061
- data/.travis.yml +0 -45
- data/Appraisals +0 -30
- data/CONTRIBUTING.md +0 -85
- data/Gemfile +0 -19
- data/NEWS +0 -554
- data/RELEASING.md +0 -17
- data/Rakefile +0 -52
- data/UPGRADING +0 -17
- data/features/basic_integration.feature +0 -85
- data/features/migration.feature +0 -29
- data/features/rake_tasks.feature +0 -62
- data/features/step_definitions/attachment_steps.rb +0 -120
- data/features/step_definitions/html_steps.rb +0 -15
- data/features/step_definitions/rails_steps.rb +0 -257
- data/features/step_definitions/s3_steps.rb +0 -14
- data/features/step_definitions/web_steps.rb +0 -106
- data/features/support/env.rb +0 -12
- data/features/support/fakeweb.rb +0 -11
- data/features/support/file_helpers.rb +0 -34
- data/features/support/fixtures/boot_config.txt +0 -15
- data/features/support/fixtures/gemfile.txt +0 -5
- data/features/support/fixtures/preinitializer.txt +0 -20
- data/features/support/paths.rb +0 -28
- data/features/support/rails.rb +0 -39
- data/features/support/selectors.rb +0 -19
- data/gemfiles/4.2.gemfile +0 -20
- data/gemfiles/5.0.gemfile +0 -20
- data/gemfiles/5.1.gemfile +0 -20
- data/gemfiles/5.2.gemfile +0 -20
- data/gemfiles/6.0.gemfile +0 -20
- data/gemfiles/6.1.gemfile +0 -21
- data/gemfiles/7.0.gemfile +0 -21
- data/paperclip.gemspec +0 -50
- data/spec/database.yml +0 -4
- data/spec/paperclip/attachment_definitions_spec.rb +0 -13
- data/spec/paperclip/attachment_processing_spec.rb +0 -79
- data/spec/paperclip/attachment_registry_spec.rb +0 -158
- data/spec/paperclip/attachment_spec.rb +0 -1590
- data/spec/paperclip/content_type_detector_spec.rb +0 -54
- data/spec/paperclip/file_command_content_type_detector_spec.rb +0 -40
- data/spec/paperclip/filename_cleaner_spec.rb +0 -13
- data/spec/paperclip/geometry_detector_spec.rb +0 -47
- data/spec/paperclip/geometry_parser_spec.rb +0 -73
- data/spec/paperclip/geometry_spec.rb +0 -267
- data/spec/paperclip/glue_spec.rb +0 -63
- data/spec/paperclip/has_attached_file_spec.rb +0 -78
- data/spec/paperclip/integration_spec.rb +0 -702
- data/spec/paperclip/interpolations_spec.rb +0 -270
- data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +0 -160
- data/spec/paperclip/io_adapters/attachment_adapter_spec.rb +0 -140
- data/spec/paperclip/io_adapters/data_uri_adapter_spec.rb +0 -88
- data/spec/paperclip/io_adapters/empty_string_adapter_spec.rb +0 -17
- data/spec/paperclip/io_adapters/file_adapter_spec.rb +0 -131
- data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +0 -142
- data/spec/paperclip/io_adapters/identity_adapter_spec.rb +0 -8
- data/spec/paperclip/io_adapters/nil_adapter_spec.rb +0 -25
- data/spec/paperclip/io_adapters/registry_spec.rb +0 -35
- data/spec/paperclip/io_adapters/stringio_adapter_spec.rb +0 -64
- data/spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb +0 -146
- data/spec/paperclip/io_adapters/uri_adapter_spec.rb +0 -231
- data/spec/paperclip/matchers/have_attached_file_matcher_spec.rb +0 -19
- data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +0 -108
- data/spec/paperclip/matchers/validate_attachment_presence_matcher_spec.rb +0 -69
- data/spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb +0 -88
- data/spec/paperclip/media_type_spoof_detector_spec.rb +0 -126
- data/spec/paperclip/meta_class_spec.rb +0 -30
- data/spec/paperclip/paperclip_missing_attachment_styles_spec.rb +0 -88
- data/spec/paperclip/paperclip_spec.rb +0 -196
- data/spec/paperclip/plural_cache_spec.rb +0 -37
- data/spec/paperclip/processor_helpers_spec.rb +0 -57
- data/spec/paperclip/processor_spec.rb +0 -26
- data/spec/paperclip/rails_environment_spec.rb +0 -30
- data/spec/paperclip/rake_spec.rb +0 -103
- data/spec/paperclip/schema_spec.rb +0 -252
- data/spec/paperclip/storage/filesystem_spec.rb +0 -102
- data/spec/paperclip/storage/fog_spec.rb +0 -606
- data/spec/paperclip/storage/s3_live_spec.rb +0 -188
- data/spec/paperclip/storage/s3_spec.rb +0 -1878
- data/spec/paperclip/style_spec.rb +0 -251
- data/spec/paperclip/tempfile_factory_spec.rb +0 -33
- data/spec/paperclip/tempfile_spec.rb +0 -35
- data/spec/paperclip/thumbnail_spec.rb +0 -504
- data/spec/paperclip/url_generator_spec.rb +0 -231
- data/spec/paperclip/validators/attachment_content_type_validator_spec.rb +0 -410
- data/spec/paperclip/validators/attachment_file_name_validator_spec.rb +0 -249
- data/spec/paperclip/validators/attachment_presence_validator_spec.rb +0 -85
- data/spec/paperclip/validators/attachment_size_validator_spec.rb +0 -325
- data/spec/paperclip/validators/media_type_spoof_detection_validator_spec.rb +0 -48
- data/spec/paperclip/validators_spec.rb +0 -179
- data/spec/spec_helper.rb +0 -46
- data/spec/support/assertions.rb +0 -84
- data/spec/support/fake_model.rb +0 -24
- data/spec/support/fake_rails.rb +0 -12
- data/spec/support/fixtures/12k.png +0 -0
- data/spec/support/fixtures/50x50.png +0 -0
- data/spec/support/fixtures/5k.png +0 -0
- data/spec/support/fixtures/animated +0 -0
- data/spec/support/fixtures/animated.gif +0 -0
- data/spec/support/fixtures/animated.unknown +0 -0
- data/spec/support/fixtures/aws_s3.yml +0 -13
- data/spec/support/fixtures/bad.png +0 -1
- data/spec/support/fixtures/empty.html +0 -1
- data/spec/support/fixtures/empty.xlsx +0 -0
- data/spec/support/fixtures/fog.yml +0 -8
- data/spec/support/fixtures/rotated.jpg +0 -0
- data/spec/support/fixtures/s3.yml +0 -8
- data/spec/support/fixtures/sample.xlsm +0 -0
- data/spec/support/fixtures/spaced file.jpg +0 -0
- data/spec/support/fixtures/spaced file.png +0 -0
- data/spec/support/fixtures/text.txt +0 -1
- data/spec/support/fixtures/twopage.pdf +0 -0
- data/spec/support/fixtures/uppercase.PNG +0 -0
- data/spec/support/matchers/accept.rb +0 -5
- data/spec/support/matchers/exist.rb +0 -5
- data/spec/support/matchers/have_column.rb +0 -23
- data/spec/support/mock_attachment.rb +0 -24
- data/spec/support/mock_interpolator.rb +0 -24
- data/spec/support/mock_url_generator_builder.rb +0 -26
- data/spec/support/model_reconstruction.rb +0 -72
- data/spec/support/reporting.rb +0 -11
- data/spec/support/test_data.rb +0 -13
- data/spec/support/version_helper.rb +0 -9
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
require "paperclip/schema"
|
|
3
|
-
require "active_support/testing/deprecation"
|
|
4
|
-
|
|
5
|
-
describe Paperclip::Schema do
|
|
6
|
-
include ActiveSupport::Testing::Deprecation
|
|
7
|
-
|
|
8
|
-
before do
|
|
9
|
-
rebuild_class
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
after do
|
|
13
|
-
begin
|
|
14
|
-
ActiveRecord::Migration.drop_table :dummies
|
|
15
|
-
rescue StandardError
|
|
16
|
-
nil
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context "within table definition" do
|
|
21
|
-
context "using #has_attached_file" do
|
|
22
|
-
before do
|
|
23
|
-
ActiveSupport::Deprecation.silenced = false
|
|
24
|
-
end
|
|
25
|
-
it "creates attachment columns" do
|
|
26
|
-
ActiveRecord::Migration.create_table :dummies, force: true do |t|
|
|
27
|
-
ActiveSupport::Deprecation.silence do
|
|
28
|
-
t.has_attached_file :avatar
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
columns = Dummy.columns.map { |column| [column.name, column.sql_type] }
|
|
33
|
-
|
|
34
|
-
expect(columns).to include(["avatar_file_name", "varchar"])
|
|
35
|
-
expect(columns).to include(["avatar_content_type", "varchar"])
|
|
36
|
-
expect(columns).to include(["avatar_file_size", "bigint"])
|
|
37
|
-
expect(columns).to include(["avatar_updated_at", "datetime"])
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "displays deprecation warning" do
|
|
41
|
-
ActiveRecord::Migration.create_table :dummies, force: true do |t|
|
|
42
|
-
assert_deprecated do
|
|
43
|
-
t.has_attached_file :avatar
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context "using #attachment" do
|
|
50
|
-
before do
|
|
51
|
-
ActiveRecord::Migration.create_table :dummies, force: true do |t|
|
|
52
|
-
t.attachment :avatar
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it "creates attachment columns" do
|
|
57
|
-
columns = Dummy.columns.map { |column| [column.name, column.sql_type] }
|
|
58
|
-
|
|
59
|
-
expect(columns).to include(["avatar_file_name", "varchar"])
|
|
60
|
-
expect(columns).to include(["avatar_content_type", "varchar"])
|
|
61
|
-
expect(columns).to include(["avatar_file_size", "bigint"])
|
|
62
|
-
expect(columns).to include(["avatar_updated_at", "datetime"])
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
context "using #attachment with options" do
|
|
67
|
-
before do
|
|
68
|
-
ActiveRecord::Migration.create_table :dummies, force: true do |t|
|
|
69
|
-
t.attachment :avatar, default: 1, file_name: { default: "default" }
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "sets defaults on columns" do
|
|
74
|
-
defaults_columns = ["avatar_file_name", "avatar_content_type", "avatar_file_size"]
|
|
75
|
-
columns = Dummy.columns.select { |e| defaults_columns.include? e.name }
|
|
76
|
-
|
|
77
|
-
expect(columns).to have_column("avatar_file_name").with_default("default")
|
|
78
|
-
expect(columns).to have_column("avatar_content_type").with_default("1")
|
|
79
|
-
expect(columns).to have_column("avatar_file_size").with_default(1)
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
context "within schema statement" do
|
|
85
|
-
before do
|
|
86
|
-
ActiveRecord::Migration.create_table :dummies, force: true
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
context "migrating up" do
|
|
90
|
-
context "with single attachment" do
|
|
91
|
-
before do
|
|
92
|
-
ActiveRecord::Migration.add_attachment :dummies, :avatar
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it "creates attachment columns" do
|
|
96
|
-
columns = Dummy.columns.map { |column| [column.name, column.sql_type] }
|
|
97
|
-
|
|
98
|
-
expect(columns).to include(["avatar_file_name", "varchar"])
|
|
99
|
-
expect(columns).to include(["avatar_content_type", "varchar"])
|
|
100
|
-
expect(columns).to include(["avatar_file_size", "bigint"])
|
|
101
|
-
expect(columns).to include(["avatar_updated_at", "datetime"])
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
context "with single attachment and options" do
|
|
106
|
-
before do
|
|
107
|
-
ActiveRecord::Migration.add_attachment :dummies, :avatar, default: "1", file_name: { default: "default" }
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it "sets defaults on columns" do
|
|
111
|
-
defaults_columns = ["avatar_file_name", "avatar_content_type", "avatar_file_size"]
|
|
112
|
-
columns = Dummy.columns.select { |e| defaults_columns.include? e.name }
|
|
113
|
-
|
|
114
|
-
expect(columns).to have_column("avatar_file_name").with_default("default")
|
|
115
|
-
expect(columns).to have_column("avatar_content_type").with_default("1")
|
|
116
|
-
expect(columns).to have_column("avatar_file_size").with_default(1)
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
context "with multiple attachments" do
|
|
121
|
-
before do
|
|
122
|
-
ActiveRecord::Migration.add_attachment :dummies, :avatar, :photo
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it "creates attachment columns" do
|
|
126
|
-
columns = Dummy.columns.map { |column| [column.name, column.sql_type] }
|
|
127
|
-
|
|
128
|
-
expect(columns).to include(["avatar_file_name", "varchar"])
|
|
129
|
-
expect(columns).to include(["avatar_content_type", "varchar"])
|
|
130
|
-
expect(columns).to include(["avatar_file_size", "bigint"])
|
|
131
|
-
expect(columns).to include(["avatar_updated_at", "datetime"])
|
|
132
|
-
expect(columns).to include(["photo_file_name", "varchar"])
|
|
133
|
-
expect(columns).to include(["photo_content_type", "varchar"])
|
|
134
|
-
expect(columns).to include(["photo_file_size", "bigint"])
|
|
135
|
-
expect(columns).to include(["photo_updated_at", "datetime"])
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
context "with multiple attachments and options" do
|
|
140
|
-
before do
|
|
141
|
-
ActiveRecord::Migration.add_attachment :dummies, :avatar, :photo, default: "1", file_name: { default: "default" }
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
it "sets defaults on columns" do
|
|
145
|
-
defaults_columns = ["avatar_file_name", "avatar_content_type", "avatar_file_size", "photo_file_name", "photo_content_type", "photo_file_size"]
|
|
146
|
-
columns = Dummy.columns.select { |e| defaults_columns.include? e.name }
|
|
147
|
-
|
|
148
|
-
expect(columns).to have_column("avatar_file_name").with_default("default")
|
|
149
|
-
expect(columns).to have_column("avatar_content_type").with_default("1")
|
|
150
|
-
expect(columns).to have_column("avatar_file_size").with_default(1)
|
|
151
|
-
expect(columns).to have_column("photo_file_name").with_default("default")
|
|
152
|
-
expect(columns).to have_column("photo_content_type").with_default("1")
|
|
153
|
-
expect(columns).to have_column("photo_file_size").with_default(1)
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
context "with no attachment" do
|
|
158
|
-
it "raises an error" do
|
|
159
|
-
assert_raises ArgumentError do
|
|
160
|
-
ActiveRecord::Migration.add_attachment :dummies
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
context "migrating down" do
|
|
167
|
-
before do
|
|
168
|
-
ActiveRecord::Migration.change_table :dummies do |t|
|
|
169
|
-
t.column :avatar_file_name, :string
|
|
170
|
-
t.column :avatar_content_type, :string
|
|
171
|
-
t.column :avatar_file_size, :bigint
|
|
172
|
-
t.column :avatar_updated_at, :datetime
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
context "using #drop_attached_file" do
|
|
177
|
-
before do
|
|
178
|
-
ActiveSupport::Deprecation.silenced = false
|
|
179
|
-
end
|
|
180
|
-
it "removes the attachment columns" do
|
|
181
|
-
ActiveSupport::Deprecation.silence do
|
|
182
|
-
ActiveRecord::Migration.drop_attached_file :dummies, :avatar
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
columns = Dummy.columns.map { |column| [column.name, column.sql_type] }
|
|
186
|
-
|
|
187
|
-
expect(columns).to_not include(["avatar_file_name", "varchar"])
|
|
188
|
-
expect(columns).to_not include(["avatar_content_type", "varchar"])
|
|
189
|
-
expect(columns).to_not include(["avatar_file_size", "bigint"])
|
|
190
|
-
expect(columns).to_not include(["avatar_updated_at", "datetime"])
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
it "displays a deprecation warning" do
|
|
194
|
-
assert_deprecated do
|
|
195
|
-
ActiveRecord::Migration.drop_attached_file :dummies, :avatar
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
context "using #remove_attachment" do
|
|
201
|
-
context "with single attachment" do
|
|
202
|
-
before do
|
|
203
|
-
ActiveRecord::Migration.remove_attachment :dummies, :avatar
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
it "removes the attachment columns" do
|
|
207
|
-
columns = Dummy.columns.map { |column| [column.name, column.sql_type] }
|
|
208
|
-
|
|
209
|
-
expect(columns).to_not include(["avatar_file_name", "varchar"])
|
|
210
|
-
expect(columns).to_not include(["avatar_content_type", "varchar"])
|
|
211
|
-
expect(columns).to_not include(["avatar_file_size", "bigint"])
|
|
212
|
-
expect(columns).to_not include(["avatar_updated_at", "datetime"])
|
|
213
|
-
end
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
context "with multiple attachments" do
|
|
217
|
-
before do
|
|
218
|
-
ActiveRecord::Migration.change_table :dummies do |t|
|
|
219
|
-
t.column :photo_file_name, :string
|
|
220
|
-
t.column :photo_content_type, :string
|
|
221
|
-
t.column :photo_file_size, :bigint
|
|
222
|
-
t.column :photo_updated_at, :datetime
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
ActiveRecord::Migration.remove_attachment :dummies, :avatar, :photo
|
|
226
|
-
end
|
|
227
|
-
|
|
228
|
-
it "removes the attachment columns" do
|
|
229
|
-
columns = Dummy.columns.map { |column| [column.name, column.sql_type] }
|
|
230
|
-
|
|
231
|
-
expect(columns).to_not include(["avatar_file_name", "varchar"])
|
|
232
|
-
expect(columns).to_not include(["avatar_content_type", "varchar"])
|
|
233
|
-
expect(columns).to_not include(["avatar_file_size", "bigint"])
|
|
234
|
-
expect(columns).to_not include(["avatar_updated_at", "datetime"])
|
|
235
|
-
expect(columns).to_not include(["photo_file_name", "varchar"])
|
|
236
|
-
expect(columns).to_not include(["photo_content_type", "varchar"])
|
|
237
|
-
expect(columns).to_not include(["photo_file_size", "bigint"])
|
|
238
|
-
expect(columns).to_not include(["photo_updated_at", "datetime"])
|
|
239
|
-
end
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
context "with no attachment" do
|
|
243
|
-
it "raises an error" do
|
|
244
|
-
assert_raises ArgumentError do
|
|
245
|
-
ActiveRecord::Migration.remove_attachment :dummies
|
|
246
|
-
end
|
|
247
|
-
end
|
|
248
|
-
end
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
end
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Paperclip::Storage::Filesystem do
|
|
4
|
-
context "Filesystem" do
|
|
5
|
-
context "normal file" do
|
|
6
|
-
before do
|
|
7
|
-
rebuild_model styles: { thumbnail: "25x25#" }
|
|
8
|
-
@dummy = Dummy.create!
|
|
9
|
-
|
|
10
|
-
@file = File.open(fixture_file("5k.png"))
|
|
11
|
-
@dummy.avatar = @file
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
after { @file.close }
|
|
15
|
-
|
|
16
|
-
it "allows file assignment" do
|
|
17
|
-
assert @dummy.save
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "stores the original" do
|
|
21
|
-
@dummy.save
|
|
22
|
-
assert_file_exists(@dummy.avatar.path)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "stores the thumbnail" do
|
|
26
|
-
@dummy.save
|
|
27
|
-
assert_file_exists(@dummy.avatar.path(:thumbnail))
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "is rewinded after flush_writes" do
|
|
31
|
-
@dummy.avatar.instance_eval "def after_flush_writes; end"
|
|
32
|
-
|
|
33
|
-
files = @dummy.avatar.queued_for_write.values
|
|
34
|
-
@dummy.save
|
|
35
|
-
assert files.none?(&:eof?), "Expect all the files to be rewinded."
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "is removed after after_flush_writes" do
|
|
39
|
-
paths = @dummy.avatar.queued_for_write.values.map(&:path)
|
|
40
|
-
@dummy.save
|
|
41
|
-
assert paths.none? { |path| File.exist?(path) },
|
|
42
|
-
"Expect all the files to be deleted."
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "copies the file to a known location with copy_to_local_file" do
|
|
46
|
-
tempfile = Tempfile.new("known_location")
|
|
47
|
-
@dummy.avatar.copy_to_local_file(:original, tempfile.path)
|
|
48
|
-
tempfile.rewind
|
|
49
|
-
assert_equal @file.read, tempfile.read
|
|
50
|
-
tempfile.close
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "only issues a delete call once for each unique attachment style when nullifying attachment" do
|
|
54
|
-
@dummy.save
|
|
55
|
-
@dummy.avatar.clear(:thumbnail)
|
|
56
|
-
@dummy.avatar = nil
|
|
57
|
-
assert_equal 3, @dummy.avatar.queued_for_delete.size
|
|
58
|
-
|
|
59
|
-
expect(FileUtils).to receive(:rm).twice
|
|
60
|
-
@dummy.save
|
|
61
|
-
|
|
62
|
-
FileUtils.rm_rf("tmp")
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it "only issues a delete call once for each unique attachment style when destroying model" do
|
|
66
|
-
@dummy.save
|
|
67
|
-
@dummy.avatar.clear(:thumbnail)
|
|
68
|
-
assert_equal 1, @dummy.avatar.queued_for_delete.size
|
|
69
|
-
|
|
70
|
-
expect(FileUtils).to receive(:rm).twice
|
|
71
|
-
@dummy.destroy
|
|
72
|
-
|
|
73
|
-
FileUtils.rm_rf("tmp")
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
context "with file that has space in file name" do
|
|
78
|
-
before do
|
|
79
|
-
rebuild_model styles: { thumbnail: "25x25#" }
|
|
80
|
-
@dummy = Dummy.create!
|
|
81
|
-
|
|
82
|
-
@file = File.open(fixture_file("spaced file.png"))
|
|
83
|
-
@dummy.avatar = @file
|
|
84
|
-
@dummy.save
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
after { @file.close }
|
|
88
|
-
|
|
89
|
-
it "stores the file" do
|
|
90
|
-
assert_file_exists(@dummy.avatar.path)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
it "returns a replaced version for path" do
|
|
94
|
-
assert_match /.+\/spaced_file\.png/, @dummy.avatar.path
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it "returns a replaced version for url" do
|
|
98
|
-
assert_match /.+\/spaced_file\.png/, @dummy.avatar.url
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|