mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Also create a joined table so the test won't fail
This commit is contained in:
parent
a6fa83e18c
commit
3e6463bbc5
2 changed files with 10 additions and 2 deletions
|
@ -90,6 +90,10 @@ describe Shoulda::Matchers::ActiveModel::ValidatePresenceOfMatcher do
|
||||||
has_and_belongs_to_many :children
|
has_and_belongs_to_many :children
|
||||||
validates_presence_of :children
|
validates_presence_of :children
|
||||||
end.new
|
end.new
|
||||||
|
create_table "children_parents", :id => false do |t|
|
||||||
|
t.integer :child_id
|
||||||
|
t.integer :parent_id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should require the attribute to be set" do
|
it "should require the attribute to be set" do
|
||||||
|
@ -103,6 +107,10 @@ describe Shoulda::Matchers::ActiveModel::ValidatePresenceOfMatcher do
|
||||||
@model = define_model :parent do
|
@model = define_model :parent do
|
||||||
has_and_belongs_to_many :children
|
has_and_belongs_to_many :children
|
||||||
end.new
|
end.new
|
||||||
|
create_table "children_parents", :id => false do |t|
|
||||||
|
t.integer :child_id
|
||||||
|
t.integer :parent_id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not require the attribute to be set" do
|
it "should not require the attribute to be set" do
|
||||||
|
|
|
@ -12,12 +12,12 @@ module ModelBuilder
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_table(table_name, &block)
|
def create_table(table_name, options = {}, &block)
|
||||||
connection = ActiveRecord::Base.connection
|
connection = ActiveRecord::Base.connection
|
||||||
|
|
||||||
begin
|
begin
|
||||||
connection.execute("DROP TABLE IF EXISTS #{table_name}")
|
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
|
@created_tables << table_name
|
||||||
connection
|
connection
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
|
Loading…
Reference in a new issue