<commit_before>import Ember from 'ember';
import {
    describeModel,
    it
} from 'ember-mocha';

const {run} = Ember;

describeModel(
    'user',
    'Unit: Model: user',
    {
        needs: ['model:role']
    },

    function () {
        it('has a validation type of "user"', function () {
            var model = this.subject();

            expect(model.get('validationType')).to.equal('user');
        });

        it('active property is correct', function () {
            var model = this.subject({
                status: 'active'
            });

            expect(model.get('active')).to.be.ok;

            ['warn-1', 'warn-2', 'warn-3', 'warn-4', 'locked'].forEach(function (status) {
                run(() => { model.set('status', status); });
                expect(model.get('status')).to.be.ok;
            });

            run(() => { model.set('status', 'inactive'); });
            expect(model.get('active')).to.not.be.ok;

            run(() => { model.set('status', 'invited'); });
            expect(model.get('active')).to.not.be.ok;
        });

        it('invited property is correct', function () {
            var model = this.subject({
                status: 'invited'
            });

            expect(model.get('invited')).to.be.ok;

            run(() => { model.set('status', 'invited-pending'); });
            expect(model.get('invited')).to.be.ok;

            run(() => { model.set('status', 'active'); });
            expect(model.get('invited')).to.not.be.ok;

            run(() => { model.set('status', 'inactive'); });
            expect(model.get('invited')).to.not.be.ok;
        });

        it('pending property is correct', function () {
            var model = this.subject({
                status: 'invited-pending'
            });

            expect(model.get('pending')).to.be.ok;

            run(() => { model.set('status', 'invited'); });
            expect(model.get('pending')).to.not.be.ok;

            run(() => { model.set('status', 'inactive'); });
            expect(model.get('pending')).to.not.be.ok;
        });

        it('role property is correct', function () {
            var model = this.subject();

            run(() => {
                let role = this.store().push('role', {id: 1, name: 'Author'});
                model.get('roles').pushObject(role);
            });
            expect(model.get('role.name')).to.equal('Author');

            run(() => {
                let role = this.store().push('role', {id: 1, name: 'Editor'});
                model.set('role', role);
            });
            expect(model.get('role.name')).to.equal('Editor');
        });

        it('isAuthor property is correct', function () {
            var model = this.subject();

            run(() => {
                let role = this.store().push('role', {id: 1, name: 'Author'});
                model.set('role', role);
            });
            expect(model.get('isAuthor')).to.be.ok;
            expect(model.get('isEditor')).to.not.be.ok;
            expect(model.get('isAdmin')).to.not.be.ok;
            expect(model.get('isOwner')).to.not.be.ok;
        });

        it('isEditor property is correct', function () {
            var model = this.subject();

            run(() => {
                let role = this.store().push('role', {id: 1, name: 'Editor'});
                model.set('role', role);
            });
            expect(model.get('isEditor')).to.be.ok;
            expect(model.get('isAuthor')).to.not.be.ok;
            expect(model.get('isAdmin')).to.not.be.ok;
            expect(model.get('isOwner')).to.not.be.ok;
        });

        it('isAdmin property is correct', function () {
            var model = this.subject();

            run(() => {
                let role = this.store().push('role', {id: 1, name: 'Administrator'});
                model.set('role', role);
            });
            expect(model.get('isAdmin')).to.be.ok;
            expect(model.get('isAuthor')).to.not.be.ok;
            expect(model.get('isEditor')).to.not.be.ok;
            expect(model.get('isOwner')).to.not.be.ok;
        });

        it('isOwner property is correct', function () {
            var model = this.subject();

            run(() => {
                let role = this.store().push('role', {id: 1, name: 'Owner'});
                model.set('role', role);
            });
            expect(model.get('isOwner')).to.be.ok;
            expect(model.get('isAuthor')).to.not.be.ok;
            expect(model.get('isAdmin')).to.not.be.ok;
            expect(model.get('isEditor')).to.not.be.ok;
        });
    }<commit_msg>Fix `store.push` deprecations in user model test<commit_after>import Ember from 'ember';
import {
    describeModel,
    it
} from 'ember-mocha';

const {run} = Ember;

describeModel(
    'user',
    'Unit: Model: user',
    {
        needs: ['model:role']
    },

    function () {
        it('has a validation type of "user"', function () {
            var model = this.subject();

            expect(model.get('validationType')).to.equal('user');
        });

        it('active property is correct', function () {
            var model = this.subject({
                status: 'active'
            });

            expect(model.get('active')).to.be.ok;

            ['warn-1', 'warn-2', 'warn-3', 'warn-4', 'locked'].forEach(function (status) {
                run(() => { model.set('status', status); });
                expect(model.get('status')).to.be.ok;
            });

            run(() => { model.set('status', 'inactive'); });
            expect(model.get('active')).to.not.be.ok;

            run(() => { model.set('status', 'invited'); });
            expect(model.get('active')).to.not.be.ok;
        });

        it('invited property is correct', function () {
            var model = this.subject({
                status: 'invited'
            });

            expect(model.get('invited')).to.be.ok;

            run(() => { model.set('status', 'invited-pending'); });
            expect(model.get('invited')).to.be.ok;

            run(() => { model.set('status', 'active'); });
            expect(model.get('invited')).to.not.be.ok;

            run(() => { model.set('status', 'inactive'); });
            expect(model.get('invited')).to.not.be.ok;
        });

        it('pending property is correct', function () {
            var model = this.subject({
                status: 'invited-pending'
            });

            expect(model.get('pending')).to.be.ok;

            run(() => { model.set('status', 'invited'); });
            expect(model.get('pending')).to.not.be.ok;

            run(() => { model.set('status', 'inactive'); });
            expect(model.get('pending')).to.not.be.ok;
        });

        it('role property is correct', function () {
            var model = this.subject();

            run(() => {
                let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Author'}}});
                model.get('roles').pushObject(role);
            });
            expect(model.get('role.name')).to.equal('Author');

            run(() => {
                let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Editor'}}});
                model.set('role', role);
            });
            expect(model.get('role.name')).to.equal('Editor');
        });

        it('isAuthor property is correct', function () {
            var model = this.subject();

            run(() => {
                let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Author'}}});
                model.set('role', role);
            });
            expect(model.get('isAuthor')).to.be.ok;
            expect(model.get('isEditor')).to.not.be.ok;
            expect(model.get('isAdmin')).to.not.be.ok;
            expect(model.get('isOwner')).to.not.be.ok;
        });

        it('isEditor property is correct', function () {
            var model = this.subject();

            run(() => {
                let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Editor'}}});
                model.set('role', role);
            });
            expect(model.get('isEditor')).to.be.ok;
            expect(model.get('isAuthor')).to.not.be.ok;
            expect(model.get('isAdmin')).to.not.be.ok;
            expect(model.get('isOwner')).to.not.be.ok;
        });

        it('isAdmin property is correct', function () {
            var model = this.subject();

            run(() => {
                let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Administrator'}}});
                model.set('role', role);
            });
            expect(model.get('isAdmin')).to.be.ok;
            expect(model.get('isAuthor')).to.not.be.ok;
            expect(model.get('isEditor')).to.not.be.ok;
            expect(model.get('isOwner')).to.not.be.ok;
        });

        it('isOwner property is correct', function () {
            var model = this.subject();

            run(() => {
                let role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Owner'}}});
                model.set('role', role);
            });
            expect(model.get('isOwner')).to.be.ok;
            expect(model.get('isAuthor')).to.not.be.ok;
            expect(model.get('isAdmin')).to.not.be.ok;
            expect(model.get('isEditor')).to.not.be.ok;
        });
    }
{'fraction_non_alphanumeric': 0.20080278863420303, 'fraction_numerical': 0.0021126016689553186, 'mean_word_length': 1.7238204833141542, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '6948739', 'n_tokens_mistral': 2813, 'n_tokens_neox': 2764, 'n_words': 462}