]> source.dussan.org Git - redmine.git/commitdiff
Merged bug fixes r3402, r3405 to r3408 from trunk.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 14 Feb 2010 15:48:28 +0000 (15:48 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 14 Feb 2010 15:48:28 +0000 (15:48 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3431 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/projects_controller.rb
app/models/project.rb
app/models/repository.rb
app/views/issues/gantt.rhtml
test/unit/project_test.rb

index e908388ee94c37ddcd502f1db52476186162e79c..ec22e2206edcca24a89d6cd69e6f02098d3ca12a 100644 (file)
@@ -320,13 +320,9 @@ class ProjectsController < ApplicationController
     @issues_by_version = {}
     unless @selected_tracker_ids.empty?
       @versions.each do |version|
-        conditions = {:tracker_id => @selected_tracker_ids}
-        if !@project.versions.include?(version)
-          conditions.merge!(:project_id => project_ids)
-        end
         issues = version.fixed_issues.visible.find(:all,
                                                    :include => [:project, :status, :tracker, :priority],
-                                                   :conditions => conditions,
+                                                   :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids},
                                                    :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id")
         @issues_by_version[version] = issues
       end
index b8030d7fd9345c1cc4cb74dff7ff6ca7958adef8..58ef811400ab78a021bae244820e183dffbffe37 100644 (file)
@@ -249,7 +249,7 @@ class Project < ActiveRecord::Base
     return @allowed_parents if @allowed_parents
     @allowed_parents = Project.find(:all, :conditions => Project.allowed_to_condition(User.current, :add_subprojects))
     @allowed_parents = @allowed_parents - self_and_descendants
-    if User.current.allowed_to?(:add_project, nil, :global => true)
+    if User.current.allowed_to?(:add_project, nil, :global => true) || (!new_record? && parent.nil?)
       @allowed_parents << nil
     end
     unless parent.nil? || @allowed_parents.empty? || @allowed_parents.include?(parent)
index 9f0861b1ac2a14e5b48b26c64ed9f2fa975ee77b..da1168dfd4e28ac454834f43eabf7a8a1e8ac220 100644 (file)
@@ -159,11 +159,15 @@ class Repository < ActiveRecord::Base
     end
   end
   
-  # fetch new changesets for all repositories
-  # can be called periodically by an external script
+  # Fetches new changesets for all repositories of active projects
+  # Can be called periodically by an external script
   # eg. ruby script/runner "Repository.fetch_changesets"
   def self.fetch_changesets
-    find(:all).each(&:fetch_changesets)
+    Project.active.has_module(:repository).find(:all, :include => :repository).each do |project|
+      if project.repository
+        project.repository.fetch_changesets
+      end
+    end
   end
   
   # scan changeset comments to find related and fixed issues for all repositories
index ce317ea80e42e0108e1fdfdd9d39e9e206125b97..8d6677d9c3681162bd1e2732215fc10794bb1361 100644 (file)
@@ -86,7 +86,6 @@ top = headers_height + 8
        <%= link_to_issue i %>
        <% else %>
                <span class="icon icon-package">
-               <%= h("#{i.project} -") unless @project && @project == i.project %>
                <%= link_to_version i %>
                </span>
        <% end %>       
@@ -211,8 +210,7 @@ top = headers_height + 10
     %>
     <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone">&nbsp;</div>
        <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
-               <%= h("#{i.project} -") unless @project && @project == i.project %>
-               <strong><%=h i %></strong>
+               <strong><%= format_version_name i %></strong>
        </div>
 <% end %>
        <% top = top + 20
index c1fc84330e5e39437f2275e8b2579a704b3955a0..3bf32d972016c3975cb590d741226867053dfd4c 100644 (file)
@@ -285,6 +285,48 @@ class ProjectTest < ActiveSupport::TestCase
     assert Project.new.allowed_parents.compact.empty?
   end
   
+  def test_allowed_parents_with_add_subprojects_permission
+    Role.find(1).remove_permission!(:add_project)
+    Role.find(1).add_permission!(:add_subprojects)
+    User.current = User.find(2)
+    # new project
+    assert !Project.new.allowed_parents.include?(nil)
+    assert Project.new.allowed_parents.include?(Project.find(1))
+    # existing root project
+    assert Project.find(1).allowed_parents.include?(nil)
+    # existing child
+    assert Project.find(3).allowed_parents.include?(Project.find(1))
+    assert !Project.find(3).allowed_parents.include?(nil)
+  end
+
+  def test_allowed_parents_with_add_project_permission
+    Role.find(1).add_permission!(:add_project)
+    Role.find(1).remove_permission!(:add_subprojects)
+    User.current = User.find(2)
+    # new project
+    assert Project.new.allowed_parents.include?(nil)
+    assert !Project.new.allowed_parents.include?(Project.find(1))
+    # existing root project
+    assert Project.find(1).allowed_parents.include?(nil)
+    # existing child
+    assert Project.find(3).allowed_parents.include?(Project.find(1))
+    assert Project.find(3).allowed_parents.include?(nil)
+  end
+
+  def test_allowed_parents_with_add_project_and_subprojects_permission
+    Role.find(1).add_permission!(:add_project)
+    Role.find(1).add_permission!(:add_subprojects)
+    User.current = User.find(2)
+    # new project
+    assert Project.new.allowed_parents.include?(nil)
+    assert Project.new.allowed_parents.include?(Project.find(1))
+    # existing root project
+    assert Project.find(1).allowed_parents.include?(nil)
+    # existing child
+    assert Project.find(3).allowed_parents.include?(Project.find(1))
+    assert Project.find(3).allowed_parents.include?(nil)
+  end
+  
   def test_users_by_role
     users_by_role = Project.find(1).users_by_role
     assert_kind_of Hash, users_by_role