Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
🔥 remove Posts per Page setting (#583)
Browse files Browse the repository at this point in the history
refs ##8131

- "posts per page" is now a theme-level concern
- UI has already been removed, this finishes the cleanup by removing `settings.postsPerPage` and related validation/test support
  • Loading branch information
kevinansfield authored and kirrg001 committed Mar 14, 2017
1 parent 7661212 commit 0e16bd6
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 37 deletions.
1 change: 0 additions & 1 deletion app/models/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default Model.extend(ValidationEngine, {
cover: attr('string'),
icon: attr('string'),
defaultLang: attr('string'),
postsPerPage: attr('number'),
forceI18n: attr('boolean'),
permalinks: attr('string'),
activeTimezone: attr('string', {defaultValue: 'Etc/UTC'}),
Expand Down
17 changes: 1 addition & 16 deletions app/validators/setting.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BaseValidator from './base';

export default BaseValidator.create({
properties: ['title', 'description', 'password', 'postsPerPage'],
properties: ['title', 'description', 'password'],
title(model) {
let title = model.get('title');

Expand All @@ -28,20 +28,5 @@ export default BaseValidator.create({
model.get('errors').add('password', 'Password must be supplied');
this.invalidate();
}
},

postsPerPage(model) {
let postsPerPage = model.get('postsPerPage');

if (!validator.isInt(postsPerPage)) {
model.get('errors').add('postsPerPage', 'Posts per page must be a number');
this.invalidate();
} else if (postsPerPage > 1000) {
model.get('errors').add('postsPerPage', 'The maximum number of posts per page is 1000');
this.invalidate();
} else if (postsPerPage < 1) {
model.get('errors').add('postsPerPage', 'The minimum number of posts per page is 1');
this.invalidate();
}
}
});
10 changes: 0 additions & 10 deletions mirage/fixtures/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ export default [
updated_at: '2015-10-27T17:39:58.278Z',
updated_by: 1
},
{
id: 6,
created_at: '2015-09-11T09:44:30.809Z',
created_by: 1,
key: 'postsPerPage',
type: 'blog',
updated_at: '2015-10-04T16:26:05.211Z',
updated_by: 1,
value: '5'
},
{
id: 7,
key: 'forceI18n',
Expand Down
11 changes: 1 addition & 10 deletions tests/integration/services/feature-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import run from 'ember-runloop';

const {Error: EmberError} = Ember;

function stubSettings(server, labs, validSave = true, validSettings = true) {
function stubSettings(server, labs, validSave = true) {
let settings = [
{
id: '1',
Expand All @@ -18,15 +18,6 @@ function stubSettings(server, labs, validSave = true, validSettings = true) {
}
];

if (validSettings) {
settings.push({
id: '2',
type: 'blog',
key: 'postsPerPage',
value: 1
});
}

server.get('/ghost/api/v0.1/settings/', function () {
return [200, {'Content-Type': 'application/json'}, JSON.stringify({settings})];
});
Expand Down

0 comments on commit 0e16bd6

Please sign in to comment.