handleUserCoursesOnDelete: function(userId, courseOption, done) { if (courseOption === null) { return done(null); } var pluginManager = pluginmanager.getManager(); var plugins = pluginManager.getPlugins(); var CourseContent = require(plugins.content.course.fullPath); var courseContent = new CourseContent(); const currentUserId = this.getCurrentUser()._id; courseContent.retrieve({ createdBy: userId }, {}, (err, results) => { async.eachSeries(results, (model, cb) => { // For a full description of behaviour see https://github.com/adaptlearning/adapt_authoring/pull/2277 const sharedWithList = model._shareWithUsers; const isPartiallyShared = sharedWithList && sharedWithList.length; // Delete private courses if this option was set if (courseOption === 'delete' && !model._isShared && !isPartiallyShared) { courseContent.destroy({ _id: model._id }, false, cb); return; } // Transfer ownership of all courses to current user let update = { createdBy: currentUserId }; // Remove the current user from the 'shared with' list if applicable if (isPartiallyShared) { update._shareWithUsers = sharedWithList.pull(currentUserId); } // Share private courses with everyone if this option was set if (courseOption === 'share') { update._isShared = true; } courseContent.update({ _id: model._id }, update, cb); }, done); }); },
it('hasBeenChanges : yes ', () => { const changesDetailsVal = 'details...'; const fields = { changes: { hasBeenChanges: 'yes', changesDetails: changesDetailsVal, statementOfTruthNoChanges: 'yes', statementOfTruthChanges: 'yes' } }; const req = { journey: {}, session: { MiniPetition: fields } }; const res = {}; const step = new MiniPetition(req, res); step.retrieve().validate(); const _values = step.values(); expect(_values).to.be.an('object'); expect(_values).to.have.property('changes.statementOfTruthChanges', 'yes'); expect(_values).to.have.property('changes.changesDetails', changesDetailsVal); expect(_values).to.not.have.property('changes.statementOfTruthNoChanges'); });