Commit Graph

1385 Commits

Author SHA1 Message Date
Hannah Wolfe
fa8555bda2 Initial commit of 005 version
refs #6301

- bump the default version & update corresponding test
- add empty task folders for 005 data & fixture migrations
- update tests to cover the new 005 upgrades
2016-04-14 18:59:13 +01:00
Katharina Irrgang
54347e2a31 fix: update_check_spec setup, serve-shared-file_spec setup
revert whitespace changes
2016-04-14 18:24:53 +02:00
Sebastian Gierlinger
9a674018b0 Merge pull request #6696 from ErisDS/fixture-migration-amends
Improve code for handling fixture migrations
2016-04-14 16:17:58 +02:00
Hannah Wolfe
352f4eb2fc Fixing undefined page case for page_url helper
closes #6719

- covers the case that no page should be the same as page 1
2016-04-14 11:22:23 +01:00
Jason Williams
7559bb7b26 Fix test conflicts
Closes #6710
- Restore config to baseline before testing.
- Don't mutate fixture data.
2016-04-13 11:27:26 -05:00
Sebastian Gierlinger
b2cdfb802f Merge pull request #6704 from ErisDS/grunt-test-cleanup
Dev tooling clean up
2016-04-13 17:00:31 +02:00
Hannah Wolfe
6b74e1a34a Dev tooling clean up
- remove old casper.js tests
- cleanup mochacli groups that are less useful than `grunt test:path`
- improve inline Gruntfile.js docs
- fixup coverage for new internal apps
- add new coverage-all task which works for all our tests
- reverse order of master-warn messages to make this clearer
- remove bluebird from greenkeeper ignores
2016-04-13 13:21:33 +01:00
Jason Williams
b69477e838 Return computed columns when used in "columns"
Closes #6625
- Adds a failing test for not returning computed columns as well
  as for the bookshelf bug where extra columns passed into a fetch
  will result in the model having an extra "quoted" column.
- Filter model attributes for passing into "fetch" but used the
  entire list of columns for `toJSON`.
2016-04-11 09:58:07 -05:00
Austin Burdine
1181707a9d move private-blogging functionality into an internal app
closes #5914, #6589
- moves all private-blogging related code & tests into /server/apps/private-blogging/
- rework Grunt to run private-blogging tests
- modify server apps code to have a place for internal apps
2016-04-11 08:58:41 -05:00
Hannah Wolfe
7ff74010fd Merge pull request #6659 from jaswilli/multer
Replace busboy upload middleware with multer
2016-04-11 11:07:34 +01:00
Hannah Wolfe
a96a74c5a1 Improve code for handling fixture migrations
refs #6301, #4176

- always check existence of items before attempting to create them, in order to prevent duplicates
- provide stats on how many object creations are expected vs done
- split out and improve fixture utils tests (100% covers utils)
2016-04-10 19:02:22 +01:00
Hannah Wolfe
098974917f Merge pull request #6644 from jaswilli/auth-origin
Relax origin header checking and add more CORS support
2016-04-08 22:10:02 +01:00
Jason Williams
c41ee354b1 Replace busboy upload middleware with multer
- deps: multer@1.1.0
2016-04-07 21:30:46 -05:00
Jason Williams
8af91c1a4d Fix unit test bugs
- Stub moment instead of using a fake clock.
- Do not mutate fixture data.
- Do not modify express.response.
2016-04-02 21:38:17 -05:00
Jason Williams
5f8ef26eb3 Merge pull request #6654 from ErisDS/fixture-population
Improve fixture population code
2016-04-02 09:04:24 -05:00
Hannah Wolfe
d260f7b010 Merge pull request #6633 from dbalders/password-change
Check Old Password on Password Change
2016-04-01 11:25:33 -07:00
Jason Williams
07dab144bd Add middleware for handling CORS
Refs #6644
- deps: cors@2.7.1; Add express cors package.
- Adds new middleware for proper CORS support.
- Handles CORS pre-flight checks.
- Separates request authentication/authorization from
  CORS.
2016-03-31 10:58:52 -05:00
Jason Williams
23c162796a Relax origin checking in auth middleware
Refs #6642
- Do not send CORS headers on an invalid "origin"
  header, but otherwise allow the response to
  proceed normally. This enforces CORS for the browser
  but does not blow up non-CORS requests.
2016-03-31 10:58:52 -05:00
Sebastian Gierlinger
430604d8e5 Merge pull request #6658 from jaswilli/consolidate-tmp
Replace internal tempfile name generator
2016-03-31 16:16:58 +02:00
Hannah Wolfe
d16433085f Improve fixtures & population code
refs #6301

- The order of model fixtures matters, so they should be in an array
- By splitting out the population code into a utils file, it'll be possible to use this to do updates as well
- This should make it much easier to do permissions updates in future
2016-03-31 11:48:44 +01:00
David Balderston
110a5be253 Check Old Password on Password Change
Closes #6620

* Changed it from always returning true, to evaluate if it is the
current logged in user, and if so, check the old password. If not,
ignore
2016-03-30 21:04:19 -07:00
cobbspur
5102637b8e Add structured data to static pages
refs #6534

- adds structured data on static pages
- selects post context object for static pages
- updates tests
2016-03-30 12:57:13 +01:00
Jason Williams
0ed0a72c35 Replace internal tempfile name generator
- Drops "tempfile" module in favor of using the "tmp"
  external package.
- Drop unused "rimraf-then" package.
2016-03-29 15:19:42 -05:00
Hannah Wolfe
5bd30ef183 Merge pull request #6650 from jaswilli/upload-test
Remove method stubs from upload API tests
2016-03-29 14:23:26 +01:00
Jason Williams
bdcb25a0cd Remove method stubs from upload API tests 2016-03-28 23:02:23 -05:00
Hannah Wolfe
dd64deb75b Merge pull request #6610 from dbalders/foreach-last
Change default setting for `to` inside foreach helper
2016-03-28 18:42:06 +01:00
Hannah Wolfe
681e9f9f51 Data & fixture migration cleanup
refs #6621, #6622

- remove unneeded `return new Promise.resolve()` lines
- reduce code in tests
- improve quality of tests checking that all task functions are executed
- add missing test coverage
2016-03-24 22:24:57 +00:00
Jason Williams
136bdbd9ff Return http status 204 on deletes
Closes #2871
- Refactor api http handlers.
- Update tests.
- Remove special handling of responses in ember adapter.
2016-03-22 11:42:48 -05:00
Jason Williams
9fe573a0c5 Refactor content deletion
- Simplify the `init` method in `models/index.js` so that it no longer
  returns a promise. Easier to use.
- Eliminates the `deleteAllContent` method from `models/index.js` as it
  can all be handled at the API layer in a single spot.
- Optimize `destroyAllContent` in `api/db.js`. Eliminates
  double-fetching every post from the database and converting it to
  JSON. Also only fetches ids from the database instead of the entire
  model.
- Eliminates the custom static method `destroy` in the Post model in
  favor of handling detaching tag relations in a single place (the
  `destroying` event). This also eliminates a big source of unneeded
  database round trips--needing to get post ids to feed into
  `Post.destroy()` which then re-fetches the post again.
2016-03-22 10:10:09 -05:00
Hannah Wolfe
84f387785a Migration messaging improvements
refs #6301

- fix messages that joined with comma and therefore missed outputting version no
- change `logInfo` to `logger` that has both an info and a warn method
- add new warn method to errors
- add a warn message everytime a migration (data or fixture) gets skipped over
- update logger everywhere, including tests
- update tests to check logger.warn gets called
2016-03-22 09:59:22 +00:00
Hannah Wolfe
9030620b23 Ensure fixture operations only run if needed
refs #6301

- Make sure that every fixture operation has a check to ensure that it hasn't already run
- E.g. The update of sort_order on posts_tags should only happen if there are no values which aren't a zero
  - This makes sure that we don't accidentally overwrite data on FORCE_MIGRATE
- No need to try to set settings types if they are already correct
- Only update the admin client if it needs it, else we're regenerating secrets each time
2016-03-21 18:15:01 +00:00
Sebastian Gierlinger
ea9c8235fa Merge pull request #6609 from ErisDS/new-db-upgrade
Rewrite DB update to be explicit
2016-03-21 16:14:59 +01:00
Sebastian Gierlinger
1256272640 Merge pull request #6616 from ErisDS/meta-schema-fix
Never output null JSON-LD schema
2016-03-21 10:22:06 +01:00
Sebastian Gierlinger
25c490b2ec Merge pull request #6614 from ErisDS/paginated-urls
Clean up paginated URL generation
2016-03-21 10:08:53 +01:00
Hannah Wolfe
9a8fbd5286 Never output null JSON-LD schema
refs #5091, #6612

- fixes meta data so it won't output 'null' as a JSON-LD schema
- added test coverage for this if/else
- this case cannot happen within the existing system, it only happens with custom channels after #6612
2016-03-20 22:36:02 +00:00
Hannah Wolfe
5f2c913fc1 Clean up paginated URL generation
refs #5091, #6612

- unify getNextUrl & getPrevUrl into getPaginatedUrl
- ensure that it can generate a prev, next or exact page no url
- ensure that it can figure out the base url
- use the same code from the page_url helper
- refactor the tests to ensure there's 100% coverage

Following on from #6612, this ensures that pagination always works regardless of whether the channel is default or custom
2016-03-20 22:35:00 +00:00
Hannah Wolfe
17499dbc7b Generate context from channelConfig, not URL
refs #5091

- makes post context explicit - data.post must be set, rather than post being the default
- uses channelConfig to determine the context for a channel (the channel name) rather than basing it off of the URL
- updates tests to setup the contexts more clearly, the outcome has not changed

