Skip to content

Instantly share code, notes, and snippets.

@bmsolutions
Created August 24, 2010 21:20
Show Gist options
  • Save bmsolutions/548348 to your computer and use it in GitHub Desktop.
Save bmsolutions/548348 to your computer and use it in GitHub Desktop.
class Merchant < ActiveRecord::Base
has_many :cashadvances
accepts_nested_attributes_for :cashadvances
end
class Cashadvance < ActiveRecord::Base
belongs_to :merchant
end
require 'test_helper'
class MerchantTest < ActiveSupport::TestCase
test "saves cashadvance when submitted with merchant" do
assert_difference('Cashadvance.count') do
params = { :merchant => { :mid => "000027230009876", :dba => "My favorite merchant",
:cashadvances_attributes => { "0" => { :start_date => "2010-08-23", :advance_amount => "10000",
:factor_rate => "1.2", :expected_duration => "2" } } } }
Merchant.create!(params['merchant'])
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment