Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure habtm and has_one are safely used
- Loading branch information
Luca Guidi
committed
Oct 13, 2008
1 parent
a514121
commit 5c01b60
Showing
12 changed files
with
100 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
test/active_record/associations/has_and_belongs_to_many_association_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require File.dirname(__FILE__) + '/../../test_helper' | ||
|
||
class HasAndBelongsToManyAssociationTest < Test::Unit::TestCase | ||
include ActiveRecord::Associations | ||
|
||
def test_should_not_raise_exception | ||
assert_nothing_raised ArgumentError do | ||
posts(:welcome).categories | ||
categories(:announcements).posts | ||
end | ||
end | ||
end |
12 changes: 12 additions & 0 deletions
12
test/active_record/associations/has_one_association_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require File.dirname(__FILE__) + '/../../test_helper' | ||
|
||
class HasOneAssociationTest < Test::Unit::TestCase | ||
include ActiveRecord::Associations | ||
|
||
def test_should_not_raise_exception_when_use_has_one | ||
assert_nothing_raised ArgumentError do | ||
authors(:luca).address | ||
addresses(:luca).author | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
luca: | ||
author_id: 1 | ||
street: 1 infinite loop | ||
zip: 95014 | ||
city: Cupertino | ||
state: California | ||
country: United States |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
announcements: | ||
id: 1 | ||
name: Announcements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
welcome_announcements: | ||
category_id: 1 | ||
post_id: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Address < ActiveRecord::Base | ||
belongs_to :author | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Category < ActiveRecord::Base | ||
has_and_belongs_to_many :posts | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters