Skip to content

Commit

Permalink
fix(DefaultPacker): fixes plural name not being infered from name.
Browse files Browse the repository at this point in the history
Fixes #224
  • Loading branch information
iobaixas committed May 7, 2015
1 parent b94b349 commit e4c02a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/module/support/default-packer.js
Expand Up @@ -98,10 +98,10 @@ RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', func
meta = this.getProperty('jsonMeta', 'meta');

if(_resource.$isCollection) {
name = this.getProperty('jsonRootMany') || this.getProperty('jsonRoot') || this.getProperty('plural');
name = this.getProperty('jsonRootMany') || this.getProperty('jsonRoot') || this.identity(true);
} else {
// TODO: use plural for single resource option.
name = this.getProperty('jsonRootSingle') || this.getProperty('jsonRoot') || this.getProperty('name');
name = this.getProperty('jsonRootSingle') || this.getProperty('jsonRoot') || this.identity();
}

if(meta) {
Expand Down
4 changes: 3 additions & 1 deletion test/default-packer-spec.js
Expand Up @@ -24,7 +24,9 @@ describe('DefaultPacker', function() {
});

it('should extract collection using plural name by default', function() {
var model = restmod.model('/api/bikes').mix('DefaultPacker');
var model = restmod.model().mix({
$config: { name: 'bike' }
}).mix('DefaultPacker');

var many = model.$collection();
many.$unwrap({ bikes: [{ model: 'Slash' }] });
Expand Down

0 comments on commit e4c02a1

Please sign in to comment.