citrusbyte-milton 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class MiltonTest < ActiveSupport::TestCase
4
+ context "running a syscall" do
5
+ should "return false on failure" do
6
+ assert !Milton.syscall('ls this_directory_definitely_doesnt_exist')
7
+ end
8
+
9
+ should "return output on success" do
10
+ assert_equal "foo\n", Milton.syscall("echo foo")
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,70 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ResizingTest < ActiveSupport::TestCase
4
+ context "processing thumbnails on create" do
5
+ context "with recipes" do
6
+ class ImageWithRecipes < Image
7
+ is_attachment(
8
+ :storage_options => { :root => ActiveSupport::TestCase.output_path },
9
+ :recipes => {
10
+ :foo => [{ :thumbnail => { :size => '50x50', :crop => true } }],
11
+ :bar => [{ :thumbnail => { :size => '10x10' } }],
12
+ :baz => [{ :thumbnail => { :size => '50x50' } }, { :thumbnail => { :size => '25x25', :crop => true } }],
13
+ }
14
+ )
15
+ end
16
+
17
+ setup do
18
+ @image = ImageWithRecipes.create! :file => upload('milton.jpg')
19
+ end
20
+
21
+ should "recognize options from :foo recipe" do
22
+ assert_equal 'milton.crop_size=50x50.jpg', File.basename(@image.path(:foo))
23
+ end
24
+
25
+ should "create :foo thumbnail" do
26
+ assert File.exists?(@image.path(:foo))
27
+ end
28
+
29
+ should "create :bar thumbnail" do
30
+ assert File.exists?(@image.path(:bar))
31
+ end
32
+
33
+ should "run :baz recipes in order" do
34
+ assert_equal 'milton.size=50x50.crop_size=25x25.jpg', File.basename(@image.path(:baz))
35
+ end
36
+ end
37
+
38
+ context "without sizes" do
39
+ setup do
40
+ @image = Image.create! :file => upload('milton.jpg')
41
+ end
42
+
43
+ should "not create a 50x50 thumbnail" do
44
+ assert !File.exists?(@image.path(:thumbnail => { :size => '50x50' }))
45
+ end
46
+
47
+ should "happily return path to non-existant 50x50 thumbnail" do
48
+ assert_equal 'milton.size=50x50.jpg', File.basename(@image.path(:thumbnail => { :size => '50x50' }))
49
+ end
50
+ end
51
+
52
+ context "with postprocessing" do
53
+ class ImageWithPostprocessing < Image
54
+ is_attachment :storage_options => { :root => ActiveSupport::TestCase.output_path }, :postprocessing => true
55
+ end
56
+
57
+ setup do
58
+ @image = ImageWithPostprocessing.create! :file => upload('milton.jpg')
59
+ end
60
+
61
+ should "create a 50x50 thumbnail" do
62
+ assert File.exists?(@image.path(:thumbnail => { :size => '50x50' }))
63
+ end
64
+
65
+ should "create a cropped 50x50 thumbnail" do
66
+ assert File.exists?(@image.path(:thumbnail => { :size => '50x50', :crop => true }))
67
+ end
68
+ end
69
+ end
70
+ end
data/test/schema.rb ADDED
@@ -0,0 +1,13 @@
1
+ ActiveRecord::Schema.define :version => 0 do
2
+ create_table :attachments, :force => true do |t|
3
+ t.string :filename
4
+ end
5
+
6
+ create_table :images, :force => true do |t|
7
+ t.string :filename
8
+ t.string :content_type
9
+ end
10
+
11
+ create_table :not_uploadables, :force => true do |t|
12
+ end
13
+ end
@@ -0,0 +1,62 @@
1
+ require File.dirname(__FILE__) + '/../../../../test/test_helper'
2
+ puts "\nWARNING: The tests require a Rails environment, try running them from within a Rails application.\n\n" unless defined?(Rails)
3
+ puts "\nWARNING: The tests require Contest or Shoulda gem loaded in your Rails environment\n\n" unless ActiveSupport::TestCase.respond_to?(:context)
4
+ unless %w( ActiveRecord::ConnectionAdapters::PostgreSQLAdapter ActiveRecord::ConnectionAdapters::MysqlAdapter ).include?(ActiveRecord::Base.connection.class.to_s)
5
+ puts "\nWARNING: The tests will fail using any adapter other than PostgreSQL or MySQL because they depend on a proper transaction rollback that retains the current sequence, Milton itself will still work however.\n\n"
6
+ end
7
+
8
+ require 'flexmock/test_unit'
9
+ require 'redgreen' rescue LoadError
10
+
11
+ Rails.backtrace_cleaner.remove_silencers!
12
+ Rails.backtrace_cleaner.add_silencer do |line|
13
+ (%w( /opt /var lib/active_support lib/active_record vendor/gems vendor/rails )).any? { |dir| line.include?(dir) }
14
+ end
15
+
16
+ $: << File.expand_path(File.dirname(__FILE__) + '/..')
17
+
18
+ load(File.dirname(__FILE__) + '/schema.rb')
19
+
20
+ class ActiveSupport::TestCase
21
+ self.use_transactional_fixtures = true
22
+ self.use_instantiated_fixtures = false
23
+ ActiveSupport::TestCase.fixture_path = File.join(File.dirname(__FILE__), 'fixtures/')
24
+
25
+ @@output_path = File.expand_path(File.join(File.dirname(__FILE__), 'output'))
26
+ cattr_reader :output_path
27
+ def output_path;ActiveSupport::TestCase.output_path;end;
28
+
29
+ # remove files created from previous test run, happens before instead of
30
+ # after so you can view them after you run the tests
31
+ FileUtils.rm_rf(output_path)
32
+
33
+ def upload(file, type='image/jpg')
34
+ ActionController::TestUploadedFile.new(fixture_file(file), type)
35
+ end
36
+
37
+ def fixture_file(file)
38
+ ActionController::TestCase.fixture_path + file
39
+ end
40
+ end
41
+
42
+ module ActiveSupport::Testing::Declarative
43
+ def pending_test(name, &block)
44
+ test(name) do
45
+ puts "\nPENDING: #{name} (in #{eval('"#{__FILE__}:#{__LINE__}"', block.binding)})"
46
+ end
47
+ end
48
+ end
49
+
50
+ class Attachment < ActiveRecord::Base
51
+ is_attachment :storage_options => { :root => ActiveSupport::TestCase.output_path }
52
+ end
53
+
54
+ class Image < ActiveRecord::Base
55
+ is_attachment :storage_options => { :root => ActiveSupport::TestCase.output_path }, :processors => { :thumbnail => { :postprocessing => true } }
56
+ end
57
+
58
+ class Net::HTTP
59
+ def connect
60
+ raise "Trying to hit the interwebz!!!"
61
+ end
62
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: citrusbyte-milton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Alavi
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-25 00:00:00 -07:00
12
+ date: 2009-06-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: ""
16
+ description: Rails file and upload handling plugin built for extensibility. Supports Amazon S3 and resizes images.
17
17
  email: ben.alavi@citrusbyte.com
