|
888e17dd
»
|
Squeegy |
2008-05-29 |
Fixed failing test. Thanks... |
1 |
require File.dirname(__FILE__) + '/../../test/test_helper' |
| |
2 |
|
| |
3 |
class FleximageFileUploadToDbTest < Test::Unit::TestCase |
| |
4 |
def test_should_be_valid_with_image |
| |
5 |
p = PhotoDb.new(:image_file => files(:photo)) |
| |
6 |
assert p.save, 'Record expected to be allowed to save' |
| |
7 |
|
| |
8 |
p = PhotoDb.find(p.id) |
| |
9 |
assert_kind_of Magick::Image, p.load_image |
| |
10 |
assert p.image_file_data.size > 0 |
| |
11 |
end |
| |
12 |
|
| |
13 |
def test_should_require_an_image |
| |
14 |
p = PhotoDb.new |
| |
15 |
assert !p.save, 'Record expected to not be allowed to save' |
| |
16 |
assert_equal 1, p.errors.size |
| |
17 |
assert_equal 'is required', p.errors.on(:image_file) |
| |
18 |
end |
| |
19 |
|
| |
20 |
def test_should_require_an_valid_image |
| |
21 |
p = PhotoDb.new(:image_file => files(:not_a_photo)) |
| |
22 |
assert !p.save, 'Record expected to not be allowed to save' |
| |
23 |
assert_equal 1, p.errors.size |
| |
24 |
assert_equal 'was not a readable image', p.errors.on(:image_file) |
| |
25 |
end |
| |
26 |
|
| |
27 |
def test_should_retrieve_a_stored_image |
| |
28 |
id = PhotoDb.create(:image_file => files(:photo)).id |
| |
29 |
p = PhotoDb.find(id) |
| |
30 |
assert_kind_of Magick::Image, p.load_image |
| |
31 |
assert_equal 768, p.load_image.columns |
| |
32 |
assert_equal 1024, p.load_image.rows |
| |
33 |
end |
| |
34 |
|
| |
35 |
def test_should_delete_an_image |
| |
36 |
id = PhotoDb.create(:image_file => files(:photo)).id |
| |
37 |
photo = PhotoDb.find(id) |
| |
38 |
photo.destroy |
| |
39 |
assert_nil PhotoDb.find_by_id(id) |
| |
40 |
end |
| |
41 |
end |