1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00

Better named the should clause for should_have_one when the :dependent option is in use [#81]

This commit is contained in:
Ryan McGeary 2008-09-17 16:16:41 -04:00
parent 829ebafba0
commit a692f6d882
2 changed files with 5 additions and 2 deletions

View file

@ -457,7 +457,9 @@ module ThoughtBot # :nodoc:
dependent = get_options!(associations, :dependent)
klass = model_class
associations.each do |association|
should "have one #{association}" do
name = "have one #{association}"
name += " dependent => #{dependent}" if dependent
should name do
reflection = klass.reflect_on_association(association)
assert reflection, "#{klass.name} does not have any relationship to #{association}"
assert_equal :has_one, reflection.macro

View file

@ -9,6 +9,7 @@ class UserTest < Test::Unit::TestCase
should_have_many :friendships
should_have_many :friends
should_have_one :address
should_have_one :address, :dependent => :destroy
should_have_indices :email, :name, [:email, :name]