Project

General

Profile

Patch #18134 » 5. merge-missing-in-41-from-trunk_to_rails-4.1_at_r13451.patch

Mischa The Evil, 2014-10-20 06:05

View differences:

app/helpers/application_helper.rb (working copy)
155 155
    end
156 156
  end
157 157

  
158
  # Generates a link to a version
159
  def link_to_version(version, options = {})
160
    return '' unless version && version.is_a?(Version)
161
    options = {:title => format_date(version.effective_date)}.merge(options)
162
    link_to_if version.visible?, format_version_name(version), version_path(version), options
163
  end
164

  
158 165
  # Helper that formats object for html or text rendering
159 166
  def format_object(object, html=true, &block)
160 167
    if block_given?
......
176 183
    when 'Project'
177 184
      html ? link_to_project(object) : object.to_s
178 185
    when 'Version'
179
      html ? link_to(object.name, version_path(object)) : object.to_s
186
      html ? link_to_version(object) : object.to_s
180 187
    when 'TrueClass'
181 188
      l(:general_text_Yes)
182 189
    when 'FalseClass'
......
238 245
  end
239 246

  
240 247
  def format_version_name(version)
241
    if version.project == @project
248
    if !version.shared? || version.project == @project
242 249
      h(version)
243 250
    else
244 251
      h("#{version.project} - #{version}")
app/helpers/projects_helper.rb (working copy)
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},
app/models/issue.rb (working copy)
1136 1136
  def parent_issue_id=(arg)
1137 1137
    s = arg.to_s.strip.presence
1138 1138
    if s && (m = s.match(%r{\A#?(\d+)\z})) && (@parent_issue = Issue.find_by_id(m[1]))
1139
      @parent_issue.id
1140 1139
      @invalid_parent_issue_id = nil
1141 1140
    elsif s.blank?
1142 1141
      @parent_issue = nil
app/models/project.rb (working copy)
969 969
  def copy_queries(project)
970 970
    project.queries.each do |query|
971 971
      new_query = IssueQuery.new
972
      new_query.attributes = query.attributes.dup.except("id", "project_id", "sort_criteria")
972
      new_query.attributes = query.attributes.dup.except("id", "project_id", "sort_criteria", "user_id", "type")
973 973
      new_query.sort_criteria = query.sort_criteria if query.sort_criteria
974 974
      new_query.project = self
975 975
      new_query.user_id = query.user_id
976
      new_query.role_ids = query.role_ids if query.visibility == IssueQuery::VISIBILITY_ROLES
976 977
      self.queries << new_query
977 978
    end
978 979
  end
app/models/user.rb (working copy)
727 727
    return if self.id.nil?
728 728

  
729 729
    substitute = User.anonymous
730
    Attachment.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) 
730
    Attachment.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
731 731
    Comment.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
732 732
    Issue.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
733 733
    Issue.where(['assigned_to_id = ?', id]).update_all('assigned_to_id = NULL')
734
    Journal.where(['user_id = ?', id]).update_all(['user_id = ?', substitute.id]) 
734
    Journal.where(['user_id = ?', id]).update_all(['user_id = ?', substitute.id])
735 735
    JournalDetail.
736 736
      where(["property = 'attr' AND prop_key = 'assigned_to_id' AND old_value = ?", id.to_s]).
737 737
      update_all(['old_value = ?', substitute.id.to_s])
738 738
    JournalDetail.
739 739
      where(["property = 'attr' AND prop_key = 'assigned_to_id' AND value = ?", id.to_s]).
740
      update_all(['value = ?', substitute.id.to_s]) 
740
      update_all(['value = ?', substitute.id.to_s])
741 741
    Message.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
742 742
    News.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id])
743 743
    # Remove private queries and keep public ones
app/models/version.rb (working copy)
233 233
    end
234 234
  end
235 235

  
236
  # Returns true if the version is shared, otherwise false
237
  def shared?
238
    sharing != 'none'
239
  end
240

  
236 241
  private
237 242

  
238 243
  def load_issue_counts
app/views/common/_tabs.html.erb (working copy)
8 8
  <% end -%>
9 9
  </ul>
10 10
  <div class="tabs-buttons" style="display:none;">
11
    <button class="tab-left" onclick="moveTabLeft(this); return false;"></button>
12
    <button class="tab-right" onclick="moveTabRight(this); return false;"></button>
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

  
config/initializers/30-redmine.rb (working copy)
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
config/locales/bg.yml (working copy)
914 914
  label_only: само
915 915
  label_drop_down_list: drop-down списък
916 916
  label_checkboxes: чек-бокс
917
  label_radio_buttons: радио-бутони
917 918
  label_link_values_to: URL (опция)
918 919
  label_custom_field_select_type: "Изберете тип на обект, към който потребителското поле да бъде асоциирано"
919 920
  label_check_for_updates: Проверка за нови версии
......
1111 1112
  description_date_from: Въведете начална дата
