Created
June 9, 2009 11:45
-
-
Save bigboxsoftware/126432 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "should move a list of file ids and destination folders" do | |
filebox = mock_model(Filebox) | |
folder = Folder.create!(:name => "origin_folder", :filebox => @filebox) | |
dest_folder = Folder.create!(:name => "destination_folder", :filebox => @filebox) | |
to_move = [] | |
test_files = ["test_data_1.txt", "test_data_2.txt", "test_data_3.txt"] | |
test_files.each do |test_file| | |
temp_file = mock("UploadedTempFile", :original_filename => test_file, | |
:read => "my file contents", | |
:local_path => File.join(REVISION_TEST_DATA, "set1", test_file), | |
:content_type => nil, | |
:instance_of? => true) | |
user_file = UserFile.add_uploaded_file(temp_file, @owner, folder) | |
user_file.stub!(:owner).and_return(@owner) | |
UserFile.stub!(:find).with(user_file.id).and_return(user_file) | |
to_move << user_file.id | |
end | |
#User.stub!(:owner).and_return(@owner) | |
@owner.should_receive(:can_access_folder?).and_return(false) | |
UserFile.move_files_to(to_move, dest_folder.id).should be_true | |
to_move.each do |id| | |
uf = UserFile.find(id) | |
folder.user_files.should_not include(uf) | |
uf.folder == dest_folder.name | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment