aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2017-12-01suggesting CR chages0000-cr-for-5024Robert
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: Use new hash syntaxTeddy Wing
Convert the hash syntax in `models/referential.rb` to new Ruby hash syntax. 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#lock_table: Add comment about unlockTeddy Wing
Refs #5024
2017-11-29Referential: Add comment to describe why we lock the tableTeddy Wing
Refs #5024
2017-11-29Referential: Add a comment about the `lock_table` callbackTeddy Wing
Make it clear in the code (not just in the commit message) that this callback must go last. Refs #5024
2017-11-29Referential: Lock `referentials` table before validationTeddy Wing
It was possible for two identical referentials (with the same metadata) to be created and persisted if they were created at the same time. This is validated by the test: `spec/models/referential_spec.rb:164`. As a heavy-handed solution to that problem, prevent two referentials from being created at the same time by setting a lock on the `referentials` database table before Rails validation begins. This prevents any other referentials from being saved at the same time as the current one. Thanks to Alban for coming up with the lock Postgres query. The lock should be the last `before_validation` hook that gets executed, so we put it after the other `before_validation` definitions. We want it to be the last one because we're trying to hold the lock for as little time as possible. Note that we don't need to explicitly unlock the table as this will happen automatically at the end of the transaction. 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-27ReferentialsController: Fix typo in `build_referenial` nameTeddy Wing
Rename the method to `build_referential`. Saw it because my project grep didn't work. 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-27Merge branch 'master' of github.com:af83/stif-boivcedricnjanga
2017-11-27Refs #4941 Fix objectid short version Display on viewscedricnjanga
2017-11-27Merge branch '4941-refactoring_object_id'cedricnjanga
2017-11-27Refs #5087 Take ImportResource metrics changes into account in viewscedricnjanga
2017-11-27Run yarn install after bundle install. Refs #5085Alban Peignier
2017-11-27Refs #4961 Fix typos on Import#show and ImportResource#indexcedricnjanga
2017-11-27Refs #5030 Fix missing translation for UnactivatedStopPoint ComplianceControlcedricnjanga
2017-11-27Refs 5029 Fix locale typocedricnjanga
2017-11-27Refs #5071 #5070 Adapt view to TransportModeHelper refacto to avoid errorscedricnjanga
2017-11-27Skip API key features test when STIF::Dashboard isn't used. Refs #4655Alban Peignier
2017-11-27Test Devise::CasSessionsController flash message with more specific messageAlban Peignier
2017-11-26Use t('id_codif') and t('id_reflex') to prevent hardcoded strings. Refs #5081Alban Peignier
2017-11-26Provide a default Dashboard view. Refs #4655Alban Peignier
2017-11-26Provide empty main_nav_left_content custom view. Refs #4735Alban Peignier
2017-11-26Remove base part of the nav menu in STIF main_nav_left_content. Refs #4735Alban Peignier
2017-11-26Ignore indefined current_organisation in render_custom_view. Refs #4735Alban Peignier
2017-11-26Use debug message for render_custom_view. Refs #4735Alban Peignier
2017-11-26Use an helper to invoke render method safely. Refs #4735Alban Peignier
2017-11-26Update STIF navigation left menu. Refs #4735Alban Peignier
2017-11-26Create custom view for STIF main nav left. Refs #4735Alban Peignier
2017-11-26Create STIF organisations with custom_view 'stif'. Refs #4735Alban Peignier
2017-11-26Add Organisation#custom_view and associated helper render_custom_view. Refs ↵Alban Peignier
#4735
2017-11-26Move STIF seed in db/seeds/stif.rb. Refs #5074Alban Peignier
2017-11-26Uses (sorted) .rb files found in db/seeds (instead of db/seeds.rb content). ↵Alban Peignier
Refs #5074
2017-11-24Add specs for Objectid modelscedricnjanga
2017-11-24Remove specs we dont need anymorecedricnjanga
2017-11-24class instance variables in Direction and ConnectionLinkType modelscedricnjanga
2017-11-24Take into account code reviewcedricnjanga
2017-11-23Stay up to date with master branchcedricnjanga
2017-11-23Add spec for stif_netex objectid_formatcedricnjanga
2017-11-23Remove get_objectid duplicate methodcedricnjanga
2017-11-23Add migration to update all referentials and workbenches objectid format to ↵cedricnjanga
stif_netex
2017-11-23Change the call of local id on several views to avoid bugscedricnjanga
2017-11-23Fix typos on class naming for objectid formatterscedricnjanga