Commit Graph

116 Commits

Author SHA1 Message Date
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
rgarcia
c63c734ec2 fixes specs 2017-12-12 11:04:05 +01:00
Bertocq
516081d109 Describe with a request spec the consul.json install details route 2017-12-04 18:17:10 +01:00
Bertocq
69f4e1c683 Fix all rubocop Metrics/LineLength issues (140+) 2017-07-10 13:22:49 +02:00
Bertocq
c9bc028524 Remove all unnecesary extra spacing and Layout/ExtraSpacing list from rubocop file 2017-06-28 14:12:51 +02:00
Bertocq
2fa92937d2 Fix all Style/BracesAroundHashParameters rubocop issues and remove them from rubocop_todo list 2017-06-28 14:12:51 +02:00
Bertocq
c4d90691b1 Fix all Layout/SpaceInLambdaLiteral rubocop issues and remove files from rubocop_todo list 2017-06-26 18:05:14 +02:00
Bertocq
f6fe9cc7d2 Fix all Layout/SpaceAroundOperators rubocop issues and remove file list from rubocop_todo list 2017-06-26 18:04:20 +02:00
Bertocq
9763931f55 Fix all Layout/SpaceBeforeComma rubocop issues and remove from rubocop_todo list 2017-06-26 17:57:53 +02:00
Bertocq
d759aca522 Fix all Rails/TimeZone rubocop issues and remove files from rubocop_todo list 2017-06-25 15:46:46 +02:00
Bertocq
6529e37ae8 Fix all rubocop Rails/PluralizationGrammar issues and remove the file list form rubocop_todo file 2017-06-25 15:46:46 +02:00
kikito
1701111bf5 Merge branch 'api-dev-PRs' of https://github.com/amiedes/consul into amiedes-api-dev-PRs-2 2017-06-13 12:07:28 +02:00
Raimond Garcia
59f42dfa0f Merge pull request #1579 from bertocq/chore/restore_setting_afterwards_in_specs
Cleanup Settings values modified after specs are run
2017-06-08 12:09:24 +02:00
Bertocq
798b646135 Cleanup Settings values modified after specs are run 2017-06-07 20:55:42 +02:00
decabeza
dcffa96d11 removes specs of deleted info pages 2017-06-07 18:53:23 +02:00
decabeza
5e0d5fc8c3 Merge branch 'legislation-module-stable' of https://github.com/medialab-prado/consul into medialab-legislation 2017-05-22 18:43:49 +02:00
Alberto Miedes Garcés
cad66ea85a Update GraphQL and GraphiQL gem 2017-05-11 22:29:21 +02:00