Commit Graph

132 Commits

Author SHA1 Message Date
Javi Martín
bd795be80e Check for attribute values in current budget tests
Assigning a variable to each budget we declare results in useless
assignments. We could just delete the three useless assignments and
leave the fourth one, but I find the code easier to read if we use the
name of the budgets to differenciate between them. This way we also keep
the code vertically aligned.
2019-09-30 14:29:15 +02:00
Javi Martín
9787f7f125 Remove nonexistent instance variable
The instance variable was being evaluated to `nil`, and the budget was
automatically created by the `set_denormalized_ids` method in the budget
investment class.
2019-09-29 22:52:53 +02:00
Javi Martín
aeb1655961 Use budget phase traits
We were already using them in many places, but not everywhere.
2019-09-24 21:34:06 +02:00
Javi Martín
eb7a052207 Simplify tests using delayed_job
Among other advantages, now we can run these tests with
`rspec --tag delayed_jobs`.
2019-09-23 13:47:45 +02:00
Javi Martín
da121ebc53 Remove redundant setting resets in after blocks
Settings are stored in the database, and so any changes to the settings
done during the tests are automatically rolled back between one test and
the next one.

There were also a few places where we weren't using an `after` block but
changing the setting at the end of the test.
2019-09-23 13:47:45 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
488461b8ac Remove consecutive blank lines 2019-09-10 20:02:15 +02:00
Javi Martín
17c36c6c6c Apply NotToNot rubocop rule 2019-09-10 20:02:15 +02:00
Javi Martín
71d9ddd849 Apply rule to end files with a newline character 2019-09-10 20:02:15 +02:00
Javi Martín
ae98dbf683 Use Rails 5.1 conventions in tests params 2019-08-07 15:50:00 +02:00
voodoorai2000
2acba1c5db Use Rails 5 syntax to set referer in specs
The previous way was working fine with Rails 4, but now the referer was
returning nil and therefore raising an error in this spec.
2019-06-27 09:21:19 +02:00
taitus
d2506358ef Fix found Hound violations 2019-06-27 09:21:18 +02:00
taitus
744a3d48fd Create RemoteTranslations Controller
- Create RemoteTranslations Controller to receive resources without
  translations and create RemoteTranslation instances when theirs
  translations are not enqueued.
- Create remote_translation_enqueued? class method on RemoteTranslation
  model to check if exists same remote translations without errors
  pending to translate.
2019-06-27 09:21:18 +02:00
taitus
25e9c358ad Create RemotelyTranslatable concern controller
- Create concern to reuse the logic of detection of non-existent
  translations in Controllers.
- Add detect_remote_translation method:
  * This method will be called from controllers to recover resources
    without translation.
  * Receive arrays of resources.
  * Return an array with hashes of remote_translations values for
    every resources that have not translations.
  * This array will be the param that will be sent from view to
    RemoteTranslationController for create remote translations instances.
2019-06-27 09:20:25 +02:00
Senén Rodero Rodríguez
51cda51155 Add debates translation interface
Also fix broken spec after removing translatable attributes from
strong_parameters definition. Now we need to send these attributes
as nested translations attributes.

Use activerecord.yml title attribute label so form helper could load it
from default location.
2019-06-27 09:19:36 +02:00
Julian Herrero
b122302c58 Use find instead of find_by_id
Better raise a 404 HTML NotFound exception than any other unexpected error.
2019-06-03 17:54:19 +02:00
Julian Herrero
bb25da2572 Remove Rspec deprecation warning
DEPRECATION WARNING: Using positional arguments in functional tests
has been deprecated, in favor of keyword arguments, and will be
removed in Rails 5.1.

Deprecated style:
get :show, { id: 1 }, nil, { notice: "Flash message" }

New keyword style:
get :show, params: { id: 1 }, flash: { notice: "Flash message" }
2019-05-23 13:19:45 +02:00
rgarcia
b628631769 fixes specs 2019-05-16 13:37:47 +02:00
Javier Martín
e0484e45ec Merge pull request #3459 from consul/backport-fix_cross_origin_exception
Fix InvalidCrossOriginRequest response
2019-04-25 22:01:51 +02:00
Javi Martín
d90efa15e4 Fix InvalidCrossOriginRequest response
When requesting files like `/hackattempt.js`, the pages controller was
responding with 404 status code.

However, since the request was considered a JavaScript request (because
of the `.js` extension), the response was also considered to be a
JavaScript one, and since the request wasn't an AJAX request, our
protection from forgery was preventing a potential security issue by
raising an InvalidCrossOriginRequest exception.

By setting HTML as content type, we correctly respond with a 404 status
code.

More info:

https://die-antwort.eu/techblog/2018-08-avoid-invalid-cross-origin-request-with-catch-all-route/
2019-04-25 20:48:38 +02:00
Javi Martín
286e0ca878 Handle AccessDenied in management sessions
We were raising a `CanCan::AcessDenied` and were getting a 500 Internal
Server Error.

