Sha256: 893f9197bc60f96fae697ab441d78d1043f4f38500bb72ff2801bf46275b9ae5

Contents?: true

Size: 1.88 KB

Versions: 4

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

describe Hydra::Controller::UploadBehavior do

  it "should respond to datastream_id" do
    helper.should respond_to :datastream_id  ### API method, test that it's there to be overridden
  end

  describe "add_posted_blob_to_asset" do
    it "should set object title and label, relying on datastream_id to set dsId" do
      mock_file = mock("File")
      file_name = "Posted Filename.foo"
      helper.stub(:params).and_return( :Filedata=>[mock_file], :Filename=>file_name, "container_id"=>"hydrangea:2973" )      
      mock_fa = mock("file asset")
      mock_file.should_receive(:original_filename).and_return(file_name)
      helper.stub(:datastream_id).and_return('bar')
      mock_fa.should_receive(:add_file).with(mock_file, 'bar', file_name)
      helper.add_posted_blob_to_asset(mock_fa,mock_file) # this is the deprecated 2 argument method
    end
    
    it "should support submissions from swfupload" do
      mock_file = mock("File")
      file_name = "Posted Filename.foo"
      helper.stub(:params).and_return( :Filedata=>[mock_file], :Filename=>file_name, "container_id"=>"hydrangea:2973" )      
      mock_fa = mock("file asset")
      mock_file.should_receive(:original_filename).and_return(file_name)
      mock_fa.should_receive(:add_file).with(mock_file, 'content', file_name)
      helper.add_posted_blob_to_asset(mock_fa,mock_file)
    end
    it "should support submissions from single-file uploader, defaulting to dsId of content" do
      mock_file = mock("File")
      file_name = "Posted Filename.foo"
      helper.stub(:params).and_return( :Filedata=>[mock_file], :container_id=>"hydrangea:2973" )      
      mock_file.should_receive(:original_filename).and_return(file_name)
      mock_fa = mock("file asset")
      mock_fa.should_receive(:add_file).with(mock_file, 'content', file_name)
      helper.add_posted_blob_to_asset(mock_fa,mock_file)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hydra-core-5.4.1 spec/helpers/upload_behavior_spec.rb
hydra-core-5.4.0 spec/helpers/upload_behavior_spec.rb
hydra-core-5.4.0.pre1 spec/helpers/upload_behavior_spec.rb
hydra-core-5.3.0 spec/helpers/upload_behavior_spec.rb