Since #6469 req has channelConfig attached to it.
We can use req.channelConfig to determine what the context should be for a channel (the channel name)
This allows us to remove the hardcoded URLs, and means that custom channels will automatically get their own context.
Coupled with removing 'post' from being a default/fallthrough, to being explicitly set, this will reduce
potential context errors, as we start to extend the frontend capabilities
2016-03-20 12:59:25 +00:00
David Balderston
c55140d0db Change default setting for to inside foreach helper
closes #6604

* Default for `to` was always `(from-1) + limit`. This caused a problem
where the `to` value could be higher than the length of the number of
blog posts, causing `@last` to never be called/reached
* Now sets `to` to have a default of `length` and if a limit was sent
through and not higher than `length`, to then set `to` to that value
* Added some extra tests for `@last` and `@first` use cases
* Added some inline commenting
2016-03-17 17:52:38 -07:00
Hannah Wolfe
0ad93c3df2 Rewrite DB update to be explicit
refs #6301

- Replace builder & automated database upgrade with a set of explicit tasks
- Ensure the tasks can only happen if they need to
- Remove some duplicate code between fixture & db upgrades (more to do)
- Add tests
2016-03-17 21:17:19 +00:00
Hannah Wolfe
051a917e37 Fix role fixture ordering bug in pg tests
closes #6605

- ensure that roles are being output in order of their ID before asserting
- the asserting checks both the content and order of the array - this could be done differently as order doesn't really matter here, but will let us know if there are changes in DB behaviour
2016-03-15 19:08:25 +00:00
Sebastian Gierlinger
0c483a0997 Merge pull request #6599 from ErisDS/migrations-split
Split migrations/index.js & add tests
2016-03-15 13:47:44 +01:00
Sebastian Gierlinger
f950775b48 Merge pull request #6602 from ErisDS/version-tests
Improve `getDatabaseVersion` & versioning tests
2016-03-15 11:22:09 +01:00
Hannah Wolfe
2cfee3812f Split migrations/index.js & add tests
refs #6301

- changes createTable to use createTableIfNotExists, this is consistent with deletion
- splits out backup, reset, update and populate functions from migration/index into their own files
- moves the wrapped function for populatingDefaultSettings to fixtures.ensureDefaultSettings
- moves `modelOptions` down to the fixture files that actually use it
- adds test coverage for backup, reset and populate, but not for update as that needs refactoring
2016-03-15 10:11:33 +00:00
Sebastian Gierlinger
f5602f3527 Merge pull request #6601 from ErisDS/remove-should-sinon
Remove should-sinon dependency
2016-03-15 11:10:48 +01:00
Hannah Wolfe
81deb88263 Improve getDatabaseVersion & versioning tests
refs #6301

- `currentVersion` was leftover from before the first public release of Ghost!
- simplified the code for `getDatabaseVersion`
- improved & made consistent how errors are handled in `getDatabaseVersion`
- migration error handling updated to reflect the changes in `getDatabaseVersion`
- added tests for both `getDatabaseVersion` and `setDatabaseVersion`
2016-03-14 17:11:04 +00:00
Hannah Wolfe
e4a1797085 Remove should-sinon dependency
no issue

- removes should-sinon dependency from package.json
- rewrites all usages of should-sinon to use normal should assertions

Unfortunately, should-sinon has very minimal documentation  and therefore it is hard to discern what is considered a correctly-written assertion:
- in some cases, refactoring to use should-sinon causes false positives
- in other cases, assertions that work written in the normal way fail when written using should-sinon (e.g. getters, combos with rewire)
The additional overhead created by these issues outweigh any benefit from the easier-to-read assertions
2016-03-14 16:52:22 +00:00
Hannah Wolfe
2386a69f9d Always override database config + exit tests on error
refs #6354, #6495 & #6599

- don't allow config.database to be merged, instead, override it always
- make sure that route tests call done even when they error
2016-03-14 15:39:59 +00:00
Hannah Wolfe
9309adc511 Exporter cleanup & tests
refs #6301

- change knex getter def to be configurable, else it is not testable
- remove exportPath and lang from config - neither are used
- add client_trusted_domains to tables which shouldn't be exported as there are no clients in the export
- change export signature to be an object with `doExport` function consistent with import & easier to test
- cleanup export code so it is clearer, easier to read & to test:
  - use mapSeries instead of sequence
  - use Promise.props instead of Promise.join
  - split functionality into smaller functions
- add test coverage
2016-03-12 19:01:25 +00:00
Sebastian Gierlinger
411dd47002 Merge pull request #6579 from jaswilli/auth-api
Refactor authentication API into pipeline format
2016-03-08 15:54:34 +01:00
Jason Williams
fe13503470 Refactor authentication API into pipeline format
Refs #5508
2016-03-07 11:53:54 -06:00