Project

General

Profile

« Previous | Next » 

Revision 9e312588

Added by Tomer Brisker about 9 years ago

Fixes #9593 - replace .all.map(&:<attr>) with .pluck(:attr)

View differences:

test/functional/hosts_controller_test.rb
location = taxonomies(:location1)
post :update_multiple_location, {
:location => {:id => location.id, :optimistic_import => "no"},
:host_ids => Host.all.map(&:id)
:host_ids => Host.pluck('hosts.id')
}, set_session_user
assert_redirected_to :controller => :hosts, :action => :index
assert flash[:error] == "Cannot update Location to Location 1 because of mismatch in settings"
......
assert_difference "location.hosts.count", 0 do
post :update_multiple_location, {
:location => {:id => location.id, :optimistic_import => "no"},
:host_ids => Host.all.map(&:id)
:host_ids => Host.pluck('hosts.id')
}, set_session_user
end
end
......
assert_difference "location.taxable_taxonomies.count", 0 do
post :update_multiple_location, {
:location => {:id => location.id, :optimistic_import => "no"},
:host_ids => Host.all.map(&:id)
:host_ids => Host.pluck('hosts.id')
}, set_session_user
end
end
......
location = taxonomies(:location1)
post :update_multiple_location, {
:location => {:id => location.id, :optimistic_import => "yes"},
:host_ids => Host.all.map(&:id)
:host_ids => Host.pluck('hosts.id')
}, set_session_user
assert_redirected_to :controller => :hosts, :action => :index
assert_equal "Updated hosts: Changed Location", flash[:notice]
......
assert_difference "location.hosts.count", (Host.count - cnt_hosts_location) do
post :update_multiple_location, {
:location => {:id => location.id, :optimistic_import => "yes"},
:host_ids => Host.all.map(&:id)
:host_ids => Host.pluck('hosts.id')
}, set_session_user
end
end
......
organization = taxonomies(:organization1)
post :update_multiple_organization, {
:organization => {:id => organization.id, :optimistic_import => "no"},
:host_ids => Host.all.map(&:id)
:host_ids => Host.pluck('hosts.id')
}, set_session_user
assert_redirected_to :controller => :hosts, :action => :index
assert_equal "Cannot update Organization to Organization 1 because of mismatch in settings", flash[:error]
......
assert_difference "organization.hosts.count", 0 do
post :update_multiple_organization, {
:organization => {:id => organization.id, :optimistic_import => "no"},
:host_ids => Host.all.map(&:id)
:host_ids => Host.pluck('hosts.id')
}, set_session_user
end
end
......
assert_difference "organization.taxable_taxonomies.count", 0 do
post :update_multiple_organization, {
:organization => {:id => organization.id, :optimistic_import => "no"},
:host_ids => Host.all.map(&:id)
:host_ids => Host.pluck('hosts.id')
}, set_session_user
end
end
......
organization = taxonomies(:organization1)
post :update_multiple_organization, {
:organization => {:id => organization.id, :optimistic_import => "yes"},
:host_ids => Host.all.map(&:id)
:host_ids => Host.pluck('hosts.id')
}, set_session_user
assert_redirected_to :controller => :hosts, :action => :index
assert_equal "Updated hosts: Changed Organization", flash[:notice]
......
assert_difference "organization.hosts.count", (Host.count - cnt_hosts_organization) do
post :update_multiple_organization, {
:organization => {:id => organization.id, :optimistic_import => "yes"},
:host_ids => Host.all.map(&:id)
:host_ids => Host.pluck('hosts.id')
}, set_session_user
end
end

Also available in: Unified diff