Skip to content

Commit

Permalink
Ensure that include? works on many doc associations.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Aug 4, 2010
1 parent f1e52bc commit bcd0e52
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/mongo_mapper/plugins/associations/collection.rb
Expand Up @@ -12,6 +12,11 @@ def to_ary
end
end

def include?(*args)
load_target
target.include?(*args)
end

def reset
super
target = []
Expand Down
10 changes: 10 additions & 0 deletions test/functional/associations/test_many_documents_proxy.rb
Expand Up @@ -307,6 +307,16 @@ def setup
@project2.save
end

context "include?" do
should "return true if in association" do
@project1.statuses.should include(@brand_new)
end

should "return false if not in association" do
@project1.statuses.should_not include(@in_progress)
end
end

context "dynamic finders" do
should "work with single key" do
@project1.statuses.find_by_name('New').should == @brand_new
Expand Down

0 comments on commit bcd0e52

Please sign in to comment.