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:
Zach Dennis 2012-08-06 09:23:01 -04:00
parent 71a393d000
commit b500ebe5a1
3 changed files with 13 additions and 5 deletions

View file

@ -19,6 +19,16 @@ describe "#import" do
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
let(:columns) { %w(title author_name) }
let(:valid_values) { [[ "LDAP", "Jerry Carter"], ["Rails Recipes", "Chad Fowler"]] }

3
test/models/widget.rb Normal file
View file

@ -0,0 +1,3 @@
class Widget < ActiveRecord::Base
self.primary_key = :w_id
end

View file

@ -17,9 +17,4 @@ describe "#import" do
assert_equal 1, result.num_inserts
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