active_admin_jcrop 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -0
  3. data/app/assets/javascripts/active_admin_jcrop/crop_modal.js.coffee +0 -2
  4. data/app/views/active_admin_jcrop/_jcrop_modal.html.erb +2 -2
  5. data/lib/active_admin_jcrop/railtie.rb +18 -15
  6. data/lib/active_admin_jcrop/version.rb +1 -1
  7. data/spec/dummy/app/admin/post.rb +1 -1
  8. data/spec/dummy/app/models/post.rb +1 -0
  9. data/spec/dummy/log/test.log +4474 -0
  10. data/spec/dummy/tmp/cache/assets/test/sprockets/2894eb75de440448b3c40d69d7c3daf1 +0 -0
  11. data/spec/dummy/tmp/cache/assets/test/sprockets/6e600d6b6e57393c380d4f34b7e462c1 +0 -0
  12. data/spec/dummy/tmp/cache/assets/test/sprockets/82a4b11f94b10449d88fc04cf6df3a18 +0 -0
  13. data/spec/dummy/tmp/cache/assets/test/sprockets/a60a6f908e1d257971c558b8c6db7ae5 +0 -0
  14. data/spec/dummy/tmp/cache/assets/test/sprockets/e88a13629d2c3498c801d061a01f6bf1 +0 -0
  15. data/spec/features/post_jcrop_feature_spec.rb +47 -0
  16. data/spec/spec_helper.rb +1 -1
  17. data/spec/support/carrierwave.rb +3 -4
  18. metadata +34 -38
  19. data/spec/dummy/public/uploads/post/image/1/caminhao.jpeg +0 -0
  20. data/spec/dummy/public/uploads/post/image/1/thumb_caminhao.jpeg +0 -0
  21. data/spec/dummy/public/uploads/tmp/1402854070-53359-7950/caminhao.jpeg +0 -0
  22. data/spec/dummy/public/uploads/tmp/1402854070-53359-7950/thumb_caminhao.jpeg +0 -0
  23. data/spec/dummy/public/uploads/tmp/1402854510-53557-6949/caminhao.jpeg +0 -0
  24. data/spec/dummy/public/uploads/tmp/1402854510-53557-6949/thumb_caminhao.jpeg +0 -0
  25. data/spec/dummy/public/uploads/tmp/1402854728-53655-1717/caminhao.jpeg +0 -0
  26. data/spec/dummy/public/uploads/tmp/1402854728-53655-1717/thumb_caminhao.jpeg +0 -0
  27. data/spec/dummy/public/uploads/tmp/1402855138-53797-0268/caminhao.jpeg +0 -0
  28. data/spec/dummy/public/uploads/tmp/1402855138-53797-0268/thumb_caminhao.jpeg +0 -0
  29. data/spec/dummy/public/uploads/tmp/1402856174-54150-2897/caminhao.jpeg +0 -0
  30. data/spec/dummy/public/uploads/tmp/1402856174-54150-2897/thumb_caminhao.jpeg +0 -0
  31. data/spec/dummy/public/uploads/tmp/1402856561-54391-5701/caminhao.jpeg +0 -0
  32. data/spec/dummy/public/uploads/tmp/1402856561-54391-5701/thumb_caminhao.jpeg +0 -0
  33. data/spec/dummy/public/uploads/tmp/1402884860-59723-5663/caminhao.jpeg +0 -0
  34. data/spec/dummy/public/uploads/tmp/1402884860-59723-5663/thumb_caminhao.jpeg +0 -0
  35. data/spec/support/uploads/post/image/7/example.jpeg +0 -0
  36. data/spec/support/uploads/post/image/7/thumb_example.jpeg +0 -0
@@ -1,4 +1,6 @@
1
1
  require 'spec_helper'
2
+ require 'phashion'
3
+
2
4
 
3
5
  feature 'Post admin' do
4
6
 
@@ -11,5 +13,50 @@ feature 'Post admin' do
11
13
  visit "/admin/posts/#{@post.id}/edit"
12
14
  end
13
15
 
