Patch #40008 » delete-prefix-suffix.patch
app/controllers/repositories_controller.rb | ||
---|---|---|
230 | 230 |
# Adds a related issue to a changeset |
231 | 231 |
# POST /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues |
232 | 232 |
def add_related_issue |
233 |
issue_id = params[:issue_id].to_s.sub(/^#/, '')
|
|
233 |
issue_id = params[:issue_id].to_s.delete_prefix('#')
|
|
234 | 234 |
@issue = @changeset.find_referenced_issue_by_id(issue_id) |
235 | 235 |
if @issue && (!@issue.visible? || @changeset.issues.include?(@issue)) |
236 | 236 |
@issue = nil |
app/controllers/workflows_controller.rb | ||
---|---|---|
58 | 58 | |
59 | 59 |
def permissions |
60 | 60 |
if @roles && @trackers |
61 |
@fields = (Tracker::CORE_FIELDS_ALL - @trackers.map(&:disabled_core_fields).reduce(:&)).map {|field| [field, l("field_"+field.sub(/_id$/, ''))]} |
|
61 |
@fields = (Tracker::CORE_FIELDS_ALL - @trackers.map(&:disabled_core_fields).reduce(:&)).map do |field| |
|
62 |
[field, l("field_#{field.delete_suffix('_id')}")] |
|
63 |
end |
|
62 | 64 |
@custom_fields = @trackers.map(&:custom_fields).flatten.uniq.sort |
63 | 65 |
@permissions = WorkflowPermission.rules_by_status_id(@trackers, @roles) |
64 | 66 |
@statuses.each {|status| @permissions[status.id] ||= {}} |
app/models/issue_query.rb | ||
---|---|---|
328 | 328 |
:sortable => "#{Issue.table_name}.is_private", :groupable => true) |
329 | 329 |
end |
330 | 330 | |
331 |
disabled_fields = Tracker.disabled_core_fields(trackers).map {|field| field.sub(/_id$/, '')}
|
|
331 |
disabled_fields = Tracker.disabled_core_fields(trackers).map {|field| field.delete_suffix('_id')}
|
|
332 | 332 |
disabled_fields << "total_estimated_hours" if disabled_fields.include?("estimated_hours") |
333 | 333 |
@available_columns.reject! do |column| |
334 | 334 |
disabled_fields.include?(column.name.to_s) |
... | ... | |
479 | 479 |
def sql_for_notes_field(field, operator, value) |
480 | 480 |
subquery = "SELECT 1 FROM #{Journal.table_name}" + |
481 | 481 |
" WHERE #{Journal.table_name}.journalized_type='Issue' AND #{Journal.table_name}.journalized_id=#{Issue.table_name}.id" + |
482 |
" AND (#{sql_for_field field, operator.sub(/^!/, ''), value, Journal.table_name, 'notes'})" +
|
|
482 |
" AND (#{sql_for_field field, operator.delete_prefix('!'), value, Journal.table_name, 'notes'})" +
|
|
483 | 483 |
" AND (#{Journal.visible_notes_condition(User.current, :skip_pre_condition => true)})" |
484 | 484 |
"#{/^!/.match?(operator) ? "NOT EXISTS" : "EXISTS"} (#{subquery})" |
485 | 485 |
end |
app/views/trackers/_form.html.erb | ||
---|---|---|
17 | 17 |
<% Tracker::CORE_FIELDS.each do |field| %> |
18 | 18 |
<label class="block"> |
19 | 19 |
<%= check_box_tag 'tracker[core_fields][]', field, @tracker.core_fields.include?(field), :id => nil %> |
20 |
<%= l("field_#{field}".sub(/_id$/, '')) %>
|
|
20 |
<%= l("field_#{field}".delete_suffix('_id')) %>
|
|
21 | 21 |
</label> |
22 | 22 |
<% end %> |
23 | 23 |
</p> |
app/views/trackers/fields.html.erb | ||
---|---|---|
26 | 26 |
</tr> |
27 | 27 |
<% Tracker::CORE_FIELDS.each do |field| %> |
28 | 28 |
<tr> |
29 |
<% field_name = l("field_#{field}".sub(/_id$/, '')) %>
|
|
29 |
<% field_name = l("field_#{field}".delete_suffix('_id')) %>
|
|
30 | 30 |
<td class="name"> |
31 | 31 |
<%= link_to_function('', "toggleCheckboxesBySelector('input.core-field-#{field}')", |
32 | 32 |
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}", |
config/initializers/10-patches.rb | ||
---|---|---|
4 | 4 |
class Base |
5 | 5 |
# Translate attribute names for validation errors display |
6 | 6 |
def self.human_attribute_name(attr, options = {}) |
7 |
prepared_attr = attr.to_s.sub(/_id$/, '').sub(/^.+\./, '')
|
|
7 |
prepared_attr = attr.to_s.delete_suffix('_id').sub(/^.+\./, '')
|
|
8 | 8 |
class_prefix = name.underscore.tr('/', '_') |
9 | 9 | |
10 | 10 |
redmine_default = [ |
lib/redmine/diff_table.rb | ||
---|---|---|
91 | 91 |
if both_git_diff |
92 | 92 |
if file_name && arg == "/dev/null" |
93 | 93 |
# keep the original file name |
94 |
@file_name = file_name.sub(%r{^a/}, '')
|
|
94 |
@file_name = file_name.delete_prefix('a/')
|
|
95 | 95 |
else |
96 | 96 |
# remove leading a/ |
97 |
@previous_file_name = file_name.sub(%r{^a/}, '') unless file_name == "/dev/null"
|
|
97 |
@previous_file_name = file_name.delete_prefix('a/') unless file_name == "/dev/null"
|
|
98 | 98 |
# remove leading b/ |
99 |
@file_name = arg.sub(%r{^b/}, '')
|
|
99 |
@file_name = arg.delete_prefix('b/')
|
|
100 | 100 | |
101 | 101 |
@previous_file_name = nil if @previous_file_name == @file_name |
102 | 102 |
end |
test/functional/custom_fields_controller_test.rb | ||
---|---|---|
596 | 596 |
def custom_field_classes |
597 | 597 |
files = |
598 | 598 |
Dir.glob(File.join(Rails.root, 'app/models/*_custom_field.rb')). |
599 |
map {|f| File.basename(f).sub(/\.rb$/, '')}
|
|
599 |
map {|f| File.basename(f).delete_suffix('.rb')}
|
|
600 | 600 |
classes = files.map {|x| x.classify.constantize} |
601 | 601 |
assert classes.size > 0 |
602 | 602 |
classes |