effective_assets 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
File without changes
Binary file
@@ -1,128 +0,0 @@
1
- require 'spec_helper'
2
- require 'factory_girl_rails'
3
-
4
- # Attributes
5
- describe Effective::Asset do
6
- let(:asset) { FactoryGirl.create(:asset) }
7
-
8
- it 'should be valid' do
9
- asset.valid?.should eq true
10
- end
11
- end
12
-
13
- describe Effective::Asset do
14
- let(:image_file_string) { File.read(Rails.root.join('public/sprites.png')) }
15
- let(:image_url) { 'http://cdn.sstatic.net/stackoverflow/img/sprites.png?v=1' }
16
-
17
- let (:email) do
18
- Mail.new do
19
- from 'someone@something.com'
20
- to 'info@rails-skeleton.agilestyle.com'
21
- subject 'Test email'
22
- body 'This is the body of the test email'
23
- end
24
- end
25
-
26
- it 'should be creatable from URL' do
27
- asset = Effective::Asset.create_from_url(image_url, {:title => 'a title', :user_id => 1})
28
-
29
- # A new asset should exist, and it should be unprocessed
30
- asset.should_not eq false
31
-
32
- asset.upload_file.should eq image_url
33
- asset.processed.should eq false
34
-
35
- # It should have queued up a process_asset task with delayed job
36
- Delayed::Job.count.should eq 1
37
-
38
- job = Psych.load(Delayed::Job.first.handler)
39
- job.method_name.should eq :process_asset_without_delay
40
- job.args.first.should eq asset.id
41
-
42
- # Run DelayedJob
43
- Delayed::Worker.new(:max_priority => nil, :min_priority => nil, :quiet => true).work_off
44
- Delayed::Job.count.should eq 0
45
-
46
- # We should have a totally processed Asset
47
- asset = Effective::Asset.find(asset.id)
48
- asset.processed.should eq true
49
- asset.data.kind_of?(TestAssetUploader).should eq true
50
- asset.title.should eq 'a title'
51
- asset.user_id.should eq 1
52
- asset.versions_info.present?.should eq true
53
- asset.content_type.should eq 'image/png'
54
- asset.height.should eq 1073
55
- asset.width.should eq 238
56
- end
57
-
58
- it 'should be creatable from a String' do
59
- asset = Effective::Asset.create_from_string(image_file_string, :filename => 'sprites1.png', :content_type => 'image/png')
60
-
61
- # A new asset should exist, and it should be unprocessed
62
- asset.should_not eq false
63
-
64
- asset.upload_file.should eq "string://sprites1.png"
65
- asset.processed.should eq false
66
-
67
- # It should have queued up a process_asset task with delayed job
68
- Delayed::Job.count.should eq 1
69
-
70
- job = Psych.load(Delayed::Job.first.handler)
71
- job.method_name.should eq :process_asset_without_delay
72
- job.args.first.should eq asset.id
73
-
74
- # Run DelayedJob
75
- Delayed::Worker.new(:max_priority => nil, :min_priority => nil, :quiet => true).work_off
76
- Delayed::Job.count.should eq 0
77
-
78
- # We should have a totally processed Asset
79
- asset = Effective::Asset.find(asset.id)
80
- asset.processed.should eq true
81
- asset.data.kind_of?(TestAssetUploader).should eq true
82
- asset.title.should eq 'sprites1.png'
83
- asset.user_id.should eq 1
84
- asset.versions_info.present?.should eq true
85
- asset.content_type.should eq 'image/png'
86
- asset.height.should eq 1073
87
- asset.width.should eq 238
88
- end
89
-
90
- it 'should handle an email decoded string file' do
91
- email.add_file({:filename => Rails.root.join('public/sprites.png').to_s})
92
-
93
- attachment = email.attachments.first
94
- asset = Effective::Asset.create_from_string(attachment.body.decoded, :filename => attachment.filename, :content_type => attachment.mime_type)
95
-
96
- # A new asset should exist, and it should be unprocessed
97
- asset.should_not eq false
98
-
99
- asset.upload_file.include?('public_sprites.png').should eq true
100
- asset.upload_file.include?('string://').should eq true
101
- asset.processed.should eq false
102
-
103
-
104
- # It should have queued up a process_asset task with delayed job
105
- Delayed::Job.count.should eq 1
106
-
107
- job = Psych.load(Delayed::Job.first.handler)
108
- job.method_name.should eq :process_asset_without_delay
109
- job.args.first.should eq asset.id
110
-
111
- # Run DelayedJob
112
- Delayed::Worker.new(:max_priority => nil, :min_priority => nil, :quiet => true).work_off
113
- Delayed::Job.count.should eq 0
114
-
115
- # We should have a totally processed Asset
116
- asset = Effective::Asset.find(asset.id)
117
- asset.processed.should eq true
118
- asset.data.kind_of?(TestAssetUploader).should eq true
119
- asset.user_id.should eq 1
120
- asset.versions_info.present?.should eq true
121
- asset.content_type.should eq 'image/png'
122
- asset.height.should eq 1073
123
- asset.width.should eq 238
124
-
125
-
126
- end
127
-
128
- end
data/spec/spec_helper.rb DELETED
@@ -1,40 +0,0 @@
1
- ENV["RAILS_ENV"] ||= 'test'
2
-
3
- #require File.expand_path("../dummy/config/environment", __FILE__)
4
-
5
- require 'rubygems'
6
- require 'bundler/setup'
7
- require 'factory_girl_rails'
8
- require 'combustion'
9
-
10
- Combustion.initialize! :all
11
-
12
- require 'rspec/rails'
13
- require 'rspec/autorun'
14
-
15
- # Requires supporting ruby files with custom matchers and macros, etc,
16
- # in spec/support/ and its subdirectories.
17
- Dir[Rails.root.join("../support/**/*.rb")].each {|f| require f }
18
-
19
- RSpec.configure do |config|
20
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
21
-
22
- Rails.logger.level = 4 # Output only minimal stuff to test.log
23
-
24
- config.use_transactional_fixtures = true # Make this false to once again use DatabaseCleaner
25
- config.infer_base_class_for_anonymous_controllers = false
26
- config.order = 'random'
27
- end
28
-
29
- class ActiveRecord::Base
30
- mattr_accessor :shared_connection
31
- @@shared_connection = nil
32
-
33
- def self.connection
34
- @@shared_connection || retrieve_connection
35
- end
36
- end
37
-
38
- # Forces all threads to share the same connection. This works on
39
- # Capybara because it starts the web server in a thread.
40
- ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
@@ -1,28 +0,0 @@
1
- require 'factory_girl'
2
-
3
- FactoryGirl.define do
4
- factory :asset, :class => Effective::Asset do
5
- user_id 1
6
-
7
- sequence(:title) { |n| "Title #{n}" }
8
- content_type 'image/jpg'
9
- processed true
10
-
11
- sequence(:upload_file) { |n| "http://#{EffectiveAssets.aws_bucket}.s3.amazonaws.com/uploads/asset#{n}.jpg"}
12
- sequence(:data) { |n| "asset#{n}.jpg" }
13
-
14
- data_size 123456
15
- width 600
16
- height 480
17
- versions_info Hash.new(:thumb => {:data_size => 123456, :width => 128, :height => 128}, :main => {:data_size => 123456, :width => 400, :height => 400})
18
- end
19
-
20
- # factory :attachment do
21
- # association :asset
22
- # association :attachable, :factory => :user
23
-
24
- # position 0
25
- # box 'featured_images'
26
- # end
27
-
28
- end