16
+ elements = {'button to open crop modal' => '.crop_modal_open',
17
+ 'modal div' => '.crop_modal_content',
18
+ 'image to be cropped' => '.cropping_image'
19
+ }
20
+
21
+ elements.each_pair do |name, element_class|
22
+ it "should have the #{name} displayed" do
23
+ expect(page).to have_css(element_class, visible: false)
24
+ end
25
+ end
26
+
27
+
28
+ it "should open the crop modal when clicking at the button" do
29
+ modal_classes = '.ui-dialog.ui-widget.ui-widget-content.ui-corner-all.ui-front'
30
+ expect(page).not_to have_css(modal_classes)
31
+ click_link "Crop Image"
32
+ modal = page.find(modal_classes)
33
+ expect(modal).to have_css('img.cropping_image')
34
+ end
35
+
36
+ it "should close the modal when click at cancel" do
37
+ modal_classes = '.ui-dialog.ui-widget.ui-widget-content.ui-corner-all.ui-front'
38
+ click_link "Crop Image"
39
+ click_link "Cancel"
40
+ expect(page).not_to have_css(modal_classes)
41
+ end
42
+
43
+ it "should crop the thumb version of the Image" do
44
+ thumb = Phashion::Image.new(MiniMagick::Image.open(@post.image.thumb.path).path) #load copy of image as a temp file
45
+ click_link "Crop Image"
46
+ click_button "Save Cropped Image"
47
+ sleep 3 # wait for the ajax
48
+ cropped_thumb = Phashion::Image.new @post.image.thumb.path
49
+ expect(cropped_thumb.duplicate?(thumb)).to be_falsey
50
+ end
51
+
52
+ it "should pass the options specified at the form to jcrop" do
53
+ new_options = {aspectRatio: 0.5, setSelect: [0, 0, 25, 25]}
54
+ stub_const "Post::DEFAULT_CROP_OPTIONS", new_options
55
+ visit "/admin/posts/#{@post.id}/edit"
56
+ jcrop_attributes = page.find('.cropping_image', visible: false)['data-jcrop-options']
57
+ expect(jcrop_attributes).to be_present
58
+ jcrop_attributes = JSON.parse(jcrop_attributes).symbolize_keys
59
+ expect(jcrop_attributes).to be == new_options
60
+ end
14
61
  end
15
62
  end
@@ -65,7 +65,7 @@ RSpec.configure do |config|
65
65
  # --seed 1234
66
66
  config.after(:each) do
67
67
  if Rails.env.test? || Rails.env.cucumber?
68
- FileUtils.rm_rf(Dir["#{Rails.root}/spec/support/uploads"])
68
+ FileUtils.rm_rf(Dir["#{Rails.root}/spec/dummy/public/post"])
69
69
  end
70
70
  end
71
71
 
@@ -1,7 +1,6 @@
1
1
  if Rails.env.test? || Rails.env.cucumber?
2
2
  CarrierWave.configure do |config|
3
3
  config.storage = :file
4
- config.enable_processing = false
5
4
  end
6
5
 
7
6
  # use different dirs when testing
@@ -9,15 +8,15 @@ if Rails.env.test? || Rails.env.cucumber?
9
8
  next if klass.anonymous?
10
9
  klass.class_eval do
11
10
  def cache_dir
12
- "#{Rails.root}/spec/support/uploads/tmp"
11
+ "#{Rails.root}/public/tmp"
13
12
  end
14
13
 
15
14
  def store_dir
16
- "#{Rails.root}/spec/support/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
15
+ "#{Rails.root}/public/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
17
16
  end
18
17
  end
19
18
  end
20
19
  CarrierWave.configure do |config|
21
- config.root = "#{Rails.root}/spec/support/uploads/"
20
+ config.root = "#{Rails.root}/public/"
22
21
  end
23
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_jcrop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Nacif
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-23 00:00:00.000000000 Z
11
+ date: 2014-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -178,6 +178,34 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: phashion
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rake
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
181
209
  description: Jcrop plugin for ActiveAdmin, enable image cropping solution on image
182
210
  fields
183
211
  email:
@@ -251,22 +279,6 @@ files:
251
279
  - spec/dummy/public/422.html
252
280
  - spec/dummy/public/500.html
253
281
  - spec/dummy/public/favicon.ico
