From e6717b94495dcc7c5df7cee8e5a7f14dc0747401 Mon Sep 17 00:00:00 2001 From: "Strech (Sergey Fedorov)" Date: Wed, 30 Jul 2014 12:31:18 +0600 Subject: [PATCH] Specs for table truncation without id seq --- .../active_record/truncation/postgresql_spec.rb | 8 +++++++- spec/support/active_record/schema_setup.rb | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/spec/database_cleaner/active_record/truncation/postgresql_spec.rb b/spec/database_cleaner/active_record/truncation/postgresql_spec.rb index f687a82..da62abf 100644 --- a/spec/database_cleaner/active_record/truncation/postgresql_spec.rb +++ b/spec/database_cleaner/active_record/truncation/postgresql_spec.rb @@ -27,6 +27,13 @@ module ActiveRecord User.count.should eq 0 end + it "truncates the table without id sequence" do + 2.times { Agent.create } + + connection.truncate_table('agents') + Agent.count.should eq 0 + end + it "resets AUTO_INCREMENT index of table" do 2.times { User.create } User.delete_all @@ -45,4 +52,3 @@ module ActiveRecord end end end - diff --git a/spec/support/active_record/schema_setup.rb b/spec/support/active_record/schema_setup.rb index ff02304..a91459a 100644 --- a/spec/support/active_record/schema_setup.rb +++ b/spec/support/active_record/schema_setup.rb @@ -3,8 +3,15 @@ def load_schema create_table :users, :force => true do |t| t.integer :name end + + create_table :agents, :id => false, :force => true do |t| + t.integer :name + end end end class ::User < ActiveRecord::Base end + +class ::Agent < ActiveRecord::Base +end