aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/referential
AgeCommit message (Collapse)Author
2017-12-13referential_lock_during_creation_spec: Skip truncation testsTeddy Wing
Just discussed this with Alban. The truncation tests are breaking the test suite, and I've spent way too long on this already. Take the specs out of the suite for now until we can come up with a different way to run these or test this behaviour without breaking everything. The new task to fix this is #5295. Refs #5024
2017-12-13referential_lock_during_creation_spec: Make truncation strategy stickTeddy Wing
The `truncation: true` strategy wasn't sticking. The config `before` block only ran once for this test file. Instead of attaching the filter to the `it` blocks, put it on the `context`. This correctly gets each test to run in a transaction. Remove the `truncation: false` filter I had added previously as this didn't do what I wanted it to: it prevented the `before` block from running instead of filtering out tests with `truncation: true`. Refs #5024
2017-12-13referential_lock_during_creation_spec: Extract method for threadsJohan Van Ryseghem
Refactor these tests to abstract the thread & transaction creation & handling. Thread creation and joining can now live in one place apart from the tests, and the tests have an interface to set up concurrent referential saving. Thanks to Johan for this refactor. Refs #5024
2017-12-12referential_lock_during_creation_spec: Don't create unnecessary RefTeddy Wing
The `referential_metadata` factory will create an associated referential by default. This causes errors in our tests because we haven't cleaned up the trailing referential. Refs #5024
2017-12-12Referential: Lock table on :updateTeddy Wing
We had been locking the `referentials` table on :create, but we also want to handle :update. Paired on this with Johan. When I used: referential_2.metadatas << metadata_2 the referential was saved. To add the metadata without automatically saving the referential + metadata, Johan suggested using the nested attribute method: referential_2.metadatas_attributes = [metadata_2.attributes] This allows us to add the metadata and still use the `#save` method to lock the table. Also change the callback from `before_validation` to `before_save` because before_validation :lock_table, on: [:create, :update] didn't work. That caused an error in our `expect`, as the `be_valid` triggered the lock callback. To enable the callback on both :create and :update, use a `before_save` instead. Refs #5024
2017-12-12Referential: Raise an error if the table lock times outTeddy Wing
Paired with Johan on this one. There's an internal timeout on our table lock. If it's reached, an `ActiveRecord::StatementInvalid<PG::LockNotAvailable>` error is raised. Use a custom error instead by "overriding" `#save` with a method that raises our custom error in that case instead. This will enable us to provide a custom user-facing error in the event this happens. Refs #5024
2017-12-06referential_lock spec: Don't create unnecessary referentialTeddy Wing
The factory for `referential_metadata` was creating an unnecessary `Referential` object since it has an association set up. This was causing the test to fail because that referential's schema wasn't getting cleaned in the `ensure` block. Don't create that referential to avoid the error. Refs #5024
2017-12-05Merge remote-tracking branch 'origin/master' into ↵Teddy Wing
5024-prevent-duplicate-referentials-from-being-created-during-parallel-db-transactions--rb201711271659 Conflicts: app/models/referential.rb A whitespace conflict in a place I don't even remember editing? Okaay.
2017-12-05Fixes: #5179@1h; Referential Creation Enforces objectid_format from ↵5179-ref_creation_enforces_objectid_formatRobert
associated Workbench - CR changes implemented
2017-12-05Refs: #5179@1.25h; Referential Creation Enforces objectid_format from ↵Robert
associated Workbench - changed ObjectIdFormatterSupport as requested - respeced all defined cases - implemented respec Missing: What to do in `define_default_attributes` if ref has no workbench and no `objectid_format`?
2017-12-05Refs: #5179@1h; Referential Creation Enforces objectid_format from ↵Robert
associated Workbench [skip-ci] - speced the `define_default_attributes` part - speced the Reference.new_from part
2017-12-05referential_lock_during_creation_spec: Remove extra whitespaceTeddy Wing
Refs #5024
2017-12-05referential_spec: Move lock tests to a new file, small improvementsRobert
* Move these two tests to a new file to isolate them from the normal Referential model tests * Move the `workbench` to a `let` * Remove unnecessary schema deletions in transactional synchronous test * Add comments describing the lock mechanism and how we test it with threads & sleeps
2017-11-03Refs: #4802@0.15h;Robert
CR 2nd part - typos - unnecessary `class: Referential` removed from referentials_factory - regrouping of referential_suite related model specs
2017-11-02 Refs: #4802@2h; Replaying former work. To identify spec regressionRobert
Step 2: Added validation of reference->workbench->organisation consistency Made all specs pass Chased bug #4826