18
18
  executables: []
19
19
 
@@ -21,9 +21,33 @@ extensions: []
21
21
 
22
22
  extra_rdoc_files: []
23
23
 
24
- files: []
25
-
26
- has_rdoc: true
24
+ files:
25
+ - README.markdown
26
+ - MIT-LICENSE
27
+ - Rakefile
28
+ - init.rb
29
+ - lib/milton/attachment.rb
30
+ - lib/milton/core/file.rb
31
+ - lib/milton/core/tempfile.rb
32
+ - lib/milton/derivatives/derivative.rb
33
+ - lib/milton/derivatives/thumbnail/crop_calculator.rb
34
+ - lib/milton/derivatives/thumbnail/image.rb
35
+ - lib/milton/derivatives/thumbnail.rb
36
+ - lib/milton/storage/disk_file.rb
37
+ - lib/milton/storage/s3_file.rb
38
+ - lib/milton/storage/stored_file.rb
39
+ - lib/milton/uploading.rb
40
+ - lib/milton.rb
41
+ - test/fixtures/big-milton.jpg
42
+ - test/fixtures/milton.jpg
43
+ - test/fixtures/mini-milton.jpg
44
+ - test/fixtures/unsanitary .milton.jpg
45
+ - test/milton/attachment_test.rb
46
+ - test/milton/milton_test.rb
47
+ - test/milton/resizing_test.rb
48
+ - test/schema.rb
49
+ - test/test_helper.rb
50
+ has_rdoc: false
27
51
  homepage: http://labs.citrusbyte.com/projects/milton
28
52
  post_install_message:
29
53
  rdoc_options: []
@@ -44,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
68
  version:
45
69
  requirements: []
46
70
 
47
- rubyforge_project:
71
+ rubyforge_project: milton
48
72
  rubygems_version: 1.2.0
49
73
  signing_key:
50
74
  specification_version: 2