Permalink
Browse files

select should raise error when no block or no parameter is passed

  • Loading branch information...
1 parent b8899bb commit d73fcfeb520c77a859c5be61642f138da0290102 @tenderlove tenderlove committed Sep 7, 2010
@@ -29,12 +29,12 @@ def preload(*args)
relation
end
- def select(value = nil)
+ def select(value = Proc.new)
if block_given?
- to_a.select {|*block_args| yield(*block_args) }
+ to_a.select {|*block_args| value.call(*block_args) }
else
relation = clone
- relation.select_values += [value] if value
+ relation.select_values += [value]
relation
end
end
@@ -465,6 +465,10 @@ def test_delete_all_loaded
assert davids.loaded?
end
+ def test_select_argument_error
+ assert_raises(ArgumentError) { Developer.select }
+ end
+
def test_relation_merging
devs = Developer.where("salary >= 80000") & Developer.limit(2) & Developer.order('id ASC').where("id < 3")
assert_equal [developers(:david), developers(:jamis)], devs.to_a

0 comments on commit d73fcfe

Please sign in to comment.