Feature #36679 » feature-36679-v4.patch
| app/controllers/versions_controller.rb | ||
|---|---|---|
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||
|
include VersionsHelper
|
||
|
helper :custom_fields
|
||
|
helper :projects
|
||
| ... | ... | |
|
to_a
|
||
|
end
|
||
|
format.api
|
||
|
format.text do
|
||
|
send_data(version_to_text(@version), type: 'text/plain', filename: "#{@version.name}.txt")
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| app/helpers/versions_helper.rb | ||
|---|---|---|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
module VersionsHelper
|
||
|
include Redmine::Export::Text::VersionsTextHelper
|
||
|
def version_anchor(version)
|
||
|
if @project == version.project
|
||
| app/views/versions/show.html.erb | ||
|---|---|---|
|
<% end %>
|
||
|
</div>
|
||
|
<% other_formats_links do |f| %>
|
||
|
<%= f.link_to_with_query_parameters 'TXT' %>
|
||
|
<% end %>
|
||
|
<%= call_hook :view_versions_show_bottom, :version => @version %>
|
||
|
<% html_title @version.name %>
|
||
| lib/redmine/export/text/versions_text_helper.rb | ||
|---|---|---|
|
# frozen_string_literal: true
|
||
|
# Redmine - project management software
|
||
|
# Copyright (C) 2006-2023 Jean-Philippe Lang
|
||
|
#
|
||
|
# 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.
|
||
|
module Redmine
|
||
|
module Export
|
||
|
module Text
|
||
|
module VersionsTextHelper
|
||
|
def version_to_text(version)
|
||
|
[
|
||
|
"# #{version.name}",
|
||
|
format_date(version.effective_date),
|
||
|
version.description,
|
||
|
version.fixed_issues.visible.map do |issue|
|
||
|
"* #{issue.tracker.name} ##{issue.id}: #{issue.subject}\n"
|
||
|
end.join
|
||
|
].compact.join("\n\n")
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| test/functional/versions_controller_test.rb | ||
|---|---|---|
|
require_relative '../test_helper'
|
||
|
class VersionsControllerTest < Redmine::ControllerTest
|
||
|
include Redmine::I18n
|
||
|
fixtures :projects, :enabled_modules,
|
||
|
:trackers, :projects_trackers,
|
||
|
:versions, :issue_statuses, :issue_categories, :enumerations,
|
||
| ... | ... | |
|
assert_select 'a.icon.icon-add', :text => 'New issue'
|
||
|
end
|
||
|
def test_show_with_text_format
|
||
|
version = Version.find(2)
|
||
|
get :show, params: {id: version.id, format: :text}
|
||
|
assert_response :success
|
||
|
assert_equal 'text/plain', response.media_type
|
||
|
result = response.body.split("\n\n")
|
||
|
assert_equal "# #{version.name}", result[0]
|
||
|
assert_equal format_date(version.effective_date), result[1]
|
||
|
assert_equal version.description, result[2]
|
||
|
end
|
||
|
def test_new
|
||
|
@request.session[:user_id] = 2
|
||
|
get :new, :params => {:project_id => '1'}
|
||
| test/unit/lib/redmine/export/text/versions_text_helper_test.rb | ||
|---|---|---|
|
# frozen_string_literal: true
|
||
|
# Redmine - project management software
|
||
|
# Copyright (C) 2006-2023 Jean-Philippe Lang
|
||
|
#
|
||
|
# 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.
|
||
|
require_relative '../../../../../test_helper'
|
||
|
class VersionsTextHelperTest < ActiveSupport::TestCase
|
||
|
fixtures :users, :projects, :roles, :members, :member_roles,
|
||
|
:enabled_modules, :issues, :trackers, :enumerations, :versions
|
||
|
include Redmine::I18n
|
||
|
include Redmine::Export::Text::VersionsTextHelper
|
||
|
def test_version_to_text
|
||
|
expected = <<~EXPECTED
|
||
|
# 0.1
|
||
|
07/01/2006
|
||
|
Beta
|
||
|
* Bug #11: Closed issue on a closed version
|
||
|
EXPECTED
|
||
|
assert_equal expected, version_to_text(Version.find(1))
|
||
|
end
|
||
|
end
|
||
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »