I am trying to write some basic Rails test code using the default rails testing framework. My application is for a simple forum, where users can post threads, comment etc.
I am trying to test the forum (i.e. a thread) controller, here it is:
forums_controller_test.rb
require 'test_helper'
class ForumsControllerTest < ActionController::TestCase
test "index should be success" do
get :index
assert_response :success
end
end
I am using fixtures and am following this tutorial: https://www.youtube.com/watch?v=0wIta0fITzc
Here are all my fixture files:
comments.yml
comm_one:
body: MyText
forum_id: 1
comm_two:
body: MyText
forum_id: 2
forums.yml
for_one:
title: MyString
body: MyText
user_id: 1
for_two:
title: MyString
body: MyText
user_id: 2
users.yml
user_one:
user_id: '1'
user_two:
user_id: '2'
The issue i am having is that when i run rake
in the terminal, I get this error:
Error: ForumsControllerTest#test_index_should_be_success: ActiveRecord::Fixture::FixtureError: table "users" has no column named "user_id".
Not sure if you need to see my migrate files, but if you need any other information, let me know.
I would be grateful for any advice.
Thanks
Aucun commentaire:
Enregistrer un commentaire