##// END OF EJS Templates
Use #update! instead of #update_attribute....
Jean-Philippe Lang -
r15303:f4b885d088e7
parent child
Show More
@@ -137,7 +137,7 class IssueTest < ActiveSupport::TestCase
137 137 def test_create_with_required_custom_field
138 138 set_language_if_valid 'en'
139 139 field = IssueCustomField.find_by_name('Database')
140 field.update_attribute(:is_required, true)
140 field.update!(:is_required => true)
141 141
142 142 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1,
143 143 :status_id => 1, :subject => 'test_create',
@@ -242,14 +242,14 class IssueTest < ActiveSupport::TestCase
242 242 end
243 243
244 244 def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_default
245 assert Role.anonymous.update_attribute(:issues_visibility, 'default')
245 Role.anonymous.update!(:issues_visibility => 'default')
246 246 issue = Issue.generate!(:author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
247 247 assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
248 248 assert !issue.visible?(User.anonymous)
249 249 end
250 250
251 251 def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_own
252 assert Role.anonymous.update_attribute(:issues_visibility, 'own')
252 assert Role.anonymous.update!(:issues_visibility => 'own')
253 253 issue = Issue.generate!(:author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
254 254 assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
255 255 assert !issue.visible?(User.anonymous)
@@ -267,7 +267,7 class IssueTest < ActiveSupport::TestCase
267 267 end
268 268
269 269 def test_visible_scope_for_non_member_with_own_issues_visibility
270 Role.non_member.update_attribute :issues_visibility, 'own'
270 Role.non_member.update! :issues_visibility => 'own'
271 271 Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 9, :subject => 'Issue by non member')
272 272 user = User.find(9)
273 273
@@ -331,12 +331,12 class IssueTest < ActiveSupport::TestCase
331 331 :assigned_to => user.groups.first,
332 332 :is_private => true)
333 333
334 Role.find(2).update_attribute :issues_visibility, 'default'
334 Role.find(2).update! :issues_visibility => 'default'
335 335 issues = Issue.visible(User.find(8)).to_a
336 336 assert issues.any?
337 337 assert issues.include?(issue)
338 338
339 Role.find(2).update_attribute :issues_visibility, 'own'
339 Role.find(2).update! :issues_visibility => 'own'
340 340 issues = Issue.visible(User.find(8)).to_a
341 341 assert issues.any?
342 342 assert_include issue, issues
@@ -515,7 +515,7 class IssueTest < ActiveSupport::TestCase
515 515
516 516 def test_update_issue_with_required_custom_field
517 517 field = IssueCustomField.find_by_name('Database')
518 field.update_attribute(:is_required, true)
518 field.update!(:is_required => true)
519 519
520 520 issue = Issue.find(1)
521 521 assert_nil issue.custom_value_for(field)
@@ -561,7 +561,7 class IssueTest < ActiveSupport::TestCase
561 561
562 562 def test_setting_project_should_set_version_to_default_version
563 563 version = Version.generate!(:project_id => 1)
564 Project.find(1).update_attribute(:default_version_id, version.id)
564 Project.find(1).update!(:default_version_id => version.id)
565 565
566 566 issue = Issue.new(:project_id => 1)
567 567 assert_equal version, issue.fixed_version
@@ -1477,7 +1477,7 class IssueTest < ActiveSupport::TestCase
1477 1477 end
1478 1478
1479 1479 def test_should_keep_shared_version_when_changing_project
1480 Version.find(2).update_attribute :sharing, 'tree'
1480 Version.find(2).update! :sharing => 'tree'
1481 1481
1482 1482 issue = Issue.find(2)
1483 1483 assert_equal 2, issue.fixed_version_id
@@ -1610,7 +1610,7 class IssueTest < ActiveSupport::TestCase
1610 1610
1611 1611 def test_move_to_another_project_should_clear_fixed_version_when_not_shared
1612 1612 issue = Issue.find(1)
1613 issue.update_attribute(:fixed_version_id, 1)
1613 issue.update!(:fixed_version_id => 3)
1614 1614 issue.project = Project.find(2)
1615 1615 assert issue.save
1616 1616 issue.reload
@@ -1621,7 +1621,7 class IssueTest < ActiveSupport::TestCase
1621 1621
1622 1622 def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
1623 1623 issue = Issue.find(1)
1624 issue.update_attribute(:fixed_version_id, 4)
1624 issue.update!(:fixed_version_id => 4)
1625 1625 issue.project = Project.find(5)
1626 1626 assert issue.save
1627 1627 issue.reload
@@ -1632,7 +1632,7 class IssueTest < ActiveSupport::TestCase
1632 1632
1633 1633 def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
1634 1634 issue = Issue.find(1)
1635 issue.update_attribute(:fixed_version_id, 1)
1635 issue.update!(:fixed_version_id => 3)
1636 1636 issue.project = Project.find(5)
1637 1637 assert issue.save
1638 1638 issue.reload
@@ -1643,7 +1643,7 class IssueTest < ActiveSupport::TestCase
1643 1643
1644 1644 def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
1645 1645 issue = Issue.find(1)
1646 issue.update_attribute(:fixed_version_id, 7)
1646 issue.update!(:fixed_version_id => 7)
1647 1647 issue.project = Project.find(2)
1648 1648 assert issue.save
1649 1649 issue.reload
@@ -1654,7 +1654,7 class IssueTest < ActiveSupport::TestCase
1654 1654
1655 1655 def test_move_to_another_project_should_keep_parent_if_valid
1656 1656 issue = Issue.find(1)
1657 issue.update_attribute(:parent_issue_id, 2)
1657 issue.update! :parent_issue_id => 2
1658 1658 issue.project = Project.find(3)
1659 1659 assert issue.save
1660 1660 issue.reload
@@ -1663,7 +1663,7 class IssueTest < ActiveSupport::TestCase
1663 1663
1664 1664 def test_move_to_another_project_should_clear_parent_if_not_valid
1665 1665 issue = Issue.find(1)
1666 issue.update_attribute(:parent_issue_id, 2)
1666 issue.update! :parent_issue_id => 2
1667 1667 issue.project = Project.find(2)
1668 1668 assert issue.save
1669 1669 issue.reload
@@ -1799,7 +1799,7 class IssueTest < ActiveSupport::TestCase
1799 1799 def test_recipients_should_include_previous_assignee
1800 1800 user = User.find(3)
1801 1801 user.members.update_all ["mail_notification = ?", false]
1802 user.update_attribute :mail_notification, 'only_assigned'
1802 user.update! :mail_notification => 'only_assigned'
1803 1803
1804 1804 issue = Issue.find(2)
1805 1805 issue.assigned_to = nil
@@ -1864,7 +1864,7 class IssueTest < ActiveSupport::TestCase
1864 1864
1865 1865 def test_destroying_a_stale_issue_should_not_raise_an_error
1866 1866 issue = Issue.find(1)
1867 Issue.find(1).update_attribute :subject, "Updated"
1867 Issue.find(1).update! :subject => "Updated"
1868 1868
1869 1869 assert_nothing_raised do
1870 1870 assert_difference 'Issue.count', -1 do
@@ -2345,7 +2345,7 class IssueTest < ActiveSupport::TestCase
2345 2345 ActionMailer::Base.deliveries.clear
2346 2346 user = User.find(3)
2347 2347 user.members.update_all ["mail_notification = ?", false]
2348 user.update_attribute :mail_notification, 'only_assigned'
2348 user.update! :mail_notification => 'only_assigned'
2349 2349
2350 2350 with_settings :notified_events => %w(issue_updated) do
2351 2351 issue = Issue.find(2)
@@ -2482,10 +2482,10 class IssueTest < ActiveSupport::TestCase
2482 2482 test "#done_ratio should use the issue_status according to Setting.issue_done_ratio" do
2483 2483 @issue = Issue.find(1)
2484 2484 @issue_status = IssueStatus.find(1)
2485 @issue_status.update_attribute(:default_done_ratio, 50)
2485 @issue_status.update!(:default_done_ratio => 50)
2486 2486 @issue2 = Issue.find(2)
2487 2487 @issue_status2 = IssueStatus.find(2)
2488 @issue_status2.update_attribute(:default_done_ratio, 0)
2488 @issue_status2.update!(:default_done_ratio => 0)
2489 2489
2490 2490 with_settings :issue_done_ratio => 'issue_field' do
2491 2491 assert_equal 0, @issue.done_ratio
@@ -2501,10 +2501,10 class IssueTest < ActiveSupport::TestCase
2501 2501 test "#update_done_ratio_from_issue_status should update done_ratio according to Setting.issue_done_ratio" do
2502 2502 @issue = Issue.find(1)
2503 2503 @issue_status = IssueStatus.find(1)
2504 @issue_status.update_attribute(:default_done_ratio, 50)
2504 @issue_status.update!(:default_done_ratio => 50)
2505 2505 @issue2 = Issue.find(2)
2506 2506 @issue_status2 = IssueStatus.find(2)
2507 @issue_status2.update_attribute(:default_done_ratio, 0)
2507 @issue_status2.update!(:default_done_ratio => 0)
2508 2508
2509 2509 with_settings :issue_done_ratio => 'issue_field' do
2510 2510 @issue.update_done_ratio_from_issue_status
@@ -2614,19 +2614,19 class IssueTest < ActiveSupport::TestCase
2614 2614
2615 2615 test "Issue#recipients should not include users who opt out of all email" do
2616 2616 issue = Issue.generate!(:author => User.generate!)
2617 issue.author.update_attribute(:mail_notification, :none)
2617 issue.author.update!(:mail_notification => :none)
2618 2618 assert !issue.recipients.include?(issue.author.mail)
2619 2619 end
2620 2620
2621 2621 test "Issue#recipients should not include the issue author if they are only notified of assigned issues" do
2622 2622 issue = Issue.generate!(:author => User.generate!)
2623 issue.author.update_attribute(:mail_notification, :only_assigned)
2623 issue.author.update!(:mail_notification => :only_assigned)
2624 2624 assert !issue.recipients.include?(issue.author.mail)
2625 2625 end
2626 2626
2627 2627 test "Issue#recipients should not include the assigned user if they are only notified of owned issues" do
2628 2628 issue = Issue.generate!(:assigned_to => User.generate!)
2629 issue.assigned_to.update_attribute(:mail_notification, :only_owner)
2629 issue.assigned_to.update!(:mail_notification => :only_owner)
2630 2630 assert !issue.recipients.include?(issue.assigned_to.mail)
2631 2631 end
2632 2632
@@ -2921,10 +2921,10 class IssueTest < ActiveSupport::TestCase
2921 2921
2922 2922 def test_issue_overdue_should_respect_user_timezone
2923 2923 user_in_europe = users(:users_001)
2924 user_in_europe.pref.update_attribute :time_zone, 'UTC'
2924 user_in_europe.pref.update! :time_zone => 'UTC'
2925 2925
2926 2926 user_in_asia = users(:users_002)
2927 user_in_asia.pref.update_attribute :time_zone, 'Hongkong'
2927 user_in_asia.pref.update! :time_zone => 'Hongkong'
2928 2928
2929 2929 issue = Issue.generate! :due_date => Date.parse('2016-03-20')
2930 2930
General Comments 0
You need to be logged in to leave comments. Login now