Merge pull request #9197 from edx/ziafazal/SOL-1077-fix
SOL-1077: certificate config edit/delete is only allowed if user is edX PM or for those certificate configs not active
This commit is contained in:
@@ -80,8 +80,8 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
|
||||
this.model = new CertificateModel({
|
||||
name: 'Test Name',
|
||||
description: 'Test Description',
|
||||
course_title: 'Test Course Title Override'
|
||||
|
||||
course_title: 'Test Course Title Override',
|
||||
is_active: true
|
||||
}, this.newModelOptions);
|
||||
|
||||
this.collection = new CertificatesCollection([ this.model ], {
|
||||
@@ -139,11 +139,17 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
|
||||
expect(this.model.get('editing')).toBe(true);
|
||||
});
|
||||
|
||||
it('should not present a Edit action if user is not global staff and certificate is active', function () {
|
||||
window.CMS.User = {isGlobalStaff: false};
|
||||
appendSetFixtures(this.view.render().el);
|
||||
expect(this.view.$('.action-edit .edit')).not.toExist();
|
||||
});
|
||||
|
||||
it('should present a Delete action', function () {
|
||||
expect(this.view.$('.action-delete .delete')).toExist();
|
||||
});
|
||||
|
||||
it('should not present a Delete action if user is not global staff', function () {
|
||||
it('should not present a Delete action if user is not global staff and certificate is active', function () {
|
||||
window.CMS.User = {isGlobalStaff: false};
|
||||
appendSetFixtures(this.view.render().el);
|
||||
expect(this.view.$('.action-delete .delete')).not.toExist();
|
||||
@@ -159,7 +165,7 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
|
||||
describe('Signatory details', function(){
|
||||
|
||||
beforeEach(function() {
|
||||
this.view.render(true);
|
||||
this.view.render();
|
||||
});
|
||||
|
||||
it('displays certificate signatories details', function(){
|
||||
@@ -169,6 +175,16 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
|
||||
expect(this.view.$(SELECTORS.signatory_organization_value)).toContainText('');
|
||||
});
|
||||
|
||||
it('should present Edit action on signaotry', function () {
|
||||
expect(this.view.$(SELECTORS.edit_signatory)).toExist();
|
||||
});
|
||||
|
||||
it('should not present Edit action on signaotry if user is not global staff and certificate is active', function () {
|
||||
window.CMS.User = {isGlobalStaff: false};
|
||||
this.view.render();
|
||||
expect(this.view.$(SELECTORS.edit_signatory)).not.toExist();
|
||||
});
|
||||
|
||||
it('supports in-line editing of signatory information', function() {
|
||||
|
||||
this.view.$(SELECTORS.edit_signatory).click();
|
||||
|
||||
@@ -113,7 +113,8 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
|
||||
this.newModelOptions = {add: true};
|
||||
this.model = new CertificateModel({
|
||||
name: 'Test Name',
|
||||
description: 'Test Description'
|
||||
description: 'Test Description',
|
||||
is_active: true
|
||||
|
||||
}, this.newModelOptions);
|
||||
|
||||
@@ -151,7 +152,7 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
|
||||
expect(this.view.$('.action-delete')).toExist();
|
||||
});
|
||||
|
||||
it('should not have delete button is user is not global staff', function() {
|
||||
it('should not have delete button if user is not global staff and certificate is active', function() {
|
||||
window.CMS.User = {isGlobalStaff: false};
|
||||
appendSetFixtures(this.view.render().el);
|
||||
expect(this.view.$('.action-delete')).not.toExist();
|
||||
|
||||
@@ -102,6 +102,7 @@ function($, _, Backbone, gettext,
|
||||
description: this.model.escape('description'),
|
||||
course_title: this.model.escape('course_title'),
|
||||
org_logo_path: this.model.escape('org_logo_path'),
|
||||
is_active: this.model.escape('is_active'),
|
||||
isNew: this.model.isNew()
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user