|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +#-- copyright |
| 4 | +# OpenProject is an open source project management software. |
| 5 | +# Copyright (C) the OpenProject GmbH |
| 6 | +# |
| 7 | +# This program is free software; you can redistribute it and/or |
| 8 | +# modify it under the terms of the GNU General Public License version 3. |
| 9 | +# |
| 10 | +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
| 11 | +# Copyright (C) 2006-2013 Jean-Philippe Lang |
| 12 | +# Copyright (C) 2010-2013 the ChiliProject Team |
| 13 | +# |
| 14 | +# This program is free software; you can redistribute it and/or |
| 15 | +# modify it under the terms of the GNU General Public License |
| 16 | +# as published by the Free Software Foundation; either version 2 |
| 17 | +# of the License, or (at your option) any later version. |
| 18 | +# |
| 19 | +# This program is distributed in the hope that it will be useful, |
| 20 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | +# GNU General Public License for more details. |
| 23 | +# |
| 24 | +# You should have received a copy of the GNU General Public License |
| 25 | +# along with this program; if not, write to the Free Software |
| 26 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 27 | +# |
| 28 | +# See COPYRIGHT and LICENSE files for more details. |
| 29 | +#++ |
| 30 | + |
| 31 | +require "spec_helper" |
| 32 | +require_module_spec_helper |
| 33 | + |
| 34 | +RSpec.describe "Show/Edit Document View", |
| 35 | + :js, |
| 36 | + :selenium, |
| 37 | + with_flag: { block_note_editor: true } do |
| 38 | + shared_let(:project) { create(:project) } |
| 39 | + shared_let(:member_role) { create(:existing_project_role, permissions: %i[view_documents manage_documents]) } |
| 40 | + shared_let(:member) { create(:user, member_with_roles: { project => member_role }) } |
| 41 | + |
| 42 | + let(:document_types) do |
| 43 | + %w[Specification Report].map { create(:document_type, name: it) } |
| 44 | + end |
| 45 | + let(:document) { create(:document, project:, title: "Collaborative document", type: document_types.first) } |
| 46 | + |
| 47 | + current_user { member } |
| 48 | + |
| 49 | + it "renders a collaborative document" do |
| 50 | + visit document_path(document) |
| 51 | + |
| 52 | + expect(page).to have_content("Collaborative document") |
| 53 | + |
| 54 | + aggregate_failures "can change document type" do |
| 55 | + within_test_selector("document-info-line") do |
| 56 | + click_button "Specification" |
| 57 | + click_on "Report" |
| 58 | + expect(page).to have_button("Report") |
| 59 | + end |
| 60 | + expect(document.reload.type).to eq(document_types[1]) |
| 61 | + end |
| 62 | + |
| 63 | + aggregate_failures "can edit document content" do |
| 64 | + editor = FormFields::Primerized::BlockNoteEditorInput.new |
| 65 | + editor.fill_in_with_content("This is the new **content**.") |
| 66 | + |
| 67 | + expect(page).to have_content("This is the new content.") |
| 68 | + end |
| 69 | + end |
| 70 | + |
| 71 | + context "without view documents permission" do |
| 72 | + let(:user) { create(:user) } |
| 73 | + |
| 74 | + current_user { user } |
| 75 | + |
| 76 | + it "renders a not authorized message" do |
| 77 | + visit document_path(document) |
| 78 | + expect(page).to have_text("[Error 403] You are not authorized to access this page.") |
| 79 | + end |
| 80 | + end |
| 81 | +end |
0 commit comments