Project

General

Profile

Defect #18174 ยป rm18174-reintegrate_commits_on_trunk_reverted_by_r13482_merge-trunk_r13503.patch

Mischa The Evil, 2014-10-24 08:30

View differences:

app/helpers/application_helper.rb (working copy)
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 181
    when 'Project'
175 182
      html ? link_to_project(object) : object.to_s
176 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 185
    when 'TrueClass'
179 186
      l(:general_text_Yes)
180 187
    when 'FalseClass'
......
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}")
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)
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
app/models/project.rb (working copy)
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
app/models/user.rb (working copy)
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
app/models/version.rb (working copy)
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
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
doc/CHANGELOG (working copy)
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
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!
    (1-1/1)