diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index de51676..9aeae03 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -240,7 +240,7 @@ class IssuesController < ApplicationController
       priority = params[:priority_id].blank? ? nil : IssuePriority.find_by_id(params[:priority_id])
       assigned_to = (params[:assigned_to_id].blank? || params[:assigned_to_id] == 'none') ? nil : User.find_by_id(params[:assigned_to_id])
       category = (params[:category_id].blank? || params[:category_id] == 'none') ? nil : @project.issue_categories.find_by_id(params[:category_id])
-      fixed_version = (params[:fixed_version_id].blank? || params[:fixed_version_id] == 'none') ? nil : @project.versions.find_by_id(params[:fixed_version_id])
+      fixed_version = (params[:fixed_version_id].blank? || params[:fixed_version_id] == 'none') ? nil : @project.inherited_versions.find {|v| v.id.to_s == params[:fixed_version_id] }
       custom_field_values = params[:custom_field_values] ? params[:custom_field_values].reject {|k,v| v.blank?} : nil
       
       unsaved_issue_ids = []      
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index f3280cc..accc50e 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -240,7 +240,9 @@ class ProjectsController < ApplicationController
                 'downloads' => "#{Attachment.table_name}.downloads"
                 
     @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)]
-    @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse
+    # Need get the ids separately in order to add the finder options
+    version_ids = @project.inherited_versions_visible_to_user.collect(&:id)
+    @containers += Version.find_all_by_id(version_ids, :include => :attachments, :order => sort_clause).sort.reverse
     render :layout => !request.xhr?
   end
   
@@ -248,13 +250,21 @@ class ProjectsController < ApplicationController
   def changelog
     @trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
     retrieve_selected_tracker_ids(@trackers)    
-    @versions = @project.versions.sort
+    if params[:inherited_versions]
+      @versions = @project.inherited_versions_visible_to_user.sort
+    else
+      @versions = @project.versions.sort
+    end
   end
 
   def roadmap
     @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true])
     retrieve_selected_tracker_ids(@trackers)
-    @versions = @project.versions.sort
+    if params[:inherited_versions]
+      @versions = @project.inherited_versions_visible_to_user.sort
+    else
+      @versions = @project.versions.sort
+    end
     @versions = @versions.select {|v| !v.completed? } unless params[:completed]
   end
   
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index f1b088c..3868473 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -97,6 +97,35 @@ module ApplicationHelper
     h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />")
   end
 
+  def format_version_name(version)
+    if User.current.allowed_to?(:view_issues, version.project)
+      "#{h(version.project.name)} - #{h(version.name)}"
+    else
+      "#{l(:text_not_authorized)}"
+    end
+  end
+
+  # Given an Array of emails (+recipients+), do they all have
+  # +permission+ on +project+ ?
+  def recipients_all_allowed_to?(recipients, permission, project)
+    recipients.uniq.all? do |recipient|
+      user = User.find_by_mail(recipient)
+      user && user.allowed_to?(permission, project)
+    end
+  end
+
+  # Given an Array of +versions+, are all the email addresses
+  # (+recipients+) allowed to view all of the versions?
+  def recipients_all_allowed_to_see_versions?(recipients, versions)
+    versions.uniq.all? do |version|
+      if version.nil?
+        true
+      else
+        recipients_all_allowed_to?(recipients, :view_issues, version.project)
+      end
+    end
+  end
+  
   def due_date_distance_in_words(date)
     if date
       l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index beb36b5..8e6c263 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -66,6 +66,10 @@ module IssuesHelper
     @sidebar_queries
   end
 
+  def inherited_version_options(project)
+    project.inherited_versions.sort.collect {|v| [format_version_name(v), v.id] }
+  end
+
   def show_detail(detail, no_html=false)
     case detail.property
     when 'attr'
@@ -93,8 +97,8 @@ module IssuesHelper
         c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value
         c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value
       when 'fixed_version_id'
