When two people tried to buy the same item at the same time, it was
possible to oversell the item and end up with negative stock.
Parallel checkouts could also lead to other random failures. This spec
is testing that scenario by starting two threads which would run into a
race condition unless they use effective synchronisation. The added spec
fails if the synchronisation is removed from the CheckoutController.
It turns out that we were executing `DatabaseCleaner.clean` on two
`after(:each)` blocks. One for all specs and another one for `js: true`
specs. As a result feature specs were hitting both which slows them down
considerably.
On my machine this changes consistently saves 2sec on
`spec/features/consumer/shops_spec.rb` but chances are it has an
accumulative effect when run on the whole test suite.
This enables code coverage analysis when running specs in your dev
environment. Simply run them as usual and you'll see a line like the
following at the end of the output:
Coverage report generated for RSpec to /home/pau/dev/openfoodnetwork/coverage
Simply browse to coverage/index.html and the results in a web UI.
This is a useful tool that helps you decide if the tests you added are
enough or not.
* master: (206 commits)
embedded groups layout changes
embedded groups initial test
Allow html requests for OrderCycleController#update
Move applicator calls to OrderCycleForm
Refactor OrderCycleForm to make logic clearer
Extract schedule syncing logic into OrderCycleForm
Add basic specs for OrderCyclesController#create
Add basic OrderCycleForm to handle create/update logic
Remove unnecessary respond_to blocks from OrderCyclesController
Include admin users as managers on new enterprises
Remove obsolete goWithoutHashFragments
Simplify Navigation.go, not preserving hash fragments
Only show change warning for open order cycles
Use a SubscriptionsCount query object to provide counts to IndexOrderCycleSerializer
Preload subscription counts for serialization in order cycle collection actions
Request the subscription count for change warning each time, don't cache
Ask user to confirm oc date change for open order cycles with subsciptions
Fix ordering of Gemfile.lock
Add rack-rewrite to handle redirects
Renames product bulk edit action to index
...
Addressing issue #245.
A combination of fixtures and foreign key constraints requires the postgres
user to be superuser. Otherwise an attempt to disable constraints fails.
This got fixed in Rails 4 and this patch brings the same behaviour back to
Rails 3. It will allow us to run the specs with a nosuperuser postgres user.
See:
- https://github.com/matthuhiggins/foreigner/issues/61
- 9bb27f7ffe