Permalink
Browse files

Fixing inflections for address

  • Loading branch information...
1 parent aae065c commit 44d10edd15f55826fe1f09a57de93b67a58ea83d @durran durran committed Dec 25, 2009
View
6 lib/mongoid/extensions/string/inflections.rb
@@ -4,6 +4,12 @@ module Extensions #:nodoc:
module String #:nodoc:
module Inflections #:nodoc:
+ ActiveSupport::Inflector.inflections do |inflect|
+ inflect.singular "address", "address"
+ inflect.singular "addresses", "address"
+ inflect.plural "address", "addresses"
+ end
+
REVERSALS = {
"asc" => "desc",
"ascending" => "descending",
View
1 spec/spec_helper.rb
@@ -101,6 +101,7 @@ class Animal < Mongoid::Document
class PetOwner < Mongoid::Document
field :title
has_one :pet
+ has_one :address
end
class Pet < Mongoid::Document
View
16 spec/unit/mongoid/extensions/string/inflections_spec.rb
@@ -10,6 +10,14 @@
"bat".singular?.should be_true
end
+ context "when string is added to inflections" do
+
+ it "returns true" do
+ "address".singular?.should be_true
+ end
+
+ end
+
end
context "when plural" do
@@ -18,6 +26,14 @@
"bats".singular?.should be_false
end
+ context "when string is added to inflections" do
+
+ it "returns true" do
+ "addresses".singular?.should be_false
+ end
+
+ end
+
end
end

0 comments on commit 44d10ed

Please sign in to comment.