Skip to content

Commit 4f91699

Browse files
authored
Merge pull request #472 from OSC/fix_file_favorites_urls
fix file favorite urls
2 parents 576f2bf + 4179c74 commit 4f91699

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

apps/dashboard/app/apps/ood_app.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def links
7777
title: favorite_path.title || favorite_path.path.to_s,
7878
subtitle: favorite_path.title ? favorite_path.path.to_s : nil,
7979
description: manifest.description,
80-
url: OodAppkit::Urls::Files.new(base_url: url).url(path: path),
80+
url: OodAppkit::Urls::Files.new(base_url: url).url(path: favorite_path.path.to_s),
8181
icon_uri: "fas://folder",
8282
caption: caption,
8383
new_tab: true

apps/dashboard/test/controllers/dashboard_controller_test.rb

+21-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ def dropdown_list_items(list)
2828
end
2929
end
3030

31+
# given a dropdown list, return the list items as an array of URL strings
32+
def dropdown_list_items_urls(list)
33+
css_select(list, "a").map do |item|
34+
item.attributes['href'].try(:value) || ""
35+
end
36+
end
37+
38+
3139
test "should create Jobs dropdown" do
3240
get :index
3341

@@ -37,10 +45,10 @@ def dropdown_list_items(list)
3745
end
3846

3947
test "should create Files dropdown" do
40-
scratch_path = "test/fixtures/dummy_fs/scratch"
41-
project_path = "test/fixtures/dummy_fs/project"
42-
project_path2 = Pathname.new("test/fixtures/dummy_fs/project2")
43-
missing_path = "test/fixtures/dummy_fs/missing"
48+
scratch_path = File.expand_path "test/fixtures/dummy_fs/scratch"
49+
project_path = File.expand_path "test/fixtures/dummy_fs/project"
50+
project_path2 = Pathname.new("test/fixtures/dummy_fs/project2").expand_path
51+
missing_path = "/test/fixtures/dummy_fs/missing"
4452
OodFilesApp.stubs(:candidate_favorite_paths).returns([FavoritePath.new(scratch_path, title: "Scratch"), project_path, project_path2, missing_path])
4553

4654
get :index
@@ -52,7 +60,15 @@ def dropdown_list_items(list)
5260
"Scratch #{scratch_path}",
5361
project_path,
5462
project_path2.to_s
55-
], dditems.map { |e| e.gsub(/\s+/, ' ') }
63+
], dditems.map { |e| e.gsub(/\s+/, ' ') }, "Files dropdown item text is incorrect"
64+
65+
dditemurls = dropdown_list_items_urls(dropdown_list('Files'))
66+
assert_equal [
67+
"/pun/sys/files/fs" + Dir.home,
68+
"/pun/sys/files/fs" + scratch_path,
69+
"/pun/sys/files/fs" + project_path,
70+
"/pun/sys/files/fs" + project_path2.to_s
71+
], dditemurls, "Files dropdown URLs are incorrect"
5672
end
5773

5874
test "should create Clusters dropdown with valid clusters that are alphabetically ordered by title" do

0 commit comments

Comments
 (0)