-        v = Version.find_by_id(detail.value) and value = v.name if detail.value
-        v = Version.find_by_id(detail.old_value) and old_value = v.name if detail.old_value
+        v = Version.find_by_id(detail.value) and value = format_version_name(v) if detail.value
+        v = Version.find_by_id(detail.old_value) and old_value = format_version_name(v) if detail.old_value
       when 'estimated_hours'
         value = "%0.02f" % detail.value.to_f unless detail.value.blank?
         old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb
new file mode 100644
index 0000000..a4ff772
--- /dev/null
+++ b/app/helpers/mailer_helper.rb
@@ -0,0 +1,25 @@
+# redMine - project management software
+# Copyright (C) 2006-2009  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+module MailerHelper
+  def unauthorized_version?(journal_detail, recipients)
+    return false unless journal_detail.prop_key == "fixed_version_id"
+
+    !recipients_all_allowed_to_see_versions?(recipients,
+                                             Version.find_all_by_id([journal_detail.value, journal_detail.old_value]))
+  end
+end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 912450c..45e2de9 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -18,7 +18,11 @@
 module ProjectsHelper
   def link_to_version(version, options = {})
     return '' unless version && version.is_a?(Version)
-    link_to h(version.name), { :controller => 'versions', :action => 'show', :id => version }, options
+    if User.current.allowed_to?(:view_issues, version.project)
+      link_to format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options
+    else
+      format_version_name(version)
+    end
   end
   
   def project_settings_tabs
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index fbe76ac..3ae7339 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -19,6 +19,7 @@ class Mailer < ActionMailer::Base
   helper :application
   helper :issues
   helper :custom_fields
+  helper :mailer
 
   include ActionController::UrlWriter
   include Redmine::I18n
diff --git a/app/models/project.rb b/app/models/project.rb
index 0b0c47a..1922b69 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -247,6 +247,26 @@ class Project < ActiveRecord::Base
                          :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt],
                          :order => "#{Tracker.table_name}.position")
   end
+
+  # Returns an array of the Versions used by the project, its active
+  # sub projects, and its active parent projects
+  def inherited_versions
+    @inherited_versions ||= self.root.self_and_descendants.
+      delete_if {|p| !p.active? }.
+      collect(&:versions).
+      flatten.
+      sort
+
+    yield @inherited_versions if block_given?
+    @inherited_versions
+  end
+
+  # Returns the inherited_versions that are visible to +user+
+  def inherited_versions_visible_to_user(user=User.current)
+    return inherited_versions do |versions|
+      versions.delete_if {|v| !user.allowed_to?(:view_issues, v.project) }
+    end
+  end
   
   # Returns a hash of project users grouped by role
   def users_by_role
diff --git a/app/models/query.rb b/app/models/query.rb
index 7ce95f0..d8100f3 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -182,7 +182,7 @@ class Query < ActiveRecord::Base
         @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
       end
       unless @project.versions.empty?
-        @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
+        @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.inherited_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
       end
       unless @project.descendants.active.empty?
         @available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.descendants.visible.collect{|s| [s.name, s.id.to_s] } }
diff --git a/app/views/issues/_form.rhtml b/app/views/issues/_form.rhtml
index fac2d6a..e606dcb 100644
--- a/app/views/issues/_form.rhtml
+++ b/app/views/issues/_form.rhtml
@@ -33,8 +33,8 @@
                      :class => 'small', :tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p>
 <% end %>
 <%= content_tag('p', f.select(:fixed_version_id, 
-                              (@project.versions.sort.collect {|v| [v.name, v.id]}),
-                              { :include_blank => true })) unless @project.versions.empty? %>
+                              (inherited_version_options(@project)),
+                              { :include_blank => true })) unless @project.inherited_versions.empty? %>
 </div>
 
 <div class="splitcontentright">
diff --git a/app/views/issues/bulk_edit.rhtml b/app/views/issues/bulk_edit.rhtml
index 4ea9ffd..fb9fcae 100644
--- a/app/views/issues/bulk_edit.rhtml
+++ b/app/views/issues/bulk_edit.rhtml
@@ -27,7 +27,7 @@
 <label><%= l(:field_fixed_version) %>: 
 <%= select_tag('fixed_version_id', content_tag('option', l(:label_no_change_option), :value => '') +
                                    content_tag('option', l(:label_none), :value => 'none') +
-                                   options_from_collection_for_select(@project.versions.sort, :id, :name)) %></label>
+                                   options_for_select(inherited_version_options(@project))) %></label>
 </p>
 
 <p>
diff --git a/app/views/issues/context_menu.rhtml b/app/views/issues/context_menu.rhtml
index ae9a1af..ea1e878 100644
--- a/app/views/issues/context_menu.rhtml
+++ b/app/views/issues/context_menu.rhtml
@@ -27,12 +27,12 @@
 		<% end -%>
 		</ul>
 	</li>
-	<% unless @project.nil? || @project.versions.empty? -%>
+	<% unless @project.nil? || @project.inherited_versions.empty? -%>
 	<li class="folder">			
 		<a href="#" class="submenu"><%= l(:field_fixed_version) %></a>
 		<ul>
-		<% @project.versions.sort.each do |v| -%>
-		    <li><%= context_menu_link v.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => v, :back_to => @back}, :method => :post,
+		<% @project.inherited_versions.sort.each do |v| -%>
+		    <li><%= context_menu_link format_version_name(v), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => v, :back_to => @back}, :method => :post,
 		                              :selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:update] %></li>
 		<% end -%>
 		    <li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => 'none', :back_to => @back}, :method => :post,
diff --git a/app/views/mailer/issue_edit.text.html.rhtml b/app/views/mailer/issue_edit.text.html.rhtml
index b4a1f95..02c9afc 100644
--- a/app/views/mailer/issue_edit.text.html.rhtml
+++ b/app/views/mailer/issue_edit.text.html.rhtml
@@ -2,7 +2,11 @@
 
 <ul>
 <% for detail in @journal.details %>
+<% if unauthorized_version?(detail, @recipients + @cc) %>
+    <li><%= l(:field_fixed_version) %> <%= l(:text_journal_set_to, l(:text_not_authorized)) %></li>
+    <% else %>
     <li><%= show_detail(detail, true) %></li>
+    <% end %>
 <% end %>
 </ul>
 
diff --git a/app/views/mailer/issue_edit.text.plain.rhtml b/app/views/mailer/issue_edit.text.plain.rhtml
index 870f8fa..6671e91 100644
--- a/app/views/mailer/issue_edit.text.plain.rhtml
+++ b/app/views/mailer/issue_edit.text.plain.rhtml
@@ -1,7 +1,11 @@
 <%= l(:text_issue_updated, :id => "##{@issue.id}", :author => @journal.user) %>
 
 <% for detail in @journal.details -%>
+<% if unauthorized_version?(detail, @recipients + @cc) %>
+<%= l(:field_fixed_version) %> <%= l(:text_journal_set_to, l(:text_not_authorized)) %>
+<% else %>
 <%= show_detail(detail, true) %>
+<% end %>
 <% end -%>
 
 <%= @journal.notes if @journal.notes? %>
diff --git a/app/views/projects/changelog.rhtml b/app/views/projects/changelog.rhtml
index e44d1d1..71a0854 100644
--- a/app/views/projects/changelog.rhtml
+++ b/app/views/projects/changelog.rhtml
@@ -32,6 +32,8 @@
   <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
   <%= tracker.name %></label><br />
 <% end %>
+<br />
+<label for="inherited_versions"><%= check_box_tag "inherited_versions", 1, params[:inherited_versions] %> <%= l(:label_show_inherited_versions) %></label>
 <p><%= submit_tag l(:button_apply), :class => 'button-small' %></p>
 <% end %>
 
diff --git a/app/views/projects/list_files.rhtml b/app/views/projects/list_files.rhtml
index 2b2e5e8..70e36fe 100644
--- a/app/views/projects/list_files.rhtml
+++ b/app/views/projects/list_files.rhtml
@@ -21,7 +21,7 @@
 	<% if container.is_a?(Version) -%>
   <tr>
   	<th colspan="6" align="left">
