#1080 Context menu tests
This commit is contained in:
parent
d78ed890d7
commit
7d006044f3
@ -31,15 +31,15 @@ class DmsfContextMenusController < ApplicationController
|
|||||||
def dmsf
|
def dmsf
|
||||||
if @dmsf_file
|
if @dmsf_file
|
||||||
@locked = @dmsf_file.locked?
|
@locked = @dmsf_file.locked?
|
||||||
@unlockable = @dmsf_file.unlockable? && (!@dmsf_file.locked_for_user? ||
|
|
||||||
User.current.allowed_to?(:force_file_unlock, @project))
|
|
||||||
@allowed = User.current.allowed_to? :file_manipulation, @project
|
@allowed = User.current.allowed_to? :file_manipulation, @project
|
||||||
|
@unlockable = @allowed && @dmsf_file.unlockable? && (!@dmsf_file.locked_for_user? ||
|
||||||
|
User.current.allowed_to?(:force_file_unlock, @project))
|
||||||
@email_allowed = User.current.allowed_to?(:email_documents, @project)
|
@email_allowed = User.current.allowed_to?(:email_documents, @project)
|
||||||
elsif @dmsf_folder
|
elsif @dmsf_folder
|
||||||
@locked = @dmsf_folder.locked?
|
@locked = @dmsf_folder.locked?
|
||||||
@unlockable = @dmsf_folder.unlockable? && (!@dmsf_folder.locked_for_user?) &&
|
|
||||||
User.current.allowed_to?(:force_file_unlock, @project)
|
|
||||||
@allowed = User.current.allowed_to?(:folder_manipulation, @project)
|
@allowed = User.current.allowed_to?(:folder_manipulation, @project)
|
||||||
|
@unlockable = @allowed && @dmsf_folder.unlockable? && (!@dmsf_folder.locked_for_user?) &&
|
||||||
|
User.current.allowed_to?(:force_file_unlock, @project)
|
||||||
@email_allowed = User.current.allowed_to?(:email_documents, @project)
|
@email_allowed = User.current.allowed_to?(:email_documents, @project)
|
||||||
elsif @dmsf_link
|
elsif @dmsf_link
|
||||||
@allowed = User.current.allowed_to? :file_manipulation, @project
|
@allowed = User.current.allowed_to? :file_manipulation, @project
|
||||||
|
|||||||
@ -58,6 +58,9 @@ class DmsfUploadController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if @uploads.empty?
|
||||||
|
flash.now[:error] = l(:label_attachment) + ' ' + l('activerecord.errors.messages.invalid')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# async single file upload handling
|
# async single file upload handling
|
||||||
|
|||||||
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
<% html_title l(:dmsf) %>
|
<% html_title l(:dmsf) %>
|
||||||
|
|
||||||
<%= render(:partial => '/dmsf/path',
|
<%= render(partial: '/dmsf/path',
|
||||||
:locals => {:folder => @folder, :filename => nil, :title => l(:heading_uploaded_files)}) %>
|
locals: { folder: @folder, filename: nil, title: l(:heading_uploaded_files) }) %>
|
||||||
|
|
||||||
<% if (@folder && @folder.description.present?) || @project.dmsf_description.present? %>
|
<% if (@folder && @folder.description.present?) || @project.dmsf_description.present? %>
|
||||||
<div class="wiki">
|
<div class="wiki">
|
||||||
@ -33,16 +33,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= form_tag({:action => 'commit_files', :id => @project, :folder_id => @folder},
|
<% unless@uploads.empty? %>
|
||||||
:method => :post) do %>
|
<%= form_tag({ action: 'commit_files', id: @project, folder_id: @folder },
|
||||||
<% @uploads.each_with_index do |upload, i| %>
|
method: :post) do %>
|
||||||
<% if upload.locked %>
|
<% @uploads.each_with_index do |upload, i| %>
|
||||||
<%= render(:partial => 'upload_file_locked', :locals => {:upload => upload, :i => i}) %>
|
<% if upload.locked %>
|
||||||
<% else %>
|
<%= render(partial: 'upload_file_locked', locals: { upload: upload, i: i }) %>
|
||||||
<%= render(:partial => 'upload_file', :locals => {:upload => upload, :i => i}) %>
|
<% else %>
|
||||||
|
<%= render(partial: 'upload_file', locals: { upload: upload, i: i }) %>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<div class="form-actions">
|
||||||
|
<%= submit_tag l(:submit_commit), class: 'button-positive' %>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="form-actions">
|
|
||||||
<%= submit_tag l(:submit_commit), :class => 'button-positive' %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -86,7 +86,7 @@ module RedmineDmsf
|
|||||||
|
|
||||||
def child_project(p)
|
def child_project(p)
|
||||||
project_display_name = ProjectResource.create_project_name(p)
|
project_display_name = ProjectResource.create_project_name(p)
|
||||||
new_path = +@path
|
new_path = @path
|
||||||
new_path = new_path + '/' unless new_path[-1,1] == '/'
|
new_path = new_path + '/' unless new_path[-1,1] == '/'
|
||||||
new_path = '/' + new_path unless new_path[0,1] == '/'
|
new_path = '/' + new_path unless new_path[0,1] == '/'
|
||||||
new_path += project_display_name
|
new_path += project_display_name
|
||||||
|
|||||||
@ -57,20 +57,7 @@ module RedmineDmsf
|
|||||||
# If the URL map generated by Rack::Builder did not find a matching path,
|
# If the URL map generated by Rack::Builder did not find a matching path,
|
||||||
# it will return a 404 along with the X-Cascade header set to 'pass'.
|
# it will return a 404 along with the X-Cascade header set to 'pass'.
|
||||||
if (status == 404) && (headers['X-Cascade'] == 'pass')
|
if (status == 404) && (headers['X-Cascade'] == 'pass')
|
||||||
# The MS web redirector webdav client likes to go up a level and try
|
@rails_app.call env # Let Rails handle the request
|
||||||
# OPTIONS and PROPFIND there. We catch that here and respond telling it that just
|
|
||||||
# plain HTTP is going on.
|
|
||||||
if %w(/ /dmsf).include?(env['PATH_INFO'])
|
|
||||||
if 'OPTIONS'.casecmp(env['REQUEST_METHOD']) == 0
|
|
||||||
[ '200', { 'Allow' => 'OPTIONS,HEAD,GET,PUT,POST,DELETE' }, [''] ]
|
|
||||||
elsif 'PROPFIND'.casecmp(env['REQUEST_METHOD']) == 0
|
|
||||||
[ '404', {}, [''] ]
|
|
||||||
else
|
|
||||||
@rails_app.call env # let Rails handle the request
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@rails_app.call env # let Rails handle the request
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
[status, headers, body]
|
[status, headers, body]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -71,15 +71,14 @@ module RedmineDmsf
|
|||||||
|
|
||||||
# Is this entity a folder?
|
# Is this entity a folder?
|
||||||
def collection?
|
def collection?
|
||||||
folder.present? # No need to check if entity exists, as false is returned if entity does not exist anyways
|
!folder.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if current entity is a folder and return DmsfFolder object if found (nil if not)
|
# Check if current entity is a folder and return DmsfFolder object if found (nil if not)
|
||||||
def folder
|
def folder
|
||||||
unless @folder
|
unless @folder
|
||||||
return nil unless project
|
@folder = DmsfFolder.visible.where(project_id: project.id, title: basename,
|
||||||
@folder = DmsfFolder.visible.where(:project_id => project.id, :title => basename,
|
dmsf_folder_id: parent.folder ? parent.folder.id : nil).first if project
|
||||||
:dmsf_folder_id => parent.folder ? parent.folder.id : nil).first
|
|
||||||
end
|
end
|
||||||
@folder
|
@folder
|
||||||
end
|
end
|
||||||
|
|||||||
@ -46,15 +46,11 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
|
|
||||||
def exist?
|
def exist?
|
||||||
return false if (project.nil? || User.current.anonymous?)
|
really_exist? && User.current.allowed_to?(:view_dmsf_folders, project)
|
||||||
return false unless project.module_enabled?('dmsf')
|
|
||||||
User.current.admin? || User.current.allowed_to?(:view_dmsf_folders, project)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def really_exist?
|
def really_exist?
|
||||||
return false if project.nil?
|
project && project.module_enabled?('dmsf')
|
||||||
return false unless project.module_enabled?('dmsf')
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def collection?
|
def collection?
|
||||||
@ -62,11 +58,11 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
|
|
||||||
def creation_date
|
def creation_date
|
||||||
project.created_on unless project.nil?
|
project.created_on if project
|
||||||
end
|
end
|
||||||
|
|
||||||
def last_modified
|
def last_modified
|
||||||
project.updated_on unless project.nil?
|
project.updated_on if project
|
||||||
end
|
end
|
||||||
|
|
||||||
def etag
|
def etag
|
||||||
@ -78,7 +74,7 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
|
|
||||||
def long_name
|
def long_name
|
||||||
project.name unless project.nil?
|
project.name if project
|
||||||
end
|
end
|
||||||
|
|
||||||
def content_type
|
def content_type
|
||||||
|
|||||||
14
test/fixtures/dmsf_links.yml
vendored
14
test/fixtures/dmsf_links.yml
vendored
@ -54,7 +54,6 @@ file_link2:
|
|||||||
url_link:
|
url_link:
|
||||||
id: 5
|
id: 5
|
||||||
target_project_id: 1
|
target_project_id: 1
|
||||||
target_id: 4
|
|
||||||
target_type: DmsfUrl
|
target_type: DmsfUrl
|
||||||
name: url_link
|
name: url_link
|
||||||
project_id: 1
|
project_id: 1
|
||||||
@ -62,4 +61,17 @@ url_link:
|
|||||||
deleted: 0
|
deleted: 0
|
||||||
deleted_by_user_id: NULL
|
deleted_by_user_id: NULL
|
||||||
created_at: <%= DateTime.current %>
|
created_at: <%= DateTime.current %>
|
||||||
|
updated_at: <%= DateTime.current %>
|
||||||
|
|
||||||
|
file_link3:
|
||||||
|
id: 6
|
||||||
|
target_project_id: 1
|
||||||
|
target_id: 1
|
||||||
|
target_type: DmsfFile
|
||||||
|
name: file1_link
|
||||||
|
project_id: 1
|
||||||
|
dmsf_folder_id: NULL
|
||||||
|
deleted: 0
|
||||||
|
deleted_by_user_id: NULL
|
||||||
|
created_at: <%= DateTime.current %>
|
||||||
updated_at: <%= DateTime.current %>
|
updated_at: <%= DateTime.current %>
|
||||||
@ -36,6 +36,7 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
@folder1 = DmsfFolder.find 1
|
@folder1 = DmsfFolder.find 1
|
||||||
@folder5 = DmsfFolder.find 5
|
@folder5 = DmsfFolder.find 5
|
||||||
@file_link2 = DmsfLink.find 2
|
@file_link2 = DmsfLink.find 2
|
||||||
|
@file_link6 = DmsfLink.find 6
|
||||||
@folder_link1 = DmsfLink.find 1
|
@folder_link1 = DmsfLink.find 1
|
||||||
@url_link5 = DmsfLink.find 5
|
@url_link5 = DmsfLink.find 5
|
||||||
User.current = nil
|
User.current = nil
|
||||||
@ -51,6 +52,7 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
assert_kind_of DmsfFolder, @folder1
|
assert_kind_of DmsfFolder, @folder1
|
||||||
assert_kind_of DmsfFolder, @folder5
|
assert_kind_of DmsfFolder, @folder5
|
||||||
assert_kind_of DmsfLink, @file_link2
|
assert_kind_of DmsfLink, @file_link2
|
||||||
|
assert_kind_of DmsfLink, @file_link6
|
||||||
assert_kind_of DmsfLink, @folder_link1
|
assert_kind_of DmsfLink, @folder_link1
|
||||||
assert_kind_of DmsfLink, @url_link5
|
assert_kind_of DmsfLink, @url_link5
|
||||||
assert_kind_of Role, @role1
|
assert_kind_of Role, @role1
|
||||||
@ -160,7 +162,7 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
|
|
||||||
def test_dmsf_file_link
|
def test_dmsf_file_link
|
||||||
get :dmsf, params: {
|
get :dmsf, params: {
|
||||||
id: @file_link2.project.id, folder_id: @file_link2.dmsf_folder.id, ids: ["file-link-#{@file_link2.id}"] }
|
id: @file_link6.project.id, folder_id: @file_link6.dmsf_folder, ids: ["file-link-#{@file_link6.id}"] }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'a.icon-edit', text: l(:button_edit)
|
assert_select 'a.icon-edit', text: l(:button_edit)
|
||||||
assert_select 'a.icon-lock', text: l(:button_lock)
|
assert_select 'a.icon-lock', text: l(:button_lock)
|
||||||
@ -172,7 +174,7 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_dmsf_file_link_locked
|
def test_dmsf_file_link_locked
|
||||||
@file_link2.target_file.lock!
|
assert @file_link2.target_file.locked?
|
||||||
get :dmsf, params: {
|
get :dmsf, params: {
|
||||||
id: @file_link2.project.id, folder_id: @file_link2.dmsf_folder.id, ids: ["file-link-#{@file_link2.id}"] }
|
id: @file_link2.project.id, folder_id: @file_link2.dmsf_folder.id, ids: ["file-link-#{@file_link2.id}"] }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -190,7 +192,7 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_dmsf_folder
|
def test_dmsf_folder
|
||||||
get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] }
|
get :dmsf, params: { id: @folder1.project.id, ids: ["folder-#{@folder1.id}"] }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'a.icon-edit', text: l(:button_edit)
|
assert_select 'a.icon-edit', text: l(:button_edit)
|
||||||
assert_select 'a.icon-lock', text: l(:button_lock)
|
assert_select 'a.icon-lock', text: l(:button_lock)
|
||||||
@ -208,7 +210,7 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_dmsf_folder_locked
|
def test_dmsf_folder_locked
|
||||||
@folder5.lock!
|
assert @folder5.locked?
|
||||||
get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] }
|
get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'a.icon-edit.disabled', text: l(:button_edit)
|
assert_select 'a.icon-edit.disabled', text: l(:button_edit)
|
||||||
@ -228,7 +230,7 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
|
|
||||||
def test_dmsf_folder_manipulation_permmissions_off
|
def test_dmsf_folder_manipulation_permmissions_off
|
||||||
@role1.remove_permission! :folder_manipulation
|
@role1.remove_permission! :folder_manipulation
|
||||||
get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] }
|
get :dmsf, params: { id: @folder1.project.id, ids: ["folder-#{@folder1.id}"] }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'a.icon-edit.disabled', text: l(:button_edit)
|
assert_select 'a.icon-edit.disabled', text: l(:button_edit)
|
||||||
assert_select 'a.icon-lock.disabled', text: l(:button_lock)
|
assert_select 'a.icon-lock.disabled', text: l(:button_lock)
|
||||||
@ -238,7 +240,8 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
|
|
||||||
def test_dmsf_folder_manipulation_permmissions_on
|
def test_dmsf_folder_manipulation_permmissions_on
|
||||||
@role1.add_permission! :folder_manipulation
|
@role1.add_permission! :folder_manipulation
|
||||||
get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] }
|
#assert !@folder5.locked?
|
||||||
|
get :dmsf, params: { id: @folder1.project.id, ids: ["folder-#{@folder1.id}"] }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select 'a:not(icon-edit.disabled)', text: l(:button_edit)
|
assert_select 'a:not(icon-edit.disabled)', text: l(:button_edit)
|
||||||
assert_select 'a:not(icon-lock.disabled)', text: l(:button_lock)
|
assert_select 'a:not(icon-lock.disabled)', text: l(:button_lock)
|
||||||
|
|||||||
@ -118,7 +118,6 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest
|
|||||||
# </dmsf_file_revision>
|
# </dmsf_file_revision>
|
||||||
# </dmsf_file_revisions>
|
# </dmsf_file_revisions>
|
||||||
# </dmsf_file>
|
# </dmsf_file>
|
||||||
#puts response.body
|
|
||||||
assert_select 'dmsf_file > id', text: @file1.id.to_s
|
assert_select 'dmsf_file > id', text: @file1.id.to_s
|
||||||
assert_select 'dmsf_file > title', text: @file1.title
|
assert_select 'dmsf_file > title', text: @file1.title
|
||||||
assert_select 'dmsf_file > name', text: @file1.name
|
assert_select 'dmsf_file > name', text: @file1.name
|
||||||
|
|||||||
@ -34,12 +34,12 @@ class DmsfWebdavCustomMiddlewareTest < RedmineDmsf::Test::IntegrationTest
|
|||||||
|
|
||||||
def test_options_for_root_path
|
def test_options_for_root_path
|
||||||
process :options, '/'
|
process :options, '/'
|
||||||
assert_response :success
|
assert_response :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_options_for_dmsf_root_path
|
def test_options_for_dmsf_root_path
|
||||||
process :options, '/dmsf'
|
process :options, '/dmsf'
|
||||||
assert_response :success
|
assert_response :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_propfind_for_root_path
|
def test_propfind_for_root_path
|
||||||
|
|||||||
@ -81,7 +81,7 @@ class ProjectPatchTest < RedmineDmsf::Test::UnitTest
|
|||||||
def test_copy_dmsf
|
def test_copy_dmsf
|
||||||
assert_equal 4, @project1.dmsf_files.visible.all.size
|
assert_equal 4, @project1.dmsf_files.visible.all.size
|
||||||
assert_equal 4, @project1.dmsf_folders.visible.all.size
|
assert_equal 4, @project1.dmsf_folders.visible.all.size
|
||||||
assert_equal 1, @project1.file_links.visible.all.size
|
assert_equal 2, @project1.file_links.visible.all.size
|
||||||
assert_equal 1, @project1.folder_links.visible.all.size
|
assert_equal 1, @project1.folder_links.visible.all.size
|
||||||
assert_equal 1, @project1.url_links.visible.all.size
|
assert_equal 1, @project1.url_links.visible.all.size
|
||||||
assert_equal 0, @project3.dmsf_files.visible.all.size
|
assert_equal 0, @project3.dmsf_files.visible.all.size
|
||||||
@ -92,7 +92,7 @@ class ProjectPatchTest < RedmineDmsf::Test::UnitTest
|
|||||||
@project3.copy_dmsf(@project1)
|
@project3.copy_dmsf(@project1)
|
||||||
assert_equal 4, @project3.dmsf_files.visible.all.size
|
assert_equal 4, @project3.dmsf_files.visible.all.size
|
||||||
assert_equal 4, @project3.dmsf_folders.all.size
|
assert_equal 4, @project3.dmsf_folders.all.size
|
||||||
assert_equal 1, @project3.file_links.visible.all.size
|
assert_equal 2, @project3.file_links.visible.all.size
|
||||||
assert_equal 1, @project3.folder_links.visible.all.size
|
assert_equal 1, @project3.folder_links.visible.all.size
|
||||||
assert_equal 1, @project3.url_links.visible.all.size
|
assert_equal 1, @project3.url_links.visible.all.size
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user