1112 1113
  description_date_to: Въведете крайна дата
1113 1114
  text_repository_identifier_info: 'Позволени са малки букви (a-z), цифри, тирета и _.<br />Промяна след създаването му не е възможна.'
1114
  label_radio_buttons: radio buttons
config/locales/de.yml (working copy)
684 684
  label_query: Benutzerdefinierte Abfrage
685 685
  label_query_new: Neue Abfrage
686 686
  label_query_plural: Benutzerdefinierte Abfragen
687
  label_radio_buttons: Radio-Buttons
687 688
  label_read: Lesen...
688 689
  label_readonly: Nur-Lese-Zugriff
689 690
  label_register: Registrieren
......
1124 1125
  version_status_open: offen
1125 1126

  
1126 1127
  warning_attachments_not_saved: "%{count} Datei(en) konnten nicht gespeichert werden."
1127
  label_radio_buttons: radio buttons
1128 1128
  label_group_anonymous: Anonymous users
1129 1129
  label_group_non_member: Non member users
config/locales/ja.yml (working copy)
249 249
  field_is_for_all: 全プロジェクト向け
250 250
  field_possible_values: 選択肢
251 251
  field_regexp: 正規表現
252
  field_min_length: 最小値
253
  field_max_length: 最大
252
  field_min_length: 最短長
253
  field_max_length: 最大
254 254
  field_value: 値
255 255
  field_category: カテゴリ
256 256
  field_title: タイトル
......
305 305
  field_activity: 活動
306 306
  field_spent_on: 日付
307 307
  field_identifier: 識別子
308
  field_is_filter: フィルタとして使
308
  field_is_filter: フィルタとして使
309 309
  field_issue_to: 関連するチケット
310 310
  field_delay: 遅延
311 311
  field_assignable: このロールにチケットを割り当て可能
......
314 314
  field_column_names: 項目
315 315
  field_time_entries: 時間を記録
316 316
  field_time_zone: タイムゾーン
317
  field_searchable: 検索条件に設定可能とする
317
  field_searchable: 検索対象
318 318
  field_default_value: デフォルト値
319 319
  field_comments_sorting: コメントの表示順
320 320
  field_parent_title: 親ページ
......
541 541
  label_subproject_plural: サブプロジェクト
542 542
  label_subproject_new: 新しいサブプロジェクト
543 543
  label_and_its_subprojects: "%{value} とサブプロジェクト"
544
  label_min_max_length: 最小値 - 最大値の長さ
544
  label_min_max_length: 最短 - 最大長
545 545
  label_list: リストから選択
546 546
  label_date: 日付
547 547
  label_integer: 整数
config/locales/zh-TW.yml (working copy)
996 996
  label_only: 僅於
997 997
  label_drop_down_list: 下拉式清單
998 998
  label_checkboxes: 核取方塊
999
  label_radio_buttons: 選項按鈕
999 1000
  label_link_values_to: 連結欄位值至此網址
1000 1001
  label_custom_field_select_type: 請選擇連結此自訂欄位的物件類型
1001 1002
  label_check_for_updates: 檢查更新
......
1194 1195
  description_date_from: 輸入起始日期
1195 1196
  description_date_to: 輸入結束日期
1196 1197
  text_repository_identifier_info: '僅允許使用小寫英文字母 (a-z), 阿拉伯數字, 虛線與底線。<br />一旦儲存之後, 代碼便無法再次被更改。'
1197
  label_radio_buttons: radio buttons
doc/CHANGELOG (working copy)
14 14
* Defect #16655: start_date not set despite settings[default_issue_start_date_to_creation_date] being set.
15 15
* Defect #16668: Redmine links broken when object name contains special characters
16 16
* Defect #16669: Markdown formatter should use the :no_intra_emphasis extension
17
* Defect #16708: Form is submitted when swithing tab
17
* Defect #16708: Form is submitted when switching tab
18 18
* Defect #16739: custom_fields.json only returns single tracker instead of array of trackers
19 19
* Defect #16747: Remove useless settings when editing a query from the gantt
20 20
* Defect #16755: Field set as read-only still available in the issues list context menu
lib/redmine/field_format.rb (working copy)
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)
test/object_helpers.rb (working copy)
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
test/unit/helpers/projects_helper_test.rb (working copy)
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">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 51
  end
52 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)
58
  end
59

  
53 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 62
  end
56 63

  
57 64
  def test_link_to_version_invalid_version
......
64 71
  end
65 72

  
66 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))
68 75
  end
69 76

  
70
  def test_format_version_name_for_system_version
71
    assert_equal "OnlineStore - Systemwide visible version", format_version_name(Version.find(7))
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)
72 82
  end
73 83

  
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)
88
  end
89

  
74 90
  def test_version_options_for_select_with_no_versions
75 91
    assert_equal '', version_options_for_select([])
76 92
    assert_equal '', version_options_for_select([], Version.find(1))
test/unit/project_copy_test.rb (working copy)
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!
(5-5/5)