attacheable 1.2 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
5
5
 
6
6
  spec = Gem::Specification.new do |s|
7
7
  s.name = 'attacheable'
8
- s.version = '1.2'
8
+ s.version = '1.3'
9
9
  s.summary = 'Library to handle image uploads'
10
10
  s.autorequire = 'attacheable'
11
11
  s.author = "Max Lapshin"
@@ -1,7 +1,7 @@
1
1
  module Attacheable
2
2
  module Uploading
3
3
  def prepare_uploaded_file(file_data)
4
- return prepare_merb_uploaded_file(file_data) if file_data.is_a?(Hash) && file_data["content_type"] && file_data["tempfile"]
4
+ return prepare_merb_uploaded_file(file_data) if file_data.is_a?(Hash) && file_data["tempfile"]
5
5
  return nil if file_data.nil? || !file_data.respond_to?(:original_filename) || !respond_to?(:filename=)
6
6
 
7
7
  self.filename = file_data.original_filename
@@ -21,7 +21,7 @@ module Attacheable
21
21
  end
22
22
 
23
23
  def prepare_merb_uploaded_file(file_data)
24
- return nil if file_data["tempfile"].blank? || file_data["filename"].blank? || file_data["content_type"].blank?
24
+ return nil if file_data["tempfile"].blank? || file_data["filename"].blank?
25
25
  self.filename = file_data["filename"]
26
26
  self.size = file_data["size"] if respond_to?(:size=)
27
27
  @tempfile = file_data["tempfile"]
@@ -33,7 +33,7 @@ module Attacheable
33
33
  return unless @tempfile
34
34
  self.content_type = @tempfile.content_type if @tempfile.respond_to?(:content_type)
35
35
 
36
- if content_type.blank? || content_type =~ /image\//
36
+ if content_type.blank? || content_type =~ /image\// || content_type == "application/octet-stream"
37
37
  file_type, width, height = identify_image_properties(@tempfile.path)
38
38
  if file_type
39
39
  self.width = width if(respond_to?(:width=))
@@ -73,9 +73,25 @@ class AttacheableTest < Test::Unit::TestCase
73
73
  assert !File.exists?(File.dirname(__FILE__)+"/public/system/images/0000/0001"), "Directory should be cleaned"
74
74
  end
75
75
 
76
+ def test_image_creation_from_flash
77
+ input = File.open(File.dirname(__FILE__)+"/fixtures/life.jpg")
78
+ input.extend(TestUploadExtension)
79
+ input.content_type = "application/octet-stream"
80
+ assert_equal "life.jpg", input.original_filename, "should look like uploaded file"
81
+ image = Image.new(:uploaded_data => input)
82
+ assert_equal "life_medium.jpg", image.send(:thumbnail_name_for, :medium), "should generate right thumbnail filename"
83
+ assert image.save, "Image should be saved"
84
+ assert_equal "life", image.attachment_basename
85
+ assert_equal ".jpg", image.attachment_extname
86
+ assert File.exists?(File.dirname(__FILE__)+"/public/system/images/0000/0001/life.jpg"), "File should be saved"
87
+ assert !File.exists?(File.dirname(__FILE__)+"/public/system/images/0000/0001/life_medium.jpg"), "Thumbnails should not be generated"
88
+ image.destroy
89
+ assert !File.exists?(File.dirname(__FILE__)+"/public/system/images/0000/0001"), "Directory should be cleaned"
90
+ end
91
+
76
92
  def test_merb_image_creation
77
93
  path = File.dirname(__FILE__)+"/fixtures/life.jpg"
78
- input = {"content_type"=>"image/jpeg", "size"=>File.size(path), "tempfile"=>File.open(path), "filename"=>"life.jpg"}
94
+ input = {"size"=>File.size(path), "tempfile"=>File.open(path), "filename"=>"life.jpg"}
79
95
  image = Image.new(:uploaded_data => input)
80
96
  assert image.save, "Image should be saved"
81
97
  assert_equal "life", image.attachment_basename
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attacheable
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.2"
4
+ version: "1.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Lapshin
@@ -9,7 +9,7 @@ autorequire: attacheable
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-05 00:00:00 +04:00
12
+ date: 2008-04-08 00:00:00 +04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,8 +30,6 @@ files:
30
30
  - lib/attacheable/uploading.rb
31
31
  - lib/attacheable.rb
32
32
  - MIT-LICENSE
33
- - pkg
34
- - pkg/attacheable-1.1.gem
35
33
  - Rakefile
36
34
  - README
37
35
  - README.ru
@@ -64,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
62
  requirements: []
65
63
 
66
64
  rubyforge_project: attacheable
67
- rubygems_version: 1.0.1
65
+ rubygems_version: 1.1.0
68
66
  signing_key:
69
67
  specification_version: 2
70
68
  summary: Library to handle image uploads
Binary file