Multi thread test

Hi All.
I want to test by multi thread.(functional test)
as below

  • test
    class ItemControllerTest < ActionController::TestCase

    self.use_transactional_fixtures = false
    POOL_SIZE = 5

    def setup
    @connection = ActiveRecord::Base.remove_connection

ActiveRecord::Base.establish_connection(@connection.merge({:allow_concurrency
=> true, :pool => POOL_SIZE}))
activate_authlogic
end

test “multi thread test” do
user = accounts(:one)
assert(AdAccountSession.create(user))
item = items(:one)
before_count = item.count
params = {:id => item.id.to_s, :count => 10}
threads = (1…5).map do
Thread.new do
10.times do
put :update, params
end
end
end
threads.each(&:join)
end
assert_equal before_count + 10 * 5, item.reload.count

end

  • controller
    class ItemsController < ApplicationController
    def update
    count = params[:count]
    id = params[:id]
    update_sql = “UPDATE items SET count = count + #{count} WHERE id =
    #{id}”
    Item.connection.update(update_sql)
    redirect_to(@item, :notice => ‘Item was successfully updated.’)
    return
    end
    end

But raise error
test_samaple(ItemsTransactionControllerTest):
AbstractController::DoubleRenderError: Render and/or redirect were
called multiple times in this action.
Please note that you may only call render OR redirect, and at most
once per action.
Also note that neither redirect nor render terminate execution of the
action,
so if you want to exit an action after redirecting, you need to do
something like “redirect_to(…) and return”.

This error isn’t raised in case of single thread(threads = (1…1).map
do)
How can I test by multi thread?

appreciate any help.
Thank you
Masaki.