@@ -320,13 +320,9 class ProjectsController < ApplicationController | |||
|
320 | 320 | @issues_by_version = {} |
|
321 | 321 | unless @selected_tracker_ids.empty? |
|
322 | 322 | @versions.each do |version| |
|
323 | conditions = {:tracker_id => @selected_tracker_ids} | |
|
324 | if !@project.versions.include?(version) | |
|
325 | conditions.merge!(:project_id => project_ids) | |
|
326 | end | |
|
327 | 323 | issues = version.fixed_issues.visible.find(:all, |
|
328 | 324 | :include => [:project, :status, :tracker, :priority], |
|
329 |
:conditions => |
|
|
325 | :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids}, | |
|
330 | 326 | :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id") |
|
331 | 327 | @issues_by_version[version] = issues |
|
332 | 328 | end |
@@ -249,7 +249,7 class Project < ActiveRecord::Base | |||
|
249 | 249 | return @allowed_parents if @allowed_parents |
|
250 | 250 | @allowed_parents = Project.find(:all, :conditions => Project.allowed_to_condition(User.current, :add_subprojects)) |
|
251 | 251 | @allowed_parents = @allowed_parents - self_and_descendants |
|
252 | if User.current.allowed_to?(:add_project, nil, :global => true) | |
|
252 | if User.current.allowed_to?(:add_project, nil, :global => true) || (!new_record? && parent.nil?) | |
|
253 | 253 | @allowed_parents << nil |
|
254 | 254 | end |
|
255 | 255 | unless parent.nil? || @allowed_parents.empty? || @allowed_parents.include?(parent) |
@@ -159,11 +159,15 class Repository < ActiveRecord::Base | |||
|
159 | 159 | end |
|
160 | 160 | end |
|
161 | 161 | |
|
162 |
# |
|
|
163 |
# |
|
|
162 | # Fetches new changesets for all repositories of active projects | |
|
163 | # Can be called periodically by an external script | |
|
164 | 164 | # eg. ruby script/runner "Repository.fetch_changesets" |
|
165 | 165 | def self.fetch_changesets |
|
166 | find(:all).each(&:fetch_changesets) | |
|
166 | Project.active.has_module(:repository).find(:all, :include => :repository).each do |project| | |
|
167 | if project.repository | |
|
168 | project.repository.fetch_changesets | |
|
169 | end | |
|
170 | end | |
|
167 | 171 | end |
|
168 | 172 | |
|
169 | 173 | # scan changeset comments to find related and fixed issues for all repositories |
@@ -86,7 +86,6 top = headers_height + 8 | |||
|
86 | 86 | <%= link_to_issue i %> |
|
87 | 87 | <% else %> |
|
88 | 88 | <span class="icon icon-package"> |
|
89 | <%= h("#{i.project} -") unless @project && @project == i.project %> | |
|
90 | 89 | <%= link_to_version i %> |
|
91 | 90 | </span> |
|
92 | 91 | <% end %> |
@@ -211,8 +210,7 top = headers_height + 10 | |||
|
211 | 210 | %> |
|
212 | 211 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone"> </div> |
|
213 | 212 | <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task"> |
|
214 | <%= h("#{i.project} -") unless @project && @project == i.project %> | |
|
215 | <strong><%=h i %></strong> | |
|
213 | <strong><%= format_version_name i %></strong> | |
|
216 | 214 | </div> |
|
217 | 215 | <% end %> |
|
218 | 216 | <% top = top + 20 |
@@ -285,6 +285,48 class ProjectTest < ActiveSupport::TestCase | |||
|
285 | 285 | assert Project.new.allowed_parents.compact.empty? |
|
286 | 286 | end |
|
287 | 287 | |
|
288 | def test_allowed_parents_with_add_subprojects_permission | |
|
289 | Role.find(1).remove_permission!(:add_project) | |
|
290 | Role.find(1).add_permission!(:add_subprojects) | |
|
291 | User.current = User.find(2) | |
|
292 | # new project | |
|
293 | assert !Project.new.allowed_parents.include?(nil) | |
|
294 | assert Project.new.allowed_parents.include?(Project.find(1)) | |
|
295 | # existing root project | |
|
296 | assert Project.find(1).allowed_parents.include?(nil) | |
|
297 | # existing child | |
|
298 | assert Project.find(3).allowed_parents.include?(Project.find(1)) | |
|
299 | assert !Project.find(3).allowed_parents.include?(nil) | |
|
300 | end | |
|
301 | ||
|
302 | def test_allowed_parents_with_add_project_permission | |
|
303 | Role.find(1).add_permission!(:add_project) | |
|
304 | Role.find(1).remove_permission!(:add_subprojects) | |
|
305 | User.current = User.find(2) | |
|
306 | # new project | |
|
307 | assert Project.new.allowed_parents.include?(nil) | |
|
308 | assert !Project.new.allowed_parents.include?(Project.find(1)) | |
|
309 | # existing root project | |
|
310 | assert Project.find(1).allowed_parents.include?(nil) | |
|
311 | # existing child | |
|
312 | assert Project.find(3).allowed_parents.include?(Project.find(1)) | |
|
313 | assert Project.find(3).allowed_parents.include?(nil) | |
|
314 | end | |
|
315 | ||
|
316 | def test_allowed_parents_with_add_project_and_subprojects_permission | |
|
317 | Role.find(1).add_permission!(:add_project) | |
|
318 | Role.find(1).add_permission!(:add_subprojects) | |
|
319 | User.current = User.find(2) | |
|
320 | # new project | |
|
321 | assert Project.new.allowed_parents.include?(nil) | |
|
322 | assert Project.new.allowed_parents.include?(Project.find(1)) | |
|
323 | # existing root project | |
|
324 | assert Project.find(1).allowed_parents.include?(nil) | |
|
325 | # existing child | |
|
326 | assert Project.find(3).allowed_parents.include?(Project.find(1)) | |
|
327 | assert Project.find(3).allowed_parents.include?(nil) | |
|
328 | end | |
|
329 | ||
|
288 | 330 | def test_users_by_role |
|
289 | 331 | users_by_role = Project.find(1).users_by_role |
|
290 | 332 | assert_kind_of Hash, users_by_role |
General Comments 0
You need to be logged in to leave comments.
Login now