spec/helpers/phocoder_helper_spec.rb in phocoder-rails-0.0.45 vs spec/helpers/phocoder_helper_spec.rb in phocoder-rails-0.0.46
- old
+ new
@@ -1,11 +1,12 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PhocoderHelper do #, :debug=>true
before(:each) do
- @attr = { :file => fixture_file_upload(fixture_path + '/big_eye_tiny.jpg','image/jpeg'),:width => 200,:height=>197 }
+ @fixture_path = ""
+ @attr = { :file => fixture_file_upload(@fixture_path + '/big_eye_tiny.jpg','image/jpeg'),:width => 200,:height=>197 }
@image = ImageUpload.new(@attr)
ActsAsPhocodable.storeage_mode = "local"
ActsAsPhocodable.processing_mode = "automatic"
end
@@ -27,11 +28,11 @@
end
end
describe "phocoder_link" do
before(:each) do
- @attr = { :file => fixture_file_upload(fixture_path + '/big_eye_tiny.jpg','image/jpeg') }
+ @attr = { :file => fixture_file_upload(@fixture_path + '/big_eye_tiny.jpg','image/jpeg') }
@image = ImageUpload.new(@attr)
end
it "should return raw text if the file is not ready" do
@image.encodable_status = "phocoding"
helper.phocoder_link("my link",@image).should == "my link"
@@ -52,11 +53,11 @@
vid = ImageUpload.new(:content_type=>'video/quicktime',:zencoder_status=>'s3',:id=>1,:filename=>"test.mov")
helper.should_receive(:phocoder_video_thumbnail).and_return(nil)
helper.phocoder_thumbnail(vid)
end
it "should delegate to phocoder_image_thumbnail for images" do
- img = ImageUpload.new({ :file => fixture_file_upload(fixture_path + '/big_eye_tiny.jpg','image/jpeg') })
+ img = ImageUpload.new({ :file => fixture_file_upload(@fixture_path + '/big_eye_tiny.jpg','image/jpeg') })
helper.should_receive(:phocoder_image_thumbnail).and_return(nil)
helper.phocoder_thumbnail(img)
end
it "should return an error div for elements that arent' video or image" do
obj = ImageUpload.new(:content_type=>'text/plain')
@@ -165,11 +166,11 @@
end
end #describe "when no thumbnail is passed" do
describe "when a thumbnail is passed" do
it "should return an img tag for a thumbnail that can be resolved by label and is ready" do
ActsAsPhocodable.storeage_mode = "local"
- @tattr = { :file => fixture_file_upload(fixture_path + '/big_eye_tiny.jpg','image/jpeg'), :width => 100, :height => 100 }
+ @tattr = { :file => fixture_file_upload(@fixture_path + '/big_eye_tiny.jpg','image/jpeg'), :width => 100, :height => 100 }
@thumb = ImageUpload.new(@tattr)
@thumb.filename = "big_eye_tiny_small.jpg"
@thumb.encodable_status = @image.encodable_status = "ready"
helper.should_receive(:find_or_create_thumbnail).and_return(@thumb)
output = helper.phocoder_image_online(@image,"small",{})
@@ -186,11 +187,11 @@
output.should match /waiting\.gif/ # the path in the thumbnail
end
it "should call pending_phcoder_thumbnail if the thumb is not ready" do
ActsAsPhocodable.storeage_mode = "local"
- @tattr = { :file => fixture_file_upload(fixture_path + '/big_eye_tiny.jpg','image/jpeg'), :width => 100, :height => 100 }
+ @tattr = { :file => fixture_file_upload(@fixture_path + '/big_eye_tiny.jpg','image/jpeg'), :width => 100, :height => 100 }
@thumb = ImageUpload.new(@tattr)
@thumb.filename = "big_eye_tiny_small.jpg"
@thumb.encodable_status = "phocoding"
@image.encodable_status = "ready"
helper.should_receive(:find_or_create_thumbnail).and_return(@thumb)
@@ -274,11 +275,11 @@
#
# end
#
# it "if the thumbnail is not ready, should call pending_phocoder_thumbnail" do
# ActsAsPhocodable.storeage_mode = "local"
-# @tattr = { :file => fixture_file_upload(fixture_path + '/big_eye_tiny.jpg','image/jpeg'), :width => 100, :height => 100 }
+# @tattr = { :file => fixture_file_upload(@fixture_path + '/big_eye_tiny.jpg','image/jpeg'), :width => 100, :height => 100 }
# @thumb = ImageUpload.new(@tattr)
# @thumb.filename = "big_eye_tiny_thumbnail.jpg"
# @thumb.encodable_status = "phocoding"
# helper.should_receive(:pending_phocoder_thumbnail).and_return(nil)
# helper.display_image_thumbnail(@image,@thumb,{})
@@ -290,11 +291,11 @@
# end
# end
# describe "offline_phocoder_image_thumbnail" do
# it "should render a thumbnail with the path to the original but the dimensions of the thumbnail" do
-# @tattr = { :file => fixture_file_upload(fixture_path + '/big_eye_tiny.jpg','image/jpeg'),:filename=>"big_eye_tiny_thumbnail.jpg", :width => 100, :height => 100 }
+# @tattr = { :file => fixture_file_upload(@fixture_path + '/big_eye_tiny.jpg','image/jpeg'),:filename=>"big_eye_tiny_thumbnail.jpg", :width => 100, :height => 100 }
# @thumb = ImageUpload.new(@tattr)
# @thumb.filename = "big_eye_tiny_thumbnail.jpg"
# output = helper.offline_phocoder_image_thumbnail(@image,@thumb,{})
# output.should match /<img/
# output.should match /width="100"/
@@ -302,11 +303,11 @@
# end
# end
describe "pending_phocoder_thumbnail" do
it "should return an image tag that points to a waiting image with the dimensions of the thumbnail" do
- @tattr = { :file => fixture_file_upload(fixture_path + '/big_eye_tiny.jpg','image/jpeg'), :width => 100, :height => 100 }
+ @tattr = { :file => fixture_file_upload(@fixture_path + '/big_eye_tiny.jpg','image/jpeg'), :width => 100, :height => 100 }
@thumb = ImageUpload.new(@tattr)
@thumb.filename = "big_eye_tiny_thumbnail.jpg"
output = helper.pending_phocoder_thumbnail(@image,@thumb,{})
output.should match /<img/
output.should match /width="100"/
@@ -370,10 +371,10 @@
describe "video preview functions" do
# before(:each) do
# @vid_attr = {
-# :file => fixture_file_upload(fixture_path + '/video-test.mov', 'video/quicktime')
+# :file => fixture_file_upload(@fixture_path + '/video-test.mov', 'video/quicktime')
# }
# Zencoder::Job.stub!(:create).and_return(mock(Zencoder::Response,:body=>{
# "id"=>1,
# "inputs"=>["id"=>1],
# "outputs"=>[{"label"=>"small","url"=>"http://someurl/","filename"=>"small-test-file.mp4","id"=>1}]