<commit_before>'use strict';

var helpers = require('./mockDatabase');


describe('Right model', function() {

    var app;
    var rightModel, rightRenewalModel;
    var right1;
    var renewal1;

    beforeEach(function(done) {
        helpers.mockDatabase('rightSpec', function(mockapp) {
            app = mockapp;

            rightModel = app.db.models.Right;
            rightRenewalModel = app.db.models.RightRenewal;

            done();
        });
    });


    it('create a right without monthly adjustment', function(done) {
        var right = new rightModel();

        right.name = 'Preliminary test right';
        right.quantity = 10;
        right.quantity_unit = 'D';
        right.addMonthly = {
            quantity: null
        };

        right.save(function(err, right) {
            expect(err).toBeNull();
            if (err) {
                return done();
            }

            var renewal = new rightRenewalModel();

            renewal.right = right._id;
            renewal.start = new Date();
            renewal.finish = new Date(renewal.start);
            renewal.finish.setFullYear(renewal.finish.getFullYear()+1);

            renewal.save(function(err, renewal) {
                expect(err).toBeNull();
                expect(renewal.adjustments).toBeDefined();
                expect(renewal.adjustments.length).toEqual(0);
                done();
            });
        });
    });


    it('create a right with monthly adjustment', function(done) {
        var right = new rightModel();

        right.name = 'Test right';
        right.quantity = 10;
        right.quantity_unit = 'D';
        right.addMonthly = {
            quantity: 1
        };

        right.save(function(err, right) {
            expect(err).toBeNull();
            if (err) {
                return done();
            }

            right1 = right;

            var renewal = new rightRenewalModel();

            renewal.right = right1._id;
            renewal.start = new Date();
            renewal.finish = new Date(renewal.start);
            renewal.finish.setFullYear(renewal.finish.getFullYear()+1);

            renewal.save(function(err, renewal) {
                expect(err).toBeNull();
                renewal1 = renewal;
                expect(renewal1.adjustments).toBeDefined();
                expect(renewal1.adjustments.length).toEqual(12);
                done();
            });
        });
    });<commit_msg>Fix tests, bug on february 29<commit_after>'use strict';

var helpers = require('./mockDatabase');


describe('Right model', function() {

    var app;
    var rightModel, rightRenewalModel;
    var right1;
    var renewal1;

    beforeEach(function(done) {
        helpers.mockDatabase('rightSpec', function(mockapp) {
            app = mockapp;

            rightModel = app.db.models.Right;
            rightRenewalModel = app.db.models.RightRenewal;

            done();
        });
    });


    it('create a right without monthly adjustment', function(done) {
        var right = new rightModel();

        right.name = 'Preliminary test right';
        right.quantity = 10;
        right.quantity_unit = 'D';
        right.addMonthly = {
            quantity: null
        };

        right.save(function(err, right) {
            expect(err).toBeNull();
            if (err) {
                return done();
            }

            var renewal = new rightRenewalModel();

            renewal.right = right._id;
            renewal.start = new Date();
            renewal.finish = new Date(renewal.start);
            renewal.finish.setFullYear(renewal.finish.getFullYear()+1);

            renewal.save(function(err, renewal) {
                expect(err).toBeNull();
                expect(renewal.adjustments).toBeDefined();
                expect(renewal.adjustments.length).toEqual(0);
                done();
            });
        });
    });


    it('create a right with monthly adjustment', function(done) {
        var right = new rightModel();

        right.name = 'Test right';
        right.quantity = 10;
        right.quantity_unit = 'D';
        right.addMonthly = {
            quantity: 1
        };

        right.save(function(err, right) {
            expect(err).toBeNull();
            if (err) {
                return done();
            }

            right1 = right;

            var renewal = new rightRenewalModel();

            renewal.right = right1._id;
            renewal.start = new Date();
            renewal.start.setHours(0,0,0,0);
            renewal.finish = new Date(renewal.start);
            renewal.finish.setFullYear(renewal.finish.getFullYear()+1);

            renewal.save(function(err, renewal) {
                expect(err).toBeNull();
                renewal1 = renewal;
                expect(renewal1.adjustments).toBeDefined();
                expect(renewal1.adjustments.length).toEqual(12);
                done();
            });
        });
    });
{'fraction_non_alphanumeric': 0.12101143889223359, 'fraction_numerical': 0.008027292795504716, 'mean_word_length': 1.6412294647588765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4657537', 'n_tokens_mistral': 1449, 'n_tokens_neox': 1325, 'n_words': 258}