Skip to content

Commit 19e6989

Browse files
committed
add check for unwritable directories
1 parent 5245ac6 commit 19e6989

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

apps/dashboard/test/system/project_manager_test.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,14 @@ def check_directory_breakpoints
425425
Dir.mktmpdir do |dir|
426426
# setup directory
427427
project_id = setup_project(dir)
428-
project_dir = "#{dir}/projects/#{project_id}"
428+
project_dir = "#{dir}/projects/#{project_id}"
429429
`mkdir #{project_dir}/unreadable`
430+
`mkdir #{project_dir}/unwritable`
430431
`echo 'sample' > #{project_dir}/data.json`
431432
`echo '#Title' > #{project_dir}/README.md`
432433

433434
File.chmod(0o100, "#{project_dir}/unreadable", "#{project_dir}/data.json")
434-
File.chmod(0o500, "#{project_dir}/README.md")
435+
File.chmod(0o500, "#{project_dir}/unwritable", "#{project_dir}/README.md")
435436

436437
visit project_path(project_id)
437438

@@ -446,10 +447,10 @@ def check_directory_breakpoints
446447
assert_equal 7, all("#{tframe_selector} th").length
447448

448449
rows = all("#{tframe_selector} tbody tr")
449-
assert_equal 7, rows.length
450+
assert_equal 8, rows.length
450451

451452
# set baseline for readable and writable files
452-
writable_data = rows[3].all('td')
453+
writable_data = rows[4].all('td')
453454
check_link(writable_data[1].find('a'), 'my_cool_script.sh', files_path("#{project_dir}/my_cool_script.sh"))
454455

455456
actions_cell = writable_data[2]
@@ -469,7 +470,7 @@ def check_directory_breakpoints
469470
actions_cell.find('button[data-bs-toggle="dropdown"].show').click
470471

471472
# unwritable files don't show edit links
472-
unwritable_data = rows[6].all('td')
473+
unwritable_data = rows[7].all('td')
473474
check_link(unwritable_data[1].find('a'), 'README.md', files_path("#{project_dir}/README.md"))
474475

475476
unwritable_actions_cell = unwritable_data[2]
@@ -486,8 +487,12 @@ def check_directory_breakpoints
486487

487488
unwritable_actions_cell.find('button[data-bs-toggle="dropdown"].show').click
488489

490+
# unwritable directories still show navigational links
491+
unwritable_dir_link = rows[3].find('a')
492+
check_link(unwritable_dir_link, 'unwritable', directory_frame_path(path: "#{project_dir}/unwritable"))
493+
489494
# unreadable files and directories should not show any links
490-
{'unreadable' => rows[2], 'data.json' => rows[5]}.each do |name, row|
495+
{'unreadable' => rows[2], 'data.json' => rows[6]}.each do |name, row|
491496
unreadable_data = row.all('td')
492497
assert_equal 0, unreadable_data[1].all('a').length
493498
unreadable_data[1].assert_selector('span', text: name)

0 commit comments

Comments
 (0)