Commit Graph

13088 Commits

Author SHA1 Message Date
Sam Lord
573b0db76a Merged 4.6.5 into main 2021-06-07 11:31:01 +01:00
Sam Lord
4de81087cc v4.6.5 2021-06-07 11:25:17 +01:00
Sam Lord
625406ede5 Updated Ghost-Admin to v4.6.5 2021-06-07 11:25:17 +01:00
Fabien 'egg' O'Carroll
81de2fe223 🐛 Fixed saving Members with Complimentary plans (#13008)
* 🐛 Fixed saving Members with Complimentary plans

refs https://github.com/TryGhost/Team/issues/758

Since 4.6 The Admin is using the comped flag again, rather than creating
subscriptions for zero-amount prices directly. With the `comped` flag
removed, the default state was for it to be falsy in the Admin, and when
saved would trigger the legacy comped flow, cancelling the subscription.

This reverts commit 57a176ff3d.
2021-06-07 11:16:32 +01:00
Renovate Bot
8e0b097c2c
Update dependency eslint to v7.28.0 2021-06-04 23:10:06 +00:00
Hannah Wolfe
724db487a0
Swapped _.escape for proxy.escapeExpression
- we don't need to use _.escape from lodash as we already have escapeExpression from handlebars
- it's more correct to use the escape utility from our theme engine when escaping strings _for_ our theme engine!
- Note there is a minor difference between the two:
  - Lodash: &, <, >, " and '
    - refs: https://lodash.com/docs/4.17.15#escape
  - Handlebars: &, <, >, ", ', ` and =
    - refs: https://handlebarsjs.com/api-reference/utilities.html#helper-utilities

- This could cause slightly weird behaviour in themes around ` and = characters, but as it's just convering to html entities it should be fine
2021-06-04 20:07:44 +01:00
Hannah Wolfe
c47bc35b0f
Switched test order so acceptance is last
- This highlights slowness as the thing that sits staring at you uncomfortably in your terminal window
2021-06-04 19:51:04 +01:00
Rishabh
e2e2925f9e Added missing lockfile
refs def46df589

Previous commit missed adding the lockfile for `@tryghost/members-api` bump.
2021-06-04 19:34:49 +05:30
Rishabh
def46df589 Updated portal plan settings to use named values
refs https://github.com/TryGhost/Team/issues/753

This bumps members-api to handle migration to revert portal settings to named values again as well as handle migration cleanup for old portal settings.
2021-06-04 19:25:39 +05:30
Rishabh
c7cf9855fe Updated Portal to handle multiple products
refs https://github.com/TryGhost/Team/issues/718

This bumps Portal to `~1.5.1` which handles changes for multiple tiers/products -

- Handles updated `portal_plans` setting to use monthly/yearly again
- Handles list of available prices to use prices across multiple products
2021-06-04 19:25:39 +05:30
Renovate Bot
a947f7f829 Pin dependency @tryghost/update-check-service to 0.1.0 2021-06-04 13:37:54 +01:00
Kevin Ansfield
b81e5c26dc Added postcss as explicit dev dependency
no issue

- `cssnano` requires `postcss` as a peer dependency which was causing warnings when running `yarn`
- `postcss` was available because it's a sub-dependency of `sanitize-html` so nothing was broken but explicitly adding it to `package.json` resolves the warnings
2021-06-04 12:46:09 +01:00
Rishabh
4e01fe9d09 Updated price/products data for portal settings
refs https://github.com/TryGhost/Team/issues/718

The ids for default prices for a product is now stored directly on product model instead of on global settings. This change updates
- the products data sent to Portal to use list of products with their active monthly/yearly prices, as well as
- the prices data sent to Portal to use the prices of default(first) product
2021-06-04 13:03:33 +05:30
Rishabh
ea9a83d444 Fixed product API removing included data
no refs

The product output serializer is removing the include data due to the includes being missing in frame options for some reason. This is a temporary fix that always allows the default includes as `monthly/yearly_price` to unblock the API, and we can revert it back to explicit request once fixed.
2021-06-04 12:28:56 +05:30
Fabien O'Carroll
3adeab142d Added Product data to theme middleware
refs https://github.com/TryGhost/Team/issues/708

- Defaults to an empty array on `@products` so we have valid data
   (product should be null if products isn't)
- This is the first step toward supporting multiple products at the
  theme level
2021-06-03 18:40:18 +01:00
Fabien 'egg' O'Carroll
2a81d0a986
🐛 Fixed saving Members with Complimentary plans (#13008)
* 🐛 Fixed saving Members with Complimentary plans

refs https://github.com/TryGhost/Team/issues/758

Since 4.6 The Admin is using the comped flag again, rather than creating
subscriptions for zero-amount prices directly. With the `comped` flag
removed, the default state was for it to be falsy in the Admin, and when
saved would trigger the legacy comped flow, cancelling the subscription.

This reverts commit 57a176ff3d.
2021-06-03 18:28:14 +01:00
Fabien O'Carroll
a0df10f1b8 Fixed Products API removing included data
no-issue

The include data is stored under original.options rather than original.
2021-06-03 18:04:57 +01:00
Fabien O'Carroll
83a9a1d0a5 Supported monthly & yearly price in Products API
refs https://github.com/TryGhost/Team/issues/712

- Adds a Content API for products, which can be used by the theme-engine
  middleware to populate the products data.
- Removes Stripe ids from Content API so they cannot be used to
  initiate checkout sessions directly
- The monthly_price and yearly_price are used to create new prices, and
  to set them to the default monthly & yearly price for the product.
2021-06-03 17:08:02 +01:00
Fabien O'Carroll
def07d595e Added monthly & yearly price support to products
refs https://github.com/TryGhost/Team/issues/712

The ProductRepository in members-api has been updated to accept
monthly_price & yearly_price when creating and updating products, as
well as including them when reading.
2021-06-03 17:02:32 +01:00
Naz
7d05da6185 Removed update check service in favor of external package
refs https://github.com/TryGhost/Team/issues/728

- The code of update check has been extracted into it's own package as a part of TryGhost/Core monorepo. This commit is a cleanup of the leftover files
2021-06-03 13:24:19 +04:00
Naz
a7dec233ba Fixed error being saved in notification settings
refs https://github.com/TryGhost/Team/issues/754

- This is fixing the root cause of an error being saved in `settings` table under `notifications` key. There needs to be a follow up to this fixing any possible instances that might have been affected byt the bug
2021-06-03 12:54:09 +04:00
Renovate Bot
71a0572f8a
Update dependency @sentry/node to v6.5.1 2021-06-02 18:07:24 +00:00
Daniel Lockyer
4edb8f40d6
Fixed config variable in UpdateCheck
refs 2e7d0a4e26

- the referenced commit pushed some refactors to the service but
  `this.config` should have just been `config`
- Ghost was 500ing so this commit fixes the incorrect variable
2021-06-02 14:29:11 +01:00
Naz
666baf8d50 Removed GhostMailer parameter from UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728

- This is continuation of the previous commit. TLDR: Passing only the necessary parameter data makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- Instead of passing in a whole GhostMailer instance passing only an email sending function, which again - makes things way more manageable to reason about
- The end of refactor, next will be a move of the UpdateCheckService into a separate module in tryghost/core
2021-06-02 15:18:32 +04:00
Naz
42efa043d8 Removed ghostVersion parameter from UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728

- This is continuation of the previous commit. TLDR: Passing only the necessary parameter data makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- Burned ghostVersion module passing in vafor of just one additional config parameter. Now the module along with unit tests can be easily extracted out of the codebase!
2021-06-02 15:08:26 +04:00
Naz
759f6ed3ba Removed urlFor parameter from UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728

- This is continuation of the previous commit. TLDR: Passing only the necessary API endpoint function makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- Substituted a parameter with already existing 'siteUrl' config value. No need to duplicate work!
2021-06-02 14:37:29 +04:00
Naz
bd51dd09db Limited the API surface of the UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728

- This is continuation of the previous commit. TLDR: Passing only the necessary API endpoint function makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- Limited urlUtils to only one function as that's all the UpdateCheck uses. Next step will be removing the function completely as and passing a 'blogURL' as a config value (way better readability this way)
2021-06-02 14:31:07 +04:00
Naz
2e7d0a4e26 Limited the API surface of the UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728

- This is continuation of the previous commit. TLDR: Passing only the necessary API endpoint function makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- There are 8 different configs that NotificationService depends upon it will need some further investigation around which ones are even needed anymore and the naming is not the best. To keep the time cap at bay leaving it at what it is.
2021-06-02 14:08:29 +04:00
Naz
bdab32d30a Limited the API surface of the UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728

- Passing only the necessary API endpoint function makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- The instance initialization had to be moved insided the module's exports to resolve "models" module initialization failure
2021-06-02 14:08:29 +04:00
Kevin Ansfield
0fdfcd5002 Removed unused fields relationship function on Post model
refs https://github.com/TryGhost/Ghost/issues/12565

- missed when cleaning up unused app related database fields
2021-06-02 10:09:30 +01:00
Fabien O'Carroll
c066dd157a Migrated members_{month,year}ly_price_id settings
refs https://github.com/TryGhost/Team/issues/711

Since we need to support multiple products, which will each have a
monthly and yearly price, we are moving away from storing these ids in
settings, and instead in a column on the products table. The migration
depends on the settings being prepopulated, which is done outside of
knex-migrator, in members-api, so this migration must also be done there.
2021-06-02 10:04:38 +01:00
Kevin Ansfield
a87410ef28 🐛 Fixed logs showing an error when sending an email with no feature image
no issue

- we were attempting to read an image file to determine it's dimensions when no feature image was set. This wasn't a fatal error as it was handled gracefully and had no ill consequences but it was adding confusing errors to the logs
2021-06-01 17:07:33 +01:00
Daniel Lockyer
84bfbae282
Extracted canary build to separate workflow
no issue

- by extracting it to a different workflow that uses the
  `workflow_dispatch` trigger, we can manually run a build, but also
  trigger it from Admin so we can always stay up-to-date
2021-06-01 17:04:16 +01:00
Renovate Bot
f6d67fc92d Lock file maintenance 2021-06-01 16:45:04 +01:00
Renovate Bot
66924486cf Update dependency nock to v13.1.0 2021-06-01 16:44:43 +01:00
Naz
9992cc573e Renamed update check test suite
refs https://github.com/TryGhost/Team/issues/728

- Previous name was after the do-all-the-things mega module that have now become an "initializer" for the UpdateCheckService class. The unit tests are testing the latter, so the rename is a cleanup from the previous ways
2021-06-01 17:53:46 +04:00
Naz
dd8a974639 Moved update check tests to unit tests
refs https://github.com/TryGhost/Team/issues/728

- This is the end of the refactor for update check tests. There are no dependencies for Ghost server process to run this test suite!
- Next steps will be extracting the service to an outside module
2021-06-01 17:48:19 +04:00
Naz
f929a01036 Reworded test suite name
no issue
2021-06-01 17:35:10 +04:00
Naz
83296c5c7e Removed rewire dependency in update check tests
refs https://github.com/TryGhost/Team/issues/728

- Rewire is usually a sign of massive module that is impossible to unit test without mocking big parts of that module. With a refactored UpdateCheckService and a brand new test coverage there is no need to use rewire and leave the "smell"
2021-06-01 17:35:10 +04:00
Naz
a78e034643 Added update check notificaitons test coverage
refs https://github.com/TryGhost/Team/issues/728

- This is a continuation of the test coverage for the UpdateCheckService.
- Covers scpecial cases of notification processing within Update Check
- The refactor inside the update check service was a convenience to get rid or the Bluebird dependency completely. Also, some minor preventative code added to avoid errors from referencing undefined objects
2021-06-01 17:35:10 +04:00
Naz
e9cbf3451a Added update check data test coverage
refs https://github.com/TryGhost/Team/issues/728

- This is a continuation of the test coverage for the UpdateCheckService.
- Covers a basic check for what kind of data is sent from the service to external analytics
2021-06-01 17:35:10 +04:00
Naz
64e8d0287d Fixed config utils to return a usable instance of config
no issue

- It's sometimes needed to use the config uitl intance directly in the test. For example, like it's used in the update check tests
2021-06-01 17:35:10 +04:00
Naz
3173603d96 Updated UpdateCheckService methods to async/await
refs https://github.com/TryGhost/Team/issues/728

- In additions to easier tracking of "this" context in the unit tests it gets rid of unnecessary Bluebird's "reflect" method which was making unit test dependent on Bluebird's specific Promise implementation
2021-06-01 17:35:10 +04:00
Naz
63c7d5aad1 Added test coverage from the "check" method
refs https://github.com/TryGhost/Team/issues/728

- This approach is moving away from stubbing and "rewiring" massive internal modules and instead only stubs needed dependencies for the UpdateCheckService class
- Also eliminates the need to depend on the database fixtures which should speed up test execution and move it to proper "unit test" class when the test rewrite is complete
2021-06-01 17:35:10 +04:00
Naz
d5e6dbb0fb Extraced update check code into a separate service
refs https://github.com/TryGhost/Team/issues/728

- This is a first step before moving update check code into an outside codebase.
- The aim is to have a self-contained module which could be unit tested and have a very clear API
2021-06-01 17:35:10 +04:00
Hannah Wolfe
0f42bbeac3
Moved acceptance test utils into own file
- starting and stopping Ghost is part of our rather unloved acceptance test framework
- moving them into their own file to make the different pieces clearer and also to start to make improvements
- first improvement had to happen as an aside - exposing the existingData property via a function and making the API clearer
- this was a weird thing set on module.exports, very hidden and hard to follow
- Note: stopGhost is only used once in the regression/modles/model_posts_spec.js file to make the test run fast enough...
- These tests are effectively "DB integration" tests e.g. non-unit tests because they do use the DB, they need their own framework
2021-06-01 13:17:45 +01:00
Fabien 'egg' O'Carroll
52a97957e1
Added monthly & yearly price relation to Product
refs https://github.com/TryGhost/Team/issues/710

This allows us to fetch the default monthly and yearly price models for
a product model, which is important since we no longer want to expose
the entire list of prices, but just the designated monthly & yearly prices.
2021-06-01 11:00:28 +01:00
Kevin Ansfield
035a38680e Bumped Koenig packages
no issue

- includes sub-dependency bumps for `markdown-it` packages for markdown renderer bug fixes and to keep Ghost and Admin markdown rendering in sync
2021-06-01 09:40:20 +01:00
Fabien 'egg' O'Carroll
bdd7c0f821
Added {monthly,yearly}_price columns to products
refs https://github.com/TryGhost/Team/issues/710
refs https://github.com/TryGhost/Team/issues/725

Products will now have a single monthly and yearly price which will be
used throughout Themes, Portal & Admin. These columns will be used to
track the current prices for each of them, and will update anytime we
change the pricing of a product.

Due to a circular table dependency we have not added a foreign key
constraint to the new columns, this will be handled at a later date. It
is tracked in issue 725 references above
2021-06-01 09:38:15 +01:00
Thibaut Patel
0f2c586659 Revert "Upgraded the update-check api to v4"
commit 414938cfc7

- This reverts commit 414938cfc7.
- The tests fails so I'll wait for Naz to finish the ongoing update-check tests refactoring before upgrading the api version again
2021-05-31 21:50:17 +02:00