Skip to content

Commit

Permalink
Make sure there is a server id before trying to delete a remote file.
Browse files Browse the repository at this point in the history
Fixed upload test.
  • Loading branch information
Doug Youch committed Jun 21, 2010
1 parent add30cd commit 057dffc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/models/domain_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def update_file_path #:nodoc:
# Convenience Methods
###########

# Returns the root folder of the filte system
# Returns the root folder of the file system
def self.root_folder
DomainFile.find(:first,:conditions => 'parent_id is NULL') || DomainFile.create(:name => '',:file_type => 'fld')
end
Expand Down Expand Up @@ -1016,7 +1016,7 @@ def copy_local!(dest_size=nil)
def copy_remote!; true; end

def destroy_remote!;
if @df.server_hash && ! @df.folder?
if @df.server_hash && ! @df.folder? && Server.server_id
key = self.class.set_directories_to_delete(@df.storage_directory)
url = "/website/transmit_file/delete/#{DomainModel.active_domain_id}/#{key}"
Server.send_to_all url, :except => [Server.server_id]
Expand Down
22 changes: 9 additions & 13 deletions spec/controllers/file_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,16 @@ def generate_workling(upload_key, file_processor)
end

it "should be able to upload a file" do
workerArgs = {
:filename => '/tmp/system_domains.gif',
:domain_id => DomainModel.active_domain_id,
:parent_id => @subfolder.id,
:creator_id => @myself.id,
:tmp_dir => '/tmp',
:extract_archive => false,
:replace_same => false
}

fdata = fixture_file_upload("files/system_domains.gif",'image/gif')
DomainFile.should_receive(:generate_temporary_directory).once.and_return('/tmp')
FileWorker.should_receive(:async_do_work).once.with(workerArgs).and_return('my_upload_key')
post 'upload', :upload_file => {:filename => fdata, :parent_id => @subfolder.id}, :extract_archive => false, :replace_same => false
FileWorker.should_receive(:async_do_work).once.and_return('my_upload_key')

assert_difference 'DomainFile.count', 1 do
post 'upload', :upload_file => {:filename => fdata, :parent_id => @subfolder.id}, :extract_archive => false, :replace_same => false
end

@df = DomainFile.find :last
File.exists?(@df.filename).should be_true
(@df.filename =~ /system_domains.gif$/).should be_true
end

it "should responded to progress" do
Expand Down

0 comments on commit 057dffc

Please sign in to comment.