robinboening-fleximage 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/CHANGELOG.rdoc +14 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +257 -0
  4. data/Rakefile +49 -0
  5. data/VERSION +1 -0
  6. data/autotest.rb +5 -0
  7. data/fleximage.gemspec +179 -0
  8. data/init.rb +1 -0
  9. data/lib/dsl_accessor.rb +52 -0
  10. data/lib/fleximage.rb +56 -0
  11. data/lib/fleximage/aviary_controller.rb +75 -0
  12. data/lib/fleximage/blank.rb +70 -0
  13. data/lib/fleximage/helper.rb +41 -0
  14. data/lib/fleximage/image_proxy.rb +69 -0
  15. data/lib/fleximage/legacy_view.rb +63 -0
  16. data/lib/fleximage/model.rb +711 -0
  17. data/lib/fleximage/operator/background.rb +62 -0
  18. data/lib/fleximage/operator/base.rb +189 -0
  19. data/lib/fleximage/operator/border.rb +50 -0
  20. data/lib/fleximage/operator/crop.rb +58 -0
  21. data/lib/fleximage/operator/image_overlay.rb +85 -0
  22. data/lib/fleximage/operator/resize.rb +92 -0
  23. data/lib/fleximage/operator/shadow.rb +87 -0
  24. data/lib/fleximage/operator/text.rb +104 -0
  25. data/lib/fleximage/operator/trim.rb +14 -0
  26. data/lib/fleximage/operator/unsharp_mask.rb +36 -0
  27. data/lib/fleximage/rmagick_image_patch.rb +5 -0
  28. data/lib/fleximage/view.rb +57 -0
  29. data/tasks/fleximage_tasks.rake +154 -0
  30. data/test/fixtures/100x1.jpg +0 -0
  31. data/test/fixtures/100x100.jpg +0 -0
  32. data/test/fixtures/1x1.jpg +0 -0
  33. data/test/fixtures/1x100.jpg +0 -0
  34. data/test/fixtures/cmyk.jpg +0 -0
  35. data/test/fixtures/not_a_photo.xml +1 -0
  36. data/test/fixtures/photo.jpg +0 -0
  37. data/test/mock_file.rb +21 -0
  38. data/test/rails_root/app/controllers/application.rb +10 -0
  39. data/test/rails_root/app/controllers/avatars_controller.rb +85 -0
  40. data/test/rails_root/app/controllers/photo_bares_controller.rb +85 -0
  41. data/test/rails_root/app/controllers/photo_dbs_controller.rb +85 -0
  42. data/test/rails_root/app/controllers/photo_files_controller.rb +85 -0
  43. data/test/rails_root/app/helpers/application_helper.rb +3 -0
  44. data/test/rails_root/app/helpers/avatars_helper.rb +2 -0
  45. data/test/rails_root/app/helpers/photo_bares_helper.rb +2 -0
  46. data/test/rails_root/app/helpers/photo_dbs_helper.rb +2 -0
  47. data/test/rails_root/app/helpers/photo_files_helper.rb +2 -0
  48. data/test/rails_root/app/locales/de.yml +7 -0
  49. data/test/rails_root/app/locales/en.yml +8 -0
  50. data/test/rails_root/app/models/abstract.rb +8 -0
  51. data/test/rails_root/app/models/avatar.rb +4 -0
  52. data/test/rails_root/app/models/photo_bare.rb +7 -0
  53. data/test/rails_root/app/models/photo_custom_error.rb +10 -0
  54. data/test/rails_root/app/models/photo_db.rb +3 -0
  55. data/test/rails_root/app/models/photo_file.rb +3 -0
  56. data/test/rails_root/app/models/photo_s3.rb +5 -0
  57. data/test/rails_root/app/views/avatars/edit.html.erb +17 -0
  58. data/test/rails_root/app/views/avatars/index.html.erb +20 -0
  59. data/test/rails_root/app/views/avatars/new.html.erb +16 -0
  60. data/test/rails_root/app/views/avatars/show.html.erb +8 -0
  61. data/test/rails_root/app/views/layouts/avatars.html.erb +17 -0
  62. data/test/rails_root/app/views/layouts/photo_bares.html.erb +17 -0
  63. data/test/rails_root/app/views/layouts/photo_dbs.html.erb +17 -0
  64. data/test/rails_root/app/views/layouts/photo_files.html.erb +17 -0
  65. data/test/rails_root/app/views/photo_bares/edit.html.erb +12 -0
  66. data/test/rails_root/app/views/photo_bares/index.html.erb +18 -0
  67. data/test/rails_root/app/views/photo_bares/new.html.erb +11 -0
  68. data/test/rails_root/app/views/photo_bares/show.html.erb +3 -0
  69. data/test/rails_root/app/views/photo_dbs/edit.html.erb +32 -0
  70. data/test/rails_root/app/views/photo_dbs/index.html.erb +26 -0
  71. data/test/rails_root/app/views/photo_dbs/new.html.erb +31 -0
  72. data/test/rails_root/app/views/photo_dbs/show.html.erb +23 -0
  73. data/test/rails_root/app/views/photo_files/edit.html.erb +27 -0
  74. data/test/rails_root/app/views/photo_files/index.html.erb +24 -0
  75. data/test/rails_root/app/views/photo_files/new.html.erb +26 -0
  76. data/test/rails_root/app/views/photo_files/show.html.erb +18 -0
  77. data/test/rails_root/config/boot.rb +109 -0
  78. data/test/rails_root/config/database.yml +7 -0
  79. data/test/rails_root/config/environment.rb +66 -0
  80. data/test/rails_root/config/environments/development.rb +18 -0
  81. data/test/rails_root/config/environments/production.rb +19 -0
  82. data/test/rails_root/config/environments/sqlite3.rb +0 -0
  83. data/test/rails_root/config/environments/test.rb +22 -0
  84. data/test/rails_root/config/initializers/inflections.rb +10 -0
  85. data/test/rails_root/config/initializers/load_translations.rb +4 -0
  86. data/test/rails_root/config/initializers/mime_types.rb +5 -0
  87. data/test/rails_root/config/routes.rb +43 -0
  88. data/test/rails_root/db/migrate/001_create_photo_files.rb +16 -0
  89. data/test/rails_root/db/migrate/002_create_photo_dbs.rb +16 -0
  90. data/test/rails_root/db/migrate/003_create_photo_bares.rb +12 -0
  91. data/test/rails_root/db/migrate/004_create_avatars.rb +13 -0
  92. data/test/rails_root/db/migrate/005_create_photo_s3s.rb +12 -0
  93. data/test/rails_root/public/.htaccess +40 -0
  94. data/test/rails_root/public/404.html +30 -0
  95. data/test/rails_root/public/422.html +30 -0
  96. data/test/rails_root/public/500.html +30 -0
  97. data/test/rails_root/public/dispatch.cgi +10 -0
  98. data/test/rails_root/public/dispatch.fcgi +24 -0
  99. data/test/rails_root/public/dispatch.rb +10 -0
  100. data/test/rails_root/public/favicon.ico +0 -0
  101. data/test/rails_root/public/images/rails.png +0 -0
  102. data/test/rails_root/public/index.html +277 -0
  103. data/test/rails_root/public/javascripts/application.js +2 -0
  104. data/test/rails_root/public/javascripts/controls.js +963 -0
  105. data/test/rails_root/public/javascripts/dragdrop.js +972 -0
  106. data/test/rails_root/public/javascripts/effects.js +1120 -0
  107. data/test/rails_root/public/javascripts/prototype.js +4225 -0
  108. data/test/rails_root/public/robots.txt +5 -0
  109. data/test/rails_root/public/stylesheets/scaffold.css +74 -0
  110. data/test/rails_root/vendor/plugins/fleximage/init.rb +2 -0
  111. data/test/s3_stubs.rb +7 -0
  112. data/test/test_helper.rb +82 -0
  113. data/test/unit/abstract_test.rb +20 -0
  114. data/test/unit/basic_model_test.rb +40 -0
  115. data/test/unit/blank_test.rb +23 -0
  116. data/test/unit/default_image_path_option_test.rb +16 -0
  117. data/test/unit/dsl_accessor_test.rb +120 -0
  118. data/test/unit/file_upload_from_local_test.rb +31 -0
  119. data/test/unit/file_upload_from_strings_test.rb +23 -0
  120. data/test/unit/file_upload_from_url_test.rb +35 -0
  121. data/test/unit/file_upload_to_db_test.rb +41 -0
  122. data/test/unit/has_store_test.rb +4 -0
  123. data/test/unit/i18n_messages_test.rb +49 -0
  124. data/test/unit/image_directory_option_test.rb +20 -0
  125. data/test/unit/image_proxy_test.rb +17 -0
  126. data/test/unit/image_storage_format_option_test.rb +31 -0
  127. data/test/unit/magic_columns_test.rb +34 -0
  128. data/test/unit/minimum_image_size_test.rb +56 -0
  129. data/test/unit/operator_base_test.rb +124 -0
  130. data/test/unit/operator_resize_test.rb +18 -0
  131. data/test/unit/preprocess_image_option_test.rb +21 -0
  132. data/test/unit/require_image_option_test.rb +30 -0
  133. data/test/unit/temp_image_test.rb +23 -0
  134. data/test/unit/use_creation_date_based_directories_option_test.rb +16 -0
  135. metadata +258 -0
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -0,0 +1,74 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ .fieldWithErrors {
20
+ padding: 2px;
21
+ background-color: red;
22
+ display: table;
23
+ }
24
+
25
+ #errorExplanation {
26
+ width: 400px;
27
+ border: 2px solid red;
28
+ padding: 7px;
29
+ padding-bottom: 12px;
30
+ margin-bottom: 20px;
31
+ background-color: #f0f0f0;
32
+ }
33
+
34
+ #errorExplanation h2 {
35
+ text-align: left;
36
+ font-weight: bold;
37
+ padding: 5px 5px 5px 15px;
38
+ font-size: 12px;
39
+ margin: -7px;
40
+ background-color: #c00;
41
+ color: #fff;
42
+ }
43
+
44
+ #errorExplanation p {
45
+ color: #333;
46
+ margin-bottom: 0;
47
+ padding: 5px;
48
+ }
49
+
50
+ #errorExplanation ul li {
51
+ font-size: 12px;
52
+ list-style: square;
53
+ }
54
+
55
+ div.uploadStatus {
56
+ margin: 5px;
57
+ }
58
+
59
+ div.progressBar {
60
+ margin: 5px;
61
+ }
62
+
63
+ div.progressBar div.border {
64
+ background-color: #fff;
65
+ border: 1px solid gray;
66
+ width: 100%;
67
+ }
68
+
69
+ div.progressBar div.background {
70
+ background-color: #333;
71
+ height: 18px;
72
+ width: 0%;
73
+ }
74
+
@@ -0,0 +1,2 @@
1
+ init_path = "#{RAILS_ROOT}/../../init.rb"
2
+ silence_warnings { eval(IO.read(init_path), binding, init_path) }
data/test/s3_stubs.rb ADDED
@@ -0,0 +1,7 @@
1
+ class AWS::S3::Bucket
2
+
3
+ def self.find(*args)
4
+ return new
5
+ end
6
+
7
+ end
@@ -0,0 +1,82 @@
1
+ # Load the environment
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ require File.dirname(__FILE__) + '/rails_root/config/environment.rb'
4
+
5
+ # Load the testing framework
6
+ require 'test_help'
7
+ silence_warnings { RAILS_ENV = ENV['RAILS_ENV'] }
8
+
9
+ # Run the migrations
10
+ ActiveRecord::Migrator.migrate("#{RAILS_ROOT}/db/migrate")
11
+
12
+ # Setup the fixtures path
13
+ Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
14
+ $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
15
+
16
+ require File.dirname(__FILE__) + '/mock_file'
17
+ require File.dirname(__FILE__) + '/s3_stubs'
18
+ require 'open-uri'
19
+
20
+ unless Magick::QuantumDepth == 16
21
+ puts "**** WARNING ****"
22
+ puts "* Tests expect a ImageMagick bit depth of 16, you have Magick::QuantumDepth == #{Magick::QuantumDepth}"
23
+ puts "* Color checking tests will likely fail"
24
+ end
25
+
26
+ class Test::Unit::TestCase #:nodoc:
27
+ def create_fixtures(*table_names)
28
+ if block_given?
29
+ Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
30
+ else
31
+ Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
32
+ end
33
+ end
34
+
35
+ self.use_transactional_fixtures = true
36
+ self.use_instantiated_fixtures = false
37
+
38
+ def files(name)
39
+ case name
40
+ when :photo
41
+ MockFile.new("#{RAILS_ROOT}/../fixtures/photo.jpg")
42
+
43
+ when :not_a_photo
44
+ MockFile.new("#{RAILS_ROOT}/../fixtures/not_a_photo.xml")
45
+
46
+ when :web_photo
47
+ 'http://www.google.com/intl/en_ALL/images/logo.gif'
48
+
49
+ when :cmyk
50
+ MockFile.new("#{RAILS_ROOT}/../fixtures/cmyk.jpg")
51
+
52
+ when :i100x100
53
+ MockFile.new("#{RAILS_ROOT}/../fixtures/100x100.jpg")
54
+
55
+ when :i1x100
56
+ MockFile.new("#{RAILS_ROOT}/../fixtures/1x100.jpg")
57
+
58
+ when :i100x1
59
+ MockFile.new("#{RAILS_ROOT}/../fixtures/100x1.jpg")
60
+
61
+ when :i1x1
62
+ MockFile.new("#{RAILS_ROOT}/../fixtures/1x1.jpg")
63
+
64
+ end
65
+ end
66
+
67
+ def color_at(image, coords)
68
+ image.load_image.pixel_color(*coords)
69
+ end
70
+
71
+ def to_color(rgb)
72
+ Magick::Pixel.new(*rgb)
73
+ end
74
+
75
+ def assert_color(expected, coords, image)
76
+ coords = coords.split('x').collect(&:to_i)
77
+ expected = to_color(expected)
78
+ actual = color_at(image, coords)
79
+
80
+ assert_equal(expected, actual, "Wrong color at (#{coords.join(',')}). Expected #{expected}, Got #{actual}")
81
+ end
82
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../../test/test_helper'
2
+
3
+ class FleximageAbstractTest < Test::Unit::TestCase
4
+
5
+ def test_should_generate_a_default_image
6
+ p = Abstract.new
7
+ assert p.save
8
+
9
+ assert_equal 320, p.load_image.columns
10
+ assert_equal 240, p.load_image.rows
11
+ assert_color [65535, 0, 0], '160x120', p
12
+ end
13
+
14
+ def test_should_delete_an_abstract_model
15
+ p = Abstract.new
16
+ assert p.save
17
+ assert_nothing_raised { p.destroy }
18
+ end
19
+
20
+ end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../../test/test_helper'
2
+
3
+ class FleximageBasicModelTest < Test::Unit::TestCase
4
+ def test_should_have_correct_file_path_with_creation_date_based_storage
5
+ p = PhotoBare.create(:image_file => files(:photo))
6
+ assert_equal "#{RAILS_ROOT}/public/uploads/#{Time.now.year}/#{Time.now.month}/#{Time.now.day}/#{p.id}.png", p.file_path
7
+ end
8
+
9
+ def test_should_have_correct_directory_path_with_creation_date_based_storage
10
+ p = PhotoBare.create(:image_file => files(:photo))
11
+ assert_equal "#{RAILS_ROOT}/public/uploads/#{Time.now.year}/#{Time.now.month}/#{Time.now.day}", p.directory_path
12
+ end
13
+
14
+ def test_should_have_correct_file_path_without_creation_date_based_storage
15
+ PhotoBare.use_creation_date_based_directories = false
16
+ p = PhotoBare.create(:image_file => files(:photo))
17
+ assert_equal "#{RAILS_ROOT}/public/uploads/#{p.id}.png", p.file_path
18
+ ensure
19
+ PhotoBare.use_creation_date_based_directories = true
20
+ end
21
+
22
+ def test_should_have_correct_directory_path_without_creation_date_based_storage
23
+ PhotoBare.use_creation_date_based_directories = false
24
+ p = PhotoBare.create(:image_file => files(:photo))
25
+ assert_equal "#{RAILS_ROOT}/public/uploads", p.directory_path
26
+ ensure
27
+ PhotoBare.use_creation_date_based_directories = true
28
+ end
29
+
30
+ def test_should_not_prepend_rails_root_to_absolute_path
31
+ PhotoBare.image_directory = '/tmp'
32
+ PhotoBare.use_creation_date_based_directories = false
33
+ p = PhotoBare.create(:image_file => files(:photo))
34
+ assert_equal '/tmp', p.directory_path
35
+ end
36
+
37
+ def test_should_confirm_presence_of_a_store_when_using_s3
38
+ assert PhotoS3.has_store?
39
+ end
40
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../../test/test_helper'
2
+
3
+ class FleximageBlankTest < Test::Unit::TestCase
4
+
5
+ def test_should_create_blank_image_of_proper_dimensions
6
+ p = Fleximage::Blank.new('320x480')
7
+ p.operate do |image|
8
+ assert_equal(320, image.width)
9
+ assert_equal(480, image.height)
10
+ end
11
+ end
12
+
13
+ def test_should_be_transparent_by_default
14
+ p = Fleximage::Blank.new('320x480')
15
+ assert_color([0, 0, 0, 65535], '50x50', p)
16
+ end
17
+
18
+ def test_should_color_image
19
+ p = Fleximage::Blank.new('320x480', :color => 'red')
20
+ assert_color([65535, 0, 0, 0], '50x50', p)
21
+ end
22
+
23
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../../test/test_helper'
2
+
3
+ class FleximageDefaultImagePathOptionTest < Test::Unit::TestCase
4
+ def test_should_use_a_default_image
5
+ PhotoBare.require_image = false
6
+ PhotoBare.default_image_path = "../fixtures/photo.jpg"
7
+
8
+ p = PhotoBare.new
9
+ assert p.save
10
+ assert_equal 1024, p.load_image.rows
11
+ assert_equal 768, p.load_image.columns
12
+ ensure
13
+ PhotoBare.require_image = true
14
+ PhotoBare.default_image_path = nil
15
+ end
16
+ end
@@ -0,0 +1,120 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class DslAccessorTest < Test::Unit::TestCase
4
+ class CoolActiveRecord
5
+ dsl_accessor :primary_key
6
+ dsl_accessor :table_name
7
+ end
8
+
9
+ class Item < CoolActiveRecord
10
+ end
11
+
12
+ class LegacyItem < CoolActiveRecord
13
+ primary_key :itcd
14
+ table_name :item
15
+ end
16
+
17
+
18
+ def test_accessor_without_initialization
19
+ assert_equal nil, Item.primary_key
20
+ assert_equal nil, Item.table_name
21
+
22
+ Item.primary_key :itcd
23
+ Item.table_name :item
24
+
25
+ assert_equal :itcd, Item.primary_key
26
+ assert_equal :item, Item.table_name
27
+ end
28
+
29
+ def test_accessor_with_initialization
30
+ assert_equal :itcd, LegacyItem.primary_key
31
+ assert_equal :item, LegacyItem.table_name
32
+
33
+ LegacyItem.primary_key :item_id
34
+ LegacyItem.table_name :item_table
35
+
36
+ assert_equal :item_id, LegacyItem.primary_key
37
+ assert_equal :item_table, LegacyItem.table_name
38
+ end
39
+ end
40
+
41
+
42
+ class DslDefaultAccessorTest < Test::Unit::TestCase
43
+
44
+ class CoolActiveRecord
45
+ dsl_accessor :primary_key, :default=>"id"
46
+ dsl_accessor :table_name, :default=>proc{|klass| klass.name.demodulize.underscore.pluralize}
47
+ end
48
+
49
+ class Item < CoolActiveRecord
50
+ end
51
+
52
+ class User < CoolActiveRecord
53
+ end
54
+
55
+ class Folder
56
+ dsl_accessor :array_folder, :default=>[]
57
+ dsl_accessor :hash_folder, :default=>{}
58
+ end
59
+
60
+ class SubFolder < Folder
61
+ end
62
+
63
+ def test_default_accessor_with_string
64
+ assert_equal "id", Item.primary_key
65
+ assert_equal "id", User.primary_key
66
+ end
67
+
68
+ def test_default_accessor_with_proc
69
+ assert_equal "items", Item.table_name
70
+ assert_equal "users", User.table_name
71
+ end
72
+
73
+ def test_default_accessor_should_duplicate_empty_array_or_hash
74
+ Folder.array_folder << 1
75
+ Folder.hash_folder[:name] = "maiha"
76
+
77
+ assert_equal([1], Folder.array_folder)
78
+ assert_equal({:name=>"maiha"}, Folder.hash_folder)
79
+
80
+ assert_equal([], SubFolder.array_folder)
81
+ assert_equal({}, SubFolder.hash_folder)
82
+ end
83
+ end
84
+
85
+
86
+ class DslOverwritenDefaultAccessorTest < Test::Unit::TestCase
87
+ class CoolActiveRecord
88
+ dsl_accessor :primary_key, :default=>"id"
89
+ dsl_accessor :table_name, :default=>proc{|klass| klass.name.demodulize.underscore.pluralize}
90
+ end
91
+
92
+ class Item < CoolActiveRecord
93
+ primary_key :item_id
94
+ table_name :item_table
95
+ end
96
+
97
+ def test_overwrite_default_accessor
98
+ assert_equal :item_id, Item.primary_key
99
+ assert_equal :item_table, Item.table_name
100
+ end
101
+ end
102
+
103
+
104
+ class DslWriterAccessorTest < Test::Unit::TestCase
105
+ class Item
106
+ dsl_accessor :primary_key, :writer=>proc{|value| value.to_s}
107
+ end
108
+
109
+ def test_string_writer
110
+ assert_equal "", Item.primary_key
111
+
112
+ Item.primary_key :id
113
+ assert_equal "id", Item.primary_key
114
+
115
+ Item.primary_key "id"
116
+ assert_equal "id", Item.primary_key
117
+ end
118
+ end
119
+
120
+
@@ -0,0 +1,31 @@
1
+ require File.dirname(__FILE__) + '/../../test/test_helper'
2
+
3
+ class FleximageFileUploadFromLocalTest < Test::Unit::TestCase
4
+ def test_should_be_valid_with_image
5
+ p = PhotoBare.new(:image_file => files(:photo))
6
+ assert p.save, 'Record expected to be allowed to save'
7
+ end
8
+
9
+ def test_should_require_an_image
10
+ p = PhotoBare.new
11
+ assert !p.save, 'Record expected to not be allowed to save'
12
+ assert_equal 1, p.errors.size
13
+ assert_equal 'is required', p.errors.on(:image_file)
14
+ end
15
+
16
+ def test_should_require_an_valid_image
17
+ p = PhotoBare.new(:image_file => files(:not_a_photo))
18
+ assert !p.save, 'Record expected to not be allowed to save'
19
+ assert_equal 1, p.errors.size
20
+ assert_equal 'was not a readable image', p.errors.on(:image_file)
21
+ end
22
+
23
+ def test_should_correct_colorspace_and_dpi
24
+ p = PhotoBare.new(:image_file => files(:cmyk))
25
+ image = p.load_image
26
+ assert_equal Magick::RGBColorspace, image.colorspace
27
+ assert_equal '72x72', image.density
28
+ assert_equal 300, image.columns
29
+ assert_equal 300, image.rows
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../../test/test_helper'
2
+
3
+ class FleximageFileUploadFromStringsTest < Test::Unit::TestCase
4
+ def test_should_accept_file_as_string
5
+ data = files(:photo).read
6
+
7
+ p = PhotoBare.new
8
+ p.image_file_string = data
9
+ p.save
10
+ assert p.save, 'Record expected to be allowed to save'
11
+ assert p.has_image?
12
+ end
13
+
14
+ def test_should_accept_file_as_base64
15
+ data = Base64.encode64(files(:photo).read)
16
+
17
+ p = PhotoBare.new
18
+ p.image_file_base64 = data
19
+ p.save
20
+ assert p.save, 'Record expected to be allowed to save'
21
+ assert p.has_image?
22
+ end
23
+ end