Module: ActiveRecord::Metal::Postgresql::PreparedQueries::Etest
- Includes:
- EtestBase
- Defined in:
- lib/active_record/metal/postgresql/prepared_queries.rb
Constant Summary
Constants included
from EtestBase
EtestBase::SELF
Instance Method Summary
collapse
Methods included from EtestBase
#count, load_expectation_assertions, #metal, #setup
Instance Method Details
#test_prepared_queries_housekeeping ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/active_record/metal/postgresql/prepared_queries.rb', line 60
def test_prepared_queries_housekeeping
alloys = metal.ask "SELECT COUNT(*) FROM alloys WHERE id >= $1", 0
other_metal = ActiveRecord::Metal.new
expect! other_metal.ask("SELECT COUNT(*) FROM alloys WHERE id >= $1", 0) => alloys
expect! metal.ask("SELECT COUNT(*) FROM alloys WHERE id >= $1", 0) => alloys
end
|
#test_prepared_query_fails_during_import ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/active_record/metal/postgresql/prepared_queries.rb', line 69
def test_prepared_query_fails_during_import
metal.ask "DELETE FROM alloys"
query = metal.prepare "INSERT INTO alloys (id, num) VALUES($1, $1)"
assert_raise(PG::Error) {
records = [ [1,1], [1,1] ]
metal.import "alloys", records, :columns => [ "id", "num"]
}
end
|
#test_transaction_aborted ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/active_record/metal/postgresql/prepared_queries.rb', line 89
def test_transaction_aborted
metal.ask "DELETE FROM alloys"
metal.transaction do
metal.ask "INSERT INTO alloys (id, num) VALUES($1, $1)", 1
assert_raise(PG::Error) {
metal.ask "INSERT INTO alloys (id, num) VALUES($1, $1)", 1
}
assert_raise(PG::Error) {
metal.ask "INSERT INTO alloys (id, num) VALUES($1, $1)", 2
}
end
end
|