hide certificate configuration activate/deactivate and delete buttons

added line break
This commit is contained in:
Zia Fazal
2015-07-29 17:48:12 +05:00
parent 601f160271
commit 3a6b2c30b5
8 changed files with 35 additions and 6 deletions

View File

@@ -55,10 +55,12 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
course_modes: ['honor', 'test'],
certificate_web_view_url: '/users/1/courses/orgX/009/2016'
});
window.CMS.User = {isGlobalStaff: true};
});
afterEach(function() {
delete window.course;
delete window.CMS.User;
});
describe('Certificate Details Spec:', function() {
@@ -141,6 +143,12 @@ function(_, Course, CertificatesCollection, CertificateModel, CertificateDetails
expect(this.view.$('.action-delete .delete')).toExist();
});
it('should not present a Delete action if user is not global staff', function () {
window.CMS.User = {isGlobalStaff: false};
appendSetFixtures(this.view.render().el);
expect(this.view.$('.action-delete .delete')).not.toExist();
});
it('should prompt the user when when clicking the Delete button', function(){
expect(this.view.$('.action-delete .delete')).toExist();
this.view.$('.action-delete .delete').click();

View File

@@ -86,12 +86,12 @@ function(_, Course, CertificateModel, SignatoryModel, CertificatesCollection, Ce
num: 'course_num',
revision: 'course_rev'
});
window.CMS.User = {isGlobalStaff: true};
});
afterEach(function() {
delete window.course;
delete window.CMS.User;
});
describe('Certificate editor view', function() {
@@ -151,6 +151,12 @@ 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() {
window.CMS.User = {isGlobalStaff: false};
appendSetFixtures(this.view.render().el);
expect(this.view.$('.action-delete')).not.toExist();
});
it('should save properly', function() {
var requests = AjaxHelpers.requests(this),
notificationSpy = ViewHelpers.createNotificationSpy();

View File

@@ -18,7 +18,7 @@ function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHel
preview_certificate: '.preview-certificate-link'
};
beforeEach(function() {
beforeEach(function() {
window.course = new Course({
id: '5',
name: 'Course Name',
@@ -27,11 +27,13 @@ function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHel
num: 'course_num',
revision: 'course_rev'
});
window.CMS.User = {isGlobalStaff: true};
});
afterEach(function() {
delete window.course;
});
delete window.course;
delete window.CMS.User;
});
describe('Certificate Web Preview Spec:', function() {
@@ -85,6 +87,12 @@ function(_, $, Course, CertificatePreview, TemplateHelpers, ViewHelpers, AjaxHel
expect(this.view.toggleCertificateActivation).toHaveBeenCalled();
});
it('toggle certificate activation button should not be present if user is not global staff', function () {
window.CMS.User = {isGlobalStaff: false};
appendSetFixtures(this.view.render().el);
expect(this.view.$(SELECTORS.activate_certificate)).not.toExist();
});
it('certificate deactivation works fine', function () {
var requests = AjaxHelpers.requests(this),
notificationSpy = ViewHelpers.createNotificationSpy();