254
- - spec/dummy/public/uploads/post/image/1/caminhao.jpeg
255
- - spec/dummy/public/uploads/post/image/1/thumb_caminhao.jpeg
256
- - spec/dummy/public/uploads/tmp/1402854070-53359-7950/caminhao.jpeg
257
- - spec/dummy/public/uploads/tmp/1402854070-53359-7950/thumb_caminhao.jpeg
258
- - spec/dummy/public/uploads/tmp/1402854510-53557-6949/caminhao.jpeg
259
- - spec/dummy/public/uploads/tmp/1402854510-53557-6949/thumb_caminhao.jpeg
260
- - spec/dummy/public/uploads/tmp/1402854728-53655-1717/caminhao.jpeg
261
- - spec/dummy/public/uploads/tmp/1402854728-53655-1717/thumb_caminhao.jpeg
262
- - spec/dummy/public/uploads/tmp/1402855138-53797-0268/caminhao.jpeg
263
- - spec/dummy/public/uploads/tmp/1402855138-53797-0268/thumb_caminhao.jpeg
264
- - spec/dummy/public/uploads/tmp/1402856174-54150-2897/caminhao.jpeg
265
- - spec/dummy/public/uploads/tmp/1402856174-54150-2897/thumb_caminhao.jpeg
266
- - spec/dummy/public/uploads/tmp/1402856561-54391-5701/caminhao.jpeg
267
- - spec/dummy/public/uploads/tmp/1402856561-54391-5701/thumb_caminhao.jpeg
268
- - spec/dummy/public/uploads/tmp/1402884860-59723-5663/caminhao.jpeg
269
- - spec/dummy/public/uploads/tmp/1402884860-59723-5663/thumb_caminhao.jpeg
270
282
  - spec/dummy/tmp/cache/assets/development/sprockets/01cc28ef6cf61e838f8df3854de4e76b
271
283
  - spec/dummy/tmp/cache/assets/development/sprockets/04815176b18d23ced953077cdab6c799
272
284
  - spec/dummy/tmp/cache/assets/development/sprockets/05329eaf5e8ad8c55f7356cd6f1a208d
@@ -438,6 +450,7 @@ files:
438
450
  - spec/dummy/tmp/cache/assets/test/sprockets/7f8b2599f8306c1dc7d1e3e5b9deded8
439
451
  - spec/dummy/tmp/cache/assets/test/sprockets/81dd6767e418fdc1ab0263c94cd79d8b
440
452
  - spec/dummy/tmp/cache/assets/test/sprockets/8247e64103aa55a761ab0f354ff45c16
453
+ - spec/dummy/tmp/cache/assets/test/sprockets/82a4b11f94b10449d88fc04cf6df3a18
441
454
  - spec/dummy/tmp/cache/assets/test/sprockets/82a8bc708c97f88caaf13018bf6b279d
442
455
  - spec/dummy/tmp/cache/assets/test/sprockets/83054e22209abf270f4394486dd2629b
443
456
  - spec/dummy/tmp/cache/assets/test/sprockets/833571bbb8aac2c2d7ead0bb6c360747
@@ -463,6 +476,7 @@ files:
463
476
  - spec/dummy/tmp/cache/assets/test/sprockets/9b9cde87d5e9f732acdc4fb18077c71d
464
477
  - spec/dummy/tmp/cache/assets/test/sprockets/9ba436ceb3644f8f052f05eeff94a880
465
478
  - spec/dummy/tmp/cache/assets/test/sprockets/9f495611485125fd9772059d732fd3ec
479
+ - spec/dummy/tmp/cache/assets/test/sprockets/a60a6f908e1d257971c558b8c6db7ae5
466
480
  - spec/dummy/tmp/cache/assets/test/sprockets/a6b936ad9b28fb786d3135a007e5d5b8
467
481
  - spec/dummy/tmp/cache/assets/test/sprockets/a6eedf5e824ca04685c9da227f406b8f
468
482
  - spec/dummy/tmp/cache/assets/test/sprockets/a759d4068225951d142110473dd6c8b3
@@ -519,8 +533,6 @@ files:
519
533
  - spec/spec_helper.rb
520
534
  - spec/support/active_record.rb
521
535
  - spec/support/carrierwave.rb
522
- - spec/support/uploads/post/image/7/example.jpeg
523
- - spec/support/uploads/post/image/7/thumb_example.jpeg
524
536
  - vendor/assets/images/active_admin_jcrop/Jcrop.gif
525
537
  - vendor/assets/javascripts/active_admin_jcrop/jquery.Jcrop.js
526
538
  - vendor/assets/javascripts/active_admin_jcrop/jquery.Jcrop.min.js
@@ -598,22 +610,6 @@ test_files:
598
610
  - spec/dummy/public/422.html
