From 3e6463bbc5c45e24e55c5ff66727acd0671706a1 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Mon, 12 Sep 2011 17:25:31 +0700 Subject: [PATCH] Also create a joined table so the test won't fail --- .../active_model/validate_presence_of_matcher_spec.rb | 8 ++++++++ spec/support/model_builder.rb | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/shoulda/active_model/validate_presence_of_matcher_spec.rb b/spec/shoulda/active_model/validate_presence_of_matcher_spec.rb index 0282e216..ceb16c97 100644 --- a/spec/shoulda/active_model/validate_presence_of_matcher_spec.rb +++ b/spec/shoulda/active_model/validate_presence_of_matcher_spec.rb @@ -90,6 +90,10 @@ describe Shoulda::Matchers::ActiveModel::ValidatePresenceOfMatcher do has_and_belongs_to_many :children validates_presence_of :children end.new + create_table "children_parents", :id => false do |t| + t.integer :child_id + t.integer :parent_id + end end it "should require the attribute to be set" do @@ -103,6 +107,10 @@ describe Shoulda::Matchers::ActiveModel::ValidatePresenceOfMatcher do @model = define_model :parent do has_and_belongs_to_many :children end.new + create_table "children_parents", :id => false do |t| + t.integer :child_id + t.integer :parent_id + end end it "should not require the attribute to be set" do diff --git a/spec/support/model_builder.rb b/spec/support/model_builder.rb index 106f7fb7..a3a06aad 100644 --- a/spec/support/model_builder.rb +++ b/spec/support/model_builder.rb @@ -12,12 +12,12 @@ module ModelBuilder end end - def create_table(table_name, &block) + def create_table(table_name, options = {}, &block) connection = ActiveRecord::Base.connection begin connection.execute("DROP TABLE IF EXISTS #{table_name}") - connection.create_table(table_name, &block) + connection.create_table(table_name, options, &block) @created_tables << table_name connection rescue Exception => e