@@ -0,0 +1,12 | |||||
|
1 | class AddProjectsDefaultVersionId < ActiveRecord::Migration | |||
|
2 | def self.up | |||
|
3 | # Don't try to add the column if redmine_default_version plugin was used | |||
|
4 | unless column_exists?(:projects, :default_version_id, :integer) | |||
|
5 | add_column :projects, :default_version_id, :integer, :default => nil | |||
|
6 | end | |||
|
7 | end | |||
|
8 | ||||
|
9 | def self.down | |||
|
10 | remove_column :projects, :default_version_id | |||
|
11 | end | |||
|
12 | end |
@@ -87,6 +87,14 module ProjectsHelper | |||||
87 | end |
|
87 | end | |
88 | end |
|
88 | end | |
89 |
|
89 | |||
|
90 | def project_default_version_options(project) | |||
|
91 | versions = project.shared_versions.open.to_a | |||
|
92 | if project.default_version && !versions.include?(project.default_version) | |||
|
93 | versions << project.default_version | |||
|
94 | end | |||
|
95 | version_options_for_select(versions, project.default_version) | |||
|
96 | end | |||
|
97 | ||||
90 | def format_version_sharing(sharing) |
|
98 | def format_version_sharing(sharing) | |
91 | sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing) |
|
99 | sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing) | |
92 | l("label_version_sharing_#{sharing}") |
|
100 | l("label_version_sharing_#{sharing}") |
@@ -327,10 +327,13 class Issue < ActiveRecord::Base | |||||
327 | # Unless keep_tracker argument is set to true, this will change the tracker |
|
327 | # Unless keep_tracker argument is set to true, this will change the tracker | |
328 | # to the first tracker of the new project if the previous tracker is not part |
|
328 | # to the first tracker of the new project if the previous tracker is not part | |
329 | # of the new project trackers. |
|
329 | # of the new project trackers. | |
330 | # This will clear the fixed_version is it's no longer valid for the new project. |
|
330 | # This will: | |
331 |
# |
|
331 | # * clear the fixed_version is it's no longer valid for the new project. | |
332 | # This will set the category to the category with the same name in the new |
|
332 | # * clear the parent issue if it's no longer valid for the new project. | |
333 | # project if it exists, or clear it if it doesn't. |
|
333 | # * set the category to the category with the same name in the new | |
|
334 | # project if it exists, or clear it if it doesn't. | |||
|
335 | # * for new issue, set the fixed_version to the project default version | |||
|
336 | # if it's a valid fixed_version. | |||
334 | def project=(project, keep_tracker=false) |
|
337 | def project=(project, keep_tracker=false) | |
335 | project_was = self.project |
|
338 | project_was = self.project | |
336 | association(:project).writer(project) |
|
339 | association(:project).writer(project) | |
@@ -355,6 +358,12 class Issue < ActiveRecord::Base | |||||
355 | @custom_field_values = nil |
|
358 | @custom_field_values = nil | |
356 | @workflow_rule_by_attribute = nil |
|
359 | @workflow_rule_by_attribute = nil | |
357 | end |
|
360 | end | |
|
361 | # Set fixed_version to the project default version if it's valid | |||
|
362 | if new_record? && fixed_version.nil? && project && project.default_version_id? | |||
|
363 | if project.shared_versions.open.exists?(project.default_version_id) | |||
|
364 | self.fixed_version_id = project.default_version_id | |||
|
365 | end | |||
|
366 | end | |||
358 | self.project |
|
367 | self.project | |
359 | end |
|
368 | end | |
360 |
|
369 |
@@ -38,6 +38,7 class Project < ActiveRecord::Base | |||||
38 | has_many :issues, :dependent => :destroy |
|
38 | has_many :issues, :dependent => :destroy | |
39 | has_many :issue_changes, :through => :issues, :source => :journals |
|
39 | has_many :issue_changes, :through => :issues, :source => :journals | |
40 | has_many :versions, lambda {order("#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC")}, :dependent => :destroy |
|
40 | has_many :versions, lambda {order("#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC")}, :dependent => :destroy | |
|
41 | belongs_to :default_version, :class_name => 'Version' | |||
41 | has_many :time_entries, :dependent => :destroy |
|
42 | has_many :time_entries, :dependent => :destroy | |
42 | has_many :queries, :class_name => 'IssueQuery', :dependent => :delete_all |
|
43 | has_many :queries, :class_name => 'IssueQuery', :dependent => :delete_all | |
43 | has_many :documents, :dependent => :destroy |
|
44 | has_many :documents, :dependent => :destroy | |
@@ -687,7 +688,8 class Project < ActiveRecord::Base | |||||
687 | 'custom_fields', |
|
688 | 'custom_fields', | |
688 | 'tracker_ids', |
|
689 | 'tracker_ids', | |
689 | 'issue_custom_field_ids', |
|
690 | 'issue_custom_field_ids', | |
690 | 'parent_id' |
|
691 | 'parent_id', | |
|
692 | 'default_version_id' | |||
691 |
|
693 | |||
692 | safe_attributes 'enabled_module_names', |
|
694 | safe_attributes 'enabled_module_names', | |
693 | :if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) } |
|
695 | :if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) } |
@@ -17,7 +17,10 | |||||
17 |
|
17 | |||
18 | class Version < ActiveRecord::Base |
|
18 | class Version < ActiveRecord::Base | |
19 | include Redmine::SafeAttributes |
|
19 | include Redmine::SafeAttributes | |
|
20 | ||||
20 | after_update :update_issues_from_sharing_change |
|
21 | after_update :update_issues_from_sharing_change | |
|
22 | before_destroy :nullify_projects_default_version | |||
|
23 | ||||
21 | belongs_to :project |
|
24 | belongs_to :project | |
22 | has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify |
|
25 | has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify | |
23 | acts_as_customizable |
|
26 | acts_as_customizable | |
@@ -297,4 +300,8 class Version < ActiveRecord::Base | |||||
297 | CustomValue.joins(:custom_field). |
|
300 | CustomValue.joins(:custom_field). | |
298 | where(:value => id.to_s, :custom_fields => {:field_format => 'version'}).any? |
|
301 | where(:value => id.to_s, :custom_fields => {:field_format => 'version'}).any? | |
299 | end |
|
302 | end | |
|
303 | ||||
|
304 | def nullify_projects_default_version | |||
|
305 | Project.where(:default_version_id => id).update_all(:default_version_id => nil) | |||
|
306 | end | |||
300 | end |
|
307 | end |
@@ -20,6 +20,10 | |||||
20 | <p><%= f.check_box :inherit_members %></p> |
|
20 | <p><%= f.check_box :inherit_members %></p> | |
21 | <% end %> |
|
21 | <% end %> | |
22 |
|
22 | |||
|
23 | <% if @project.safe_attribute?('default_version_id') && (default_version_options = project_default_version_options(@project)).present? %> | |||
|
24 | <p><%= f.select :default_version_id, project_default_version_options(@project), :include_blank => true %></p> | |||
|
25 | <% end %> | |||
|
26 | ||||
23 | <%= wikitoolbar_for 'project_description' %> |
|
27 | <%= wikitoolbar_for 'project_description' %> | |
24 |
|
28 | |||
25 | <% @project.custom_field_values.each do |value| %> |
|
29 | <% @project.custom_field_values.each do |value| %> |
@@ -348,6 +348,7 en: | |||||
348 | field_users_visibility: Users visibility |
|
348 | field_users_visibility: Users visibility | |
349 | field_time_entries_visibility: Time logs visibility |
|
349 | field_time_entries_visibility: Time logs visibility | |
350 | field_total_estimated_hours: Total estimated time |
|
350 | field_total_estimated_hours: Total estimated time | |
|
351 | field_default_version: Default version | |||
351 |
|
352 | |||
352 | setting_app_title: Application title |
|
353 | setting_app_title: Application title | |
353 | setting_app_subtitle: Application subtitle |
|
354 | setting_app_subtitle: Application subtitle |
@@ -368,6 +368,7 fr: | |||||
368 | field_users_visibility: Visibilité des utilisateurs |
|
368 | field_users_visibility: Visibilité des utilisateurs | |
369 | field_time_entries_visibility: Visibilité du temps passé |
|
369 | field_time_entries_visibility: Visibilité du temps passé | |
370 | field_total_estimated_hours: Temps estimé total |
|
370 | field_total_estimated_hours: Temps estimé total | |
|
371 | field_default_version: Version par défaut | |||
371 |
|
372 | |||
372 | setting_app_title: Titre de l'application |
|
373 | setting_app_title: Titre de l'application | |
373 | setting_app_subtitle: Sous-titre de l'application |
|
374 | setting_app_subtitle: Sous-titre de l'application |
@@ -1715,6 +1715,19 class IssuesControllerTest < ActionController::TestCase | |||||
1715 | end |
|
1715 | end | |
1716 | end |
|
1716 | end | |
1717 |
|
1717 | |||
|
1718 | def test_new_should_preselect_default_version | |||
|
1719 | version = Version.generate!(:project_id => 1) | |||
|
1720 | Project.find(1).update_attribute :default_version_id, version.id | |||
|
1721 | @request.session[:user_id] = 2 | |||
|
1722 | ||||
|
1723 | get :new, :project_id => 1 | |||
|
1724 | assert_response :success | |||
|
1725 | assert_equal version, assigns(:issue).fixed_version | |||
|
1726 | assert_select 'select[name=?]', 'issue[fixed_version_id]' do | |||
|
1727 | assert_select 'option[value=?][selected=selected]', version.id.to_s | |||
|
1728 | end | |||
|
1729 | end | |||
|
1730 | ||||
1718 | def test_get_new_with_list_custom_field |
|
1731 | def test_get_new_with_list_custom_field | |
1719 | @request.session[:user_id] = 2 |
|
1732 | @request.session[:user_id] = 2 | |
1720 | get :new, :project_id => 1, :tracker_id => 1 |
|
1733 | get :new, :project_id => 1, :tracker_id => 1 |
@@ -496,6 +496,14 class IssueTest < ActiveSupport::TestCase | |||||
496 | assert_equal custom_value.id, issue.custom_value_for(field).id |
|
496 | assert_equal custom_value.id, issue.custom_value_for(field).id | |
497 | end |
|
497 | end | |
498 |
|
498 | |||
|
499 | def test_setting_project_should_set_version_to_default_version | |||
|
500 | version = Version.generate!(:project_id => 1) | |||
|
501 | Project.find(1).update_attribute(:default_version_id, version.id) | |||
|
502 | ||||
|
503 | issue = Issue.new(:project_id => 1) | |||
|
504 | assert_equal version, issue.fixed_version | |||
|
505 | end | |||
|
506 | ||||
499 | def test_should_not_update_custom_fields_on_changing_tracker_with_different_custom_fields |
|
507 | def test_should_not_update_custom_fields_on_changing_tracker_with_different_custom_fields | |
500 | issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, |
|
508 | issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, | |
501 | :status_id => 1, :subject => 'Test', |
|
509 | :status_id => 1, :subject => 'Test', |
General Comments 0
You need to be logged in to leave comments.
Login now