mirror of
https://github.com/redmine/redmine.git
synced 2025-11-07 22:05:56 +01:00
Fix RuboCop offense Performance/MapMethodChain (#37247).
git-svn-id: https://svn.redmine.org/redmine/trunk@22280 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -66,7 +66,7 @@ class RepositoriesController < ApplicationController
|
||||
def committers
|
||||
@committers = @repository.committers
|
||||
@users = @project.users.to_a
|
||||
additional_user_ids = @committers.collect(&:last).collect(&:to_i) - @users.collect(&:id)
|
||||
additional_user_ids = @committers.collect {|c| c.last.to_i} - @users.collect(&:id)
|
||||
@users += User.where(:id => additional_user_ids).to_a unless additional_user_ids.empty?
|
||||
@users.compact!
|
||||
@users.sort!
|
||||
|
||||
@@ -996,7 +996,7 @@ class Query < ActiveRecord::Base
|
||||
|
||||
if field == 'project_id' || (self.type == 'ProjectQuery' && %w[id parent_id].include?(field))
|
||||
if v.delete('mine')
|
||||
v += User.current.memberships.map(&:project_id).map(&:to_s)
|
||||
v += User.current.memberships.map {|m| m.project_id.to_s}
|
||||
end
|
||||
if v.delete('bookmarks')
|
||||
v += User.current.bookmarked_project_ids
|
||||
|
||||
@@ -597,7 +597,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
||||
files =
|
||||
Dir.glob(File.join(Rails.root, 'app/models/*_custom_field.rb')).
|
||||
map {|f| File.basename(f).sub(/\.rb$/, '')}
|
||||
classes = files.map(&:classify).map(&:constantize)
|
||||
classes = files.map {|x| x.classify.constantize}
|
||||
assert classes.size > 0
|
||||
classes
|
||||
end
|
||||
|
||||
@@ -101,7 +101,7 @@ class NewsControllerTest < Redmine::ControllerTest
|
||||
get(:show, :params => {:id => 1})
|
||||
assert_response :success
|
||||
|
||||
comments = css_select('#comments .wiki').map(&:text).map(&:strip)
|
||||
comments = css_select('#comments .wiki').map {|e| e.text.strip}
|
||||
assert_equal ["This is an other comment", "my first comment"], comments
|
||||
end
|
||||
|
||||
|
||||
@@ -1177,7 +1177,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal(
|
||||
[t2, t1, t3].map(&:id).map(&:to_s),
|
||||
[t2, t1, t3].map {|t| t.id.to_s},
|
||||
css_select('input[name="ids[]"]').map {|e| e.attr(:value)}
|
||||
)
|
||||
get(
|
||||
@@ -1192,7 +1192,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
||||
)
|
||||
assert_response :success
|
||||
assert_equal(
|
||||
[t3, t1, t2].map(&:id).map(&:to_s),
|
||||
[t3, t1, t2].map {|t| t.id.to_s},
|
||||
css_select('input[name="ids[]"]').map {|e| e.attr(:value)}
|
||||
)
|
||||
end
|
||||
@@ -1218,7 +1218,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
||||
].each do |sort_criteria, expected|
|
||||
get :index, :params => params.dup.merge(sort_criteria)
|
||||
assert_response :success
|
||||
expected_ids = expected.map(&:id).map(&:to_s)
|
||||
expected_ids = expected.map {|t| t.id.to_s}
|
||||
actual_ids = css_select('input[name="ids[]"]').map {|e| e.attr(:value)}
|
||||
assert_equal expected_ids, actual_ids
|
||||
end
|
||||
@@ -1255,7 +1255,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
)
|
||||
assert_response :success
|
||||
assert_equal [entry].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr(:value)}
|
||||
assert_equal [entry.id.to_s], css_select('input[name="ids[]"]').map {|e| e.attr(:value)}
|
||||
end
|
||||
|
||||
def text_index_with_issue_subject_filter
|
||||
@@ -1334,7 +1334,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
||||
:v => {'issue.tracker_id' => ['2']}
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal [entry].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr(:value)}
|
||||
assert_equal [entry.id.to_s], css_select('input[name="ids[]"]').map {|e| e.attr(:value)}
|
||||
end
|
||||
|
||||
def test_index_with_issue_tracker_column
|
||||
@@ -1518,7 +1518,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal(
|
||||
[entry].map(&:id).map(&:to_s),
|
||||
[entry.id.to_s],
|
||||
css_select('input[name="ids[]"]').map {|e| e.attr(:value)}
|
||||
)
|
||||
end
|
||||
|
||||
@@ -52,7 +52,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest
|
||||
statuses = IssueStatus.where(:id => [2, 3, 5]).sorted.pluck(:name)
|
||||
assert_equal(
|
||||
["New issue"] + statuses,
|
||||
css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip)
|
||||
css_select('table.workflows.transitions-always tbody tr td:first').map {|e| e.text.strip}
|
||||
)
|
||||
# allowed transitions
|
||||
assert_select 'input[type=checkbox][name=?][value="1"][checked=checked]', 'transitions[3][5][always]'
|
||||
@@ -79,7 +79,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest
|
||||
statuses = IssueStatus.where(:id => [2, 3]).sorted.pluck(:name)
|
||||
assert_equal(
|
||||
["New issue"] + statuses,
|
||||
css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip)
|
||||
css_select('table.workflows.transitions-always tbody tr td:first').map {|e| e.text.strip}
|
||||
)
|
||||
end
|
||||
|
||||
@@ -95,7 +95,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest
|
||||
statuses = IssueStatus.where(:id => [2, 3]).sorted.pluck(:name)
|
||||
assert_equal(
|
||||
["New issue"] + statuses,
|
||||
css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip)
|
||||
css_select('table.workflows.transitions-always tbody tr td:first').map {|e| e.text.strip}
|
||||
)
|
||||
end
|
||||
|
||||
@@ -130,7 +130,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest
|
||||
statuses = IssueStatus.all.sorted.pluck(:name)
|
||||
assert_equal(
|
||||
["New issue"] + statuses,
|
||||
css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip)
|
||||
css_select('table.workflows.transitions-always tbody tr td:first').map {|e| e.text.strip}
|
||||
)
|
||||
assert_select 'input[type=checkbox][name=?]', 'transitions[0][1][always]'
|
||||
end
|
||||
@@ -343,7 +343,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest
|
||||
statuses = IssueStatus.all.sorted.pluck(:name)
|
||||
assert_equal(
|
||||
statuses,
|
||||
css_select('table.workflows.fields_permissions thead tr:nth-child(2) td:not(:first-child)').map(&:text).map(&:strip)
|
||||
css_select('table.workflows.fields_permissions thead tr:nth-child(2) td:not(:first-child)').map {|e| e.text.strip}
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ module Redmine
|
||||
class ControllerTest < ActionController::TestCase
|
||||
# Returns the issues that are displayed in the list in the same order
|
||||
def issues_in_list
|
||||
ids = css_select('tr.issue td.id').map(&:text).map(&:to_i)
|
||||
ids = css_select('tr.issue td.id').map {|e| e.text.to_i}
|
||||
Issue.where(:id => ids).sort_by {|issue| ids.index(issue.id)}
|
||||
end
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ class EnumerationTest < ActiveSupport::TestCase
|
||||
b = IssuePriority.create!(:name => 'B')
|
||||
c = DocumentCategory.create!(:name => 'C')
|
||||
|
||||
assert_equal [1, 2, 1], [a, b, c].map(&:reload).map(&:position)
|
||||
assert_equal [1, 2, 1], [a, b, c].map {|e| e.reload.position}
|
||||
end
|
||||
|
||||
def test_override_should_be_created_with_same_position_as_parent
|
||||
@@ -151,7 +151,7 @@ class EnumerationTest < ActiveSupport::TestCase
|
||||
b = IssuePriority.create!(:name => 'B')
|
||||
override = IssuePriority.create!(:name => 'BB', :parent_id => b.id)
|
||||
|
||||
assert_equal [1, 2, 2], [a, b, override].map(&:reload).map(&:position)
|
||||
assert_equal [1, 2, 2], [a, b, override].map {|e| e.reload.position}
|
||||
end
|
||||
|
||||
def test_override_position_should_be_updated_with_parent_position
|
||||
@@ -163,7 +163,7 @@ class EnumerationTest < ActiveSupport::TestCase
|
||||
b.position -= 1
|
||||
b.save!
|
||||
|
||||
assert_equal [2, 1, 1], [a, b, override].map(&:reload).map(&:position)
|
||||
assert_equal [2, 1, 1], [a, b, override].map {|e| e.reload.position}
|
||||
end
|
||||
|
||||
def test_destroying_override_should_not_update_positions
|
||||
@@ -174,10 +174,10 @@ class EnumerationTest < ActiveSupport::TestCase
|
||||
b = IssuePriority.create!(:name => 'B')
|
||||
c = IssuePriority.create!(:name => 'C')
|
||||
override = IssuePriority.create!(:name => 'BB', :parent_id => b.id)
|
||||
assert_equal [1, 2, 3, 2], [a, b, c, override].map(&:reload).map(&:position)
|
||||
assert_equal [1, 2, 3, 2], [a, b, c, override].map {|e| e.reload.position}
|
||||
|
||||
override.destroy
|
||||
assert_equal [1, 2, 3], [a, b, c].map(&:reload).map(&:position)
|
||||
assert_equal [1, 2, 3], [a, b, c].map {|e| e.reload.position}
|
||||
end
|
||||
|
||||
def test_spaceship_operator_with_incomparable_value_should_return_nil
|
||||
|
||||
@@ -110,7 +110,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
||||
import.save!
|
||||
|
||||
issues = new_records(Issue, 3) {import.run}
|
||||
assert_equal ['New', 'New', 'Assigned'], issues.map(&:status).map(&:name)
|
||||
assert_equal ['New', 'New', 'Assigned'], issues.map {|x| x.status.name}
|
||||
end
|
||||
|
||||
def test_parent_should_be_set
|
||||
|
||||
@@ -85,8 +85,8 @@ class PrincipalTest < ActiveSupport::TestCase
|
||||
users = scope.select {|p| p.is_a?(User)}.sort
|
||||
groups = scope.select {|p| p.is_a?(Group)}.sort
|
||||
|
||||
assert_equal (users + groups).map(&:name).map(&:downcase),
|
||||
scope.sorted.map(&:name).map(&:downcase)
|
||||
assert_equal (users + groups).map {|p| p.name.downcase},
|
||||
scope.sorted.map {|p| p.name.downcase}
|
||||
end
|
||||
|
||||
test "like scope should search login" do
|
||||
|
||||
@@ -111,9 +111,9 @@ class TimeEntryQueryTest < ActiveSupport::TestCase
|
||||
:is_filter => true)
|
||||
query = TimeEntryQuery.new(:project => Project.find(3))
|
||||
|
||||
assert_include "issue.cf_#{global.id}", query.available_columns.map(&:name).map(&:to_s)
|
||||
assert_include "issue.cf_#{field_on_project.id}", query.available_columns.map(&:name).map(&:to_s)
|
||||
assert_not_include "issue.cf_#{field_not_on_project.id}", query.available_columns.map(&:name).map(&:to_s)
|
||||
assert_include "issue.cf_#{global.id}", query.available_columns.map {|c| c.name.to_s}
|
||||
assert_include "issue.cf_#{field_on_project.id}", query.available_columns.map {|c| c.name.to_s}
|
||||
assert_not_include "issue.cf_#{field_not_on_project.id}", query.available_columns.map {|c| c.name.to_s}
|
||||
end
|
||||
|
||||
def test_issue_category_filter_should_not_be_available_in_global_queries
|
||||
|
||||
@@ -61,8 +61,8 @@ class UserTest < ActiveSupport::TestCase
|
||||
|
||||
def test_sorted_scope_should_sort_user_by_display_name
|
||||
# Use .active to ignore anonymous with localized display name
|
||||
assert_equal User.active.map(&:name).map(&:downcase).sort,
|
||||
User.active.sorted.map(&:name).map(&:downcase)
|
||||
assert_equal User.active.map {|u| u.name.downcase}.sort,
|
||||
User.active.sorted.map {|u| u.name.downcase}
|
||||
end
|
||||
|
||||
def test_generate
|
||||
|
||||
Reference in New Issue
Block a user