I've chosen to do the same thing we do in the ApplicationController.
There are other options to handle this request, like redirecting to the
login page or returning a 401 Unauthorized HTTP status.
2019-04-25 20:36:50 +02:00
Julian Herrero
6e88031537 Fix several rubocop warnings
Metrics/LineLength: Line is too long.
RSpec/InstanceVariable: Use let instead of an instance variable.
Layout/TrailingBlankLines: Final newline missing.
Style/StringLiterals: Prefer double-quoted strings.
2019-04-17 17:40:56 +02:00
rgarcia
fca7ef6cc9 removes params deprecation warning 2019-04-17 17:40:55 +02:00
alejandro
e63f6eec49 removes controller spec deprecation warnings 2019-04-17 17:40:55 +02:00
rgarcia
9a49716f22 updates controller specs deprecation warnings 2019-04-17 17:40:55 +02:00
rgarcia
a910eb69cd removes stats controller spec deprecation warning 2019-04-17 17:40:55 +02:00
rgarcia
bca824b759 removes controller spec deprecation warnings 2019-04-17 17:40:55 +02:00
Juanjo Bazán
0f34cae2ad updates specs to new keyword styles 2019-04-17 17:40:55 +02:00
alejandro
bafab3b769 fixes some deprecation warnings 2019-04-17 17:40:52 +02:00
Javi Martín
78c6395e5f Respond with 404 when confirming an invalid token
We were getting a 500 Internal Server Error because `find_by` returned
`nil`, but the code assumed it returned an object responding to
`encrypted_password`. In this case, maybe some other status code (like
400 or 401) might be more appropriate, but I've kept 404 because it was
easier to implement and I wasn't sure which one was better.

Also note ideally we would test the controller using:

expect(response).to have_http_status(:not_found)

However, we would need to configure the test to show exceptions and not
to consider all requests local. I haven't been able to do so for
controller tests, and doing so for feature/request specs seems to
require changes in the test environment configuration which would affect
other tests.
2019-04-10 12:41:21 +02:00
Javi Martín
4c35df4812 Use double quotes inside string interpolation 2019-03-25 14:58:54 +01:00
Javi Martín
2b4e1cf358 Add missing double quotes
We overlooked a few single quotes while we changed thousands of them.
2019-03-25 13:22:35 +01:00
Julian Herrero
87be6f302c Add default site customization pages
From now on these static pages:

`/privacy'
`/conditions'
`/accesibility'
`/help/faq'
`/welcome'

have been moved to the DB and can be modified easily by any
administrator in `/admin/site_customization/pages'
2019-03-14 18:35:51 +01:00
Julian Herrero
31ac8b7f55 Change single quotes to double quotes 2019-02-15 11:40:39 +01:00
Julian Herrero
9a23393535 Use find instead of find_by_id
This method will raise an exception if resource is not found when
trying to call score_action on nil.
Prefer to raise a 404 HTML NotFound error instead.
2019-01-25 09:03:56 +01:00
decabeza
46671fe447 Removes unnecessary pages 2018-11-15 11:52:57 +01:00
Raimond Garcia
1692abc54a Merge pull request #2374 from wairbut-m2c/upload_documents_feature
Upload documents feature
2018-04-05 19:39:12 +02:00
Bertocq
633cc1283b Fix Date & DateTime parsings to use default timezone
Date.new(...) does not take into account the current timezone, while other
parts of the application do. By default always parsing any date with the
default timezone and converting the resulting Time to Date would prevent
this kind of issues

DateTime.parse(...).in_time_zone gives an unexpected result, as the
DateTime.parse(...) will create a DateTime with +0000 time zone and the
`in_time_zone` will modify the DateTime to adjust to the default zone.

Maybe its better explained with an example, using 'Lima' as timezone:

DateTime.parse("2015-01-01")
> Thu, 01 Jan 2015 00:00:00 +0000

DateTime.parse("2015-01-01").in_time_zone
> Wed, 31 Dec 2014 19:00:00 -05 -05:00

And that's not the desired date but the previous day!
2018-04-04 14:21:39 +02:00
decabeza
42d0f471ee Updates i18n keys and images folder 2018-01-30 19:10:48 +01:00
Vicente Mendoza
410caced3e test added for changes at documentable's view 2018-01-24 12:48:06 +01:00
Bertocq
28008d64e2 Improve performance swapping keys.each for each_key, plus line lenght comply 2018-01-19 23:44:08 +01:00
BertoCQ
3e316edc40 Merge pull request #2185 from consul/improve_consul_json_spec
Improve consul.json request spec
2018-01-18 21:08:54 +01:00
rgarcia
be554a629c Make current_budget accessible in controller and views 2018-01-15 19:13:45 +01:00
Bertocq
34bb9d65b1 Enable RSpec/NotToNot cop and fix all issues
Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NotToNot
2018-01-07 17:39:48 +01:00
Bertocq
cdbf0a77e1 Improve consul.json request spec, to avoid maintaining the setting features list up with seeds.rb content 2018-01-07 15:24:46 +01:00
Bertocq
1441de5107 Enable RSpec/HookArgument cop and fix issues
To be consistent about before/after arguments, as `:each` or `:example`
 are same and default scopes, best not to send an argument in those
 scenarios.

Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HookArgument
2018-01-07 02:07:19 +01:00
Bertocq
ed16a78f42 Enables RSpec/ExampleWording and fixes all issues
Both avoiding 'should' and repiting 'it' on the tests description
improves reading them and also makes all descriptions consistent.

Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWording
2018-01-07 01:03:45 +01:00
Bertocq
6ec6f64675 Enable RSpec/DescribeClass rubocop rspec cop & fix issues
Manually fixes all issues & "stashed" false positives at .rubocop_todo.yml

Read about the cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass
2018-01-07 00:20:55 +01:00
Alberto García
19925de06b Merge pull request #2170 from consul/design
Design improvements
2017-12-14 11:31:31 +01:00
Bertocq
34f07bcc82 Add feature allow_images flag to installation specs 2017-12-13 14:30:43 +01:00