Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

implemented test for asset processing with image resizing, and skippe…

…d image resizing for the other tests to speed them up.
  • Loading branch information...
commit 5dab7b6ccdb34d099e463b0115248633d2910d09 1 parent 47d9104
@mceachen authored
View
7 Gemfile
@@ -63,7 +63,7 @@ gem 'delayed_job_active_record'
gem 'hirefire'
gem 'nokogiri'
-gem 'rufus-lru'
+#gem 'rufus-lru'
#group :test do
#gem 'rspec', '~> 2.7.0'
@@ -80,10 +80,15 @@ gem 'rufus-lru'
#gem 'factory_girl_rails' #TODO: needed?
#end
+group :development do
+# TODO: seemed cool: gem "rails-erd"
+end
+
group :test do
gem 'minitest'
gem 'minitest-reporters'
gem 'miniskirt'
+ gem 'mocha'
#gem 'mini_backtrace' # Use Rails.backtrace_cleaner with MiniTest.
# gem 'capybara'
View
6 Gemfile.lock
@@ -97,6 +97,7 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
+ metaclass (0.0.1)
micro_magick (0.0.5)
mime-types (1.18)
miniskirt (1.1.1)
@@ -106,6 +107,8 @@ GEM
ansi
minitest (~> 2.0)
ruby-progressbar
+ mocha (0.10.5)
+ metaclass (~> 0.0.1)
multi_json (1.2.0)
mysql2 (0.3.11)
netrc (0.7.1)
@@ -147,7 +150,6 @@ GEM
mime-types (>= 1.16)
ruby-progressbar (0.0.10)
rubyzip (0.9.7)
- rufus-lru (1.0.5)
rush (0.6.8)
session
sass (3.1.15)
@@ -194,6 +196,7 @@ DEPENDENCIES
miniskirt
minitest
minitest-reporters
+ mocha
mysql2
nokogiri
parallel
@@ -203,7 +206,6 @@ DEPENDENCIES
rb-fsevent
rb-inotify
ruby-geonames!
- rufus-lru
sass-rails
sqlite3
thin
View
1  test/minitest_helper.rb
@@ -6,6 +6,7 @@
require 'active_support/testing/setup_and_teardown'
require 'miniskirt'
require 'factories'
+require 'mocha'
=begin
require "capybara/rails"
View
49 test/models/asset_processor_test.rb
@@ -1,30 +1,31 @@
require "minitest_helper"
-describe AssetProcessor do
+describe "asset processing without image resizing" do
before :each do
- p = Pathname.new("test/images/IMG_2452.jpg")
+ ImageResizer.stubs(:visit_asset) # this takes a while, and we aren't testing it here, so skip.
@ap = AssetProcessor.new(nil)
- @asset = @ap.process(p)
- @asset.save!
- @path = p.realpath
- @uri = @path.to_uri.to_s
end
- def assert_path
- @asset.uri.must_equal(@path.to_uri)
- @asset.asset_uris.size.must_equal 1
- au = @asset.asset_uris.first
- au.to_uri.must_equal(@path.to_uri)
- au.uri.must_equal(@path.to_uri.to_s)
+ def process_img_2452
+ p = Pathname.new("test/images/IMG_2452.jpg")
+ asset = @ap.process(p)
+ asset.save!
+ return asset, p.realpath
end
it "should work on insert" do
- assert_path
+ asset, path = process_img_2452
+ asset.uri.must_equal(path.to_uri)
+ asset.asset_uris.size.must_equal 1
+ au = asset.asset_uris.first
+ au.to_uri.must_equal(path.to_uri)
+ au.uri.must_equal(path.to_uri.to_s)
end
it "should find the prior asset" do
- a2 = @ap.process(@path)
- a2.must_equal(@asset)
+ asset, path = process_img_2452
+ a2 = @ap.process(path)
+ a2.must_equal(asset)
end
it "should return false for non-exif-encoded assets" do
@@ -62,5 +63,21 @@ def assert_path
].sort
end
- it "should create resized image assets"
+end
+
+describe "asset processing with image resizing" do
+ it "should create resized image assets" do
+ #with_tmp_dir do |dir|
+ dir = "/var/tmp/testing123"
+ Settings.defaults[:cache_dir] = dir.to_pathname
+ ap = AssetProcessor.new(nil)
+ ap.process("test/images/Canon 20D.jpg")
+ expected_sizes = Settings.resizes + Settings.square_crop_sizes.collect { |i| "#{i}x#{i}" }
+ actual_sizes = Dir["#{dir}/**/*.jpg"].collect do |f|
+ r = ExifMixin.exif_result(f)
+ "#{r[:image_width].to_i}x#{r[:image_height].to_i}"
+ end
+ actual_sizes.sort.must_equal expected_sizes.sort
+ #end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.