Skip to content

Commit

Permalink
test(model): repro Automattic#7547
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Mar 7, 2019
1 parent 39eec7c commit fa662ee
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/model.discriminator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,5 +1265,25 @@ describe('model', function() {

done();
});

it('with subclassing (gh-7547)', function() {
const options = { discriminatorKey: "kind" };

const eventSchema = new mongoose.Schema({ time: Date }, options);
const eventModelUser1 =
mongoose.model('gh7547_Event', eventSchema, 'user1_events');
const eventModelUser2 =
mongoose.model('gh7547_Event', eventSchema, 'user2_events');

const clickEventUser1 = eventModelUser1.discriminator(
'gh7547_ClickedEvent',
new mongoose.Schema({ url: String }, options),
);
const clickEventUser2 =
eventModelUser2.discriminators['gh7547_ClickedEvent'];

assert.equal(clickEventUser1.collection.name, 'user1_events');
assert.equal(clickEventUser2.collection.name, 'user2_events');
});
});
});

0 comments on commit fa662ee

Please sign in to comment.