Commit 068abad0 authored by jplang's avatar jplang

Restores commits reverted when rails-4.1 branch was merged (#18174).

Patch by Mischa The Evil.

git-svn-id: https://svn.redmine.org/redmine/trunk@13504 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 21502879
...@@ -153,6 +153,13 @@ module ApplicationHelper ...@@ -153,6 +153,13 @@ module ApplicationHelper
end end
end end
# Generates a link to a version
def link_to_version(version, options = {})
return '' unless version && version.is_a?(Version)
options = {:title => format_date(version.effective_date)}.merge(options)
link_to_if version.visible?, format_version_name(version), version_path(version), options
end
# Helper that formats object for html or text rendering # Helper that formats object for html or text rendering
def format_object(object, html=true, &block) def format_object(object, html=true, &block)
if block_given? if block_given?
...@@ -174,7 +181,7 @@ module ApplicationHelper ...@@ -174,7 +181,7 @@ module ApplicationHelper
when 'Project' when 'Project'
html ? link_to_project(object) : object.to_s html ? link_to_project(object) : object.to_s
when 'Version' when 'Version'
html ? link_to(object.name, version_path(object)) : object.to_s html ? link_to_version(object) : object.to_s
when 'TrueClass' when 'TrueClass'
l(:general_text_Yes) l(:general_text_Yes)
when 'FalseClass' when 'FalseClass'
...@@ -236,7 +243,7 @@ module ApplicationHelper ...@@ -236,7 +243,7 @@ module ApplicationHelper
end end
def format_version_name(version) def format_version_name(version)
if version.project == @project if !version.shared? || version.project == @project
h(version) h(version)
else else
h("#{version.project} - #{version}") h("#{version.project} - #{version}")
......
...@@ -18,11 +18,6 @@ ...@@ -18,11 +18,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module ProjectsHelper module ProjectsHelper
def link_to_version(version, options = {})
return '' unless version && version.is_a?(Version)
link_to_if version.visible?, format_version_name(version), version_path(version), options
end
def project_settings_tabs def project_settings_tabs
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural}, tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
{:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural}, {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
......
...@@ -1132,7 +1132,6 @@ class Issue < ActiveRecord::Base ...@@ -1132,7 +1132,6 @@ class Issue < ActiveRecord::Base
def parent_issue_id=(arg) def parent_issue_id=(arg)
s = arg.to_s.strip.presence s = arg.to_s.strip.presence
if s && (m = s.match(%r{\A#?(\d+)\z})) && (@parent_issue = Issue.find_by_id(m[1])) if s && (m = s.match(%r{\A#?(\d+)\z})) && (@parent_issue = Issue.find_by_id(m[1]))
@parent_issue.id
@invalid_parent_issue_id = nil @invalid_parent_issue_id = nil
elsif s.blank? elsif s.blank?
@parent_issue = nil @parent_issue = nil
......
...@@ -962,10 +962,11 @@ class Project < ActiveRecord::Base ...@@ -962,10 +962,11 @@ class Project < ActiveRecord::Base
def copy_queries(project) def copy_queries(project)
project.queries.each do |query| project.queries.each do |query|
new_query = IssueQuery.new new_query = IssueQuery.new
new_query.attributes = query.attributes.dup.except("id", "project_id", "sort_criteria") new_query.attributes = query.attributes.dup.except("id", "project_id", "sort_criteria", "user_id", "type")
new_query.sort_criteria = query.sort_criteria if query.sort_criteria new_query.sort_criteria = query.sort_criteria if query.sort_criteria
new_query.project = self new_query.project = self
new_query.user_id = query.user_id new_query.user_id = query.user_id
new_query.role_ids = query.role_ids if query.visibility == IssueQuery::VISIBILITY_ROLES
self.queries << new_query self.queries << new_query
end end
end end
......
...@@ -220,6 +220,11 @@ class Version < ActiveRecord::Base ...@@ -220,6 +220,11 @@ class Version < ActiveRecord::Base
end end
end end
# Returns true if the version is shared, otherwise false
def shared?
sharing != 'none'
end
private private
def load_issue_counts def load_issue_counts
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
<% end -%> <% end -%>
</ul> </ul>
<div class="tabs-buttons" style="display:none;"> <div class="tabs-buttons" style="display:none;">
<button class="tab-left" onclick="moveTabLeft(this); return false;"></button> <button class="tab-left" type="button" onclick="moveTabLeft(this);"></button>
<button class="tab-right" onclick="moveTabRight(this); return false;"></button> <button class="tab-right" type="button" onclick="moveTabRight(this);"></button>
</div> </div>
</div> </div>
......
...@@ -22,3 +22,9 @@ Redmine::Plugin.load ...@@ -22,3 +22,9 @@ Redmine::Plugin.load
unless Redmine::Configuration['mirror_plugins_assets_on_startup'] == false unless Redmine::Configuration['mirror_plugins_assets_on_startup'] == false
Redmine::Plugin.mirror_assets Redmine::Plugin.mirror_assets
end end
Rails.application.config.to_prepare do
Redmine::FieldFormat::RecordList.subclasses.each do |klass|
klass.instance.reset_target_class
end
end
\ No newline at end of file
...@@ -86,7 +86,7 @@ http://www.redmine.org/ ...@@ -86,7 +86,7 @@ http://www.redmine.org/
* Defect #16655: start_date not set despite settings[default_issue_start_date_to_creation_date] being set. * Defect #16655: start_date not set despite settings[default_issue_start_date_to_creation_date] being set.
* Defect #16668: Redmine links broken when object name contains special characters * Defect #16668: Redmine links broken when object name contains special characters
* Defect #16669: Markdown formatter should use the :no_intra_emphasis extension * Defect #16669: Markdown formatter should use the :no_intra_emphasis extension
* Defect #16708: Form is submitted when swithing tab * Defect #16708: Form is submitted when switching tab
* Defect #16739: custom_fields.json only returns single tracker instead of array of trackers * Defect #16739: custom_fields.json only returns single tracker instead of array of trackers
* Defect #16747: Remove useless settings when editing a query from the gantt * Defect #16747: Remove useless settings when editing a query from the gantt
* Defect #16755: Field set as read-only still available in the issues list context menu * Defect #16755: Field set as read-only still available in the issues list context menu
......
...@@ -598,6 +598,10 @@ module Redmine ...@@ -598,6 +598,10 @@ module Redmine
@target_class ||= self.class.name[/^(.*::)?(.+)Format$/, 2].constantize rescue nil @target_class ||= self.class.name[/^(.*::)?(.+)Format$/, 2].constantize rescue nil
end end
def reset_target_class
@target_class = nil
end
def possible_custom_value_options(custom_value) def possible_custom_value_options(custom_value)
options = possible_values_options(custom_value.custom_field, custom_value.customized) options = possible_values_options(custom_value.custom_field, custom_value.customized)
missing = [custom_value.value_was].flatten.reject(&:blank?) - options.map(&:last) missing = [custom_value.value_was].flatten.reject(&:blank?) - options.map(&:last)
......
...@@ -178,6 +178,14 @@ module ObjectHelpers ...@@ -178,6 +178,14 @@ module ObjectHelpers
changeset.save! changeset.save!
changeset changeset
end end
def Query.generate!(attributes={})
query = new(attributes)
query.name = "Generated query" if query.name.blank?
query.user ||= User.find(1)
query.save!
query
end
end end
module IssueObjectHelpers module IssueObjectHelpers
......
...@@ -42,16 +42,23 @@ class ProjectsHelperTest < ActionView::TestCase ...@@ -42,16 +42,23 @@ class ProjectsHelperTest < ActionView::TestCase
def test_link_to_version_within_project def test_link_to_version_within_project
@project = Project.find(2) @project = Project.find(2)
User.current = User.find(1) User.current = User.find(1)
assert_equal '<a href="/versions/5">Alpha</a>', link_to_version(Version.find(5)) assert_equal '<a href="/versions/5" title="07/01/2006">Alpha</a>', link_to_version(Version.find(5))
end end
def test_link_to_version def test_link_to_version
User.current = User.find(1) User.current = User.find(1)
assert_equal '<a href="/versions/5">OnlineStore - Alpha</a>', link_to_version(Version.find(5)) assert_equal '<a href="/versions/5" title="07/01/2006">Alpha</a>', link_to_version(Version.find(5))
end
def test_link_to_version_without_effective_date
User.current = User.find(1)
version = Version.find(5)
version.effective_date = nil
assert_equal '<a href="/versions/5">Alpha</a>', link_to_version(version)
end end
def test_link_to_private_version def test_link_to_private_version
assert_equal 'OnlineStore - Alpha', link_to_version(Version.find(5)) assert_equal 'Alpha', link_to_version(Version.find(5))
end end
def test_link_to_version_invalid_version def test_link_to_version_invalid_version
...@@ -64,11 +71,20 @@ class ProjectsHelperTest < ActionView::TestCase ...@@ -64,11 +71,20 @@ class ProjectsHelperTest < ActionView::TestCase
end end
def test_format_version_name def test_format_version_name
assert_equal "eCookbook - 0.1", format_version_name(Version.find(1)) assert_equal "0.1", format_version_name(Version.find(1))
end
def test_format_version_name_for_shared_version_within_project_should_not_display_project_name
@project = Project.find(1)
version = Version.find(1)
version.sharing = 'system'
assert_equal "0.1", format_version_name(version)
end end
def test_format_version_name_for_system_version def test_format_version_name_for_shared_version_should_display_project_name
assert_equal "OnlineStore - Systemwide visible version", format_version_name(Version.find(7)) version = Version.find(1)
version.sharing = 'system'
assert_equal "eCookbook - 0.1", format_version_name(version)
end end
def test_version_options_for_select_with_no_versions def test_version_options_for_select_with_no_versions
......
...@@ -222,6 +222,17 @@ class ProjectCopyTest < ActiveSupport::TestCase ...@@ -222,6 +222,17 @@ class ProjectCopyTest < ActiveSupport::TestCase
assert_equal @source_project.queries.map(&:user_id).sort, @project.queries.map(&:user_id).sort assert_equal @source_project.queries.map(&:user_id).sort, @project.queries.map(&:user_id).sort
end end
def test_copy_should_copy_queries_roles_visibility
source = Project.generate!
target = Project.new(:name => 'Copy Test', :identifier => 'copy-test')
IssueQuery.generate!(:project => source, :visibility => Query::VISIBILITY_ROLES, :roles => Role.where(:id => [1, 3]).to_a)
assert target.copy(source)
assert_equal 1, target.queries.size
query = target.queries.first
assert_equal [1, 3], query.role_ids.sort
end
test "#copy should copy versions" do test "#copy should copy versions" do
@source_project.versions << Version.generate! @source_project.versions << Version.generate!
@source_project.versions << Version.generate! @source_project.versions << Version.generate!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment