Do not display projects without DMSF available

This commit is contained in:
karel.picman@lbcfree.net 2020-10-06 16:00:32 +02:00
parent 7f93a95743
commit 3425654869
3 changed files with 16 additions and 3 deletions

View File

@ -207,9 +207,22 @@ module RedmineDmsf
def load_projects(project_scope)
project_scope.visible.find_each do |p|
if dmsf_available?(p)
@children << child_project(p)
end
end
end
private
# Go recursively through the project tree until a dmsf enabled project is found
def dmsf_available?(p)
return true if(p.visible? && p.module_enabled?(:dmsf))
p.children.each do |child|
return true if dmsf_available?(child)
end
false
end
end
end

View File

@ -71,7 +71,7 @@ module RedmineDmsf
end
def etag
sprintf '%x-%x-%x', 0, 4096, last_modified.to_i
sprintf '%x-%x-%x', 0, 4096, (last_modified ? last_modified.to_i : 0)
end
def name

View File

@ -61,11 +61,11 @@ class DmsfWebdavGetTest < RedmineDmsf::Test::IntegrationTest
assert_match project1_uri, response.body
end
def test_should_list_non_dmsf_enabled_project
def test_should_not_list_non_dmsf_enabled_project
@project2.disable_module! :dmsf
get '/dmsf/webdav', params: nil, headers: @jsmith
assert_response :success
assert response.body.match(@project2.identifier)
assert !response.body.match(@project2.identifier)
end
def test_should_return_status_404_when_project_does_not_exist