diff --git a/app/controllers/dmsf_context_menus_controller.rb b/app/controllers/dmsf_context_menus_controller.rb index 0ab88c81..5c2ff5a5 100644 --- a/app/controllers/dmsf_context_menus_controller.rb +++ b/app/controllers/dmsf_context_menus_controller.rb @@ -35,8 +35,6 @@ class DmsfContextMenusController < ApplicationController User.current.allowed_to?(:force_file_unlock, @project)) @allowed = User.current.allowed_to? :file_manipulation, @project @email_allowed = User.current.allowed_to?(:email_documents, @project) - Rails.logger.info ">>> #{User.current}" - Rails.logger.info ">>> #{@locked}, #{@unlockable}, #{@allowed}, #{@email_allowed}" elsif @dmsf_folder @locked = @dmsf_folder.locked? @unlockable = @dmsf_folder.unlockable? && (!@dmsf_folder.locked_for_user?) && diff --git a/test/functional/dmsf_context_menus_controller_test.rb b/test/functional/dmsf_context_menus_controller_test.rb index f99aa240..a215894a 100644 --- a/test/functional/dmsf_context_menus_controller_test.rb +++ b/test/functional/dmsf_context_menus_controller_test.rb @@ -29,7 +29,7 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase def setup @user_member = User.find 2 # John Smith - manager - @user_member3 = User.find 2 # Foo + @user_member3 = User.find 3 # Foo @project1 = Project.find 1 @project1.enable_module! :dmsf @file1 = DmsfFile.find 1 @@ -43,41 +43,41 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase @role1 = Role.find 1 # Manager end - # def test_truth - # assert_kind_of User, @user_member - # assert_kind_of User, @user_member3 - # assert_kind_of Project, @project1 - # assert_kind_of DmsfFile, @file1 - # assert_kind_of DmsfFolder, @folder1 - # assert_kind_of DmsfFolder, @folder5 - # assert_kind_of DmsfLink, @file_link2 - # assert_kind_of DmsfLink, @folder_link1 - # assert_kind_of DmsfLink, @url_link5 - # assert_kind_of Role, @role1 - # end - # - # def test_dmsf_file - # get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a.icon-edit', text: l(:button_edit) - # assert_select 'a.icon-lock', text: l(:button_lock) - # assert_select 'a.icon-email-add', text: l(:label_notifications_on) - # assert_select 'a.icon-del', text: l(:button_delete) - # assert_select 'a.icon-download', text: l(:button_download) - # assert_select 'a.icon-email', text: l(:field_mail) - # assert_select 'a.icon-file', text: l(:button_edit_content) - # end - # - # def test_dmsf_file_locked - # @file1.lock! - # get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a.icon-edit.disabled', text: l(:button_edit) - # assert_select 'a.icon-unlock', text: l(:button_unlock) - # assert_select 'a.icon-lock', text: l(:button_lock), count: 0 - # assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # end + def test_truth + assert_kind_of User, @user_member + assert_kind_of User, @user_member3 + assert_kind_of Project, @project1 + assert_kind_of DmsfFile, @file1 + assert_kind_of DmsfFolder, @folder1 + assert_kind_of DmsfFolder, @folder5 + assert_kind_of DmsfLink, @file_link2 + assert_kind_of DmsfLink, @folder_link1 + assert_kind_of DmsfLink, @url_link5 + assert_kind_of Role, @role1 + end + + def test_dmsf_file + get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a.icon-edit', text: l(:button_edit) + assert_select 'a.icon-lock', text: l(:button_lock) + assert_select 'a.icon-email-add', text: l(:label_notifications_on) + assert_select 'a.icon-del', text: l(:button_delete) + assert_select 'a.icon-download', text: l(:button_download) + assert_select 'a.icon-email', text: l(:field_mail) + assert_select 'a.icon-file', text: l(:button_edit_content) + end + + def test_dmsf_file_locked + @file1.lock! + get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a.icon-edit.disabled', text: l(:button_edit) + assert_select 'a.icon-unlock', text: l(:button_unlock) + assert_select 'a.icon-lock', text: l(:button_lock), count: 0 + assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) + assert_select 'a.icon-del.disabled', text: l(:button_delete) + end def test_dmsf_file_locked_force_unlock_permission_off l = @file1.lock! @@ -90,277 +90,276 @@ class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase assert_select 'a.icon-unlock.disabled', text: l(:button_unlock) end - # def test_dmsf_file_locked_force_unlock_permission_on - # l = @file1.lock! - # l.user = @user_member3 - # l.save - # @role1.add_permission! :force_file_unlock - # @role1.add_permission! :file_manipulation - # get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a:not(icon-unlock.disabled)', text: l(:button_unlock) - # assert_select 'a.icon-unlock.disabled', text: l(:button_unlock), count: 0 - # end + def test_dmsf_file_locked_force_unlock_permission_on + l = @file1.lock! + l.user = @user_member3 + l.save + @role1.add_permission! :force_file_unlock + @role1.add_permission! :file_manipulation + get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a.icon-unlock.disabled', text: l(:button_unlock), count: 0 + end - # def test_dmsf_file_notification_on - # @file1.notify_activate - # get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a.icon-email', text: l(:label_notifications_off) - # assert_select 'a.icon-email-add', text: l(:label_notifications_on), count: 0 - # end - # - # def test_dmsf_file_manipulation_permission_off - # @role1.remove_permission! :file_manipulation - # get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a.icon-edit.disabled', text: l(:button_edit) - # assert_select 'a.icon-lock.disabled', text: l(:button_lock) - # assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # end - # - # def test_dmsf_file_manipulation_permission_on - # @role1.add_permission! :file_manipulation - # get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # 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-email-add.disabled)', text: l(:label_notifications_on) - # assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) - # end - # - # def test_dmsf_file_email_permission_off - # @role1.remove_permission! :email_document - # get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a.icon-email.disabled', text: l(:field_mail) - # end - # - # def test_dmsf_file_email_permission_on - # @role1.remove_permission! :email_document - # get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a:not(icon-email.disabled)', text: l(:field_mail) - # end - # - # def test_dmsf_file_delete_permission_off - # @role1.remove_permission! :file_delete - # get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # end - # - # def test_dmsf_file_delete_permission_on - # @role1.remove_permission! :file_delete - # get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) - # assert_select 'a.icon-del', text: l(:button_delete) - # end - # - # def test_dmsf_file_link - # get :dmsf, params: { - # id: @file_link2.project.id, folder_id: @file_link2.dmsf_folder.id, ids: ["file-link-#{@file_link2.id}"] } - # assert_response :success - # assert_select 'a.icon-edit', text: l(:button_edit) - # assert_select 'a.icon-lock', text: l(:button_lock) - # assert_select 'a.icon-email-add', text: l(:label_notifications_on) - # assert_select 'a.icon-del', text: l(:button_delete) - # assert_select 'a.icon-download', text: l(:button_download) - # assert_select 'a.icon-email', text: l(:field_mail) - # assert_select 'a.icon-file', text: l(:button_edit_content) - # end - # - # def test_dmsf_file_link_locked - # @file_link2.target_file.lock! - # get :dmsf, params: { - # id: @file_link2.project.id, folder_id: @file_link2.dmsf_folder.id, ids: ["file-link-#{@file_link2.id}"] } - # assert_response :success - # assert_select 'a.icon-edit.disabled', text: l(:button_edit) - # assert_select 'a.icon-unlock', text: l(:button_unlock) - # assert_select 'a.icon-lock', text: l(:button_lock), count: 0 - # assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # end - # - # def test_dmsf_url_link - # get :dmsf, params: { id: @url_link5.project.id, ids: ["url-link-#{@url_link5.id}"] } - # assert_response :success - # assert_select 'a.icon-del', text: l(:button_delete) - # end - # - # def test_dmsf_folder - # get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } - # assert_response :success - # assert_select 'a.icon-edit', text: l(:button_edit) - # assert_select 'a.icon-lock', text: l(:button_lock) - # assert_select 'a.icon-email-add', text: l(:label_notifications_on) - # assert_select 'a.icon-del', text: l(:button_delete) - # assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) - # assert_select 'a.icon-download', text: l(:button_download) - # assert_select 'a.icon-email', text: l(:field_mail) - # end - # - # def test_dmsf_folder_not_empty - # get :dmsf, params: { id: @folder1.project.id, ids: ["folder-#{@folder1.id}"] } - # assert_response :success - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # end - # - # def test_dmsf_folder_locked - # @folder5.lock! - # get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } - # assert_response :success - # assert_select 'a.icon-edit.disabled', text: l(:button_edit) - # assert_select 'a.icon-unlock', text: l(:button_unlock) - # assert_select 'a.icon-lock', text: l(:button_lock), count: 0 - # assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # end - # - # def test_dmsf_folder_notification_on - # @folder5.notify_activate - # get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } - # assert_response :success - # assert_select 'a.icon-email', text: l(:label_notifications_off) - # assert_select 'a.icon-email-add', text: l(:label_notifications_on), count: 0 - # end - # - # def test_dmsf_folder_manipulation_permmissions_off - # @role1.remove_permission! :folder_manipulation - # get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } - # assert_response :success - # assert_select 'a.icon-edit.disabled', text: l(:button_edit) - # assert_select 'a.icon-lock.disabled', text: l(:button_lock) - # assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # end - # - # def test_dmsf_folder_manipulation_permmissions_on - # @role1.add_permission! :folder_manipulation - # get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } - # assert_response :success - # 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-email-add.disabled)', text: l(:label_notifications_on) - # assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) - # end - # - # def test_dmsf_folder_email_permmissions_off - # @role1.remove_permission! :email_documents - # get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } - # assert_response :success - # assert_select 'a.icon-email.disabled', text: l(:field_mail) - # end - # - # def test_dmsf_folder_email_permmissions_on - # @role1.add_permission! :email_documents - # get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } - # assert_response :success - # assert_select 'a:not(icon-email.disabled)', text: l(:field_mail) - # end - # - # def test_dmsf_folder_link - # get :dmsf, params: { id: @folder_link1.project.id, ids: ["folder-#{@folder_link1.id}"] } - # assert_response :success - # assert_select 'a.icon-edit', text: l(:button_edit) - # assert_select 'a.icon-lock', text: l(:button_lock) - # assert_select 'a.icon-email-add', text: l(:label_notifications_on) - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # assert_select 'a.icon-download', text: l(:button_download) - # assert_select 'a.icon-email', text: l(:field_mail) - # end - # - # def test_dmsf_folder_link_locked - # @folder_link1.target_folder.lock! - # get :dmsf, params: { id: @folder_link1.project.id, ids: ["folder-#{@folder_link1.id}"] } - # assert_response :success - # assert_select 'a.icon-edit.disabled', text: l(:button_edit) - # assert_select 'a.icon-unlock', text: l(:button_unlock) - # assert_select 'a.icon-lock', text: l(:button_lock), count: 0 - # assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # end - # - # def test_dmsf_multiple - # get :dmsf, params: { id: @project1.id, ids: ["folder-#{@folder1.id}", "file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a.icon-edit', text: l(:button_edit), count: 0 - # assert_select 'a.icon-unlock', text: l(:button_unlock), count: 0 - # assert_select 'a.icon-lock', text: l(:button_lock), count: 0 - # assert_select 'a.icon-email-add', text: l(:label_notifications_on), count: 0 - # assert_select 'a.icon-email', text: l(:label_notifications_off), count: 0 - # assert_select 'a.icon-del', text: l(:button_delete) - # assert_select 'a.icon-download', text: l(:button_download) - # assert_select 'a.icon-email', text: l(:field_mail) - # end - # - # def test_trash_file - # get :trash, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a.icon-cancel', text: l(:title_restore) - # assert_select 'a.icon-del', text: l(:button_delete) - # end - # - # def test_trash_file_manipulation_permissions_off - # @role1.remove_permission! :file_manipulation - # get :trash, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a.icon-cancel.disabled', text: l(:title_restore) - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # end - # - # def test_trash_file_manipulation_permissions_on - # @role1.add_permission! :file_manipulation - # get :trash, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a:not(icon-cancel.disabled)', text: l(:title_restore) - # assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) - # end - # - # def test_trash_file_delete_permissions_off - # @role1.remove_permission! :file_delete - # get :trash, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # end - # - # def test_trash_file_delete_permissions_on - # @role1.add_permission! :file_delete - # get :trash, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } - # assert_response :success - # assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) - # end - # - # def test_trash_folder - # get :trash, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } - # assert_response :success - # assert_select 'a.icon-cancel', text: l(:title_restore) - # assert_select 'a.icon-del', text: l(:button_delete) - # end - # - # def test_trash_folder_manipulation_permissions_off - # @role1.remove_permission! :folder_manipulation - # get :trash, params: { id: @folder1.project.id, ids: ["folder-#{@folder1.id}"] } - # assert_response :success - # assert_select 'a.icon-cancel.disabled', text: l(:title_restore) - # assert_select 'a.icon-del.disabled', text: l(:button_delete) - # end - # - # def test_trash_folder_manipulation_permissions_on - # @role1.add_permission! :folder_manipulation - # get :trash, params: { id: @folder1.project.id, ids: ["folder-#{@folder1.id}"] } - # assert_response :success - # assert_select 'a:not(icon-cancel.disabled)', text: l(:title_restore) - # assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) - # end - # - # def test_trash_multiple - # get :trash, params: { id: @project1.id, ids: ["file-#{@file1.id}", "folder-#{@folder1.id}"] } - # assert_response :success - # assert_select 'a.icon-cancel', text: l(:title_restore) - # assert_select 'a.icon-del', text: l(:button_delete) - # end + def test_dmsf_file_notification_on + @file1.notify_activate + get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a.icon-email', text: l(:label_notifications_off) + assert_select 'a.icon-email-add', text: l(:label_notifications_on), count: 0 + end + + def test_dmsf_file_manipulation_permission_off + @role1.remove_permission! :file_manipulation + get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a.icon-edit.disabled', text: l(:button_edit) + assert_select 'a.icon-lock.disabled', text: l(:button_lock) + assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) + assert_select 'a.icon-del.disabled', text: l(:button_delete) + end + + def test_dmsf_file_manipulation_permission_on + @role1.add_permission! :file_manipulation + get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + 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-email-add.disabled)', text: l(:label_notifications_on) + assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) + end + + def test_dmsf_file_email_permission_off + @role1.remove_permission! :email_document + get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a.icon-email.disabled', text: l(:field_mail) + end + + def test_dmsf_file_email_permission_on + @role1.remove_permission! :email_document + get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a:not(icon-email.disabled)', text: l(:field_mail) + end + + def test_dmsf_file_delete_permission_off + @role1.remove_permission! :file_delete + get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a.icon-del.disabled', text: l(:button_delete) + end + + def test_dmsf_file_delete_permission_on + @role1.remove_permission! :file_delete + get :dmsf, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) + assert_select 'a.icon-del', text: l(:button_delete) + end + + def test_dmsf_file_link + get :dmsf, params: { + id: @file_link2.project.id, folder_id: @file_link2.dmsf_folder.id, ids: ["file-link-#{@file_link2.id}"] } + assert_response :success + assert_select 'a.icon-edit', text: l(:button_edit) + assert_select 'a.icon-lock', text: l(:button_lock) + assert_select 'a.icon-email-add', text: l(:label_notifications_on) + assert_select 'a.icon-del', text: l(:button_delete) + assert_select 'a.icon-download', text: l(:button_download) + assert_select 'a.icon-email', text: l(:field_mail) + assert_select 'a.icon-file', text: l(:button_edit_content) + end + + def test_dmsf_file_link_locked + @file_link2.target_file.lock! + get :dmsf, params: { + id: @file_link2.project.id, folder_id: @file_link2.dmsf_folder.id, ids: ["file-link-#{@file_link2.id}"] } + assert_response :success + assert_select 'a.icon-edit.disabled', text: l(:button_edit) + assert_select 'a.icon-unlock', text: l(:button_unlock) + assert_select 'a.icon-lock', text: l(:button_lock), count: 0 + assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) + assert_select 'a.icon-del.disabled', text: l(:button_delete) + end + + def test_dmsf_url_link + get :dmsf, params: { id: @url_link5.project.id, ids: ["url-link-#{@url_link5.id}"] } + assert_response :success + assert_select 'a.icon-del', text: l(:button_delete) + end + + def test_dmsf_folder + get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } + assert_response :success + assert_select 'a.icon-edit', text: l(:button_edit) + assert_select 'a.icon-lock', text: l(:button_lock) + assert_select 'a.icon-email-add', text: l(:label_notifications_on) + assert_select 'a.icon-del', text: l(:button_delete) + assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) + assert_select 'a.icon-download', text: l(:button_download) + assert_select 'a.icon-email', text: l(:field_mail) + end + + def test_dmsf_folder_not_empty + get :dmsf, params: { id: @folder1.project.id, ids: ["folder-#{@folder1.id}"] } + assert_response :success + assert_select 'a.icon-del.disabled', text: l(:button_delete) + end + + def test_dmsf_folder_locked + @folder5.lock! + get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } + assert_response :success + assert_select 'a.icon-edit.disabled', text: l(:button_edit) + assert_select 'a.icon-unlock', text: l(:button_unlock) + assert_select 'a.icon-lock', text: l(:button_lock), count: 0 + assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) + assert_select 'a.icon-del.disabled', text: l(:button_delete) + end + + def test_dmsf_folder_notification_on + @folder5.notify_activate + get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } + assert_response :success + assert_select 'a.icon-email', text: l(:label_notifications_off) + assert_select 'a.icon-email-add', text: l(:label_notifications_on), count: 0 + end + + def test_dmsf_folder_manipulation_permmissions_off + @role1.remove_permission! :folder_manipulation + get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } + assert_response :success + assert_select 'a.icon-edit.disabled', text: l(:button_edit) + assert_select 'a.icon-lock.disabled', text: l(:button_lock) + assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) + assert_select 'a.icon-del.disabled', text: l(:button_delete) + end + + def test_dmsf_folder_manipulation_permmissions_on + @role1.add_permission! :folder_manipulation + get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } + assert_response :success + 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-email-add.disabled)', text: l(:label_notifications_on) + assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) + end + + def test_dmsf_folder_email_permmissions_off + @role1.remove_permission! :email_documents + get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } + assert_response :success + assert_select 'a.icon-email.disabled', text: l(:field_mail) + end + + def test_dmsf_folder_email_permmissions_on + @role1.add_permission! :email_documents + get :dmsf, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } + assert_response :success + assert_select 'a:not(icon-email.disabled)', text: l(:field_mail) + end + + def test_dmsf_folder_link + get :dmsf, params: { id: @folder_link1.project.id, ids: ["folder-#{@folder_link1.id}"] } + assert_response :success + assert_select 'a.icon-edit', text: l(:button_edit) + assert_select 'a.icon-lock', text: l(:button_lock) + assert_select 'a.icon-email-add', text: l(:label_notifications_on) + assert_select 'a.icon-del.disabled', text: l(:button_delete) + assert_select 'a.icon-download', text: l(:button_download) + assert_select 'a.icon-email', text: l(:field_mail) + end + + def test_dmsf_folder_link_locked + @folder_link1.target_folder.lock! + get :dmsf, params: { id: @folder_link1.project.id, ids: ["folder-#{@folder_link1.id}"] } + assert_response :success + assert_select 'a.icon-edit.disabled', text: l(:button_edit) + assert_select 'a.icon-unlock', text: l(:button_unlock) + assert_select 'a.icon-lock', text: l(:button_lock), count: 0 + assert_select 'a.icon-email-add.disabled', text: l(:label_notifications_on) + assert_select 'a.icon-del.disabled', text: l(:button_delete) + end + + def test_dmsf_multiple + get :dmsf, params: { id: @project1.id, ids: ["folder-#{@folder1.id}", "file-#{@file1.id}"] } + assert_response :success + assert_select 'a.icon-edit', text: l(:button_edit), count: 0 + assert_select 'a.icon-unlock', text: l(:button_unlock), count: 0 + assert_select 'a.icon-lock', text: l(:button_lock), count: 0 + assert_select 'a.icon-email-add', text: l(:label_notifications_on), count: 0 + assert_select 'a.icon-email', text: l(:label_notifications_off), count: 0 + assert_select 'a.icon-del', text: l(:button_delete) + assert_select 'a.icon-download', text: l(:button_download) + assert_select 'a.icon-email', text: l(:field_mail) + end + + def test_trash_file + get :trash, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a.icon-cancel', text: l(:title_restore) + assert_select 'a.icon-del', text: l(:button_delete) + end + + def test_trash_file_manipulation_permissions_off + @role1.remove_permission! :file_manipulation + get :trash, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a.icon-cancel.disabled', text: l(:title_restore) + assert_select 'a.icon-del.disabled', text: l(:button_delete) + end + + def test_trash_file_manipulation_permissions_on + @role1.add_permission! :file_manipulation + get :trash, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a:not(icon-cancel.disabled)', text: l(:title_restore) + assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) + end + + def test_trash_file_delete_permissions_off + @role1.remove_permission! :file_delete + get :trash, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a.icon-del.disabled', text: l(:button_delete) + end + + def test_trash_file_delete_permissions_on + @role1.add_permission! :file_delete + get :trash, params: { id: @file1.project.id, ids: ["file-#{@file1.id}"] } + assert_response :success + assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) + end + + def test_trash_folder + get :trash, params: { id: @folder5.project.id, ids: ["folder-#{@folder5.id}"] } + assert_response :success + assert_select 'a.icon-cancel', text: l(:title_restore) + assert_select 'a.icon-del', text: l(:button_delete) + end + + def test_trash_folder_manipulation_permissions_off + @role1.remove_permission! :folder_manipulation + get :trash, params: { id: @folder1.project.id, ids: ["folder-#{@folder1.id}"] } + assert_response :success + assert_select 'a.icon-cancel.disabled', text: l(:title_restore) + assert_select 'a.icon-del.disabled', text: l(:button_delete) + end + + def test_trash_folder_manipulation_permissions_on + @role1.add_permission! :folder_manipulation + get :trash, params: { id: @folder1.project.id, ids: ["folder-#{@folder1.id}"] } + assert_response :success + assert_select 'a:not(icon-cancel.disabled)', text: l(:title_restore) + assert_select 'a:not(icon-del.disabled)', text: l(:button_delete) + end + + def test_trash_multiple + get :trash, params: { id: @project1.id, ids: ["file-#{@file1.id}", "folder-#{@folder1.id}"] } + assert_response :success + assert_select 'a.icon-cancel', text: l(:title_restore) + assert_select 'a.icon-del', text: l(:button_delete) + end end \ No newline at end of file