mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-07 03:22:21 +03:00
9da7b956d5
refs #9043 - Split public-related and context code into logical components - Split tests up to match - Ensure we have 100% unit test coverage - General cleanup
97 lines
2.8 KiB
JavaScript
97 lines
2.8 KiB
JavaScript
var should = require('should'), // jshint ignore:line
|
|
parseContext = require('../../../server/permissions/parse-context');
|
|
|
|
describe('Permissions', function () {
|
|
describe('parseContext', function () {
|
|
it('should return public for no context', function () {
|
|
parseContext().should.eql({
|
|
internal: false,
|
|
external: false,
|
|
user: null,
|
|
app: null,
|
|
public: true
|
|
});
|
|
parseContext({}).should.eql({
|
|
internal: false,
|
|
external: false,
|
|
user: null,
|
|
app: null,
|
|
public: true
|
|
});
|
|
});
|
|
|
|
it('should return public for random context', function () {
|
|
parseContext('public').should.eql({
|
|
internal: false,
|
|
external: false,
|
|
user: null,
|
|
app: null,
|
|
public: true
|
|
});
|
|
parseContext({client: 'thing'}).should.eql({
|
|
internal: false,
|
|
external: false,
|
|
user: null,
|
|
app: null,
|
|
public: true
|
|
});
|
|
});
|
|
|
|
it('should return user if user populated', function () {
|
|
parseContext({user: 1}).should.eql({
|
|
internal: false,
|
|
external: false,
|
|
user: 1,
|
|
app: null,
|
|
public: false
|
|
});
|
|
});
|
|
|
|
it('should return app if app populated', function () {
|
|
parseContext({app: 5}).should.eql({
|
|
internal: false,
|
|
external: false,
|
|
user: null,
|
|
app: 5,
|
|
public: false
|
|
});
|
|
});
|
|
|
|
it('should return internal if internal provided', function () {
|
|
parseContext({internal: true}).should.eql({
|
|
internal: true,
|
|
external: false,
|
|
user: null,
|
|
app: null,
|
|
public: false
|
|
});
|
|
|
|
parseContext('internal').should.eql({
|
|
internal: true,
|
|
external: false,
|
|
user: null,
|
|
app: null,
|
|
public: false
|
|
});
|
|
});
|
|
|
|
it('should return external if external provided', function () {
|
|
parseContext({external: true}).should.eql({
|
|
internal: false,
|
|
external: true,
|
|
user: null,
|
|
app: null,
|
|
public: false
|
|
});
|
|
|
|
parseContext('external').should.eql({
|
|
internal: false,
|
|
external: true,
|
|
user: null,
|
|
app: null,
|
|
public: false
|
|
});
|
|
});
|
|
});
|
|
});
|