summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Ho <clemmakesapps@gmail.com>2018-03-18 15:28:04 +0000
committerJacob Schatz <jschatz@gitlab.com>2018-03-18 15:28:04 +0000
commit78a8a79b01df2c766b9a76a525b940483a0f7106 (patch)
treeb5b090da16460263315276afbf37c96cf0d907e9
parentea5221aeb358ef6c349cfa09b9c6993bd7bd027d (diff)
downloadgitlab-ce-78a8a79b01df2c766b9a76a525b940483a0f7106.tar.gz
Fix dropzone project show
-rw-r--r--app/assets/javascripts/pages/projects/show/index.js21
-rw-r--r--changelogs/unreleased/fix-dropzone-project-show.yml5
-rw-r--r--spec/features/projects/show_project_spec.rb22
3 files changed, 44 insertions, 4 deletions
diff --git a/app/assets/javascripts/pages/projects/show/index.js b/app/assets/javascripts/pages/projects/show/index.js
index a6a172402d8..3b0f0f960b8 100644
--- a/app/assets/javascripts/pages/projects/show/index.js
+++ b/app/assets/javascripts/pages/projects/show/index.js
@@ -1,4 +1,5 @@
import $ from 'jquery';
+import initBlob from '~/blob_edit/blob_bundle';
import ShortcutsNavigation from '~/shortcuts_navigation';
import NotificationsForm from '~/notifications_form';
import UserCallout from '~/user_callout';
@@ -19,10 +20,22 @@ document.addEventListener('DOMContentLoaded', () => {
className: 'js-autodevops-banner',
});
- if ($('#tree-slider').length) new TreeView(); // eslint-disable-line no-new
- if ($('.blob-viewer').length) new BlobViewer(); // eslint-disable-line no-new
- if ($('.project-show-activity').length) new Activities(); // eslint-disable-line no-new
- $('#tree-slider').waitForImages(() => {
+ // Project show page loads different overview content based on user preferences
+ const treeSlider = document.querySelector('#tree-slider');
+ if (treeSlider) {
+ new TreeView(); // eslint-disable-line no-new
+ initBlob();
+ }
+
+ if (document.querySelector('.blob-viewer')) {
+ new BlobViewer(); // eslint-disable-line no-new
+ }
+
+ if (document.querySelector('.project-show-activity')) {
+ new Activities(); // eslint-disable-line no-new
+ }
+
+ $(treeSlider).waitForImages(() => {
ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath);
});
});
diff --git a/changelogs/unreleased/fix-dropzone-project-show.yml b/changelogs/unreleased/fix-dropzone-project-show.yml
new file mode 100644
index 00000000000..660780812d8
--- /dev/null
+++ b/changelogs/unreleased/fix-dropzone-project-show.yml
@@ -0,0 +1,5 @@
+---
+title: Fix file upload on project show page
+merge_request:
+author:
+type: fixed
diff --git a/spec/features/projects/show_project_spec.rb b/spec/features/projects/show_project_spec.rb
index 0a014e9f080..e4f13e6cab7 100644
--- a/spec/features/projects/show_project_spec.rb
+++ b/spec/features/projects/show_project_spec.rb
@@ -1,6 +1,8 @@
require 'spec_helper'
describe 'Project show page', :feature do
+ include DropzoneHelper
+
context 'when project pending delete' do
let(:project) { create(:project, :empty_repo, pending_delete: true) }
@@ -334,4 +336,24 @@ describe 'Project show page', :feature do
end
end
end
+
+ describe 'dropzone', :js do
+ let(:project) { create(:project, :repository) }
+ let(:user) { create(:user) }
+
+ before do
+ project.add_master(user)
+ sign_in(user)
+
+ visit project_path(project)
+ end
+
+ it 'can upload files' do
+ find('.add-to-tree').click
+ click_link 'Upload file'
+ drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
+
+ expect(find('.dz-filename')).to have_content('doc_sample.txt')
+ end
+ end
end