@@ -99,6 +99,7 module ObjectHelpers | |||
|
99 | 99 | @generated_version_name.succ! |
|
100 | 100 | version = Version.new(attributes) |
|
101 | 101 | version.name = @generated_version_name.dup if version.name.blank? |
|
102 | version.project ||= Project.find(1) | |
|
102 | 103 | yield version if block_given? |
|
103 | 104 | version.save! |
|
104 | 105 | version |
@@ -20,21 +20,19 require File.expand_path('../../../test_helper', __FILE__) | |||
|
20 | 20 | class PatchesTest < ActiveSupport::TestCase |
|
21 | 21 | include Redmine::I18n |
|
22 | 22 | |
|
23 | context "ActiveRecord::Base.human_attribute_name" do | |
|
24 | setup do | |
|
23 | def setup | |
|
25 | 24 |
|
|
26 | 25 |
|
|
27 | 26 | |
|
28 |
|
|
|
27 | test "ActiveRecord::Base.human_attribute_name should transform name to field_name" do | |
|
29 | 28 |
|
|
30 | 29 |
|
|
31 | 30 | |
|
32 |
|
|
|
31 | test "ActiveRecord::Base.human_attribute_name should cut extra _id suffix for better validation" do | |
|
33 | 32 |
|
|
34 | 33 |
|
|
35 | 34 | |
|
36 |
|
|
|
35 | test "ActiveRecord::Base.human_attribute_name should default to humanized value if no translation has been found (useful for custom fields)" do | |
|
37 | 36 |
|
|
38 | 37 |
|
|
39 | 38 |
|
|
40 | end |
@@ -18,20 +18,18 | |||
|
18 | 18 | require File.expand_path('../../../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class Redmine::MenuManager::MapperTest < ActiveSupport::TestCase |
|
21 | context "Mapper#initialize" do | |
|
22 | should "define a root MenuNode if menu is not present in items" do | |
|
21 | test "Mapper#initialize should define a root MenuNode if menu is not present in items" do | |
|
23 | 22 |
|
|
24 | 23 |
|
|
25 | 24 |
|
|
26 | 25 |
|
|
27 | 26 |
|
|
28 | 27 | |
|
29 |
|
|
|
28 | test "Mapper#initialize should use existing MenuNode if present" do | |
|
30 | 29 |
|
|
31 | 30 |
|
|
32 | 31 |
|
|
33 | 32 |
|
|
34 | end | |
|
35 | 33 | |
|
36 | 34 | def test_push_onto_root |
|
37 | 35 | menu_mapper = Redmine::MenuManager::Mapper.new(:test_menu, {}) |
@@ -404,14 +404,13 class UserTest < ActiveSupport::TestCase | |||
|
404 | 404 | assert_not_nil u.errors[:mail_notification] |
|
405 | 405 | end |
|
406 | 406 | |
|
407 | context "User#try_to_login" do | |
|
408 | should "fall-back to case-insensitive if user login is not found as-typed." do | |
|
407 | test "User#try_to_login should fall-back to case-insensitive if user login is not found as-typed" do | |
|
409 | 408 |
|
|
410 | 409 |
|
|
411 | 410 |
|
|
412 | 411 |
|
|
413 | 412 | |
|
414 |
|
|
|
413 | test "User#try_to_login should select the exact matching user first" do | |
|
415 | 414 |
|
|
416 | 415 |
|
|
417 | 416 |
|
@@ -421,8 +420,6 class UserTest < ActiveSupport::TestCase | |||
|
421 | 420 |
|
|
422 | 421 |
|
|
423 | 422 |
|
|
424 | ||
|
425 | end | |
|
426 | 423 | end |
|
427 | 424 | |
|
428 | 425 | def test_password |
@@ -527,21 +524,15 class UserTest < ActiveSupport::TestCase | |||
|
527 | 524 | assert_equal nil, user |
|
528 | 525 | end |
|
529 | 526 | |
|
530 | context ".try_to_login" do | |
|
531 | context "with good credentials" do | |
|
532 | should "return the user" do | |
|
527 | test ".try_to_login with good credentials should return the user" do | |
|
533 | 528 |
|
|
534 | 529 |
|
|
535 | 530 |
|
|
536 | 531 |
|
|
537 | end | |
|
538 | 532 | |
|
539 |
|
|
|
540 | should "return nil" do | |
|
533 | test ".try_to_login with wrong credentials should return nil" do | |
|
541 | 534 |
|
|
542 | 535 |
|
|
543 | end | |
|
544 | end | |
|
545 | 536 | |
|
546 | 537 | if ldap_configured? |
|
547 | 538 | context "#try_to_login using LDAP" do |
@@ -684,8 +675,7 class UserTest < ActiveSupport::TestCase | |||
|
684 | 675 | end |
|
685 | 676 | end |
|
686 | 677 | |
|
687 | context "User#api_key" do | |
|
688 | should "generate a new one if the user doesn't have one" do | |
|
678 | test "#api_key should generate a new one if the user doesn't have one" do | |
|
689 | 679 |
|
|
690 | 680 |
|
|
691 | 681 | |
@@ -695,7 +685,7 class UserTest < ActiveSupport::TestCase | |||
|
695 | 685 |
|
|
696 | 686 |
|
|
697 | 687 | |
|
698 |
|
|
|
688 | test "#api_key should return the existing api token value" do | |
|
699 | 689 |
|
|
700 | 690 |
|
|
701 | 691 |
|
@@ -703,14 +693,12 class UserTest < ActiveSupport::TestCase | |||
|
703 | 693 | |
|
704 | 694 |
|
|
705 | 695 |
|
|
706 | end | |
|
707 | 696 | |
|
708 | context "User#find_by_api_key" do | |
|
709 | should "return nil if no matching key is found" do | |
|
697 | test "#find_by_api_key should return nil if no matching key is found" do | |
|
710 | 698 |
|
|
711 | 699 |
|
|
712 | 700 | |
|
713 |
|
|
|
701 | test "#find_by_api_key should return nil if the key is found for an inactive user" do | |
|
714 | 702 |
|
|
715 | 703 |
|
|
716 | 704 |
|
@@ -720,7 +708,7 class UserTest < ActiveSupport::TestCase | |||
|
720 | 708 |
|
|
721 | 709 |
|
|
722 | 710 | |
|
723 |
|
|
|
711 | test "#find_by_api_key should return the user if the key is found for an active user" do | |
|
724 | 712 |
|
|
725 | 713 |
|
|
726 | 714 |
|
@@ -728,7 +716,6 class UserTest < ActiveSupport::TestCase | |||
|
728 | 716 | |
|
729 | 717 |
|
|
730 | 718 |
|
|
731 | end | |
|
732 | 719 | |
|
733 | 720 | def test_default_admin_account_changed_should_return_false_if_account_was_not_changed |
|
734 | 721 | user = User.find_by_login("admin") |
@@ -880,13 +867,12 class UserTest < ActiveSupport::TestCase | |||
|
880 | 867 | assert !u.password_confirmation.blank? |
|
881 | 868 | end |
|
882 | 869 | |
|
883 |
|
|
|
884 | should "be allowed if no auth source is set" do | |
|
870 | test "#change_password_allowed? should be allowed if no auth source is set" do | |
|
885 | 871 |
|
|
886 | 872 |
|
|
887 | 873 |
|
|
888 | 874 | |
|
889 |
|
|
|
875 | test "#change_password_allowed? should delegate to the auth source" do | |
|
890 | 876 |
|
|
891 | 877 | |
|
892 | 878 |
|
@@ -903,7 +889,6 class UserTest < ActiveSupport::TestCase | |||
|
903 | 889 |
|
|
904 | 890 |
|
|
905 | 891 |
|
|
906 | end | |
|
907 | 892 | |
|
908 | 893 | def test_own_account_deletable_should_be_true_with_unsubscrive_enabled |
|
909 | 894 | with_settings :unsubscribe => '1' do |
@@ -132,75 +132,64 class VersionTest < ActiveSupport::TestCase | |||
|
132 | 132 | assert_equal false, version.completed? |
|
133 | 133 | end |
|
134 | 134 | |
|
135 | context "#behind_schedule?" do | |
|
136 | setup do | |
|
137 | ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests | |
|
138 | @project = Project.create!(:name => 'test0', :identifier => 'test0') | |
|
139 | @project.trackers << Tracker.create!(:name => 'track') | |
|
140 | ||
|
141 | @version = Version.create!(:project => @project, :effective_date => nil, :name => 'version') | |
|
142 | end | |
|
143 | ||
|
144 | should "be false if there are no issues assigned" do | |
|
145 | @version.update_attribute(:effective_date, Date.yesterday) | |
|
146 | assert_equal false, @version.behind_schedule? | |
|
135 | test "#behind_schedule? should be false if there are no issues assigned" do | |
|
136 | version = Version.generate!(:effective_date => Date.yesterday) | |
|
137 | assert_equal false, version.behind_schedule? | |
|
147 | 138 |
|
|
148 | 139 | |
|
149 |
|
|
|
150 | assert_equal false, @version.behind_schedule? | |
|
140 | test "#behind_schedule? should be false if there is no effective_date" do | |
|
141 | version = Version.generate!(:effective_date => nil) | |
|
142 | assert_equal false, version.behind_schedule? | |
|
151 | 143 |
|
|
152 | 144 | |
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
145 | test "#behind_schedule? should be false if all of the issues are ahead of schedule" do | |
|
146 | version = Version.generate!(:effective_date => 7.days.from_now.to_date) | |
|
147 | add_issue(version, :start_date => 7.days.ago, :done_ratio => 60) # 14 day span, 60% done, 50% time left | |
|
148 | add_issue(version, :start_date => 7.days.ago, :done_ratio => 60) # 14 day span, 60% done, 50% time left | |
|
149 | assert_equal 60, version.completed_percent | |
|
150 | assert_equal false, version.behind_schedule? | |
|
159 | 151 |
|
|
160 | 152 | |
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
153 | test "#behind_schedule? should be true if any of the issues are behind schedule" do | |
|
154 | version = Version.generate!(:effective_date => 7.days.from_now.to_date) | |
|
155 | add_issue(version, :start_date => 7.days.ago, :done_ratio => 60) # 14 day span, 60% done, 50% time left | |
|
156 | add_issue(version, :start_date => 7.days.ago, :done_ratio => 20) # 14 day span, 20% done, 50% time left | |
|
157 | assert_equal 40, version.completed_percent | |
|
158 | assert_equal true, version.behind_schedule? | |
|
167 | 159 |
|
|
168 | 160 | |
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 | end | |
|
161 | test "#behind_schedule? should be false if all of the issues are complete" do | |
|
162 | version = Version.generate!(:effective_date => 7.days.from_now.to_date) | |
|
163 | add_issue(version, :start_date => 14.days.ago, :done_ratio => 100, :status => IssueStatus.find(5)) # 7 day span | |
|
164 | add_issue(version, :start_date => 14.days.ago, :done_ratio => 100, :status => IssueStatus.find(5)) # 7 day span | |
|
165 | assert_equal 100, version.completed_percent | |
|
166 | assert_equal false, version.behind_schedule? | |
|
176 | 167 | end |
|
177 | 168 | |
|
178 | context "#estimated_hours" do | |
|
179 | setup do | |
|
180 | @version = Version.create!(:project_id => 1, :name => '#estimated_hours') | |
|
169 | test "#estimated_hours should return 0 with no assigned issues" do | |
|
170 | version = Version.generate! | |
|
171 | assert_equal 0, version.estimated_hours | |
|
181 | 172 |
|
|
182 | 173 | |
|
183 |
|
|
|
184 | assert_equal 0, @version.estimated_hours | |
|
174 | test "#estimated_hours should return 0 with no estimated hours" do | |
|
175 | version = Version.generate! | |
|
176 | add_issue(version) | |
|
177 | assert_equal 0, version.estimated_hours | |
|
185 | 178 |
|
|
186 | 179 | |
|
187 |
|
|
|
188 | add_issue(@version) | |
|
189 |
|
|
|
180 | test "#estimated_hours should return return the sum of estimated hours" do | |
|
181 | version = Version.generate! | |
|
182 | add_issue(version, :estimated_hours => 2.5) | |
|
183 | add_issue(version, :estimated_hours => 5) | |
|
184 | assert_equal 7.5, version.estimated_hours | |
|
190 | 185 |
|
|
191 | 186 | |
|
192 |
|
|
|
193 | add_issue(@version, :estimated_hours => 2.5) | |
|
194 |
add_issue( |
|
|
195 | assert_equal 7.5, @version.estimated_hours | |
|
196 | end | |
|
197 | ||
|
198 | should "return the sum of leaves estimated hours" do | |
|
199 | parent = add_issue(@version) | |
|
200 | add_issue(@version, :estimated_hours => 2.5, :parent_issue_id => parent.id) | |
|
201 | add_issue(@version, :estimated_hours => 5, :parent_issue_id => parent.id) | |
|
202 | assert_equal 7.5, @version.estimated_hours | |
|
203 | end | |
|
187 | test "#estimated_hours should return the sum of leaves estimated hours" do | |
|
188 | version = Version.generate! | |
|
189 | parent = add_issue(version) | |
|
190 | add_issue(version, :estimated_hours => 2.5, :parent_issue_id => parent.id) | |
|
191 | add_issue(version, :estimated_hours => 5, :parent_issue_id => parent.id) | |
|
192 | assert_equal 7.5, version.estimated_hours | |
|
204 | 193 | end |
|
205 | 194 | |
|
206 | 195 | test "should update all issue's fixed_version associations in case the hierarchy changed XXX" do |
General Comments 0
You need to be logged in to leave comments.
Login now