-  		<%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package") %>
+  		<%= link_to(h(container.project.name) + ' - ' + h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package") %>
 		</th>
 	</tr>
 	<% end -%>
diff --git a/app/views/projects/roadmap.rhtml b/app/views/projects/roadmap.rhtml
index bcba13a..581bcd5 100644
--- a/app/views/projects/roadmap.rhtml
+++ b/app/views/projects/roadmap.rhtml
@@ -6,7 +6,7 @@
 <div id="roadmap">
 <% @versions.each do |version| %>   
     <%= tag 'a', :name => version.name %>
-    <h3 class="icon22 icon22-package"><%= link_to h(version.name), :controller => 'versions', :action => 'show', :id => version %></h3>
+    <h3 class="icon22 icon22-package"><%= link_to h(version.project.name) + " - " + h(version.name), :controller => 'versions', :action => 'show', :id => version %></h3>
     <%= render :partial => 'versions/overview', :locals => {:version => version} %>
     <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %>
 
@@ -39,6 +39,8 @@
 <% end %>
 <br />
 <label for="completed"><%= check_box_tag "completed", 1, params[:completed] %> <%= l(:label_show_completed_versions) %></label>
+<br />
+<label for="inherited_versions"><%= check_box_tag "inherited_versions", 1, params[:inherited_versions] %> <%= l(:label_show_inherited_versions) %></label>
 <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
 <% end %>
 
diff --git a/config/locales/en.yml b/config/locales/en.yml
index b907a56..20ba2a8 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -615,6 +615,7 @@ en:
   label_stay_logged_in: Stay logged in
   label_disabled: disabled
   label_show_completed_versions: Show completed versions
+  label_show_inherited_versions: Show inherited versions
   label_me: me
   label_board: Forum
   label_board_new: New forum
@@ -778,6 +779,8 @@ en:
   text_wiki_page_nullify_children: "Keep child pages as root pages"
   text_wiki_page_destroy_children: "Delete child pages and all their descendants"
   text_wiki_page_reassign_children: "Reassign child pages to this parent page"
+  text_not_authorized: You are not authorized to view this.
+
   
   default_role_manager: Manager
   default_role_developper: Developer
diff --git a/test/fixtures/attachments.yml b/test/fixtures/attachments.yml
index 94c118f..f738200 100644
--- a/test/fixtures/attachments.yml
+++ b/test/fixtures/attachments.yml
@@ -121,4 +121,15 @@ attachments_010:
   filename: picture.jpg
   author_id: 2
   content_type: image/jpeg
-  
\ No newline at end of file
+attachments_011: 
+  created_on: 2006-07-19 21:07:27 +02:00
+  container_type: Version
+  container_id: 1
+  downloads: 0
+  disk_filename: 060719210727_version_file.zip
+  digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
+  id: 11
+  filesize: 452
+  filename: version_file.zip
+  author_id: 2
+  content_type: application/octet-stream
diff --git a/test/fixtures/journal_details.yml b/test/fixtures/journal_details.yml
index 058abd1..da0b6e6 100644
--- a/test/fixtures/journal_details.yml
+++ b/test/fixtures/journal_details.yml
@@ -13,3 +13,10 @@ journal_details_002:
   value: "30"
   prop_key: done_ratio
   journal_id: 1
+journal_details_003: 
+  old_value: nil
+  property: attr
+  id: 3
+  value: "6"
+  prop_key: fixed_version_id
+  journal_id: 4
diff --git a/test/fixtures/journals.yml b/test/fixtures/journals.yml
index 3ee66ae..fe406a7 100644
--- a/test/fixtures/journals.yml
+++ b/test/fixtures/journals.yml
@@ -20,4 +20,11 @@ journals_003:
   journalized_type: Issue
   user_id: 2
   journalized_id: 2
-  
\ No newline at end of file
+journals_004: 
+  created_on: <%= 1.days.ago.to_date.to_s(:db) %>
+  notes: "A comment with a private version."
+  id: 4
+  journalized_type: Issue
+  user_id: 1
+  journalized_id: 6
+    
\ No newline at end of file
diff --git a/test/fixtures/members.yml b/test/fixtures/members.yml
index b1b19c3..9967bdb 100644
--- a/test/fixtures/members.yml
+++ b/test/fixtures/members.yml
@@ -30,4 +30,10 @@ members_005:
   project_id: 5
   user_id: 2
   mail_notification: true
+members_006: 
+  created_on: 2006-07-19 19:35:33 +02:00
+  project_id: 5
+  id: 6
+  user_id: 1
+  mail_notification: true
   
\ No newline at end of file
diff --git a/test/fixtures/versions.yml b/test/fixtures/versions.yml
index 62c5e6f..26bc141 100644
--- a/test/fixtures/versions.yml
+++ b/test/fixtures/versions.yml
@@ -23,4 +23,27 @@ versions_003:
   id: 3
   description: Future version
   effective_date: 
-  
\ No newline at end of file
+versions_004: 
+  created_on: 2006-07-19 21:00:33 +02:00
+  name: "2.0"
+  project_id: 3
+  updated_on: 2006-07-19 21:00:33 +02:00
+  id: 4
+  description: Future version on subproject
+  effective_date: 
+versions_005: 
+  created_on: 2006-07-19 21:00:07 +02:00
+  name: "Alpha"
+  project_id: 2
+  updated_on: 2006-07-19 21:00:07 +02:00
+  id: 5
+  description: Private Alpha
+  effective_date: 2006-07-01
+versions_006: 
+  created_on: 2006-07-19 21:00:07 +02:00
+  name: "Private Version of public subproject"
+  project_id: 5
+  updated_on: 2006-07-19 21:00:07 +02:00
+  id: 6
+  description: "Should be done any day now..."
+  effective_date: 
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 95e75b4..72e0551 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -840,6 +840,22 @@ class IssuesControllerTest < Test::Unit::TestCase
     assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
   end
   
+  def test_post_edit_should_allow_fixed_version_to_be_set_to_a_subproject
+    issue = Issue.find(2)
+    @request.session[:user_id] = 2
+
+    post :edit,
+         :id => issue.id,
+         :issue => {
+           :fixed_version_id => 4
+         }
+
+    assert_response :redirect
+    issue.reload
+    assert_equal 4, issue.fixed_version_id
+    assert_not_equal issue.project_id, issue.fixed_version.project_id
+  end
+  
   def test_get_bulk_edit
     @request.session[:user_id] = 2
     get :bulk_edit, :ids => [1, 2]
@@ -920,6 +936,21 @@ class IssuesControllerTest < Test::Unit::TestCase
     assert_nil Issue.find(2).assigned_to
   end
   
+  def test_post_bulk_edit_should_allow_fixed_version_to_be_set_to_a_subproject
+    @request.session[:user_id] = 2
+
+    post :bulk_edit,
+         :ids => [1,2],
+         :fixed_version_id => 4
+
+    assert_response :redirect
+    issues = Issue.find([1,2])
+    issues.each do |issue|
+      assert_equal 4, issue.fixed_version_id
+      assert_not_equal issue.project_id, issue.fixed_version.project_id
+    end
+  end
+
   def test_move_routing
     assert_routing(
       {:method => :get, :path => '/issues/1/move'},
@@ -982,6 +1013,17 @@ class IssuesControllerTest < Test::Unit::TestCase
     assert_tag :tag => 'a', :content => 'Immediate',
                             :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;priority_id=8',
                                              :class => '' }
+    # Versions
+    assert_tag :tag => 'a', :content => 'eCookbook - 0.1',
+                            :attributes => { :href => '/issues/bulk_edit?fixed_version_id=1&amp;ids%5B%5D=1',
+                                             :class => '' }
+    assert_tag :tag => 'a', :content => 'eCookbook - 1.0',
+                            :attributes => { :href => '/issues/bulk_edit?fixed_version_id=2&amp;ids%5B%5D=1',
+                                             :class => '' }
+    assert_tag :tag => 'a', :content => 'eCookbook Subproject 1 - 2.0',
+                            :attributes => { :href => '/issues/bulk_edit?fixed_version_id=4&amp;ids%5B%5D=1',
+                                             :class => '' }
+
     assert_tag :tag => 'a', :content => 'Dave Lopper',
                             :attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&amp;ids%5B%5D=1',
                                              :class => '' }
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb
index 0560a54..f17927e 100644
--- a/test/functional/projects_controller_test.rb
+++ b/test/functional/projects_controller_test.rb
@@ -316,6 +316,16 @@ class ProjectsControllerTest < Test::Unit::TestCase
                    :attributes => { :href => '/attachments/download/9/version_file.zip' }
   end
 
+  def test_list_files_with_inherited_versions
+    get :list_files, :id => 1
+    assert_response :success
+    assert_not_nil assigns(:containers)
+    
+    # file attached to a subproject's version
+    assert_tag :a, :content => 'version_file.zip',
+                   :attributes => { :href => '/attachments/download/11/version_file.zip' }
+  end
+
   def test_list_files_routing
     assert_routing(
       {:method => :get, :path => '/projects/33/files'},
@@ -337,6 +347,15 @@ class ProjectsControllerTest < Test::Unit::TestCase
     assert_not_nil assigns(:versions)
   end
   
+  def test_changelog_showing_inherited_versions
+    get :changelog, :id => 1, :inherited_versions => 1
+    assert_response :success
+    assert_template 'changelog'
+    assert_not_nil assigns(:versions)
+    # Version on subproject appears
+    assert assigns(:versions).include?(Version.find(4))
+  end
+
   def test_roadmap_routing
     assert_routing(
       {:method => :get, :path => 'projects/33/roadmap'},
@@ -365,6 +384,15 @@ class ProjectsControllerTest < Test::Unit::TestCase
     # Completed version appears
     assert assigns(:versions).include?(Version.find(1))
   end
+
+  def test_roadmap_showing_inherited_versions
+    get :roadmap, :id => 1, :inherited_versions => 1
+    assert_response :success
+    assert_template 'roadmap'
+    assert_not_nil assigns(:versions)
+    # Version on subproject appears
+    assert assigns(:versions).include?(Version.find(4))
+  end
   
   def test_project_activity_routing
     assert_routing(
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 2dc5067..bdd4ef1 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -32,6 +32,16 @@ class ApplicationHelperTest < HelperTestCase
   def setup
     super
   end
+
+  def test_format_version_name_is_authorized
+    User.current = User.find(1)
+    assert_equal "eCookbook - 0.1", format_version_name(Version.find(1))
+  end
+  
+  def test_format_version_name_is_unauthorized
+    User.current = User.find(3)
+    assert_equal "You are not authorized to view this.", format_version_name(Version.find(5))
+  end
   
   def test_auto_links
     to_test = {
diff --git a/test/unit/helpers/projects_helper_test.rb b/test/unit/helpers/projects_helper_test.rb
new file mode 100644
index 0000000..3b379a9
--- /dev/null
+++ b/test/unit/helpers/projects_helper_test.rb
@@ -0,0 +1,44 @@
+# Redmine - project management software
+# Copyright (C) 2006-2009  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../../test_helper'
+
+class ProjectsHelperTest < HelperTestCase
+  include ApplicationHelper
+  include ProjectsHelper
+  
+  fixtures :all
+
+  def setup
+    super
+    set_language_if_valid('en')
+  end
+
+  def test_link_to_version
+    User.current = User.find(1)
+    assert_equal '<a href="/versions/show/1">eCookbook - 0.1</a>', link_to_version(Version.find(1))
+  end
+
+  def test_link_to_version_invalid_version
+    assert_equal '', link_to_version(Object)
+  end
+
+  def test_link_to_version_unauthorized
+    User.current = User.find(3)
+    assert_equal "You are not authorized to view this.", link_to_version(Version.find(5))
+  end
+end
diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb
index b1c39bb..df7a90c 100644
--- a/test/unit/mailer_test.rb
+++ b/test/unit/mailer_test.rb
@@ -238,4 +238,23 @@ class MailerTest < Test::Unit::TestCase
     assert mail.bcc.include?('dlopper@somenet.foo')
     assert mail.body.include?('Bug #3: Error 281 when updating a recipe')
   end
+
+  def test_issue_edit_should_not_show_private_version_changes_if_any_recipients_are_unauthorized
+    Setting.default_language = 'en'
+    # Move issue to a public project but with a Journal showing a
+    # Private Version
+    issue = Issue.find(6)
+    issue.update_attribute(:project_id, 1)
+
+    # User is allowed to see the Private Version
+    User.current = User.find(1)
+    # but another Member of Project #1 is not (dlopper@somenet.foo)
+
+    journal = Journal.find(4)
+    Mailer.deliver_issue_edit(journal)
+    mail = ActionMailer::Base.deliveries.last
+    
+    assert !mail.body.include?('Private Version of public subproject'), "Private version exposed to unauthorized user"
+    assert mail.body.include?('You are not authorized to view this.'), "Unauthorized message not displayed"
+  end
 end
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index 60bc4f1..f15d178 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -21,7 +21,7 @@ class ProjectTest < Test::Unit::TestCase
   fixtures :projects, :enabled_modules, 
            :issues, :issue_statuses, :journals, :journal_details,
            :users, :members, :member_roles, :roles, :projects_trackers, :trackers, :boards,
-           :queries
+           :queries, :versions
 
   def setup
     @ecookbook = Project.find(1)
@@ -233,7 +233,51 @@ class ProjectTest < Test::Unit::TestCase
     
     assert_equal [1,2], parent.rolled_up_trackers.collect(&:id)
   end
-  
+
+  def test_inherited_versions
+    parent = Project.find(1)
+    child = parent.children.find(3)
+    
+    assert [1,2,3], parent.version_ids
+    assert [4], child.version_ids
+
+    assert_equal 5, parent.inherited_versions.size
+    parent.inherited_versions.each do |version|
+      assert_kind_of Version, version
+    end
+
+    assert_equal [1,2,3,4,6], parent.inherited_versions.collect(&:id)
+  end
+
+  def test_inherited_versions_should_ignore_archived_subprojects
+    parent = Project.find(1)
+    child = parent.children.find(3)
+    child.archive
+    parent.reload
+    
+    assert [1,2,3], parent.version_ids
+    assert [4], child.version_ids
+    assert !parent.inherited_versions.collect(&:id).include?(4)
+  end
+
+  def test_inherited_versions_visible_to_user
+    user = User.find(3)
+    parent = Project.find(1)
+    child = parent.children.find(5)
+    
+    assert [1,2,3], parent.version_ids
+    assert [6], child.version_ids
+
+    versions = parent.inherited_versions_visible_to_user(user)
+    
+    assert_equal 4, versions.size
+    versions.each do |version|
+      assert_kind_of Version, version
+    end
+
+    assert !versions.collect(&:id).include?(6)
+  end
+
   def test_next_identifier
     ProjectCustomField.delete_all
     Project.create!(:name => 'last', :identifier => 'p2008040')
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 73efa42..4cef567 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -31,6 +31,14 @@ class QueryTest < Test::Unit::TestCase
       :include => [ :assigned_to, :status, :tracker, :project, :priority ], 
       :conditions => query.statement
   end
+
+  def test_query_should_allow_inherited_versions_for_a_project_query
+    subproject_version = Version.find(4)
+    query = Query.new(:project => Project.find(1), :name => '_')
+    query.add_filter('fixed_version_id', '=', [subproject_version.id.to_s])
+
+    assert query.statement.include?("#{Issue.table_name}.fixed_version_id IN ('4')")
+  end
   
   def test_query_with_multiple_custom_fields
     query = Query.find(1)
