I'm new to rails and testing and have a problem with loading my fixtures.
payment.yml
payment:
name: something
amount: 1.5
event: some_event
user: some_user
description: long text
users: some_user, some_user2
users.yml
some_user:
email: [email protected] nick: name
some_user2:
email: [email protected]
nick: name
okey, so the problem is that when I'm doing the functionaltest for creating a payment
test "should create payment" do
assert_difference('Payment.count') do
post :create, :payment => @payment.attributes
end
it just sends
< Payment id: nil, name: "something", amount: 1.5, event_id: 972288058, user_id: 63246679, created_at: "2010-11-05 19:56:53", updated_at: "2010-11-05 19:56:53", description: "long text" >
and not the users array with multiple users. I use the "user" to define who owns the payment and users (in a seperate join table) as a list of users sharing the payment.
Any idea what I'm doing wrong?
here is the model for payments
class Payment < ActiveRecord::Base
has_many :comments, :as => :commentable, :dependent => :destroy
belongs_to :event
belongs_to :user
has_and_belongs_to_many :users
end