Skip to content

Commit

Permalink
making test pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj Singh committed Jun 30, 2011
1 parent 6a07be3 commit d1f266e
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions test/rails_root/test/unit/user_phone_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,8 @@ def setup
PhoneNumber.delete_all
end

def test_pie_chart_for_user_with_phones_vs_users_without_phones
5.times { Factory(:user) }
3.times do
user = Factory(:user)
Factory(:phone_number, :user => user)
end
assert_equal 8, User.count
assert_equal 3, PhoneNumber.count

main_klass = User
hm_klass = PhoneNumber
hm_relationship = :phone_numbers
require 'ruby-debug'; debugger
foreign_key = main_klass.reflections[hm_relationship].instance_variable_get('@active_record').name.foreign_key
def count_of_main_klass_records_not_in_hm_klass(main_klass, hm_klass, hm_relationship_name)
foreign_key = main_klass.reflections[hm_relationship_name].instance_variable_get('@active_record').name.foreign_key

sql = %Q{
Expand All @@ -33,15 +21,24 @@ def test_pie_chart_for_user_with_phones_vs_users_without_phones
)
}
record = main_klass.find_by_sql(sql).first
record['count(*)']
end

u = User.find_by_sql(sql).first
puts u

u2 = u['count(*)']
puts u2
def test_pie_chart_for_user_with_phones_vs_users_without_phones
5.times { Factory(:user) }
3.times do
user = Factory(:user)
Factory(:phone_number, :user => user)
end
assert_equal 8, User.count
assert_equal 3, PhoneNumber.count

main_klass = User
hm_klass = PhoneNumber
hm_relationship = :phone_numbers

assert_equal 5, u2
assert_equal 5, count_of_main_klass_records_not_in_hm_klass(User, PhoneNumber, :phone_numbers)
end
end

0 comments on commit d1f266e

Please sign in to comment.