From d201c54455fd15d0069de5a60bc99a57cc380ba3 Mon Sep 17 00:00:00 2001
From: Jean-Philippe Lang
Date: Sun, 8 Nov 2009 13:03:41 +0000
Subject: [PATCH] Adds version status to limit issue assignments (#1245).
Available version statuses are:
* open: no restriction
* locked: can not assign new issues to the version
* closed: can not assign new issues and can not reopen assigned issues
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3020 e93f8b46-1217-0410-a6f0-8f06a7374b81
---
app/models/issue.rb | 25 ++++++++++++
app/models/version.rb | 11 ++++-
app/views/issues/_form.rhtml | 6 +--
app/views/issues/_form_update.rhtml | 6 +--
app/views/issues/bulk_edit.rhtml | 2 +-
app/views/issues/context_menu.rhtml | 4 +-
app/views/projects/settings/_versions.rhtml | 13 +++---
app/views/versions/_form.rhtml | 1 +
config/locales/bg.yml | 4 ++
config/locales/bs.yml | 4 ++
config/locales/ca.yml | 4 ++
config/locales/cs.yml | 4 ++
config/locales/da.yml | 4 ++
config/locales/de.yml | 4 ++
config/locales/el.yml | 4 ++
config/locales/en.yml | 5 +++
config/locales/es.yml | 4 ++
config/locales/fi.yml | 4 ++
config/locales/fr.yml | 5 +++
config/locales/gl.yml | 4 ++
config/locales/he.yml | 4 ++
config/locales/hu.yml | 4 ++
config/locales/it.yml | 4 ++
config/locales/ja.yml | 4 ++
config/locales/ko.yml | 4 ++
config/locales/lt.yml | 4 ++
config/locales/nl.yml | 4 ++
config/locales/no.yml | 4 ++
config/locales/pl.yml | 4 ++
config/locales/pt-BR.yml | 4 ++
config/locales/pt.yml | 4 ++
config/locales/ro.yml | 4 ++
config/locales/ru.yml | 4 ++
config/locales/sk.yml | 4 ++
config/locales/sl.yml | 4 ++
config/locales/sr.yml | 4 ++
config/locales/sv.yml | 4 ++
config/locales/th.yml | 4 ++
config/locales/tr.yml | 4 ++
config/locales/uk.yml | 4 ++
config/locales/vi.yml | 4 ++
config/locales/zh-TW.yml | 4 ++
config/locales/zh.yml | 4 ++
db/migrate/20091108092559_add_versions_status.rb | 9 +++++
public/stylesheets/application.css | 2 +
test/fixtures/issues.yml | 32 +++++++++++++++
test/fixtures/versions.yml | 3 ++
test/unit/issue_test.rb | 51 ++++++++++++++++++++++++
test/unit/version_test.rb | 1 +
49 files changed, 293 insertions(+), 15 deletions(-)
create mode 100644 db/migrate/20091108092559_add_versions_status.rb
diff --git a/app/models/issue.rb b/app/models/issue.rb
index f7b2f8a3..ea6eb130 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -143,6 +143,14 @@ class Issue < ActiveRecord::Base
if start_date && soonest_start && start_date < soonest_start
errors.add :start_date, :invalid
end
+
+ if fixed_version
+ if !assignable_versions.include?(fixed_version)
+ errors.add :fixed_version_id, :inclusion
+ elsif reopened? && fixed_version.closed?
+ errors.add_to_base I18n.t(:error_can_not_reopen_issue_on_closed_version)
+ end
+ end
end
def validate_on_create
@@ -193,6 +201,18 @@ class Issue < ActiveRecord::Base
self.status.is_closed?
end
+ # Return true if the issue is being reopened
+ def reopened?
+ if !new_record? && status_id_changed?
+ status_was = IssueStatus.find_by_id(status_id_was)
+ status_new = IssueStatus.find_by_id(status_id)
+ if status_was && status_new && status_was.is_closed? && !status_new.is_closed?
+ return true
+ end
+ end
+ false
+ end
+
# Returns true if the issue is overdue
def overdue?
!due_date.nil? && (due_date < Date.today) && !status.is_closed?
@@ -203,6 +223,11 @@ class Issue < ActiveRecord::Base
project.assignable_users
end
+ # Versions that the issue can be assigned to
+ def assignable_versions
+ @assignable_versions ||= (project.versions.open + [Version.find_by_id(fixed_version_id_was)]).compact.uniq.sort
+ end
+
# Returns true if this issue is blocked by another issue that is still open
def blocked?
!relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
diff --git a/app/models/version.rb b/app/models/version.rb
index 13d33e25..dc72e821 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -22,11 +22,16 @@ class Version < ActiveRecord::Base
acts_as_attachable :view_permission => :view_files,
:delete_permission => :manage_files
+ VERSION_STATUSES = %w(open locked closed)
+
validates_presence_of :name
validates_uniqueness_of :name, :scope => [:project_id]
validates_length_of :name, :maximum => 60
validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :not_a_date, :allow_nil => true
-
+ validates_inclusion_of :status, :in => VERSION_STATUSES
+
+ named_scope :open, :conditions => {:status => 'open'}
+
def start_date
effective_date
end
@@ -45,6 +50,10 @@ class Version < ActiveRecord::Base
@spent_hours ||= TimeEntry.sum(:hours, :include => :issue, :conditions => ["#{Issue.table_name}.fixed_version_id = ?", id]).to_f
end
+ def closed?
+ status == 'closed'
+ end
+
# Returns true if the version is completed: due date reached and no open issues
def completed?
effective_date && (effective_date <= Date.today) && (open_issues_count == 0)
diff --git a/app/views/issues/_form.rhtml b/app/views/issues/_form.rhtml
index fac2d6a3..c61c79d6 100644
--- a/app/views/issues/_form.rhtml
+++ b/app/views/issues/_form.rhtml
@@ -32,9 +32,9 @@
{:controller => 'projects', :action => 'add_issue_category', :id => @project},
:class => 'small', :tabindex => 199) if authorize_for('projects', 'add_issue_category') %>
<% 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? %>
+<% unless @issue.assignable_versions.empty? %>
+<%= f.select :fixed_version_id, (@issue.assignable_versions.collect {|v| [v.name, v.id]}), :include_blank => true %>
+<% end %>
diff --git a/app/views/issues/_form_update.rhtml b/app/views/issues/_form_update.rhtml
index 3f17a030..5304ee23 100644
--- a/app/views/issues/_form_update.rhtml
+++ b/app/views/issues/_form_update.rhtml
@@ -5,8 +5,8 @@
<%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %>
-<%= content_tag('p', f.select(:fixed_version_id,
- (@project.versions.sort.collect {|v| [v.name, v.id]}),
- { :include_blank => true })) unless @project.versions.empty? %>
+<% unless @issue.assignable_versions.empty? %>
+
<%= f.select :fixed_version_id, (@issue.assignable_versions.collect {|v| [v.name, v.id]}), :include_blank => true %>
+<% end %>
diff --git a/app/views/issues/bulk_edit.rhtml b/app/views/issues/bulk_edit.rhtml
index 4ea9ffd3..10a5bb5a 100644
--- a/app/views/issues/bulk_edit.rhtml
+++ b/app/views/issues/bulk_edit.rhtml
@@ -27,7 +27,7 @@
+ options_from_collection_for_select(@project.versions.open.sort, :id, :name)) %>
diff --git a/app/views/issues/context_menu.rhtml b/app/views/issues/context_menu.rhtml
index ae9a1afc..073f12bd 100644
--- a/app/views/issues/context_menu.rhtml
+++ b/app/views/issues/context_menu.rhtml
@@ -27,11 +27,11 @@
<% end -%>
- <% unless @project.nil? || @project.versions.empty? -%>
+ <% unless @project.nil? || @project.versions.open.empty? -%>
- <% @project.versions.sort.each do |v| -%>
+ <% @project.versions.open.sort.each do |v| -%>
- <%= context_menu_link v.name, {: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] %>
<% end -%>
diff --git a/app/views/projects/settings/_versions.rhtml b/app/views/projects/settings/_versions.rhtml
index 1f66dec4..95b72f17 100644
--- a/app/views/projects/settings/_versions.rhtml
+++ b/app/views/projects/settings/_versions.rhtml
@@ -1,22 +1,25 @@
<% if @project.versions.any? %>
-
+
<%= l(:label_version) %> |
<%= l(:field_effective_date) %> |
<%= l(:field_description) %> |
+ <%= l(:field_status) %> |
<%= l(:label_wiki_page) unless @project.wiki.nil? %> |
|
- |
<% for version in @project.versions.sort %>
-
+
<%= link_to h(version.name), :controller => 'versions', :action => 'show', :id => version %> |
<%= format_date(version.effective_date) %> |
<%=h version.description %> |
+ <%= l("version_status_#{version.status}") %> |
<%= link_to(h(version.wiki_page_title), :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %> |
- <%= link_to_if_authorized l(:button_edit), { :controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %> |
- <%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> |
+
+ <%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %>
+ <%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
+ |
<% end; reset_cycle %>
diff --git a/app/views/versions/_form.rhtml b/app/views/versions/_form.rhtml
index adc83b57..dfdbc18f 100644
--- a/app/views/versions/_form.rhtml
+++ b/app/views/versions/_form.rhtml
@@ -3,6 +3,7 @@
<%= f.text_field :name, :size => 60, :required => true %>
<%= f.text_field :description, :size => 60 %>
+
<%= f.select :status, Version::VERSION_STATUSES.collect {|s| [l("version_status_#{s}"), s]} %>
<%= f.text_field :wiki_page_title, :label => :label_wiki_page, :size => 60, :disabled => @project.wiki.nil? %>
<%= f.text_field :effective_date, :size => 10 %><%= calendar_for('version_effective_date') %>
diff --git a/config/locales/bg.yml b/config/locales/bg.yml
index 46551d69..c35138a1 100644
--- a/config/locales/bg.yml
+++ b/config/locales/bg.yml
@@ -827,3 +827,7 @@ bg:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/bs.yml b/config/locales/bs.yml
index d7460488..f8bf5b13 100644
--- a/config/locales/bs.yml
+++ b/config/locales/bs.yml
@@ -851,3 +851,7 @@ bs:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/ca.yml b/config/locales/ca.yml
index 24bb33eb..6a85787b 100644
--- a/config/locales/ca.yml
+++ b/config/locales/ca.yml
@@ -830,3 +830,7 @@ ca:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/cs.yml b/config/locales/cs.yml
index c1c429d5..68cbb412 100644
--- a/config/locales/cs.yml
+++ b/config/locales/cs.yml
@@ -833,3 +833,7 @@ cs:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/da.yml b/config/locales/da.yml
index 7ebea2c7..00d430b7 100644
--- a/config/locales/da.yml
+++ b/config/locales/da.yml
@@ -853,3 +853,7 @@ da:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 8f99608f..f9ffc106 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -853,3 +853,7 @@ de:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/el.yml b/config/locales/el.yml
index 6147bd5c..ce4fc264 100644
--- a/config/locales/el.yml
+++ b/config/locales/el.yml
@@ -833,3 +833,7 @@ el:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 71e599a5..eedf48df 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -155,6 +155,7 @@ en:
error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
error_no_tracker_in_project: 'No tracker is associated to this project. Please check the Project settings.'
error_no_default_issue_status: 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
+ error_can_not_reopen_issue_on_closed_version: 'An issue assigned to a closed version can not be reopened'
warning_attachments_not_saved: "{{count}} file(s) could not be saved."
@@ -749,6 +750,10 @@ en:
status_active: active
status_registered: registered
status_locked: locked
+
+ version_status_open: open
+ version_status_locked: locked
+ version_status_closed: closed
field_active: Active
diff --git a/config/locales/es.yml b/config/locales/es.yml
index e76929dc..864cd141 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -874,3 +874,7 @@ es:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/fi.yml b/config/locales/fi.yml
index fffddc6f..34214fee 100644
--- a/config/locales/fi.yml
+++ b/config/locales/fi.yml
@@ -863,3 +863,7 @@ fi:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 82936b4a..2c4dbf6f 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -177,6 +177,7 @@ fr:
error_scm_command_failed: "Une erreur s'est produite lors de l'accès au dépôt: {{value}}"
error_scm_annotate: "L'entrée n'existe pas ou ne peut pas être annotée."
error_issue_not_found_in_project: "La demande n'existe pas ou n'appartient pas à ce projet"
+ error_can_not_reopen_issue_on_closed_version: 'Une demande assignée à une version fermée ne peut pas être réouverte'
warning_attachments_not_saved: "{{count}} fichier(s) n'ont pas pu être sauvegardés."
@@ -767,6 +768,10 @@ fr:
status_registered: enregistré
status_locked: vérouillé
+ version_status_open: ouvert
+ version_status_locked: vérouillé
+ version_status_closed: fermé
+
text_select_mail_notifications: Actions pour lesquelles une notification par e-mail est envoyée
text_regexp_info: ex. ^[A-Z0-9]+$
text_min_max_length_info: 0 pour aucune restriction
diff --git a/config/locales/gl.yml b/config/locales/gl.yml
index 00bdbbfb..b2a8d49d 100644
--- a/config/locales/gl.yml
+++ b/config/locales/gl.yml
@@ -853,3 +853,7 @@ gl:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/he.yml b/config/locales/he.yml
index ecf58209..d60b94e4 100644
--- a/config/locales/he.yml
+++ b/config/locales/he.yml
@@ -837,3 +837,7 @@ he:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/hu.yml b/config/locales/hu.yml
index 70b0d00a..b7c9dff6 100644
--- a/config/locales/hu.yml
+++ b/config/locales/hu.yml
@@ -858,3 +858,7 @@
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/it.yml b/config/locales/it.yml
index d51e2408..7d6ccac2 100644
--- a/config/locales/it.yml
+++ b/config/locales/it.yml
@@ -840,3 +840,7 @@ it:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index 35121b70..9e70679e 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -862,3 +862,7 @@ ja:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/ko.yml b/config/locales/ko.yml
index 82ab8050..4441ebe6 100644
--- a/config/locales/ko.yml
+++ b/config/locales/ko.yml
@@ -893,3 +893,7 @@ ko:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/lt.yml b/config/locales/lt.yml
index fbe3c67d..3d7fcc6c 100644
--- a/config/locales/lt.yml
+++ b/config/locales/lt.yml
@@ -863,3 +863,7 @@ lt:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index 9f89b811..4212d445 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -815,3 +815,7 @@ nl:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/no.yml b/config/locales/no.yml
index c22200cb..df91bdf4 100644
--- a/config/locales/no.yml
+++ b/config/locales/no.yml
@@ -828,3 +828,7 @@
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/pl.yml b/config/locales/pl.yml
index 4f6a28c6..fa232a29 100644
--- a/config/locales/pl.yml
+++ b/config/locales/pl.yml
@@ -856,3 +856,7 @@ pl:
field_active: Aktywne
enumeration_system_activity: AktywnoÅÄ Systemowa
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml
index 287a0684..51d5221e 100644
--- a/config/locales/pt-BR.yml
+++ b/config/locales/pt-BR.yml
@@ -859,3 +859,7 @@ pt-BR:
field_active: Ativo
enumeration_system_activity: Atividade do sistema
permission_delete_issue_watchers: Deletar observadores
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/pt.yml b/config/locales/pt.yml
index 2086af47..e9c6423a 100644
--- a/config/locales/pt.yml
+++ b/config/locales/pt.yml
@@ -845,3 +845,7 @@ pt:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/ro.yml b/config/locales/ro.yml
index c3b8dd2f..b6244961 100644
--- a/config/locales/ro.yml
+++ b/config/locales/ro.yml
@@ -830,3 +830,7 @@ ro:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
index c885447f..14b00334 100644
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -941,3 +941,7 @@ ru:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/sk.yml b/config/locales/sk.yml
index 59a5faa3..efb0325b 100644
--- a/config/locales/sk.yml
+++ b/config/locales/sk.yml
@@ -832,3 +832,7 @@ sk:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/sl.yml b/config/locales/sl.yml
index bfc5e087..d3a6a311 100644
--- a/config/locales/sl.yml
+++ b/config/locales/sl.yml
@@ -829,3 +829,7 @@ sl:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/sr.yml b/config/locales/sr.yml
index 0f8ed109..90f3a212 100644
--- a/config/locales/sr.yml
+++ b/config/locales/sr.yml
@@ -848,3 +848,7 @@
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/sv.yml b/config/locales/sv.yml
index d775e953..301debd9 100644
--- a/config/locales/sv.yml
+++ b/config/locales/sv.yml
@@ -881,3 +881,7 @@ sv:
enumeration_doc_categories: Dokumentkategorier
enumeration_activities: Aktiviteter (tidsuppföljning)
enumeration_system_activity: Systemaktivitet
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/th.yml b/config/locales/th.yml
index fb6b36e0..24d16bf3 100644
--- a/config/locales/th.yml
+++ b/config/locales/th.yml
@@ -830,3 +830,7 @@ th:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/tr.yml b/config/locales/tr.yml
index d51e4654..d835ab1a 100644
--- a/config/locales/tr.yml
+++ b/config/locales/tr.yml
@@ -860,3 +860,7 @@ tr:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/uk.yml b/config/locales/uk.yml
index c14f604c..3502c52d 100644
--- a/config/locales/uk.yml
+++ b/config/locales/uk.yml
@@ -829,3 +829,7 @@ uk:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/vi.yml b/config/locales/vi.yml
index 766b462a..6ae80851 100644
--- a/config/locales/vi.yml
+++ b/config/locales/vi.yml
@@ -892,3 +892,7 @@ vi:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml
index a9cd42e6..05b4b214 100644
--- a/config/locales/zh-TW.yml
+++ b/config/locales/zh-TW.yml
@@ -923,3 +923,7 @@
enumeration_doc_categories: æ件åé¡
enumeration_activities: æ´»å (æé追蹤)
enumeration_system_activity: 系統活å
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 596a08df..bb60315b 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -855,3 +855,7 @@ zh:
field_active: Active
enumeration_system_activity: System Activity
permission_delete_issue_watchers: Delete watchers
+ version_status_closed: closed
+ version_status_locked: locked
+ version_status_open: open
+ error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
diff --git a/db/migrate/20091108092559_add_versions_status.rb b/db/migrate/20091108092559_add_versions_status.rb
new file mode 100644
index 00000000..d71d490a
--- /dev/null
+++ b/db/migrate/20091108092559_add_versions_status.rb
@@ -0,0 +1,9 @@
+class AddVersionsStatus < ActiveRecord::Migration
+ def self.up
+ add_column :versions, :status, :string, :default => 'open'
+ end
+
+ def self.down
+ remove_column :versions, :status
+ end
+end
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index a5e845d8..5042c128 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -124,6 +124,8 @@ tr.message td.last_message { font-size: 80%; }
tr.message.locked td.subject a { background-image: url(../images/locked.png); }
tr.message.sticky td.subject a { background-image: url(../images/sticky.png); font-weight: bold; }
+tr.version.closed, tr.version.closed a { color: #999; }
+
tr.user td { width:13%; }
tr.user td.email { width:18%; }
tr.user td { white-space: nowrap; }
diff --git a/test/fixtures/issues.yml b/test/fixtures/issues.yml
index f7917639..03197458 100644
--- a/test/fixtures/issues.yml
+++ b/test/fixtures/issues.yml
@@ -157,3 +157,35 @@ issues_010:
status_id: 1
start_date: <%= Date.today.to_s(:db) %>
due_date: <%= 1.days.from_now.to_date.to_s(:db) %>
+issues_011:
+ created_on: <%= 3.days.ago.to_date.to_s(:db) %>
+ project_id: 1
+ updated_on: <%= 1.day.ago.to_date.to_s(:db) %>
+ priority_id: 5
+ subject: Closed issue on a closed version
+ id: 11
+ fixed_version_id: 1
+ category_id: 1
+ description:
+ tracker_id: 1
+ assigned_to_id:
+ author_id: 2
+ status_id: 5
+ start_date: <%= 1.day.ago.to_date.to_s(:db) %>
+ due_date:
+issues_012:
+ created_on: <%= 3.days.ago.to_date.to_s(:db) %>
+ project_id: 1
+ updated_on: <%= 1.day.ago.to_date.to_s(:db) %>
+ priority_id: 5
+ subject: Closed issue on a locked version
+ id: 12
+ fixed_version_id: 2
+ category_id: 1
+ description:
+ tracker_id: 1
+ assigned_to_id:
+ author_id: 2
+ status_id: 5
+ start_date: <%= 1.day.ago.to_date.to_s(:db) %>
+ due_date:
diff --git a/test/fixtures/versions.yml b/test/fixtures/versions.yml
index 9306811f..bcecb67d 100644
--- a/test/fixtures/versions.yml
+++ b/test/fixtures/versions.yml
@@ -7,6 +7,7 @@ versions_001:
id: 1
description: Beta
effective_date: 2006-07-01
+ status: closed
versions_002:
created_on: 2006-07-19 21:00:33 +02:00
name: "1.0"
@@ -15,6 +16,7 @@ versions_002:
id: 2
description: Stable release
effective_date: <%= 20.day.from_now.to_date.to_s(:db) %>
+ status: locked
versions_003:
created_on: 2006-07-19 21:00:33 +02:00
name: "2.0"
@@ -23,4 +25,5 @@ versions_003:
id: 3
description: Future version
effective_date:
+ status: open
\ No newline at end of file
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 147d31f8..a8010cf4 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -20,6 +20,7 @@ require File.dirname(__FILE__) + '/../test_helper'
class IssueTest < ActiveSupport::TestCase
fixtures :projects, :users, :members, :member_roles,
:trackers, :projects_trackers,
+ :versions,
:issue_statuses, :issue_categories, :issue_relations, :workflows,
:enumerations,
:issues,
@@ -184,6 +185,56 @@ class IssueTest < ActiveSupport::TestCase
assert !issue1.reload.closed?
end
+ def test_assignable_versions
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
+ assert_equal ['open'], issue.assignable_versions.collect(&:status).uniq
+ end
+
+ def test_should_not_be_able_to_assign_a_new_issue_to_a_closed_version
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 1, :subject => 'New issue')
+ assert !issue.save
+ assert_not_nil issue.errors.on(:fixed_version_id)
+ end
+
+ def test_should_not_be_able_to_assign_a_new_issue_to_a_locked_version
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 2, :subject => 'New issue')
+ assert !issue.save
+ assert_not_nil issue.errors.on(:fixed_version_id)
+ end
+
+ def test_should_be_able_to_assign_a_new_issue_to_an_open_version
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :fixed_version_id => 3, :subject => 'New issue')
+ assert issue.save
+ end
+
+ def test_should_be_able_to_update_an_issue_assigned_to_a_closed_version
+ issue = Issue.find(11)
+ assert_equal 'closed', issue.fixed_version.status
+ issue.subject = 'Subject changed'
+ assert issue.save
+ end
+
+ def test_should_not_be_able_to_reopen_an_issue_assigned_to_a_closed_version
+ issue = Issue.find(11)
+ issue.status_id = 1
+ assert !issue.save
+ assert_not_nil issue.errors.on_base
+ end
+
+ def test_should_be_able_to_reopen_and_reassign_an_issue_assigned_to_a_closed_version
+ issue = Issue.find(11)
+ issue.status_id = 1
+ issue.fixed_version_id = 3
+ assert issue.save
+ end
+
+ def test_should_be_able_to_reopen_an_issue_assigned_to_a_locked_version
+ issue = Issue.find(12)
+ assert_equal 'locked', issue.fixed_version.status
+ issue.status_id = 1
+ assert issue.save
+ end
+
def test_move_to_another_project_with_same_category
issue = Issue.find(1)
assert issue.move_to(Project.find(2))
diff --git a/test/unit/version_test.rb b/test/unit/version_test.rb
index 7df85792..5702fd18 100644
--- a/test/unit/version_test.rb
+++ b/test/unit/version_test.rb
@@ -26,6 +26,7 @@ class VersionTest < ActiveSupport::TestCase
def test_create
v = Version.new(:project => Project.find(1), :name => '1.1', :effective_date => '2011-03-25')
assert v.save
+ assert_equal 'open', v.status
end
def test_invalid_effective_date_validation
--
2.11.0