summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-10-12 23:10:25 +0000
committerGo MAEDA <maeda@farend.jp>2023-10-12 23:10:25 +0000
commitb81818100c905df209caf2659faafda80542e16f (patch)
tree1cabf693320dda821fc0990ddfbd6954171d1e7d /test
parentcb617673b3e072e9d64c198b45e8a020cc754c70 (diff)
downloadredmine-b81818100c905df209caf2659faafda80542e16f.tar.gz
redmine-b81818100c905df209caf2659faafda80542e16f.zip
Fix RuboCop offense Rails/RedundantActiveRecordAllMethod (#37248).
git-svn-id: https://svn.redmine.org/redmine/trunk@22340 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/custom_fields_controller_test.rb4
-rw-r--r--test/functional/trackers_controller_test.rb2
-rw-r--r--test/integration/twofa_test.rb2
-rw-r--r--test/object_helpers.rb2
-rw-r--r--test/unit/issue_import_test.rb4
-rw-r--r--test/unit/issue_test.rb12
-rw-r--r--test/unit/query_test.rb2
-rw-r--r--test/unit/time_entry_test.rb6
8 files changed, 17 insertions, 17 deletions
diff --git a/test/functional/custom_fields_controller_test.rb b/test/functional/custom_fields_controller_test.rb
index 8dcc2a2be..b6e4ed6ce 100644
--- a/test/functional/custom_fields_controller_test.rb
+++ b/test/functional/custom_fields_controller_test.rb
@@ -361,7 +361,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
assert_select "input[type=checkbox][name=?][value=#{tracker_id}][checked=checked]", 'custom_field[tracker_ids][]'
end
# tracker not checked
- (Tracker.all.pluck(:id) - tracker_ids).each do |tracker_id|
+ (Tracker.pluck(:id) - tracker_ids).each do |tracker_id|
assert_select "input[type=checkbox][name=?][value=#{tracker_id}]", 'custom_field[tracker_ids][]'
end
# project checked
@@ -369,7 +369,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
assert_select "input[type=checkbox][name=?][value=#{project_id}][checked=checked]", 'custom_field[project_ids][]'
end
# project not checked
- (Project.all.pluck(:id) - project_ids).each do |project_id|
+ (Project.pluck(:id) - project_ids).each do |project_id|
assert_select "input[type=checkbox][name=?][value=#{project_id}]", 'custom_field[project_ids][]'
end
end
diff --git a/test/functional/trackers_controller_test.rb b/test/functional/trackers_controller_test.rb
index 218397ca5..49e1e18c2 100644
--- a/test/functional/trackers_controller_test.rb
+++ b/test/functional/trackers_controller_test.rb
@@ -107,7 +107,7 @@ class TrackersControllerTest < Redmine::ControllerTest
assert_select "input[type=checkbox][name=?][value=#{project_id}][checked=checked]", 'tracker[project_ids][]'
end
# project not checked
- (Project.all.pluck(:id) - project_ids).each do |project_id|
+ (Project.pluck(:id) - project_ids).each do |project_id|
assert_select "input[type=checkbox][name=?][value=#{project_id}]", 'tracker[project_ids][]'
end
# workflow copy selected
diff --git a/test/integration/twofa_test.rb b/test/integration/twofa_test.rb
index eb24de402..b35a44575 100644
--- a/test/integration/twofa_test.rb
+++ b/test/integration/twofa_test.rb
@@ -56,7 +56,7 @@ class TwofaTest < Redmine::IntegrationTest
user = User.find_by_login 'jsmith'
assert_not user.must_activate_twofa?
- group = Group.all.first
+ group = Group.first
group.update_column :twofa_required, true
group.users << user
user.reload
diff --git a/test/object_helpers.rb b/test/object_helpers.rb
index 3900bc45d..49596fec6 100644
--- a/test/object_helpers.rb
+++ b/test/object_helpers.rb
@@ -208,7 +208,7 @@ module ObjectHelpers
def IssueCustomField.generate!(attributes={})
super do |field|
field.is_for_all = true unless attributes.key?(:is_for_all)
- field.tracker_ids = Tracker.all.ids unless attributes.key?(:tracker_ids) || attributes.key?(:trackers)
+ field.tracker_ids = Tracker.ids unless attributes.key?(:tracker_ids) || attributes.key?(:trackers)
yield field if block_given?
end
end
diff --git a/test/unit/issue_import_test.rb b/test/unit/issue_import_test.rb
index 04d9a2ba3..d68f0e44c 100644
--- a/test/unit/issue_import_test.rb
+++ b/test/unit/issue_import_test.rb
@@ -316,7 +316,7 @@ class IssueImportTest < ActiveSupport::TestCase
def test_list_custom_field_should_be_set
field = CustomField.find(1)
- field.tracker_ids = Tracker.all.ids
+ field.tracker_ids = Tracker.ids
field.save!
import = generate_import_with_mapping
import.mapping["cf_1"] = '8'
@@ -330,7 +330,7 @@ class IssueImportTest < ActiveSupport::TestCase
def test_multiple_list_custom_field_should_be_set
field = CustomField.find(1)
- field.tracker_ids = Tracker.all.ids
+ field.tracker_ids = Tracker.ids
field.multiple = true
field.save!
import = generate_import_with_mapping
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index bfb35b264..14124f7bd 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -58,7 +58,7 @@ class IssueTest < ActiveSupport::TestCase
def test_create
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
- :status_id => 1, :priority => IssuePriority.all.first,
+ :status_id => 1, :priority => IssuePriority.first,
:subject => 'test_create',
:description => 'IssueTest#test_create', :estimated_hours => '1:30')
assert issue.save
@@ -375,7 +375,7 @@ class IssueTest < ActiveSupport::TestCase
with_settings :issue_group_assignment => '1' do
issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 3,
- :status_id => 1, :priority => IssuePriority.all.first,
+ :status_id => 1, :priority => IssuePriority.first,
:subject => 'Assignment test',
:assigned_to => group,
:is_private => true)
@@ -798,7 +798,7 @@ class IssueTest < ActiveSupport::TestCase
def test_category_based_assignment
issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3,
- :status_id => 1, :priority => IssuePriority.all.first,
+ :status_id => 1, :priority => IssuePriority.first,
:subject => 'Assignment test',
:description => 'Assignment test', :category_id => 1)
assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
@@ -2690,7 +2690,7 @@ class IssueTest < ActiveSupport::TestCase
ActionMailer::Base.deliveries.clear
issue = Issue.new(:project_id => 1, :tracker_id => 1,
:author_id => 3, :status_id => 1,
- :priority => IssuePriority.all.first,
+ :priority => IssuePriority.first,
:subject => 'test_create', :estimated_hours => '1:30')
with_settings :notified_events => %w(issue_added) do
assert issue.save
@@ -2702,7 +2702,7 @@ class IssueTest < ActiveSupport::TestCase
ActionMailer::Base.deliveries.clear
issue = Issue.new(:project_id => 1, :tracker_id => 1,
:author_id => 3, :status_id => 1,
- :priority => IssuePriority.all.first,
+ :priority => IssuePriority.first,
:subject => 'test_create', :estimated_hours => '1:30')
with_settings :notified_events => %w(issue_added issue_updated) do
assert issue.save
@@ -2714,7 +2714,7 @@ class IssueTest < ActiveSupport::TestCase
ActionMailer::Base.deliveries.clear
issue = Issue.new(:project_id => 1, :tracker_id => 1,
:author_id => 3, :status_id => 1,
- :priority => IssuePriority.all.first,
+ :priority => IssuePriority.first,
:subject => 'test_create', :estimated_hours => '1:30')
with_settings :notified_events => [] do
assert issue.save
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index bb3eecb04..52195e584 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -860,7 +860,7 @@ class QueryTest < ActiveSupport::TestCase
}
)
result = find_issues_with_query(query)
- expected = Issue.all.order(:id).ids - [8, 11, 12]
+ expected = Issue.order(:id).ids - [8, 11, 12]
assert_equal expected, result.map(&:id).sort
end
diff --git a/test/unit/time_entry_test.rb b/test/unit/time_entry_test.rb
index e1013afd7..380f8bb37 100644
--- a/test/unit/time_entry_test.rb
+++ b/test/unit/time_entry_test.rb
@@ -141,7 +141,7 @@ class TimeEntryTest < ActiveSupport::TestCase
def test_activity_id_should_be_set_automatically_if_there_is_only_one_activity_available
project = Project.find(1)
- TimeEntry.all.destroy_all
+ TimeEntry.destroy_all
TimeEntryActivity.destroy_all
only_one_activity = TimeEntryActivity.create!(
name: 'Development',
@@ -221,7 +221,7 @@ class TimeEntryTest < ActiveSupport::TestCase
anon = User.anonymous
project = Project.find(1)
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => anon.id, :status_id => 1,
- :priority => IssuePriority.all.first, :subject => 'test_create',
+ :priority => IssuePriority.first, :subject => 'test_create',
:description => 'IssueTest#test_create', :estimated_hours => '1:30')
assert issue.save
activity = TimeEntryActivity.find_by_name('Design')
@@ -254,7 +254,7 @@ class TimeEntryTest < ActiveSupport::TestCase
anon = User.anonymous
project = Project.find(1)
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => anon.id, :status_id => 1,
- :priority => IssuePriority.all.first, :subject => 'test_create',
+ :priority => IssuePriority.first, :subject => 'test_create',
:description => 'IssueTest#test_create', :estimated_hours => '1:30')
assert issue.save
activity = TimeEntryActivity.find_by_name('Design')