aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/import_spec.rb
AgeCommit message (Collapse)Author
2018-03-12refs #6133; Add some basic specsZog
2018-03-12Refs #6133; Fix specsZog
2018-02-06imports.rake: Change `abort_old` to `netex_abort_old`Teddy Wing
After re-reading the ticket, I see now that the aborting of old imports should only apply to `NetexImport`s. Update the code to make this happen. Refs #4963
2018-02-06Import.abort_old: Don't change finished importsTeddy Wing
Imports that have a `finished_status` should not be changed to `aborted`. Refs #4963
2018-02-06Import: Add `.abort_old` methodTeddy Wing
This will abort all imports that don't have a finished status and were created more than four hours ago. We want to add this functionality to the import cron to auto-abort stale imports. Refs #4963
2017-12-29Validates import file extension with CarrierWave extension_whitelist. Refs #4762Alban Peignier
2017-12-07Fix worbench_import status update when a netex_import has a warning status ↵Luc Donnet
and others successful Refs #5202
2017-11-17Refs: #4461@1.5h; Repaired netex_import factory, adapted spec/models/import_specRobert
2017-10-31Fix locales problem for wrong file extension in import Refs #4816Luc Donnet
2017-10-24Fix error on build due to missing translationcedricnjanga
2017-09-11Import specs: Add tests to verify dependent-destroy of associationsTeddy Wing
When an import is destroyed, all: * child imports * associated `ImportReference`s * associated `ImportMessage`s must be destroyed. This is handled by a `dependent: :destory` on the associations. Here we add tests to validate that the records get properly destroyed. Refs #4412
2017-09-04Update workbench_import, netex_import and import_resources views Refs #4256 ↵Luc Donnet
#4257 #4258
2017-08-31Fix import spec to use new status values Refs #1726Luc Donnet
2017-08-30Import spec: Add basic tests for `#update_referentials`Teddy Wing
2017-08-30Import spec: Test that `ended_at` gets updated correctlyTeddy Wing
2017-08-30Import spec: Add test for 'failed' with comination of child statusesTeddy Wing
When any one of a parent import's children have failed, the parent import should get status 'failed'.
2017-08-30Import spec: Rewrite test that checks 'successful' status on parentTeddy Wing
Getting rid of the other commented test that checks failure because that combination is no longer relevant and the basic failure cases are handled by the specs just above.
2017-08-30Import spec: Remove `Timecop` from test that no longer needs itTeddy Wing
Since we're not verifying `ended_at`, we have no need for the `Timecop` block.
2017-08-30Import spec: Update status set to 'failed' testsTeddy Wing
The name doesn't really match what's happening, since no `child` is passed in as an argument any more. This just always happens any time there are one or more failing children. Remove the mock expectation because the extra fields don't really relate to what we're supposed to be testing here, namely `status`.
2017-08-30Import spec#update_status: Get rid of obsolete testsTeddy Wing
These tests fail and are now wrong. While we previously prevented updating the import object in the old code, now the `#update` method gets called no matter what.
2017-08-30Import spec: Move most `#child_change` specs to `#update_status`Teddy Wing
The new `#child_change` doesn't do a whole lot, so the specs that used to test it don't belong any more. Update them so they test `#update_status` instead, where this logic now lives.
2017-08-30Import spec: Use new `#update_referentials` method nameTeddy Wing
This method name was changed in 46aafcc4dbc65ef3216fbcae3b11b263e1c025c0 because it handles multiple referentials now. Update the tests to reflect that.
2017-08-30Import spec: Get a few old specs to passTeddy Wing
Update the mock to include the `ended_at` field update that happens in the code to get these tests green again. Not sure if we're going to continue to use them in their current state, but we'll worry about that later.
2017-08-30Import spec: Use new hash syntaxTeddy Wing
2017-08-29Import spec: SKIP ALL THE SPECSTeddy Wing
Need to get this ready for QA and I have to leave for a client meeting RIGHT NOW. As concluded in discussions, SKIP ALL THE THINGS so we can get the code into the hands of testers.
2017-08-29Import#update_status: Update `ended_at` when import has finished statusTeddy Wing
Previously we were only updating the `ended_at` field when the import had a 'successful' status. But there are other statuses that indicate the import finished, and the `ended_at` field should be updated in these cases also. Committing what I have now which seems to work but I didn't write specs for it because it was a pain to test (what with creating a child, etc.). The `#update_status` method should be refactored to make testing the `ended_at` update easier. This needs to be committed without specs now because I'm off to go to a client meeting and this work/branch is blocking QA of imports both internally and externally. So I guess doing things right comes later. That is to say, probably a lot later. Who knows.
2017-08-29Import: Add TODOsTeddy Wing
A bunch of things that need to be written to get this in proper working order.
2017-08-29Import: Remove `#ready?`Teddy Wing
This method is no longer used, now that we have Alban's `#update_status` method. Originally this was supposed to be used to determine if the import was finished or not. Now, the parent import status field update doesn't depend on it, and we can use the `Referential#ready` field to determine whether or not to display the import in the interface.
2017-08-28Import spec: Fix mock argumentsTeddy Wing
* The `allow` on the first line didn't appear to be necessary * Need to use `create` instead of `build_stubbed` in order to provide access to the `children` relation * The `#update` method gets called with a hash of arguments now, containing `current_step` and `status`. Update the mock to match the new code.
2017-08-28Import spec: Remove argument to `#child_change`Teddy Wing
`Import#child_change` no longer takes an argument, so we need to remove if from the tests.
2017-08-28Import spec: Ensure `#update_` methods are called on `#child_change`Teddy Wing
Some quick tests for the recent changes to `#child_change`, to ensure that `#update_status` and `#update_referential` are called by the method.
2017-08-23Model Import belong_to referential is no longer requiredXinhui
Refs #4280
2017-08-16Import validate presence of creatorXinhui
Refs #4270
2017-08-02Import spec: Extract `let`sTeddy Wing
I'm still not a fan of these myself, but let's make Robert happy. Refs #3511
2017-08-02Import spec: Convert helper methods to shared examplesTeddy Wing
At Robert's suggestion, convert these methods to RSpec shared examples. I had thought about using shared examples when I originally wanted to write these tests, but was trying to get things working quickly and couldn't figure out how to use them at the time, so I went with something that seemed obvious to me and worked. Now we can take advantage of the testing DSL available. Refs #3509, #3511
2017-08-01Import#notify_parent: Update :notified_parent_atTeddy Wing
The `#notify_parent` method should update the `notified_parent_at` field on the child import so we know not to query it in subsequent batches of parent import notifications. Add the Timecop gem in order to be able to safely test the DateTime update. Refs #3511
2017-08-01Import spec: Move helper method into `it` blockTeddy Wing
Not sure if this could cause any problems, but it makes more sense to me to put the helper method in the test where it's used, since that's the only place where it's used and that test is the only reason why it exists. Refs #3509, #3511
2017-08-01Import#child_change: Fix bug when parent status already setTeddy Wing
Don't update the parent status if it's already been set to a finished status. This protects against situations like this: child_import_1 status: :failed #child_change => parent_import status: :failed child_import_2 status: :successful #child_change => parent_import status: :successful In that scenario, even though one of the parent's children had failed, it still gets a successful status at the end. To prevent that situation, don't update the parent's status if it's already been set to a finished status. Refs #3509, #3511
2017-08-01Import spec: Get rid of thought process commentsTeddy Wing
I had apparently committed these comments from before I had written any tests and was thinking about what to test. Remove them. Refs #3509, #3511
2017-08-01Import: Make #child_change workTeddy Wing
The `#child_change` method should update the current import (the parent) with a 'failed' or 'successful' status depending on the status of the child passed in. If the child has a failure status, the parent import should be updated to failed. If the import is `#ready?`, that tells us that all children have called `#child_change` without any problems, and we can update the parent's status to be successful. THAT PARAGRAPH IS WRONG. We could have `#ready?` with failed children. NEED TO UPDATE TO SUPPORT THAT. Add a method that describes the possible "failing" statuses. These are the ones that will cause 'failed' to be set on the parent. Refs #3509, #3511
2017-08-01Import: Add #ready?Teddy Wing
This boolean method answers whether or not the current import's `current_step` and `total_steps` fields match. If so, all of its subtasks are finished, in which case it can be thought of as "ready". Refs #4174, #3511
2017-08-01Import#notify_parent: Call #child_change on parent importTeddy Wing
Calling `#notify_parent` should call the `#child_change` method on the import's parent import. That `#child_change` method will tell the parent to update itself based on the status of the child. Refs #3511
2017-08-01Add a service that notifies parent imports of sub-import statusTeddy Wing
A new service, `ParentImportNotifier`, will be called by a Cron job every 5 minutes. This service will query all finished sub-imports that haven't yet notified their parent, and tell them to do so. factories/workbench_imports.rb: Add a `WorkbenchImport` factory. This is currently incomplete. We'll want to correctly initialise the `file` attribute eventually. import.rb: factories/imports.rb: In order to get the test setup to work correctly, we skip the `before_create` callback on `Import`. This is because that callback initialises `status` to "new". We want to be able to set any status value in our tests to test things properly. Thus the callback messes with our buttermilk. For all imports created by the factory, skip this callback. In order to skip the callback, I had to put it in its own method and pass the method name to `#skip_callback`. That's why the callback is now in a new method in `Import`. Adds an empty `#notify_parent` method in `Import`. For now this doesn't do anything, but eventually it will be filled in to perform the actual notification. I this changeset, all we're doing is setting up the connecting logic to notify the right things from the Cron job. import_spec.rb: Remove the `.class_name` validation because we removed that previously in `Import`. The `belongs_to` is now a polymorphic association, with no class name specified. parent_import_notifier_spec.rb: Needed to use `create` instead of `build_stubbed` in a lot of these cases so that I could validate the query. Really don't like this because now this set of tests is SUPER SLOW. If you have any ideas for how to speed it up, let's do that. Refs #3511
2017-08-01Refs: #3507@2h; CR Step 4Robert
- Added tests for HTTPService (regression) - Removed some dead code (Workbench model spec, Import factory) - Changed front_end_host to rails_host in config
2017-07-31Refs: #3507@2h CR 2nd legRobert
2017-07-31Refs: #3507_1726@6h Code ReviewRobert
2017-07-20Refs: #3507@1hRobert
Introduction of Presence Validation in Import model, for: - workbench - referential
2017-07-17Fixes: #3555@1hRobert
- Import#parent_id & #parent_type migration generated - Import#belongs_to :parent, class_name: to_s specified - Import#belongs_to :parent, class_name: to_s implemented
2017-03-31Fix import with apartment and make a link with iev serverLuc Donnet
2017-02-28Refs #2670 : Update Import modelVlatka Pavisic