599
611
  - spec/dummy/public/500.html
600
612
  - spec/dummy/public/favicon.ico
601
- - spec/dummy/public/uploads/post/image/1/caminhao.jpeg
602
- - spec/dummy/public/uploads/post/image/1/thumb_caminhao.jpeg
603
- - spec/dummy/public/uploads/tmp/1402854070-53359-7950/caminhao.jpeg
604
- - spec/dummy/public/uploads/tmp/1402854070-53359-7950/thumb_caminhao.jpeg
605
- - spec/dummy/public/uploads/tmp/1402854510-53557-6949/caminhao.jpeg
606
- - spec/dummy/public/uploads/tmp/1402854510-53557-6949/thumb_caminhao.jpeg
607
- - spec/dummy/public/uploads/tmp/1402854728-53655-1717/caminhao.jpeg
608
- - spec/dummy/public/uploads/tmp/1402854728-53655-1717/thumb_caminhao.jpeg
609
- - spec/dummy/public/uploads/tmp/1402855138-53797-0268/caminhao.jpeg
610
- - spec/dummy/public/uploads/tmp/1402855138-53797-0268/thumb_caminhao.jpeg
611
- - spec/dummy/public/uploads/tmp/1402856174-54150-2897/caminhao.jpeg
612
- - spec/dummy/public/uploads/tmp/1402856174-54150-2897/thumb_caminhao.jpeg
613
- - spec/dummy/public/uploads/tmp/1402856561-54391-5701/caminhao.jpeg
614
- - spec/dummy/public/uploads/tmp/1402856561-54391-5701/thumb_caminhao.jpeg
615
- - spec/dummy/public/uploads/tmp/1402884860-59723-5663/caminhao.jpeg
616
- - spec/dummy/public/uploads/tmp/1402884860-59723-5663/thumb_caminhao.jpeg
617
613
  - spec/dummy/Rakefile
618
614
  - spec/dummy/README.rdoc
619
615
  - spec/dummy/tmp/cache/assets/development/sprockets/01cc28ef6cf61e838f8df3854de4e76b
@@ -787,6 +783,7 @@ test_files:
787
783
  - spec/dummy/tmp/cache/assets/test/sprockets/7f8b2599f8306c1dc7d1e3e5b9deded8
788
784
  - spec/dummy/tmp/cache/assets/test/sprockets/81dd6767e418fdc1ab0263c94cd79d8b
789
785
  - spec/dummy/tmp/cache/assets/test/sprockets/8247e64103aa55a761ab0f354ff45c16
786
+ - spec/dummy/tmp/cache/assets/test/sprockets/82a4b11f94b10449d88fc04cf6df3a18
790
787
  - spec/dummy/tmp/cache/assets/test/sprockets/82a8bc708c97f88caaf13018bf6b279d
791
788
  - spec/dummy/tmp/cache/assets/test/sprockets/83054e22209abf270f4394486dd2629b
792
789
  - spec/dummy/tmp/cache/assets/test/sprockets/833571bbb8aac2c2d7ead0bb6c360747
@@ -812,6 +809,7 @@ test_files:
812
809
  - spec/dummy/tmp/cache/assets/test/sprockets/9b9cde87d5e9f732acdc4fb18077c71d
813
810
  - spec/dummy/tmp/cache/assets/test/sprockets/9ba436ceb3644f8f052f05eeff94a880
814
811
  - spec/dummy/tmp/cache/assets/test/sprockets/9f495611485125fd9772059d732fd3ec
812
+ - spec/dummy/tmp/cache/assets/test/sprockets/a60a6f908e1d257971c558b8c6db7ae5
815
813
  - spec/dummy/tmp/cache/assets/test/sprockets/a6b936ad9b28fb786d3135a007e5d5b8
816
814
  - spec/dummy/tmp/cache/assets/test/sprockets/a6eedf5e824ca04685c9da227f406b8f
817
815
  - spec/dummy/tmp/cache/assets/test/sprockets/a759d4068225951d142110473dd6c8b3
@@ -868,5 +866,3 @@ test_files:
868
866
  - spec/spec_helper.rb
869
867
  - spec/support/active_record.rb
870
868
  - spec/support/carrierwave.rb
871
- - spec/support/uploads/post/image/7/example.jpeg
872
- - spec/support/uploads/post/image/7/thumb_example.jpeg