Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create organisation before stubbing patch_links
Creating an organisation causes a call to Whitehall::PublishingApi.patch_links due to Active Record callbacks. In Mocha 1.12.0 there was a change (presumably freerange/mocha#474) that causes the test to start failing in it's previous incantation. My understanding is that this fail occurs because the organisation is being created after the mock (`expects`) is applied to Whitehall::PublishingApi, which leads to the test failing because it thinks the `patch_links` method has been invoked twice. As per: ``` Error: patch_links::#organisations#test_patches_links_for_organisations: DRb::DRbRemoteError: unexpected invocation: Whitehall::PublishingApi.patch_links(#<Organisation:0x3e620>, {:bulk_publishing => true}) unsatisfied expectations: - expected exactly once, invoked twice: Whitehall::PublishingApi.patch_links(#<Organisation:0x3e530>, {:bulk_publishing => true}) satisfied expectations: - allowed any number of times, invoked never: #<User:0x3e490>.persisted?(any_parameters) - allowed any number of times, invoked never: #<User:0x3e490>.id(any_parameters) - allowed any number of times, invoked never: Services.asset_manager(any_parameters) (Minitest::Assertion) lib/tasks/publishing_api.rake:152:in `block (4 levels) in <top (required)>' lib/tasks/publishing_api.rake:149:in `each' lib/tasks/publishing_api.rake:149:in `each_with_index' lib/tasks/publishing_api.rake:149:in `block (3 levels) in <top (required)>' test/unit/tasks/publishing_api_test.rb:165:in `block (3 levels) in <class:PublishingApiRake>' ```
- Loading branch information