aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
Commit message (Collapse)AuthorAgeLines
* Move getting recent requests into a helper method.Louise Crow2013-11-25-42/+0
|
* Merge branch 'all-authorities-reduce-memory' into rails-3-developMark Longair2013-11-19-0/+14
|\ | | | | | | | | This has already been cherry-picked into the wdtk branch, but it should also be merged into rails-3-develop
| * Reduce the memory used to serve /body/all-authorities.csvMark Longair2013-11-14-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On WDTK, /body/all-authorities was using lots of memory - this commit reduces that by (a) fetching the public bodies in batches, rather than keeping them all in memory at one time and (b) writing the CSV to a file and then returning it with X-Sendfile (or equivalent), rather than returning the whole file from memory with send_data. There's a FIXME to do with the layout of download directories; if that's changed, the example nginx config, etc. will need to be updated too. This commit also adds a basic test for reasonable CSV being returned and switches from FasterCSV to CSV in order to fix this NotImplementedError under Ruby 1.9: Please switch to Ruby 1.9's standard CSV library. It's FasterCSV plus support for Ruby 1.9's m17n encoding engine. (The CSV version seems to still work fine under 1.8.7.)
* | Fix construction of example public bodies for upstream globalizeMark Longair2013-11-19-14/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We're trying to switch to an upstream version of globalize, which now has Henare's change to allowed blank values without them being converted to nil - however, there is another intermediate change that was introduced which means that the name is only written back to the original table if the locale matches the default locale. This is described in more depth here: https://github.com/globalize/globalize/pull/183 This change broke the make_single_language_example helper, but this commit fixes that by also setting the default locale before creating the example public bodies.
* | Refactor some tests to use with_default_localeMark Longair2013-11-19-17/+15
|/
* Merge branch 'feature/1118-fix-ask-us-to-add-links' into rails-3-developMark Longair2013-11-07-0/+16
|\
| * Show 'browse all' and 'ask us to add' one for authority only search.Louise Crow2013-11-07-0/+5
| | | | | | | | | | This is for the case where there are no results and the user was explicitly searching for authorities.
| * Show highlights and correction regardless of search type.Louise Crow2013-11-07-0/+11
| | | | | | | | Contributes to #1118.
* | Factor out code for generating graphable data and add testsMark Longair2013-11-05-0/+87
| | | | | | | | | | | | This simplifies the statistics action of the PublicBodyController and makes it easier to test the functionality now in the simplify_stats_for_graphs method.
* | Fix the indentation of a PublicBodyController testMark Longair2013-11-05-28/+28
|/
* Merge branch 'hotfix/0.14.0.3' into rails-3-developLouise Crow2013-10-24-0/+33
|\
| * Don't allow redirects to another host.Louise Crow2013-10-02-0/+33
| |
* | Fix for an aborted transaction not being rolled-backMark Longair2013-10-07-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were seeing errors in xapian_create_job that indicated that the current transaction had been aborted but not rolled-back. It seems that this happened because sometimes xapian_create_job was called from within another transaction (e.g. from the transaction block in AdminIncomingMessageController#redeliver). The default behaviour of nested transactions in Rails is for them to behave as if all but the outermost transaction blocks had no effect; this means that the exception thrown in the inner transaction block in xapian_create_job wasn't causing a rollback, and it was then being caught before propagating up to the outermost transaction. Thus the transaction was never being rolled-back so any subsequent operation on this database connection would error. This commit fixes this problem by using the :requires_new => true option to transaction, which asks ActiveRecord to fake genuinely nested transcations using SAVEPOINT. Fixes #1124.
* | Allow public body listing based on first letter outside US-ASCIIMark Longair2013-10-04-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Under Ruby 1.8, it was previously impossible to use one of the "first letter" alphabet links on the public body listing page if the first letter was outside [A-Za-z] since the test for the parameter only being a single letter wasn't aware of the possibly of multi-byte characters. In addition, upcasing of letters outside [A-Za-z] didn't work because String#upcase in Ruby 1.8 isn't Unicode-aware. This commit fixes these two problems, so that non-US-ASCII first letter links will work under Ruby 1.8. (Fixes #1112.)
* | Add to fixtures a public body with an accented initial letterMark Longair2013-10-04-1/+2
|/ | | | | | | | | | | | | | | | | This adds a public body called "Åčçèñtéd Authority" in the Czech locale (cs) so that we can create tests that exercise, for example, searching based on an initial letter that has a multi-byte representation in UTF-8. An old test for "add mass tags" in the admin needed to be updated since it implicitly assumed that all the public bodies in the fixtures had translations in the :en locale. The tests for loading CSV files of public bodies also needed to be updated, since they were assuming that public body names only contained letters in [A-Za-z ]. Since Unicode character classes aren't easily available in Ruby 1.8 and it makes little difference to the test, the character class is replaced by '.'.
* Remove extra "is invalid" message.Louise Crow2013-09-18-0/+8
| | | | Fixes #1101.
* Fix erroneous line break.Louise Crow2013-09-17-2/+1
|
* Merge branch 'feature/hide-individual-responses' into rails-3-developLouise Crow2013-09-17-261/+453
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: Gemfile app/views/admin_request/edit_outgoing.html.erb config/packages doc/CHANGES.md doc/INSTALL.md spec/models/info_request_spec.rb spec/models/public_body_spec.rb
| * Use 403, not 410, for hidden items.Louise Crow2013-09-16-4/+4
| | | | | | | | | | As @mhl points out, this more clearly indicates that they may come back at some point.
| * Use earlier factory_girl syntaxLouise Crow2013-09-16-5/+7
| |
| * Add public criteria for message event access methodsLouise Crow2013-09-16-9/+10
| | | | | | | | | | | | | | get_last_response_event and get_last_outgoing_event are used in various places to determine which events to link to, use in queries etc. Restrict them to refer to the last publicly visible event of the relevant type, and rename them to make that clear.
| * Fix spec descriptionsLouise Crow2013-09-16-2/+2
| |
| * Add prominence fields and cache expiry to outgoing adminLouise Crow2013-09-16-13/+95
| |
| * Restore the download for hidden requestsLouise Crow2013-09-16-6/+0
| | | | | | | | | | | | This was disabled for hidden requests as the download was by redirect, allowing people who have not been authenticated to conceivably access the download. We'll be moving to send_file instead, so can restore it.
| * Rewrite download specLouise Crow2013-09-16-45/+3
| | | | | | | | | | Make it an integration spec so we don't need to touch the internals so much.
| * Replace fixture-based spec with factory-based equivalent.Louise Crow2013-09-16-10/+6
| |
| * Use expectation for hidden responses more generally.Louise Crow2013-09-16-9/+9
| |
| * Fix request in spec for hidden attachments not being viewed.Louise Crow2013-09-16-2/+15
| | | | | | | | | | Add another spec for the same behaviour when an incoming message is hidden.
| * Add new code and specs for hiding attachments.Louise Crow2013-09-16-1/+106
| |
| * Refactor expectation into a methodLouise Crow2013-09-16-6/+8
| | | | | | | | Remove expectation of pdf contents - we're looking at the raw file.
| * Refactor prominence specs to use factories not fixtures.Louise Crow2013-09-16-116/+74
| |
| * Clarify specs.Louise Crow2013-09-16-5/+5
| | | | | | | | They refer to the case where the request itself is hidden.
| * Add the meat of the update action.Louise Crow2013-09-16-0/+70
| |
| * Add a simple edit action and templateLouise Crow2013-09-16-5/+28
| |
| * Slightly nicer action names.Louise Crow2013-09-16-5/+5
| |
| * Move incoming message admin to its own controller.Louise Crow2013-09-16-74/+51
| | | | | | | | | | Make specs that depend on multiple controllers and models interacting integration specs.
| * Move outgoing message admin actions to their own controller.Louise Crow2013-09-16-12/+23
| | | | | | | | Eventually this should use standard RESTful routing.
* | Merge branch 'public-body-locale-fallback' into rails-3-developLouise Crow2013-09-12-8/+66
|\ \ | | | | | | | | | | | | | | | | | | Conflicts: app/controllers/public_body_controller.rb config/general.yml-example lib/configuration.rb
| * | Don't display duplicate public bodies with the fallbackMark Longair2013-09-12-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces some raw SQL statement for the fallback case, but we can't see an easy way to avoid that in this case. This commit also adds some tests that assert the sorting and non-duplication properties of the listing. Thanks to Louise Crow for working out the SQL expression for falling back to the default locale.
| * | Factor out the code to generate example single language public bodiesMark Longair2013-09-10-16/+23
| | | | | | | | | | | | | | | It's useful to be able to generate example public bodies that only have translations in particular languages.
| * | Add tests to assert the new public body listing behaviourMark Longair2013-09-10-0/+14
| | | | | | | | | | | | | | | | | | These tests will fail unless we have the new behaviour for public body listing, which depend on the setting of PUBLIC_BODY_LIST_FALLBACK_TO_DEFAULT_LOCALE.
| * | Make falling back to default locale in public body listings optionalMark Longair2013-09-10-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As the code stood, the list method in PublicBodyController would only return results that had translations of the public body in the default locale. This has a variety of problems if you're viewing pages in the non-default locale - for example, the "first letter" links wouldn't bring up the public bodies that began with that letter in the current locale, only those that began with it in the default locale. Ideally, every public body would be translated into every available locale for the site, but there are cases where deployers wish to have public body listings also include those from the default locale, in case there are untralsated public bodies: https://groups.google.com/d/msg/alaveteli-dev/zUY_USaAMAM/M7KTQ9RC5YUJ This commit makes the default behaviour to look for public body listings only in the current locale, but if the new configuration option PUBLIC_BODY_LIST_FALLBACK_TO_DEFAULT_LOCALE is set, then public body listings will be looked for in both the current locale and the default locale. Fixes #1000
* | | Save cached columns once updated.Louise Crow2013-09-05-1/+1
| | |
* | | Add a config option to enable the public body statistics pageMark Longair2013-08-20-0/+1
| | |
* | | Improve calculation of PublicBody statistics columnsMark Longair2013-08-20-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On PublicBody, we don't need to update info_requests_count because that's already done with :counter_cache. On the other hand, info_requests_successful_count and info_requests_not_held_count can't be updated easily with counter_cache (since they need conditions to be attached). Instead we update them in post_save and post_destroy, as suggested here: http://blog.douglasfshearer.com/post/17495285851/custom-counter-cache-with-conditions This also adds tests to ensure that the after_(save|destroy) callbacks are called and that they modify the counts correctly.
* | | Add a test for the PublicBodyController statistics actionMark Longair2013-08-20-0/+34
|/ /
* / Set the calculated state on external requests.Louise Crow2013-08-15-0/+3
|/ | | | Set to 'waiting_response' on creation, to match the displayed state.
* Handle the case of a name that hits the character limits and has been ↵Louise Crow2013-07-29-5/+25
| | | | suffixed with a number.
* Merge branch 'feature/localisation-fixes' into rails-3-developLouise Crow2013-07-29-138/+24
|\
| * Patch Globalize to compensate for the way gettext_i18n_rails patches ↵Louise Crow2013-07-23-0/+18
| | | | | | | | 118n.locale in the handling of locales with underscores. Fixes #999.