Merge pull request #8772 from opf/fix/flickering_documents_attachment_spec

Fix/flickering documents attachment spec
pull/8774/head
ulferts 4 years ago committed by GitHub
commit 073ac6562a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      modules/documents/app/helpers/documents_helper.rb
  2. 5
      modules/documents/app/views/documents/_form.html.erb
  3. 5
      modules/documents/app/views/documents/show.html.erb
  4. 7
      modules/documents/spec/features/attachment_upload_spec.rb
  5. 23
      modules/reporting/spec/models/cost_query/chaining_spec.rb

@ -0,0 +1,36 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
module DocumentsHelper
def api_v3_document_resource(document)
::API::V3::Documents::DocumentRepresenter.new(document,
current_user: current_user,
embed_links: true)
end
end

@ -28,9 +28,6 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
<%= error_messages_for 'document' %>
<% resource = ::API::V3::Documents::DocumentRepresenter.new(f.object,
current_user: current_user,
embed_links: true) %>
<div class="form--field -required">
<%= f.select :category_id,
@ -45,6 +42,6 @@ See docs/COPYRIGHT.rdoc for more details.
<%= f.text_area :description,
container_class: '-xxwide',
with_text_formatting: true,
resource: resource,
resource: api_v3_document_resource(f.object),
preview_context: preview_context(f.object.project) %>
</div>

@ -52,8 +52,5 @@ See docs/COPYRIGHT.rdoc for more details.
<%= format_text @document.description, attachments: @document.attachments %>
</div>
<% resource = ::API::V3::Documents::DocumentRepresenter.new(@document,
current_user: current_user,
embed_links: true) %>
<%= list_attachments(resource) %>
<%= list_attachments(api_v3_document_resource(@document)) %>

@ -62,6 +62,7 @@ describe 'Upload attachment to documents', js: true do
click_on 'Create'
# Expect it to be present on the index page
expect(page).to have_selector('.document-category-elements--header', text: 'New documentation')
expect(page).to have_selector('#content img', count: 1)
expect(page).to have_content('Image uploaded on creation')
@ -69,8 +70,13 @@ describe 'Upload attachment to documents', js: true do
document = ::Document.last
expect(document.title).to eq 'New documentation'
# Expect it to be present on the show page
find('.document-category-elements--header a', text: 'New documentation').click
expect(page).to have_current_path "/documents/#{document.id}", wait: 10
expect(page).to have_selector('#content img', count: 1)
expect(page).to have_content('Image uploaded on creation')
# Adding a second image
find('.toolbar-items .button', text: 'Edit').click
expect(page).to have_current_path "/documents/#{document.id}/edit", wait: 10
@ -79,6 +85,7 @@ describe 'Upload attachment to documents', js: true do
click_on 'Save'
# Expect both images to be present on the show page
expect(page).to have_selector('#content img', count: 2)
expect(page).to have_content('Image uploaded on creation')
expect(page).to have_content('Image uploaded the second time')

@ -80,17 +80,6 @@ describe CostQuery, type: :model, reporting_query_helper: true do
expect(@query.chain.top.type).to eq(:row)
end
it "should place rows in front of columns when adding a row first" do
skip "This fails unreproducible on travis" if ENV['CI']
@query.row :project_id
expect(@query.chain.bottom.parent.type).to eq(:row)
expect(@query.chain.top.type).to eq(:row)
@query.column :project_id
expect(@query.chain.bottom.parent.type).to eq(:column)
expect(@query.chain.top.type).to eq(:row)
end
it "should place rows in front of filters" do
@query.row :project_id
expect(@query.chain.bottom.parent.type).to eq(:row)
@ -102,18 +91,6 @@ describe CostQuery, type: :model, reporting_query_helper: true do
expect(@query.chain.top.type).to eq(:row)
end
it "should place columns in front of filters" do
skip "This fails unreproducible on travis" if ENV['CI']
@query.column :project_id
expect(@query.chain.bottom.parent.type).to eq(:column)
expect(@query.chain.top.type).to eq(:column)
@query.filter :project_id
expect(@query.chain.bottom.parent).to be_a(CostQuery::Filter::ProjectId)
expect(@query.chain.top).to be_a(CostQuery::GroupBy::Base)
expect(@query.chain.top.type).to eq(:column)
end
it "should return all filters, including the NoFilter" do
@query.filter :project_id
@query.group_by :project_id

Loading…
Cancel
Save