Skip to content

Commit

Permalink
Factory.aliases should not alias attributes like "_id"
Browse files Browse the repository at this point in the history
  • Loading branch information
karmi authored and jferris committed Jul 26, 2010
1 parent 4824125 commit 418cbfb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/factory_girl/aliases.rb
Expand Up @@ -4,7 +4,7 @@ class << self
attr_accessor :aliases #:nodoc:
end
self.aliases = [
[/(.*)_id/, '\1'],
[/(.+)_id/, '\1'],
[/(.*)/, '\1_id']
]

Expand Down
4 changes: 4 additions & 0 deletions spec/factory_girl/aliases_spec.rb
Expand Up @@ -14,6 +14,10 @@
FactoryGirl.aliases_for(:test).should include(:test_id)
end

it "should NOT include an attribute as an alias when it starts with underscore" do
FactoryGirl.aliases_for(:_id).should_not include(:id)
end

describe "after adding an alias" do

before do
Expand Down

0 comments on commit 418cbfb

Please sign in to comment.