This is a mistake I made in commit f2ef27d3. Back then I thought we
needed to keep Globalize.locale and I18n.locale in sync, but the truth
is it automatically happens when setting Globalize.locale to nil.
So now we can use I18n.with_locale (at least in the tests) and forget
about Globalize, which will make it easier to switch to Mobility in the
future.
We already configure `I18n.locale` and we reset Globalize's fallbacks
before every test.
On the other hand, RSpec automatically resets anything which is stub
with `allow`, so there's no need to use `and_call_original` in an
`after` block.
The images from OpenStreetMap take a while to load, sometimes even
causing Net::ReadTimeout errors if the internet connection is slow. It's
happened a lot recently on Travis builds.
Using capybara-webmock we guarantee the test suite doesn't fail due to
network issues.
The dates are saved on UTC times on the database. So, for example,
if living in West Australia, `Date.current.beginning_of_day` will be
stored as UTC's yesterday at 15:15:00, while `Date.current.end_of_day`
will be stored as UTC's today at 15:14:59.
When we use the `DATE` database function, PostgreSQL will select the
records with the same UTC date as the current UTC date. However, we need
the records with the same application date (as defined in
`config.time_zone`) as the current application date. The test passed
(for us) because we were using `beginning_of_day + 3.hours` to make sure
we were creating records when the date in Madrid was the same as the UTC
date.
Using a ruby interval for the time condition solves the problem.
When any helper, lib, mailer, model or view spec is executed
after a feature, controller or request spec Globalize.fallbacks
returns nil and this can cause some flaky specs. With this
patch we are ensuring to initialize Globalize fallbacks
between specs.
Controller, feature and request specs do not need this patch
because of application_controller is currently initializing
Globalize.fallback on each request.
Resetting sessions and driver is automatically done by requiring
'capybara/rspec', as shown by the (lack of) that configuration for RSpec
in the Capybara README, manual testing of those settings, and Capybara's
code itself.
Using `Date.today` caused some milestones to be published before/after
the date defined by `Rails.application.config.time_zone`.
See also commit AyuntamientoMadird/consul@088c76d for a more detailed
explanation.
The test "Budget Investments Show milestones" was failing in certain
cases where `Globalize.locale` had been changed in a previous test.
Since having different values in `Globalize.locale` and `I18n.locale`
has proven to be an issue on the test enviroment, this commit also
changes application code in order to avoid similar situations on
production.
See issue #2718.
This makes tests run a tiny bit faster and cleans up the logs when
running specs locally
We can still configure rspec to run the profiler when we go into improving spec performance
Keep a blank line before and after private
Keep a blank line before and after protected
Remove extra empty line at class body end
Remove extra blank line
Add final newline
Use 2 (not 3) spaces for indentation
Use 2 (not 4) spaces for indentation
Remove space before comma
Add space after comma
Remove trailing whitespaces
Remove unnecessary spacing
Use snake_case for variable names
Do not use then for multi-line if
Remove unused block argument - i
Use the new Ruby 1.9 hash syntax
Remove unused assignment to variable
Indent when as deep as case
Align attributes
Align end with def
The logs are always stored in log/bullet.log
If you run the specs with `BULLET=true bin/rspec`:
* Any feature test which makes bullet angry will fail
If you run rails with `BULLET=true bin/rails s`:
* It will print the bullet logs in both the rails log and the bullet log
* It will show a footer on each page with the N+1 queries etc.