From b500ebe5a12daa5531a30934ecd1a26275ea7bf2 Mon Sep 17 00:00:00 2001 From: Zach Dennis Date: Mon, 6 Aug 2012 09:23:01 -0400 Subject: [PATCH] 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] --- test/import_test.rb | 10 ++++++++++ test/models/widget.rb | 3 +++ test/postgresql/import_test.rb | 5 ----- 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 test/models/widget.rb diff --git a/test/import_test.rb b/test/import_test.rb index d89c5de..d25e069 100644 --- a/test/import_test.rb +++ b/test/import_test.rb @@ -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"]] } diff --git a/test/models/widget.rb b/test/models/widget.rb new file mode 100644 index 0000000..15bea59 --- /dev/null +++ b/test/models/widget.rb @@ -0,0 +1,3 @@ +class Widget < ActiveRecord::Base + self.primary_key = :w_id +end \ No newline at end of file diff --git a/test/postgresql/import_test.rb b/test/postgresql/import_test.rb index 0dec7e3..45e97ef 100644 --- a/test/postgresql/import_test.rb +++ b/test/postgresql/import_test.rb @@ -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