aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/referential_spec.rb
AgeCommit message (Collapse)Author
2018-05-03Refs #6920; Fix typoZog
2018-05-02Refs #6572; Crete Referentials in a pending stateZog
And fix a bug preventing the deletion of referentials without a schema
2018-04-27Refs #6572; Fix specsZog
2018-04-27Refs #6572; New Referential#Show for noredy referentialsZog
2018-04-27Refs #6572; Use new statesZog
2018-04-27Refs #6572; Define 4 different states on ReferentialsZog
With according methods and scopes
2018-04-26Truncate Referential#slug. Refs #6811Alban Peignier
2018-03-29Refs #4658; Remove `current_functional_scope`Zog
2018-03-02Merge pull request #295 from af83/5865-validate-referential-cloningLuc Donnet
5865 Ensure user is allowed to duplicate a referential
2018-02-22Add a spec to verify to Referential migration count after creation. Refs #6010Alban Peignier
2018-02-22Keep original slug format (with _). Avoid full numeric slug. Refs #56095609_slug_formatAlban Peignier
2018-02-21Refs #5865 @1h; Ensure user is allowed to duplicate a referential before ↵Zog
doing so I also changed the way 403 errors are handled, to properly respond with a 403 HTTP code
2018-02-20Refs #5609 Change slug formatcedricnjanga
2018-01-09Refs: #5413@0.5h; Refactoring of #archived_or_finalised?Robert
2018-01-05Ignore detect_overlapped_referentials when Referential is into a ↵Alban Peignier
ReferentialSuite. Refs #5299
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-29referential_spec(duplicate referential): Remove unnecessary associationTeddy Wing
When creating `ReferentialMetadata`s, I had written in associations with the `Referential`s built at the top of the tests. However, since those referentials weren't saved and had no IDs, these "associations" had no meaning. They can just be removed, and the association will be taken care of by the `referential_#.metadatas <<` lines. Thanks to Robert for pointing this out in pre-review. Refs #5024
2017-11-29spec/support/referential: Rename `:js` filter to `:truncation`Teddy Wing
This `before` hook allows tests to use the "truncation" database cleanup strategy. It doesn't do anything explicitly JavaScript-related. Rather, it was named JS because it was intended to be used for feature tests with JavaScript. However, now that I need to use it for a couple tests in `spec/models/referential_spec.rb`, the `:js` name doesn't make sense. Rename the filter to something that says what it does, not how it should be used. Refs #5024
2017-11-29referential_spec(duplicate referential): Check that lock gets releasedTeddy Wing
Add an extra referential to the test and check that it gets saved to confirm that the table lock gets released at the end of the transaction. Not sure if this is actually necessary to verify, but wanted to make sure before I had gone and read the Postgres docs (https://www.postgresql.org/docs/9.4/static/explicit-locking.html#ADVISORY-LOCKS). Refs #5024
2017-11-29referential_spec: Add threaded version of duplicate referential specTeddy Wing
This replicates the synchronous test and adds threads and sleeps to save the two referentials asynchronously. This version fails, which is consistent with the current behaviour of the application. Refs #5024
2017-11-29referential_spec: Clean up duplicate referential specTeddy Wing
Remove old commented code that no longer relates. The thread code will be moved to a new test. This test now validates the existing behaviour synchronously. Update the test descriptions accordingly. Refs #5024
2017-11-29referential_spec(duplicate referential): Validate existing behaviourTeddy Wing
Change bits of the test to validate that when saving duplicate `Referential`s synchronously, the second one fails to be saved. A few things needed to be changed since the last commit in order to get this test working: * Most crucially: The `metadata_1.save` lines needed to be removed. The metadata is indended to be saved at the same time as the `Referential`s. Otherwise, the validation doesn't work the way it should. * `create` the workbench in order to be able to associate it with the new referentials. * Explicitly set the referential organisation to the workbench organisation to pass validation that they both refer to the same organisation. * Explicitly make the `has_many` association of the metadata objects to referentials. * Since the second referential doesn't get saved when the spec passes, no schema is created for it. Thus our previous `Apartment` `drop` call failed for the second schema. To cover our bases for when the test both fails and passes, check if the referentials were persisted as a way of knowing whether the schema exists before trying to remove it. Refs #5024
2017-11-29referential_spec: Duplicate Referential spec not workingTeddy Wing
I removed the threads to try to test this synchronously. What should happen is, the second referential should not be created. But it does get created. So I'm thinking I made a mistake in setting up the data, and the validation for 'same referentials' isn't run: Failures: 1) Referential when two identical Referentials are created at the same time only creates one Referential Failure/Error: expect(referential_2).not_to be_persisted expected `#<Referential id: 3, name: "Test 1", slug: "test_1_different", created_at: "2017-11-28 15:41:04", upd...t: nil, created_from_id: nil, ready: true, referential_suite_id: nil, objectid_format: "stif_netex">.persisted?` to return false, got true # ./spec/models/referential_spec.rb:174:in `block (3 levels) in <top (required)>' # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load' # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `block in load' # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency' # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load' # .../.gem/ruby/2.3.3/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `call' # -e:1:in `<main>' Finished in 8.46 seconds (files took 0.82295 seconds to load) 1 example, 1 failure Just committing this to have it around since I spent a long time fiddling with it. Next, planning to replace the factories with actual imports to see if I can get the right result. Edit: just realised that actually I can't try it with actual imports because that's handled by Java. Refs #5024
2017-11-28Referential spec: Add spec that two similar Referentials being persistedTeddy Wing
Here we formalise a bug whereby two "identical" `Referential`s are able to be saved even though Rails validation would normally prevent this. It can happen when two `Referential`s are functionally identical (but have different `slug`s, as this would trigger a Postgres error). In practise, this happens when multiple imports of the same data are launched at similar times. We'll want to make this test pass by not allowing the identical `Referential` to be created. This will be accomplished as agreed with the team by a database table lock. The threads and sleeps (in particular) are unfortunate necessities needed to get the two `Referential`s to be saved at the same time. TODO: Need to check this again with the threads & sleeps turned off to confirm that this passes in that case (actually it doesn't), so this test needs some modification in order to be correct. Refs #5024
2017-11-27referential_spec: Remove obsolete commented testTeddy Wing
This test was commented in October 2016, over a year ago (6acac72115b2e575fb1698d74958356fe4d542f8). Seems like a good time to get rid of it. Refs #5024
2017-11-24Remove specs we dont need anymorecedricnjanga
2017-11-10Add validation and specs to models on objectid_format presencecedricnjanga
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
2017-09-22Add `has_many` association between `Referential` and `ReferentialSuite`Teddy Wing
`ReferentialSuite` has many `Referential`s. Need to add a foreign key column to the `referentials` table to allow that to work. Refs #3519
2017-09-04add some change for the Referential#new_from to only have a line collection ↵cedricnjanga
regarding the functional scope of the current organozation
2017-07-21Fix cloned ref should belong to current user organisationXinhui
Refs #4132
2017-05-02 Refs #3053Robert
passes current_organization down from the controller into Reference.new_from adds joint models *ReferenceMemeberships to excluded Apartment models
2017-03-06Fix workbench#show filter referential by periode rangeXinhui
Refs #2665
2016-11-22Manage several ReferentialMetadata::Periods in ReferentialMetadata. Refs #2035Alban Peignier
2016-11-21Change periods before saving clone. Refs #1864Alban Peignier
2016-11-20Manage metadatas in Referential.new_from (to have expected metadatas in new ↵Alban Peignier
form). Refs #1782
2016-11-19Add support for Ransack search on has_array_of collection. Refs #1782Alban Peignier
2016-11-19Finalize ReferentialMetadata model support. Refs #1786Alban Peignier
2016-10-26Referential clonning refactoring + clone metadatasXinhui
Refs #1863
2016-10-25Worker referential_cloningXinhui
Refs #1863
2016-10-20Fix migration referential_metadata periodes as daterange:arrayXinhui
2016-10-19Model ReferentialMetadataXinhui
Refs #1782
2015-03-10Merging intermediate stateZakaria BOUZIANE
2015-02-17Upgrading FactoryGirl to V4.5.0Zakaria BOUZIANE
2015-01-15Fix tests and merge masterLuc Donnet
2015-01-05Initialize rails 4 migrationLuc Donnet
2014-12-16extract ninoxe overwriting from Referential modelMichel Etienne
2014-02-05fix rule_parameter_set creation when referential.createMarc Florisson
2013-06-28remove projection attributes from stop areas and access points in databaseMichel Etienne
2012-06-04add fields to referentials and update textilesMichel Etienne