spec/search_spec.rb in binarylogic-searchlogic-2.1.13 vs spec/search_spec.rb in binarylogic-searchlogic-2.2.0

- old
+ new

@@ -108,16 +108,18 @@ search.orders_total_gt = 10 search.orders_total_gt.should == 10 end it "should allow setting pre-existing association conditions" do + User.named_scope :uname, lambda { |value| {:conditions => ["users.username = ?", value]} } search = Company.search search.users_uname = "bjohnson" search.users_uname.should == "bjohnson" end it "should allow setting pre-existing association alias conditions" do + User.alias_scope :username_has, lambda { |value| User.username_like(value) } search = Company.search search.users_username_has = "bjohnson" search.users_username_has.should == "bjohnson" end @@ -154,9 +156,14 @@ end it "should not allow setting conditions that are not scopes" do search = User.search lambda { search.unknown = true }.should raise_error(Searchlogic::Search::UnknownConditionError) + end + + it "should not allow setting conditions on sensitive methods" do + search = User.search + lambda { search.destroy = true }.should raise_error(Searchlogic::Search::UnknownConditionError) end it "should not use the ruby implementation of the id method" do search = User.search search.id.should be_nil