attachs 4.0.0.0 → 4.0.0.1

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.
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+
3
+ class RecordTest < ActiveSupport::TestCase
4
+ include StorageHelper
5
+
6
+ test 'inherit' do
7
+ Subclass = Class.new(Product)
8
+ assert_equal Product.attachments, Subclass.attachments
9
+ end
10
+
11
+ test 'clear attachments' do
12
+ shop = Shop.new(logo: image).dup
13
+ assert shop.logo.source.blank?
14
+
15
+ shop = Shop.create(logo: image).reload
16
+ assert shop.logo.source.blank?
17
+ end
18
+
19
+ end
@@ -7,6 +7,26 @@ class TaskTest < ActiveSupport::TestCase
7
7
  Dummy::Application.load_tasks
8
8
  end
9
9
 
10
+ test 'exist' do
11
+ shop = Shop.create(name: 'first', logo: image)
12
+ shop.run_callbacks :commit
13
+ shop_old_path = shop.logo.paths[:original]
14
+ shop.update name: 'second'
15
+ shop.run_callbacks :commit
16
+ shop_path = shop.logo.paths[:original]
17
+
18
+ product = Product.create(pictures: [image, image])
19
+ product.run_callbacks :commit
20
+ product_path = product.pictures.first.paths[:original]
21
+
22
+ assert Attachs.exists?(shop_old_path)
23
+ assert Attachs.exists?(shop_path)
24
+ assert Attachs.exists?(product_path)
25
+
26
+ shop.logo.destroy
27
+ product.pictures.destroy
28
+ end
29
+
10
30
  test 'reprocess' do
11
31
  shop = Shop.new(logo: image)
12
32
  assert_raises do
@@ -6,9 +6,13 @@ class UploadTest < ActiveSupport::TestCase
6
6
  test 'upload' do
7
7
  upload = Upload.create(file: image, record_type: 'Shop', record_attribute: 'logo')
8
8
  upload.run_callbacks :commit
9
+
9
10
  shop = Shop.create(logo: upload)
10
11
  shop.run_callbacks :commit
11
12
  assert_equal 5, shop.logo.paths.size
13
+ upload.file.styles.each do |style, geometry|
14
+ assert_url upload.file.url(style)
15
+ end
12
16
  shop.logo.styles.each do |style, geometry|
13
17
  assert_url shop.logo.url(style)
14
18
  end
@@ -17,10 +21,14 @@ class UploadTest < ActiveSupport::TestCase
17
21
  shop = Shop.create(logo: upload.id)
18
22
  shop.run_callbacks :commit
19
23
  assert_equal 5, shop.logo.paths.size
24
+ upload.file.styles.each do |style, geometry|
25
+ assert_url upload.file.url(style)
26
+ end
20
27
  shop.logo.styles.each do |style, geometry|
21
28
  assert_url shop.logo.url(style)
22
29
  end
23
30
  shop.logo.destroy
31
+
24
32
  upload.file.destroy
25
33
  end
26
34
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attachs
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.0
4
+ version: 4.0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmontossi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-06 00:00:00.000000000 Z
11
+ date: 2016-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -114,7 +114,6 @@ files:
114
114
  - lib/tasks/attachs.rake
115
115
  - test/attachment_test.rb
116
116
  - test/collection_test.rb
117
- - test/concern_test.rb
118
117
  - test/dummy/Rakefile
119
118
  - test/dummy/app/assets/javascripts/application.js
120
119
  - test/dummy/app/assets/stylesheets/application.css
@@ -167,7 +166,7 @@ files:
167
166
  - test/fixtures/small_image.jpg
168
167
  - test/generator_test.rb
169
168
  - test/helper_test.rb
170
- - test/query_test.rb
169
+ - test/record_test.rb
171
170
  - test/support/storage_helper.rb
172
171
  - test/task_test.rb
173
172
  - test/test_helper.rb
@@ -201,7 +200,6 @@ summary: File attachments for rails.
201
200
  test_files:
202
201
  - test/attachment_test.rb
203
202
  - test/collection_test.rb
204
- - test/concern_test.rb
205
203
  - test/dummy/app/assets/javascripts/application.js
206
204
  - test/dummy/app/assets/stylesheets/application.css
207
205
  - test/dummy/app/controllers/application_controller.rb
@@ -254,7 +252,7 @@ test_files:
254
252
  - test/fixtures/small_image.jpg
255
253
  - test/generator_test.rb
256
254
  - test/helper_test.rb
257
- - test/query_test.rb
255
+ - test/record_test.rb
258
256
  - test/support/storage_helper.rb
259
257
  - test/task_test.rb
260
258
  - test/test_helper.rb
@@ -1,10 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ConcernTest < ActiveSupport::TestCase
4
-
5
- test 'inherit' do
6
- Subclass = Class.new(Product)
7
- assert_equal Product.attachments, Subclass.attachments
8
- end
9
-
10
- end
@@ -1,26 +0,0 @@
1
- require 'test_helper'
2
-
3
- class QueryTest < ActiveSupport::TestCase
4
- include StorageHelper
5
-
6
- test 'exist' do
7
- shop = Shop.create(name: 'first', logo: image)
8
- shop.run_callbacks :commit
9
- shop_old_path = shop.logo.paths[:original]
10
- shop.update name: 'second'
11
- shop.run_callbacks :commit
12
- shop_path = shop.logo.paths[:original]
13
-
14
- product = Product.create(pictures: [image, image])
15
- product.run_callbacks :commit
16
- product_path = product.pictures.first.paths[:original]
17
-
18
- assert Attachs.exists?(shop_old_path)
19
- assert Attachs.exists?(shop_path)
20
- assert Attachs.exists?(product_path)
21
-
22
- shop.logo.destroy
23
- product.pictures.destroy
24
- end
25
-
26
- end