##// END OF EJS Templates
Restores commits reverted when rails-4.1 branch was merged (#18174)....
Jean-Philippe Lang -
r13122:67c4936908e6
parent child
Show More
@@ -153,6 +153,13 module ApplicationHelper
153 end
153 end
154 end
154 end
155
155
156 # Generates a link to a version
157 def link_to_version(version, options = {})
158 return '' unless version && version.is_a?(Version)
159 options = {:title => format_date(version.effective_date)}.merge(options)
160 link_to_if version.visible?, format_version_name(version), version_path(version), options
161 end
162
156 # Helper that formats object for html or text rendering
163 # Helper that formats object for html or text rendering
157 def format_object(object, html=true, &block)
164 def format_object(object, html=true, &block)
158 if block_given?
165 if block_given?
@@ -174,7 +181,7 module ApplicationHelper
174 when 'Project'
181 when 'Project'
175 html ? link_to_project(object) : object.to_s
182 html ? link_to_project(object) : object.to_s
176 when 'Version'
183 when 'Version'
177 html ? link_to(object.name, version_path(object)) : object.to_s
184 html ? link_to_version(object) : object.to_s
178 when 'TrueClass'
185 when 'TrueClass'
179 l(:general_text_Yes)
186 l(:general_text_Yes)
180 when 'FalseClass'
187 when 'FalseClass'
@@ -236,7 +243,7 module ApplicationHelper
236 end
243 end
237
244
238 def format_version_name(version)
245 def format_version_name(version)
239 if version.project == @project
246 if !version.shared? || version.project == @project
240 h(version)
247 h(version)
241 else
248 else
242 h("#{version.project} - #{version}")
249 h("#{version.project} - #{version}")
@@ -18,11 +18,6
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
20 module ProjectsHelper
20 module ProjectsHelper
21 def link_to_version(version, options = {})
22 return '' unless version && version.is_a?(Version)
23 link_to_if version.visible?, format_version_name(version), version_path(version), options
24 end
25
26 def project_settings_tabs
21 def project_settings_tabs
27 tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
22 tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
28 {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
23 {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
@@ -1132,7 +1132,6 class Issue < ActiveRecord::Base
1132 def parent_issue_id=(arg)
1132 def parent_issue_id=(arg)
1133 s = arg.to_s.strip.presence
1133 s = arg.to_s.strip.presence
1134 if s && (m = s.match(%r{\A#?(\d+)\z})) && (@parent_issue = Issue.find_by_id(m[1]))
1134 if s && (m = s.match(%r{\A#?(\d+)\z})) && (@parent_issue = Issue.find_by_id(m[1]))
1135 @parent_issue.id
1136 @invalid_parent_issue_id = nil
1135 @invalid_parent_issue_id = nil
1137 elsif s.blank?
1136 elsif s.blank?
1138 @parent_issue = nil
1137 @parent_issue = nil
@@ -962,10 +962,11 class Project < ActiveRecord::Base
962 def copy_queries(project)
962 def copy_queries(project)
963 project.queries.each do |query|
963 project.queries.each do |query|
964 new_query = IssueQuery.new
964 new_query = IssueQuery.new
965 new_query.attributes = query.attributes.dup.except("id", "project_id", "sort_criteria")
965 new_query.attributes = query.attributes.dup.except("id", "project_id", "sort_criteria", "user_id", "type")
966 new_query.sort_criteria = query.sort_criteria if query.sort_criteria
966 new_query.sort_criteria = query.sort_criteria if query.sort_criteria
967 new_query.project = self
967 new_query.project = self
968 new_query.user_id = query.user_id
968 new_query.user_id = query.user_id
969 new_query.role_ids = query.role_ids if query.visibility == IssueQuery::VISIBILITY_ROLES
969 self.queries << new_query
970 self.queries << new_query
970 end
971 end
971 end
972 end
@@ -722,17 +722,17 class User < Principal
722 return if self.id.nil?
722 return if self.id.nil?
723
723
724 substitute = User.anonymous
724 substitute = User.anonymous
725 Attachment.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
725 Attachment.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
726 Comment.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
726 Comment.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
727 Issue.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
727 Issue.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
728 Issue.where(['assigned_to_id = ?', id]).update_all('assigned_to_id = NULL')
728 Issue.where(['assigned_to_id = ?', id]).update_all('assigned_to_id = NULL')
729 Journal.where(['user_id = ?', id]).update_all(['user_id = ?', substitute.id])
729 Journal.where(['user_id = ?', id]).update_all(['user_id = ?', substitute.id])
730 JournalDetail.
730 JournalDetail.
731 where(["property = 'attr' AND prop_key = 'assigned_to_id' AND old_value = ?", id.to_s]).
731 where(["property = 'attr' AND prop_key = 'assigned_to_id' AND old_value = ?", id.to_s]).
732 update_all(['old_value = ?', substitute.id.to_s])
732 update_all(['old_value = ?', substitute.id.to_s])
733 JournalDetail.
733 JournalDetail.
734 where(["property = 'attr' AND prop_key = 'assigned_to_id' AND value = ?", id.to_s]).
734 where(["property = 'attr' AND prop_key = 'assigned_to_id' AND value = ?", id.to_s]).
735 update_all(['value = ?', substitute.id.to_s])
735 update_all(['value = ?', substitute.id.to_s])
736 Message.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
736 Message.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
737 News.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
737 News.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
738 # Remove private queries and keep public ones
738 # Remove private queries and keep public ones
@@ -220,6 +220,11 class Version < ActiveRecord::Base
220 end
220 end
221 end
221 end
222
222
223 # Returns true if the version is shared, otherwise false
224 def shared?
225 sharing != 'none'
226 end
227
223 private
228 private
224
229
225 def load_issue_counts
230 def load_issue_counts
@@ -8,8 +8,8
8 <% end -%>
8 <% end -%>
9 </ul>
9 </ul>
10 <div class="tabs-buttons" style="display:none;">
10 <div class="tabs-buttons" style="display:none;">
11 <button class="tab-left" onclick="moveTabLeft(this); return false;"></button>
11 <button class="tab-left" type="button" onclick="moveTabLeft(this);"></button>
12 <button class="tab-right" onclick="moveTabRight(this); return false;"></button>
12 <button class="tab-right" type="button" onclick="moveTabRight(this);"></button>
13 </div>
13 </div>
14 </div>
14 </div>
15
15
@@ -22,3 +22,9 Redmine::Plugin.load
22 unless Redmine::Configuration['mirror_plugins_assets_on_startup'] == false
22 unless Redmine::Configuration['mirror_plugins_assets_on_startup'] == false
23 Redmine::Plugin.mirror_assets
23 Redmine::Plugin.mirror_assets
24 end
24 end
25
26 Rails.application.config.to_prepare do
27 Redmine::FieldFormat::RecordList.subclasses.each do |klass|
28 klass.instance.reset_target_class
29 end
30 end No newline at end of file
@@ -86,7 +86,7 http://www.redmine.org/
86 * Defect #16655: start_date not set despite settings[default_issue_start_date_to_creation_date] being set.
86 * Defect #16655: start_date not set despite settings[default_issue_start_date_to_creation_date] being set.
87 * Defect #16668: Redmine links broken when object name contains special characters
87 * Defect #16668: Redmine links broken when object name contains special characters
88 * Defect #16669: Markdown formatter should use the :no_intra_emphasis extension
88 * Defect #16669: Markdown formatter should use the :no_intra_emphasis extension
89 * Defect #16708: Form is submitted when swithing tab
89 * Defect #16708: Form is submitted when switching tab
90 * Defect #16739: custom_fields.json only returns single tracker instead of array of trackers
90 * Defect #16739: custom_fields.json only returns single tracker instead of array of trackers
91 * Defect #16747: Remove useless settings when editing a query from the gantt
91 * Defect #16747: Remove useless settings when editing a query from the gantt
92 * Defect #16755: Field set as read-only still available in the issues list context menu
92 * Defect #16755: Field set as read-only still available in the issues list context menu
@@ -597,6 +597,10 module Redmine
597 def target_class
597 def target_class
598 @target_class ||= self.class.name[/^(.*::)?(.+)Format$/, 2].constantize rescue nil
598 @target_class ||= self.class.name[/^(.*::)?(.+)Format$/, 2].constantize rescue nil
599 end
599 end
600
601 def reset_target_class
602 @target_class = nil
603 end
600
604
601 def possible_custom_value_options(custom_value)
605 def possible_custom_value_options(custom_value)
602 options = possible_values_options(custom_value.custom_field, custom_value.customized)
606 options = possible_values_options(custom_value.custom_field, custom_value.customized)
@@ -178,6 +178,14 module ObjectHelpers
178 changeset.save!
178 changeset.save!
179 changeset
179 changeset
180 end
180 end
181
182 def Query.generate!(attributes={})
183 query = new(attributes)
184 query.name = "Generated query" if query.name.blank?
185 query.user ||= User.find(1)
186 query.save!
187 query
188 end
181 end
189 end
182
190
183 module IssueObjectHelpers
191 module IssueObjectHelpers
@@ -42,16 +42,23 class ProjectsHelperTest < ActionView::TestCase
42 def test_link_to_version_within_project
42 def test_link_to_version_within_project
43 @project = Project.find(2)
43 @project = Project.find(2)
44 User.current = User.find(1)
44 User.current = User.find(1)
45 assert_equal '<a href="/versions/5">Alpha</a>', link_to_version(Version.find(5))
45 assert_equal '<a href="/versions/5" title="07/01/2006">Alpha</a>', link_to_version(Version.find(5))
46 end
46 end
47
47
48 def test_link_to_version
48 def test_link_to_version
49 User.current = User.find(1)
49 User.current = User.find(1)
50 assert_equal '<a href="/versions/5">OnlineStore - Alpha</a>', link_to_version(Version.find(5))
50 assert_equal '<a href="/versions/5" title="07/01/2006">Alpha</a>', link_to_version(Version.find(5))
51 end
52
53 def test_link_to_version_without_effective_date
54 User.current = User.find(1)
55 version = Version.find(5)
56 version.effective_date = nil
57 assert_equal '<a href="/versions/5">Alpha</a>', link_to_version(version)
51 end
58 end
52
59
53 def test_link_to_private_version
60 def test_link_to_private_version
54 assert_equal 'OnlineStore - Alpha', link_to_version(Version.find(5))
61 assert_equal 'Alpha', link_to_version(Version.find(5))
55 end
62 end
56
63
57 def test_link_to_version_invalid_version
64 def test_link_to_version_invalid_version
@@ -64,11 +71,20 class ProjectsHelperTest < ActionView::TestCase
64 end
71 end
65
72
66 def test_format_version_name
73 def test_format_version_name
67 assert_equal "eCookbook - 0.1", format_version_name(Version.find(1))
74 assert_equal "0.1", format_version_name(Version.find(1))
75 end
76
77 def test_format_version_name_for_shared_version_within_project_should_not_display_project_name
78 @project = Project.find(1)
79 version = Version.find(1)
80 version.sharing = 'system'
81 assert_equal "0.1", format_version_name(version)
68 end
82 end
69
83
70 def test_format_version_name_for_system_version
84 def test_format_version_name_for_shared_version_should_display_project_name
71 assert_equal "OnlineStore - Systemwide visible version", format_version_name(Version.find(7))
85 version = Version.find(1)
86 version.sharing = 'system'
87 assert_equal "eCookbook - 0.1", format_version_name(version)
72 end
88 end
73
89
74 def test_version_options_for_select_with_no_versions
90 def test_version_options_for_select_with_no_versions
@@ -222,6 +222,17 class ProjectCopyTest < ActiveSupport::TestCase
222 assert_equal @source_project.queries.map(&:user_id).sort, @project.queries.map(&:user_id).sort
222 assert_equal @source_project.queries.map(&:user_id).sort, @project.queries.map(&:user_id).sort
223 end
223 end
224
224
225 def test_copy_should_copy_queries_roles_visibility
226 source = Project.generate!
227 target = Project.new(:name => 'Copy Test', :identifier => 'copy-test')
228 IssueQuery.generate!(:project => source, :visibility => Query::VISIBILITY_ROLES, :roles => Role.where(:id => [1, 3]).to_a)
229
230 assert target.copy(source)
231 assert_equal 1, target.queries.size
232 query = target.queries.first
233 assert_equal [1, 3], query.role_ids.sort
234 end
235
225 test "#copy should copy versions" do
236 test "#copy should copy versions" do
226 @source_project.versions << Version.generate!
237 @source_project.versions << Version.generate!
227 @source_project.versions << Version.generate!
238 @source_project.versions << Version.generate!
General Comments 0
You need to be logged in to leave comments. Login now