@@ -153,6 +153,13 module ApplicationHelper | |||
|
153 | 153 | end |
|
154 | 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 | 163 | # Helper that formats object for html or text rendering |
|
157 | 164 | def format_object(object, html=true, &block) |
|
158 | 165 | if block_given? |
@@ -174,7 +181,7 module ApplicationHelper | |||
|
174 | 181 | when 'Project' |
|
175 | 182 | html ? link_to_project(object) : object.to_s |
|
176 | 183 | when 'Version' |
|
177 |
html ? link_to(object |
|
|
184 | html ? link_to_version(object) : object.to_s | |
|
178 | 185 | when 'TrueClass' |
|
179 | 186 | l(:general_text_Yes) |
|
180 | 187 | when 'FalseClass' |
@@ -236,7 +243,7 module ApplicationHelper | |||
|
236 | 243 | end |
|
237 | 244 | |
|
238 | 245 | def format_version_name(version) |
|
239 | if version.project == @project | |
|
246 | if !version.shared? || version.project == @project | |
|
240 | 247 | h(version) |
|
241 | 248 | else |
|
242 | 249 | h("#{version.project} - #{version}") |
@@ -18,11 +18,6 | |||
|
18 | 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
19 | 19 | |
|
20 | 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 | 21 | def project_settings_tabs |
|
27 | 22 | tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural}, |
|
28 | 23 | {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural}, |
@@ -1132,7 +1132,6 class Issue < ActiveRecord::Base | |||
|
1132 | 1132 | def parent_issue_id=(arg) |
|
1133 | 1133 | s = arg.to_s.strip.presence |
|
1134 | 1134 | if s && (m = s.match(%r{\A#?(\d+)\z})) && (@parent_issue = Issue.find_by_id(m[1])) |
|
1135 | @parent_issue.id | |
|
1136 | 1135 | @invalid_parent_issue_id = nil |
|
1137 | 1136 | elsif s.blank? |
|
1138 | 1137 | @parent_issue = nil |
@@ -962,10 +962,11 class Project < ActiveRecord::Base | |||
|
962 | 962 | def copy_queries(project) |
|
963 | 963 | project.queries.each do |query| |
|
964 | 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 | 966 | new_query.sort_criteria = query.sort_criteria if query.sort_criteria |
|
967 | 967 | new_query.project = self |
|
968 | 968 | new_query.user_id = query.user_id |
|
969 | new_query.role_ids = query.role_ids if query.visibility == IssueQuery::VISIBILITY_ROLES | |
|
969 | 970 | self.queries << new_query |
|
970 | 971 | end |
|
971 | 972 | end |
@@ -722,17 +722,17 class User < Principal | |||
|
722 | 722 | return if self.id.nil? |
|
723 | 723 | |
|
724 | 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 | 726 | Comment.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) |
|
727 | 727 | Issue.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) |
|
728 | 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 | 730 | JournalDetail. |
|
731 | 731 | where(["property = 'attr' AND prop_key = 'assigned_to_id' AND old_value = ?", id.to_s]). |
|
732 | 732 | update_all(['old_value = ?', substitute.id.to_s]) |
|
733 | 733 | JournalDetail. |
|
734 | 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 | 736 | Message.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) |
|
737 | 737 | News.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) |
|
738 | 738 | # Remove private queries and keep public ones |
@@ -220,6 +220,11 class Version < ActiveRecord::Base | |||
|
220 | 220 | end |
|
221 | 221 | end |
|
222 | 222 | |
|
223 | # Returns true if the version is shared, otherwise false | |
|
224 | def shared? | |
|
225 | sharing != 'none' | |
|
226 | end | |
|
227 | ||
|
223 | 228 | private |
|
224 | 229 | |
|
225 | 230 | def load_issue_counts |
@@ -8,8 +8,8 | |||
|
8 | 8 | <% end -%> |
|
9 | 9 | </ul> |
|
10 | 10 | <div class="tabs-buttons" style="display:none;"> |
|
11 |
<button class="tab-left" onclick="moveTabLeft(this) |
|
|
12 |
<button class="tab-right" onclick="moveTabRight(this) |
|
|
11 | <button class="tab-left" type="button" onclick="moveTabLeft(this);"></button> | |
|
12 | <button class="tab-right" type="button" onclick="moveTabRight(this);"></button> | |
|
13 | 13 | </div> |
|
14 | 14 | </div> |
|
15 | 15 |
@@ -22,3 +22,9 Redmine::Plugin.load | |||
|
22 | 22 | unless Redmine::Configuration['mirror_plugins_assets_on_startup'] == false |
|
23 | 23 | Redmine::Plugin.mirror_assets |
|
24 | 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 | 86 | * Defect #16655: start_date not set despite settings[default_issue_start_date_to_creation_date] being set. |
|
87 | 87 | * Defect #16668: Redmine links broken when object name contains special characters |
|
88 | 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 | 90 | * Defect #16739: custom_fields.json only returns single tracker instead of array of trackers |
|
91 | 91 | * Defect #16747: Remove useless settings when editing a query from the gantt |
|
92 | 92 | * Defect #16755: Field set as read-only still available in the issues list context menu |
@@ -597,6 +597,10 module Redmine | |||
|
597 | 597 | def target_class |
|
598 | 598 | @target_class ||= self.class.name[/^(.*::)?(.+)Format$/, 2].constantize rescue nil |
|
599 | 599 | end |
|
600 | ||
|
601 | def reset_target_class | |
|
602 | @target_class = nil | |
|
603 | end | |
|
600 | 604 | |
|
601 | 605 | def possible_custom_value_options(custom_value) |
|
602 | 606 | options = possible_values_options(custom_value.custom_field, custom_value.customized) |
@@ -178,6 +178,14 module ObjectHelpers | |||
|
178 | 178 | changeset.save! |
|
179 | 179 | changeset |
|
180 | 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 | 189 | end |
|
182 | 190 | |
|
183 | 191 | module IssueObjectHelpers |
@@ -42,16 +42,23 class ProjectsHelperTest < ActionView::TestCase | |||
|
42 | 42 | def test_link_to_version_within_project |
|
43 | 43 | @project = Project.find(2) |
|
44 | 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 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def test_link_to_version |
|
49 | 49 | User.current = User.find(1) |
|
50 |
assert_equal '<a href="/versions/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 | 58 | end |
|
52 | 59 | |
|
53 | 60 | def test_link_to_private_version |
|
54 |
assert_equal ' |
|
|
61 | assert_equal 'Alpha', link_to_version(Version.find(5)) | |
|
55 | 62 | end |
|
56 | 63 | |
|
57 | 64 | def test_link_to_version_invalid_version |
@@ -64,11 +71,20 class ProjectsHelperTest < ActionView::TestCase | |||
|
64 | 71 | end |
|
65 | 72 | |
|
66 | 73 | def test_format_version_name |
|
67 |
assert_equal " |
|
|
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 | 82 | end |
|
69 | 83 | |
|
70 |
def test_format_version_name_for_s |
|
|
71 | assert_equal "OnlineStore - Systemwide visible version", format_version_name(Version.find(7)) | |
|
84 | def test_format_version_name_for_shared_version_should_display_project_name | |
|
85 | version = Version.find(1) | |
|
86 | version.sharing = 'system' | |
|
87 | assert_equal "eCookbook - 0.1", format_version_name(version) | |
|
72 | 88 | end |
|
73 | 89 | |
|
74 | 90 | def test_version_options_for_select_with_no_versions |
@@ -222,6 +222,17 class ProjectCopyTest < ActiveSupport::TestCase | |||
|
222 | 222 | assert_equal @source_project.queries.map(&:user_id).sort, @project.queries.map(&:user_id).sort |
|
223 | 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 | 236 | test "#copy should copy versions" do |
|
226 | 237 | @source_project.versions << Version.generate! |
|
227 | 238 | @source_project.versions << Version.generate! |
General Comments 0
You need to be logged in to leave comments.
Login now