Browse Source

HUE-806 [fb] Rename operation should only propose the basename of the file

Changed to file.name instead of file.path
Added test for path rename and smart rename
Enrico Berti 13 years ago
parent
commit
c37ce00912

+ 1 - 1
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -652,7 +652,7 @@ from django.utils.translation import ugettext as _
             self.renameFile = function () {
                 $("#renameSrcPath").attr("value", self.selectedFile().path);
                 $("#renameFileName").text(self.selectedFile().path);
-                $("#newNameInput").val(self.selectedFile().path);
+                $("#newNameInput").val(self.selectedFile().name);
                 $("#renameModal").modal({
                     keyboard:true,
                     show:true

+ 19 - 0
apps/filebrowser/src/filebrowser/views_test.py

@@ -197,6 +197,25 @@ def test_chown():
   response = c.get('/filebrowser/chown', dict(path=PATH, user='chown_test', group='chown_test'))
   assert_false('<option value="__other__"' in response.content)
 
+@attr('requires_hadoop')
+def test_rename():
+    cluster = pseudo_hdfs4.shared_cluster()
+
+    c = make_logged_in_client(cluster.superuser)
+    cluster.fs.setuser(cluster.superuser)
+
+    PREFIX = u"/test-rename/"
+    NAME = u"test-rename-before"
+    NEW_NAME = u"test-rename-after"
+    cluster.fs.mkdir(PREFIX + NAME)
+    op = "rename"
+    # test for full path rename
+    c.post("/filebrowser/rename", dict(src_path=PREFIX + NAME, dest_path=PREFIX + NEW_NAME))
+    assert_true(cluster.fs.exists(PREFIX + NEW_NAME))
+    # test for smart rename
+    c.post("/filebrowser/rename", dict(src_path=PREFIX + NAME, dest_path=NEW_NAME))
+    assert_true(cluster.fs.exists(PREFIX + NEW_NAME))
+
 @attr('requires_hadoop')
 def test_listdir():
   cluster = pseudo_hdfs4.shared_cluster()