Updating tests around working with non-standard ActiveRecord models with non-sequence based primary keys.
* move into test/import_test so it runs across all supported adapters [#60]
This commit is contained in:
parent
71a393d000
commit
b500ebe5a1
|
@ -19,6 +19,16 @@ describe "#import" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "with non-default ActiveRecord models" do
|
||||||
|
context "that have a non-standard primary key (that is no sequence)" do
|
||||||
|
it "should import models successfully" do
|
||||||
|
assert_difference "Widget.count", +3 do
|
||||||
|
Widget.import Build(3, :widgets)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "with :validation option" do
|
context "with :validation option" do
|
||||||
let(:columns) { %w(title author_name) }
|
let(:columns) { %w(title author_name) }
|
||||||
let(:valid_values) { [[ "LDAP", "Jerry Carter"], ["Rails Recipes", "Chad Fowler"]] }
|
let(:valid_values) { [[ "LDAP", "Jerry Carter"], ["Rails Recipes", "Chad Fowler"]] }
|
||||||
|
|
3
test/models/widget.rb
Normal file
3
test/models/widget.rb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
class Widget < ActiveRecord::Base
|
||||||
|
self.primary_key = :w_id
|
||||||
|
end
|
|
@ -17,9 +17,4 @@ describe "#import" do
|
||||||
assert_equal 1, result.num_inserts
|
assert_equal 1, result.num_inserts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should import models whose primary key has no sequence if the primary key's value is specified" do
|
|
||||||
result = Widget.import Build(3, :widgets)
|
|
||||||
assert_equal 1, result.num_inserts
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue