File: database_statements_test.rb

package info (click to toggle)
rails 2%3A4.2.7.1-1%2Bdeb9u2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 23,416 kB
  • sloc: ruby: 186,673; yacc: 45; sql: 43; sh: 14; makefile: 12
file content (19 lines) | stat: -rw-r--r-- 753 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require "cases/helper"

class DatabaseStatementsTest < ActiveRecord::TestCase
  def setup
    @connection = ActiveRecord::Base.connection
  end

  def test_insert_should_return_the_inserted_id
    # Oracle adapter uses prefetched primary key values from sequence and passes them to connection adapter insert method
    if current_adapter?(:OracleAdapter)
      sequence_name = "accounts_seq"
      id_value = @connection.next_sequence_value(sequence_name)
      id = @connection.insert("INSERT INTO accounts (id, firm_id,credit_limit) VALUES (accounts_seq.nextval,42,5000)", nil, :id, id_value, sequence_name)
    else
      id = @connection.insert("INSERT INTO accounts (firm_id,credit_limit) VALUES (42,5000)")
    end
    assert_not_nil id
  end
end