Methods
Public Instance methods
[ show source ]
# File test/ar_base_tests_runner.rb, line 326
326: def test_inserts
327: topics = create_fixtures("topics")
328: # firstRow = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'David'")
329: firstRow = ActiveRecord::Base.connection.db.get_table(:topics).select{|rec| rec.author_name == 'David'}.first
330: assert_equal("The First Topic", firstRow["title"])
331:
332: # secondRow = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'Mary'")
333: secondRow = ActiveRecord::Base.connection.db.get_table(:topics).select{|rec| rec.author_name == 'Mary'}.first
334: assert_nil(secondRow["author_email_address"])
335: end
[ show source ]
# File test/ar_base_tests_runner.rb, line 337
337: def test_inserts_with_pre_and_suffix
338: ActiveRecord::Base.connection.create_table :prefix_topics_suffix do |t|
339: t.column :title, :string
340: t.column :author_name, :string
341: t.column :author_email_address, :string
342: t.column :written_on, :datetime
343: t.column :bonus_time, :time
344: t.column :last_read, :date
345: t.column :content, :text
346: t.column :approved, :boolean, :default => 1
347: t.column :replies_count, :integer, :default => 0
348: t.column :parent_id, :integer
349: t.column :type, :string, :limit => 50
350: end
351:
352: # Store existing prefix/suffix
353: old_prefix = ActiveRecord::Base.table_name_prefix
354: old_suffix = ActiveRecord::Base.table_name_suffix
355:
356: # Set a prefix/suffix we can test against
357: ActiveRecord::Base.table_name_prefix = 'prefix_'
358: ActiveRecord::Base.table_name_suffix = '_suffix'
359:
360: topics = create_fixtures("topics")
361:
362: # Restore prefix/suffix to its previous values
363: ActiveRecord::Base.table_name_prefix = old_prefix
364: ActiveRecord::Base.table_name_suffix = old_suffix
365:
366: # firstRow = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'David'")
367: firstRow = ActiveRecord::Base.connection.db.get_table(:prefix_topics_suffix).select{|rec| rec.author_name == 'David'}.first
368: assert_equal("The First Topic", firstRow["title"])
369:
370: # secondRow = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'Mary'")
371: secondRow = ActiveRecord::Base.connection.db.get_table(:prefix_topics_suffix).select{|rec| rec.author_name == 'Mary'}.first
372: assert_nil(secondRow["author_email_address"])
373: ensure
374: ActiveRecord::Base.connection.drop_table :prefix_topics_suffix rescue nil
375: end