Sha256: 85638a7ea159818bc27791b08d7c76f1c9d5efecbcc2f2f0b5e9a22a78d9c7a1

Contents?: true

Size: 641 Bytes

Versions: 1

Compression:

Stored size: 641 Bytes

Contents

require "test_helper"

class UserPhoneTest < ActiveSupport::TestCase
  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
    raise 'foreign_key is nil' unless foreign_key
    sql  = %Q{
      select count(*) as count_data
      from #{main_klass.table_name}
      where users.id NOT IN (
        select #{hm_klass.table_name}.#{foreign_key}
        from #{hm_klass.table_name}
      )
    }
    record = main_klass.find_by_sql(sql).first
    record['count_data'].to_i
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
the_jobbook_admin_data-1.3.0a test/unit/user_phone_test.rb