Feature #36679 » feature-36679.patch
| app/controllers/versions_controller.rb | ||
|---|---|---|
|
to_a
|
||
|
end
|
||
|
format.api
|
||
|
format.text do
|
||
|
send_data(@version.version_details_to_text, type: 'text/plain', filename: "version-#{@version.id}.txt")
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| app/models/version.rb | ||
|---|---|---|
|
class Version < ActiveRecord::Base
|
||
|
include Redmine::SafeAttributes
|
||
|
include Redmine::I18n
|
||
|
after_update :update_issues_from_sharing_change
|
||
|
after_save :update_default_project_version
|
||
| ... | ... | |
|
@default_project_version = (arg == '1' || arg == true)
|
||
|
end
|
||
|
def version_details_to_text
|
||
|
[
|
||
|
"# #{self.name}",
|
||
|
format_date(self.effective_date),
|
||
|
self.description,
|
||
|
self.fixed_issues.visible.map{|i| "#{i.tracker.name} ##{i.id} #{i.subject}"}.join("\n")
|
||
|
].compact.join("\n\n")
|
||
|
end
|
||
|
private
|
||
|
# Update the issue's fixed versions. Used if a version's sharing changes.
|
||
| app/views/versions/show.html.erb | ||
|---|---|---|
|
<% end %>
|
||
|
</div>
|
||
|
<% other_formats_links do |f| %>
|
||
|
<%= f.link_to_with_query_parameters 'Text' %>
|
||
|
<% end %>
|
||
|
<%= call_hook :view_versions_show_bottom, :version => @version %>
|
||
|
<% html_title @version.name %>
|
||
| test/functional/versions_controller_test.rb | ||
|---|---|---|
|
require File.expand_path('../../test_helper', __FILE__)
|
||
|
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/version_test.rb | ||
|---|---|---|
|
assert_nil version.custom_field_value(cf2)
|
||
|
end
|
||
|
def test_version_details_to_text
|
||
|
assert_equal "# 0.1\n\n07/01/2006\n\nBeta\n\nBug #11 Closed issue on a closed version", Version.find(1).version_details_to_text
|
||
|
end
|
||
|
private
|
||
|
def add_issue(version, attributes={})
|
||