From 7dfc11363d9026e99482a7a9fb31bdbb285100c8 Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Tue, 13 Feb 2018 15:45:12 +0100 Subject: [PATCH 1/4] Responsive view #682 trash --- app/views/dmsf/_dir_trash.html.erb | 2 +- app/views/dmsf/_url.html.erb | 8 ++++---- app/views/dmsf/_url_trash.html.erb | 10 +++++----- app/views/dmsf/trash.html.erb | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/views/dmsf/_dir_trash.html.erb b/app/views/dmsf/_dir_trash.html.erb index 563148b1..0d5425a9 100644 --- a/app/views/dmsf/_dir_trash.html.erb +++ b/app/views/dmsf/_dir_trash.html.erb @@ -75,7 +75,7 @@ :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:title_delete), - :class => 'icon-only icon-delete') %> + :class => 'icon-only icon-del') %> <% else %> <%= link_to('', delete_dmsf_path(:id => project, :folder_id => subfolder, :commit => 'yes'), :data => {:confirm => l(:text_are_you_sure)}, diff --git a/app/views/dmsf/_url.html.erb b/app/views/dmsf/_url.html.erb index d3ff39b0..80d67d4e 100644 --- a/app/views/dmsf/_url.html.erb +++ b/app/views/dmsf/_url.html.erb @@ -78,7 +78,7 @@ <% end %> -<%= position %> - -link.updated_at.to_i - +<%= position %> + +link.updated_at.to_i + diff --git a/app/views/dmsf/_url_trash.html.erb b/app/views/dmsf/_url_trash.html.erb index 5d73b077..9ffb09ba 100644 --- a/app/views/dmsf/_url_trash.html.erb +++ b/app/views/dmsf/_url_trash.html.erb @@ -64,10 +64,10 @@ <% if @file_delete_allowed %> <%= link_to_if(@file_delete_allowed, '', dmsf_link_path(:id => link, :commit => 'yes'), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, - :title => l(:title_delete), :class => "icon icon-delete" ) %> + :title => l(:title_delete), :class => "icon icon-del" ) %> <% end %> -1 - -link.updated_at.to_i - +1 + +link.updated_at.to_i + diff --git a/app/views/dmsf/trash.html.erb b/app/views/dmsf/trash.html.erb index 0a8e987f..fd67df88 100644 --- a/app/views/dmsf/trash.html.erb +++ b/app/views/dmsf/trash.html.erb @@ -81,10 +81,10 @@ <% end %> <% end %> <%# controls %> - <%# position %> - <%# size %> - <%# updated %> - <%# version %> + <%# position %> + <%# size %> + <%# updated %> + <%# version %> From d92f8745ee34bf162ab064bb7b098db1542f42a1 Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Wed, 14 Feb 2018 12:25:28 +0100 Subject: [PATCH 2/4] can't see files via WebDav, but see them via web-portal #827 --- app/controllers/dmsf_upload_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index 0f28a356..b2d9ff4f 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -123,6 +123,7 @@ class DmsfUploadController < ApplicationController if upload uploaded_file[:disk_filename] = upload.disk_filename uploaded_file[:tempfile_path] = upload.tempfile_path + uploaded_file[:size] = upload.size end end commit_files_internal uploaded_files From 2a3ce756c178dd3a67af209c65183d4d7c27c427 Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Wed, 14 Feb 2018 12:45:16 +0100 Subject: [PATCH 3/4] #827 unit tests --- extra/api/file.xml | 1 - .../rest_api/dmsf_file_api_test.rb | 91 ++++++++++--------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/extra/api/file.xml b/extra/api/file.xml index f1c19385..eec8bb38 100644 --- a/extra/api/file.xml +++ b/extra/api/file.xml @@ -2,7 +2,6 @@ 6118 - cat.gif cat.gif cat.gif REST API diff --git a/test/integration/rest_api/dmsf_file_api_test.rb b/test/integration/rest_api/dmsf_file_api_test.rb index 45535e91..82a87ffe 100644 --- a/test/integration/rest_api/dmsf_file_api_test.rb +++ b/test/integration/rest_api/dmsf_file_api_test.rb @@ -33,47 +33,47 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest @project1.enable_module! :dmsf end - def test_truth - assert_kind_of User, @jsmith - assert_kind_of DmsfFile, @file1 - assert_kind_of Role, @role - assert_kind_of Project, @project1 - end - - def test_get_document - @role.add_permission! :view_dmsf_files - token = Token.create!(:user => @jsmith, :action => 'api') - #curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/17216.xml - get "/dmsf/files/#{@file1.id}.xml?key=#{token.value}" - assert_response :success - assert_equal 'application/xml', @response.content_type - # - # - # 1 - # test.txt - # 1 - # 1.0 - # text/plain - # 81dc9bdb52d04dc20036dbd8313ed055 - # 4 - # Some file :-) - # http://www.example.com/dmsf/files/1/download - # - assert_select 'dmsf_file > id', :text => @file1.id.to_s - assert_select 'dmsf_file > name', :text => @file1.name - assert_select 'dmsf_file > project_id', :text => @file1.project_id.to_s - assert_select 'dmsf_file > version', :text => "#{@file1.last_revision.version}" - assert_select 'dmsf_file > mime_type', :text => @file1.last_revision.mime_type - assert_select 'dmsf_file > digest', :text => @file1.last_revision.digest - assert_select 'dmsf_file > size', :text => @file1.last_revision.size.to_s - assert_select 'dmsf_file > description', :text => @file1.last_revision.description - assert_select 'dmsf_file > content_url', :text => "http://www.example.com/dmsf/files/#{@file1.id}/download" - #curl -v -H "Content-Type: application/octet-stream" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/41532/download > file.txt - Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path '../../../fixtures/files', __FILE__ - get "/dmsf/files/#{@file1.id}/download.xml?key=#{token.value}" - assert_response :success - assert_equal '1234', @response.body - end + # def test_truth + # assert_kind_of User, @jsmith + # assert_kind_of DmsfFile, @file1 + # assert_kind_of Role, @role + # assert_kind_of Project, @project1 + # end + # + # def test_get_document + # @role.add_permission! :view_dmsf_files + # token = Token.create!(:user => @jsmith, :action => 'api') + # #curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/17216.xml + # get "/dmsf/files/#{@file1.id}.xml?key=#{token.value}" + # assert_response :success + # assert_equal 'application/xml', @response.content_type + # # + # # + # # 1 + # # test.txt + # # 1 + # # 1.0 + # # text/plain + # # 81dc9bdb52d04dc20036dbd8313ed055 + # # 4 + # # Some file :-) + # # http://www.example.com/dmsf/files/1/download + # # + # assert_select 'dmsf_file > id', :text => @file1.id.to_s + # assert_select 'dmsf_file > name', :text => @file1.name + # assert_select 'dmsf_file > project_id', :text => @file1.project_id.to_s + # assert_select 'dmsf_file > version', :text => "#{@file1.last_revision.version}" + # assert_select 'dmsf_file > mime_type', :text => @file1.last_revision.mime_type + # assert_select 'dmsf_file > digest', :text => @file1.last_revision.digest + # assert_select 'dmsf_file > size', :text => @file1.last_revision.size.to_s + # assert_select 'dmsf_file > description', :text => @file1.last_revision.description + # assert_select 'dmsf_file > content_url', :text => "http://www.example.com/dmsf/files/#{@file1.id}/download" + # #curl -v -H "Content-Type: application/octet-stream" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/41532/download > file.txt + # Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path '../../../fixtures/files', __FILE__ + # get "/dmsf/files/#{@file1.id}/download.xml?key=#{token.value}" + # assert_response :success + # assert_equal '1234', @response.body + # end def test_upload_document timestamp = DateTime.now.strftime('%y%m%d%H%M') @@ -99,7 +99,6 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest - test.txt test.txt test.txt REST API @@ -109,16 +108,20 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest } - post "/projects/#{@project1.id}/dmsf/commit.xml?&key=#{token.value}", payload, {"CONTENT_TYPE" => 'application/xml'} + assert_difference 'DmsfFileRevision.count', +1 do + post "/projects/#{@project1.id}/dmsf/commit.xml?&key=#{token.value}", payload, {"CONTENT_TYPE" => 'application/xml'} + end # # # # 17229 # test.txt # - # + # # assert_select 'dmsf_files > file > name', :text => 'test.txt' assert_response :success + revision = DmsfFileRevision.order(:id).last + assert revision && revision.size > 0 begin FileUtils.rm_rf Setting.plugin_redmine_dmsf['dmsf_storage_directory'] rescue Exception => e From 057ee20c687add12b27d2029ac4c8503de9e307e Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Wed, 14 Feb 2018 12:53:56 +0100 Subject: [PATCH 4/4] #827 unit tests --- .../rest_api/dmsf_file_api_test.rb | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/test/integration/rest_api/dmsf_file_api_test.rb b/test/integration/rest_api/dmsf_file_api_test.rb index 82a87ffe..719e8d2e 100644 --- a/test/integration/rest_api/dmsf_file_api_test.rb +++ b/test/integration/rest_api/dmsf_file_api_test.rb @@ -33,47 +33,47 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest @project1.enable_module! :dmsf end - # def test_truth - # assert_kind_of User, @jsmith - # assert_kind_of DmsfFile, @file1 - # assert_kind_of Role, @role - # assert_kind_of Project, @project1 - # end - # - # def test_get_document - # @role.add_permission! :view_dmsf_files - # token = Token.create!(:user => @jsmith, :action => 'api') - # #curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/17216.xml - # get "/dmsf/files/#{@file1.id}.xml?key=#{token.value}" - # assert_response :success - # assert_equal 'application/xml', @response.content_type - # # - # # - # # 1 - # # test.txt - # # 1 - # # 1.0 - # # text/plain - # # 81dc9bdb52d04dc20036dbd8313ed055 - # # 4 - # # Some file :-) - # # http://www.example.com/dmsf/files/1/download - # # - # assert_select 'dmsf_file > id', :text => @file1.id.to_s - # assert_select 'dmsf_file > name', :text => @file1.name - # assert_select 'dmsf_file > project_id', :text => @file1.project_id.to_s - # assert_select 'dmsf_file > version', :text => "#{@file1.last_revision.version}" - # assert_select 'dmsf_file > mime_type', :text => @file1.last_revision.mime_type - # assert_select 'dmsf_file > digest', :text => @file1.last_revision.digest - # assert_select 'dmsf_file > size', :text => @file1.last_revision.size.to_s - # assert_select 'dmsf_file > description', :text => @file1.last_revision.description - # assert_select 'dmsf_file > content_url', :text => "http://www.example.com/dmsf/files/#{@file1.id}/download" - # #curl -v -H "Content-Type: application/octet-stream" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/41532/download > file.txt - # Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path '../../../fixtures/files', __FILE__ - # get "/dmsf/files/#{@file1.id}/download.xml?key=#{token.value}" - # assert_response :success - # assert_equal '1234', @response.body - # end + def test_truth + assert_kind_of User, @jsmith + assert_kind_of DmsfFile, @file1 + assert_kind_of Role, @role + assert_kind_of Project, @project1 + end + + def test_get_document + @role.add_permission! :view_dmsf_files + token = Token.create!(:user => @jsmith, :action => 'api') + #curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/17216.xml + get "/dmsf/files/#{@file1.id}.xml?key=#{token.value}" + assert_response :success + assert_equal 'application/xml', @response.content_type + # + # + # 1 + # test.txt + # 1 + # 1.0 + # text/plain + # 81dc9bdb52d04dc20036dbd8313ed055 + # 4 + # Some file :-) + # http://www.example.com/dmsf/files/1/download + # + assert_select 'dmsf_file > id', :text => @file1.id.to_s + assert_select 'dmsf_file > name', :text => @file1.name + assert_select 'dmsf_file > project_id', :text => @file1.project_id.to_s + assert_select 'dmsf_file > version', :text => "#{@file1.last_revision.version}" + assert_select 'dmsf_file > mime_type', :text => @file1.last_revision.mime_type + assert_select 'dmsf_file > digest', :text => @file1.last_revision.digest + assert_select 'dmsf_file > size', :text => @file1.last_revision.size.to_s + assert_select 'dmsf_file > description', :text => @file1.last_revision.description + assert_select 'dmsf_file > content_url', :text => "http://www.example.com/dmsf/files/#{@file1.id}/download" + #curl -v -H "Content-Type: application/octet-stream" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/41532/download > file.txt + Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path '../../../fixtures/files', __FILE__ + get "/dmsf/files/#{@file1.id}/download.xml?key=#{token.value}" + assert_response :success + assert_equal '1234', @response.body + end def test_upload_document timestamp = DateTime.now.strftime('%y%m%d%H%M')