kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
4.3 KiB
129 lines
4.3 KiB
11 years ago
|
#-- copyright
|
||
11 years ago
|
# OpenProject Documents Plugin
|
||
11 years ago
|
#
|
||
11 years ago
|
# Former OpenProject Core functionality extracted into a plugin.
|
||
|
#
|
||
|
# Copyright (C) 2009-2014 the OpenProject Foundation (OPF)
|
||
11 years ago
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
11 years ago
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2013 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.
|
||
|
#
|
||
11 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
|
|
||
|
require 'spec_helper'
|
||
|
|
||
|
describe ApplicationHelper do
|
||
|
include ApplicationHelper
|
||
|
include ActionView::Helpers
|
||
|
include ActionDispatch::Routing
|
||
|
include Rails.application.routes.url_helpers
|
||
|
|
||
|
|
||
6 years ago
|
describe ".format_text" do
|
||
7 years ago
|
let(:project) { FactoryBot.create :valid_project }
|
||
11 years ago
|
let(:identifier) { project.identifier }
|
||
7 years ago
|
let(:role) {
|
||
7 years ago
|
FactoryBot.create(:role, permissions: [
|
||
9 years ago
|
:view_work_packages, :edit_work_packages, :view_documents, :browse_repository, :view_changesets, :view_wiki_pages
|
||
|
])
|
||
|
}
|
||
|
let(:project_member) {
|
||
7 years ago
|
FactoryBot.create :user, member_in_project: project,
|
||
9 years ago
|
member_through_role: role
|
||
|
}
|
||
|
let(:document) {
|
||
7 years ago
|
FactoryBot.create :document,
|
||
9 years ago
|
title: 'Test document',
|
||
|
project: project
|
||
|
}
|
||
11 years ago
|
|
||
|
before do
|
||
|
@project = project
|
||
10 years ago
|
allow(User).to receive(:current).and_return project_member
|
||
11 years ago
|
end
|
||
|
|
||
|
after do
|
||
10 years ago
|
allow(User).to receive(:current).and_call_original
|
||
11 years ago
|
end
|
||
|
|
||
11 years ago
|
context "Simple Document links" do
|
||
9 years ago
|
let(:document_link) {
|
||
|
link_to('Test document',
|
||
|
{ controller: 'documents', action: 'show', id: document.id },
|
||
|
class: 'document')
|
||
|
}
|
||
11 years ago
|
|
||
|
context "Plain link" do
|
||
10 years ago
|
subject { format_text("document##{document.id}") }
|
||
11 years ago
|
|
||
10 years ago
|
it { is_expected.to eq("<p>#{document_link}</p>") }
|
||
11 years ago
|
end
|
||
|
|
||
|
context "Link with document name" do
|
||
10 years ago
|
subject { format_text("document##{document.id}") }
|
||
11 years ago
|
|
||
10 years ago
|
it { is_expected.to eq("<p>#{document_link}</p>") }
|
||
11 years ago
|
end
|
||
|
|
||
|
context "Escaping plain link" do
|
||
10 years ago
|
subject { format_text("!document##{document.id}") }
|
||
11 years ago
|
|
||
10 years ago
|
it { is_expected.to eq("<p>document##{document.id}</p>") }
|
||
11 years ago
|
end
|
||
|
|
||
|
context "Escaping link with document name" do
|
||
10 years ago
|
subject { format_text('!document:"Test document"') }
|
||
11 years ago
|
|
||
10 years ago
|
it { is_expected.to eq('<p>document:"Test document"</p>') }
|
||
11 years ago
|
end
|
||
|
end
|
||
11 years ago
|
|
||
|
context 'Cross-Project Document Links' do
|
||
7 years ago
|
let(:the_other_project) { FactoryBot.create :valid_project }
|
||
11 years ago
|
|
||
|
context "By name without project" do
|
||
9 years ago
|
subject { format_text("document:\"#{document.title}\"", project: the_other_project) }
|
||
11 years ago
|
|
||
10 years ago
|
it { is_expected.to eq('<p>document:"Test document"</p>') }
|
||
11 years ago
|
end
|
||
|
|
||
|
context "By id and given project" do
|
||
9 years ago
|
subject { format_text("#{identifier}:document##{document.id}", project: the_other_project) }
|
||
11 years ago
|
|
||
9 years ago
|
it { is_expected.to eq("<p><a class=\"document\" href=\"/documents/#{document.id}\">Test document</a></p>") }
|
||
11 years ago
|
end
|
||
|
|
||
|
context "By name and given project" do
|
||
9 years ago
|
subject { format_text("#{identifier}:document:\"#{document.title}\"", project: the_other_project) }
|
||
11 years ago
|
|
||
9 years ago
|
it { is_expected.to eq("<p><a class=\"document\" href=\"/documents/#{document.id}\">Test document</a></p>") }
|
||
11 years ago
|
end
|
||
|
|
||
|
context "Invalid link" do
|
||
9 years ago
|
subject { format_text("invalid:document:\"Test document\"", project: the_other_project) }
|
||
11 years ago
|
|
||
10 years ago
|
it { is_expected.to eq('<p>invalid:document:"Test document"</p>') }
|
||
11 years ago
|
end
|
||
|
end
|
||
11 years ago
|
end
|
||
|
end
|