-
-
Save allanchaplin/126478 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 = [] | |
user_files = [] | |
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) | |
to_move << user_file.id | |
user_files << user_file | |
end | |
user_files.each do |user_file| | |
UserFile.stub!(:find).with(user_file.id).and_return(user_file) | |
end | |
@owner.should_receive(:can_access_folder?).any_number_of_times.and_return(true) | |
UserFile.move_files_to(to_move, dest_folder.id).should be_true | |
user_files.each do |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