Can anbody explain why this test doesn't work?
This is the entries.ymlCode:require 'test_helper' class UserTest < ActiveSupport::TestCase def test_should_have_an_entries_association assert_equal 2, users(:gleb).entries.size assert_equal entries(:one), users(:gleb).entries.first end end
This is the errorCode:one: title: Entry one content: Day one user: gleb two: title: Entry two content: Day two user: gleb
This is entries_controller.rbCode:Started ...F Finished in 0.059461 seconds. 1) Failure: test_should_have_an_entries_association(UserTest) [/test/unit/user_test.rb:7]: <#<Entry id: 2053932785, title: "Entry one", content: "Day one", user_id: 2102312308, created_at: "2010-01-21 20:15:48", updated_at: "2010-01-21 20:15:48">> expected but was <#<Entry id: 298486374, title: "Entry two", content: "Day two", user_id: 2102312308, created_at: "2010-01-21 20:15:48", updated_at: "2010-01-21 20:15:48">>. 4 tests, 5 assertions, 1 failures, 0 errors
Code:class EntriesController < ApplicationController before_filter :login_required, :only => [ :new, :create ] def index @entry = Entry.find(:all) end def new @entry = Entry.new end def show @entry = Entry.find(params[:id]) end def edit @entry = Entry.find(params[:id]) end def update @entry = Entry.find(params[:id]) @entry.update_attributes(params[:entry]) render :action => 'show' end def create if session[:user_id] @entry = Entry.new(params[:entry]) @current_user = User.find_by_id(session[:user_id]) @entry.user_id = @current_user.login if @entry.save flash[:notice] = 'Entry was successfully created.' redirect_to(@entry) end else redirect_to entries_path end end def destroy @entry = Entry.find(params[:id]) @entry.destroy redirect_to(entries_path) end end



one), users
Bookmarks