Testing namespaced controller using global model

I have

app/controllers/admin/post_categories_controller.rb
app/models/post_category
app/test/controllers/admin/post_categories_controller_test.rb

When I run

rake test app/test/controllers/admin/post_categories_controller.rb`

I get errors like:

  1. Error:
    PostCategoryTest#test_should_not_save_post_category_without_title:
    ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation
    “admin_post_categories” does not exist
    LINE 1: DELETE FROM “admin_post_categories”

Here’s part of my post_categories_controller_test.rb:

require ‘test_helper’

class Admin::PostCategoriesControllerTest < ActionController::TestCase
setup do
@post_category = post_categories(:one)
end

test “should get index” do
get :index
assert_response :success
assert_not_nil assigns(:post_categories)
end

test “should get new” do
get :new
assert_response :success
end

So, basically my problem is that controllers, views and other things are
namespaced (for now there is an “admin” namespace, but I will also add a
“public” namespace later), but I want to use the same models (not
namespaced models) for both the admin and the public area of this
system.

Thanks in advance for any help.

I have found the problem. I had put fixtures in

test/fixtures/admin/…

And that was causing rails tests to think my table was
admin_post_categories. As soon as I moved the fixture files back to

test/fixtures/…

All the tests just started working again.