Feature #36679 » feature-36679-v4.patch
app/controllers/versions_controller.rb | ||
---|---|---|
27 | 27 | |
28 | 28 |
accept_api_auth :index, :show, :create, :update, :destroy |
29 | 29 | |
30 |
include VersionsHelper |
|
30 | 31 |
helper :custom_fields |
31 | 32 |
helper :projects |
32 | 33 | |
... | ... | |
73 | 74 |
to_a |
74 | 75 |
end |
75 | 76 |
format.api |
77 |
format.text do |
|
78 |
send_data(version_to_text(@version), type: 'text/plain', filename: "#{@version.name}.txt") |
|
79 |
end |
|
76 | 80 |
end |
77 | 81 |
end |
78 | 82 |
app/helpers/versions_helper.rb | ||
---|---|---|
18 | 18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | 19 | |
20 | 20 |
module VersionsHelper |
21 |
include Redmine::Export::Text::VersionsTextHelper |
|
21 | 22 | |
22 | 23 |
def version_anchor(version) |
23 | 24 |
if @project == version.project |
app/views/versions/show.html.erb | ||
---|---|---|
56 | 56 |
<% end %> |
57 | 57 |
</div> |
58 | 58 | |
59 |
<% other_formats_links do |f| %> |
|
60 |
<%= f.link_to_with_query_parameters 'TXT' %> |
|
61 |
<% end %> |
|
62 | ||
59 | 63 |
<%= call_hook :view_versions_show_bottom, :version => @version %> |
60 | 64 | |
61 | 65 |
<% html_title @version.name %> |
lib/redmine/export/text/versions_text_helper.rb | ||
---|---|---|
1 |
# frozen_string_literal: true |
|
2 | ||
3 |
# Redmine - project management software |
|
4 |
# Copyright (C) 2006-2023 Jean-Philippe Lang |
|
5 |
# |
|
6 |
# This program is free software; you can redistribute it and/or |
|
7 |
# modify it under the terms of the GNU General Public License |
|
8 |
# as published by the Free Software Foundation; either version 2 |
|
9 |
# of the License, or (at your option) any later version. |
|
10 |
# |
|
11 |
# This program is distributed in the hope that it will be useful, |
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
# GNU General Public License for more details. |
|
15 |
# |
|
16 |
# You should have received a copy of the GNU General Public License |
|
17 |
# along with this program; if not, write to the Free Software |
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
19 | ||
20 |
module Redmine |
|
21 |
module Export |
|
22 |
module Text |
|
23 |
module VersionsTextHelper |
|
24 |
def version_to_text(version) |
|
25 |
[ |
|
26 |
"# #{version.name}", |
|
27 |
format_date(version.effective_date), |
|
28 |
version.description, |
|
29 |
version.fixed_issues.visible.map do |issue| |
|
30 |
"* #{issue.tracker.name} ##{issue.id}: #{issue.subject}\n" |
|
31 |
end.join |
|
32 |
].compact.join("\n\n") |
|
33 |
end |
|
34 |
end |
|
35 |
end |
|
36 |
end |
|
37 |
end |
test/functional/versions_controller_test.rb | ||
---|---|---|
20 | 20 |
require_relative '../test_helper' |
21 | 21 | |
22 | 22 |
class VersionsControllerTest < Redmine::ControllerTest |
23 |
include Redmine::I18n |
|
23 | 24 |
fixtures :projects, :enabled_modules, |
24 | 25 |
:trackers, :projects_trackers, |
25 | 26 |
:versions, :issue_statuses, :issue_categories, :enumerations, |
... | ... | |
220 | 221 |
assert_select 'a.icon.icon-add', :text => 'New issue' |
221 | 222 |
end |
222 | 223 | |
224 |
def test_show_with_text_format |
|
225 |
version = Version.find(2) |
|
226 |
get :show, params: {id: version.id, format: :text} |
|
227 |
assert_response :success |
|
228 |
assert_equal 'text/plain', response.media_type |
|
229 | ||
230 |
result = response.body.split("\n\n") |
|
231 |
assert_equal "# #{version.name}", result[0] |
|
232 |
assert_equal format_date(version.effective_date), result[1] |
|
233 |
assert_equal version.description, result[2] |
|
234 |
end |
|
235 | ||
223 | 236 |
def test_new |
224 | 237 |
@request.session[:user_id] = 2 |
225 | 238 |
get :new, :params => {:project_id => '1'} |
test/unit/lib/redmine/export/text/versions_text_helper_test.rb | ||
---|---|---|
1 |
# frozen_string_literal: true |
|
2 | ||
3 |
# Redmine - project management software |
|
4 |
# Copyright (C) 2006-2023 Jean-Philippe Lang |
|
5 |
# |
|
6 |
# This program is free software; you can redistribute it and/or |
|
7 |
# modify it under the terms of the GNU General Public License |
|
8 |
# as published by the Free Software Foundation; either version 2 |
|
9 |
# of the License, or (at your option) any later version. |
|
10 |
# |
|
11 |
# This program is distributed in the hope that it will be useful, |
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
# GNU General Public License for more details. |
|
15 |
# |
|
16 |
# You should have received a copy of the GNU General Public License |
|
17 |
# along with this program; if not, write to the Free Software |
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
19 | ||
20 |
require_relative '../../../../../test_helper' |
|
21 | ||
22 |
class VersionsTextHelperTest < ActiveSupport::TestCase |
|
23 |
fixtures :users, :projects, :roles, :members, :member_roles, |
|
24 |
:enabled_modules, :issues, :trackers, :enumerations, :versions |
|
25 | ||
26 |
include Redmine::I18n |
|
27 |
include Redmine::Export::Text::VersionsTextHelper |
|
28 | ||
29 |
def test_version_to_text |
|
30 |
expected = <<~EXPECTED |
|
31 |
# 0.1 |
|
32 | ||
33 |
07/01/2006 |
|
34 | ||
35 |
Beta |
|
36 | ||
37 |
* Bug #11: Closed issue on a closed version |
|
38 |
EXPECTED |
|
39 |
assert_equal expected, version_to_text(Version.find(1)) |
|
40 |
end |
|
41 |
end |
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »