aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
Commit message (Collapse)AuthorAgeLines
* Handle validation errors in PublicBody.import_csvGareth Rees2014-04-14-0/+13
| | | | | | | | | Specifically using save! so that anything other than an ActiveRecord::RecordInvalid doesn't get missed Note that ActiveModel::Errors#full_messages includes the attribute key in the message. This is by design, so we should consider whether we can improve the way that we use translated validation messages.
* Add missing validation to PublicBodyGareth Rees2014-04-14-0/+6
| | | | | There's a unique index on public_bodies url_name, so we should have a validation for that.
* Annotate modelsGareth Rees2014-04-09-19/+44
| | | | | Should have been run after related migrations. Could automate this to always run after migrations.
* Merge branch 'issues/1317-holding-pen-spam' into rails-3-developGareth Rees2014-04-07-0/+49
|\
| * Add SpamAddress modelGareth Rees2014-03-26-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The volume of spam in the holding pen in WDTK has increased. Over a few weeks in January 2014 the pattern was roughly: - 8 were sent "To" the same address, which was a nearly valid old request address - correct hash, but missing the second hyphen. - 1 was sent "To" an invalid request address (nearly correct hash) - 1 was sent "BCC" a valid request address - 1 was sent "BCC" request@whatdotheyknow.com If a spam was sent "To" an old valid request address then it would be rejected. It's not entirely safe to just reject mails to old requests with any hash, because sometimes authorities miss out a digit in the request number, though perhaps simply getting a failure bounce would cause them to check. In any case that wouldn't trivially catch the most frequent case above as it doesn't have an obvious request number. --- We looked at greylisting and configuring the MTA with an RBL. Greylisting was rejected as it would slow down the responsiveness of the application when people email in. This could be revisited if/when emails are parsed through a queue system depending on how we find the performance there. An RBL is already configured, but this ticket refers more to where the email is sent rather than who it came from. --- We elected to: - Create spam_address model - Add code to RequestMailer.receive to check the list of spam addresses and silently discard an incoming mail if it's addressed to one of them - Add page to admin interface for adding/removing spam addresses --- Thanks to Ganesh Sittampalam for the research and Louise Crow for the implementation strategy.
* | Merge branch 'feature/1310-better-track-translation' into rails-3-developLouise Crow2014-04-04-4/+5
|\ \ | | | | | | | | | | | | Conflicts: spec/factories.rb
| * | Make search description specs match actual casesLouise Crow2014-03-17-4/+5
| |/ | | | | | | | | | | In the largest Alaveteli instance, WDTK, only a fraction of tracks use filters and these specs represent those that have actually been used commonly.
* / Add specs for ContactValidatorGareth Rees2014-03-26-2/+47
|/
* Make test specific to versions of ruby with String.encodeLouise Crow2014-02-24-4/+6
| | | | The code being tested is specific in that way.
* Merge remote-tracking branch ↵Louise Crow2014-02-24-1/+7
|\ | | | | | | 'opennewzealand_github/feature/encode-utf8-messages' into rails-3-develop
| * Add test for _get_attachment_text_internal with invalid utf-8Rowan Crawford2014-02-23-1/+7
| |
* | Merge branch 'feature/batch-requests' into rails-3-developLouise Crow2014-01-29-3/+213
|\ \ | | | | | | | | | | | | | | | Conflicts: config/general.yml-example spec/factories.rb
| * | Send batch requests as a cron job.Louise Crow2013-12-04-0/+40
| | |
| * | Simplify return value, set sent_at in create_batch!Louise Crow2013-12-04-13/+34
| | |
| * | Use public bodies not requests in find_existingLouise Crow2013-12-04-6/+8
| | | | | | | | | | | | The requests may not have been created at this point.
| * | Split the creation of a batch and the associated requests.Louise Crow2013-12-04-10/+9
| | | | | | | | | | | | We're going to want to actually create and send the requests later.
| * | Add the specific salutations to each request.Louise Crow2013-12-04-0/+22
| | | | | | | | | | | | | | | | | | Also, wrap model creation in a transaction and do the message sending separately - we may ultimately want to do this outside the request cycle.
| * | Add check for double submission.Louise Crow2013-12-04-0/+45
| | |
| * | Make method names for finding existing objects clearerLouise Crow2013-12-04-1/+1
| | | | | | | | | | | | | | | They're not finding by the existing object, they're finding an existing object.
| * | Add InfoRequestBatch model.Louise Crow2013-12-04-0/+21
| | | | | | | | | | | | | | | Re-annotate models. Index InfoRequestBatches by user - we'll display the batches for a user when they view their own requests.
| * | Batch users don't have a daily limit.Louise Crow2013-12-04-0/+7
| | | | | | | | | | | | | | | | | | | | | It doesn't make logical sense that they would. However I am preserving the ability to make batch requests as a separate thing from not having a daily limit - I think batch sending requires a (perhaps marginally) bigger level of trust.
| * | Add some specs for existing exceeded_limit? behaviourLouise Crow2013-12-04-0/+24
| | |
| * | Create a placeholder salutation for a batch request template.Louise Crow2013-12-04-2/+12
| | |
| * | Handle the application of censor rules to a batch request template.Louise Crow2013-12-04-0/+6
| | |
| * | Add a batch_request_template flagLouise Crow2013-12-04-0/+13
| | | | | | | | | | | | | | | | | | A virtual attribute to use to customise some info request behaviours when we are using one request as a template for creating multiple requests.
* | | Merge branch 'feature/1176-automate-authority-contacts' into rails-3-developLouise Crow2014-01-28-0/+139
|\ \ \ | | | | | | | | | | | | | | | | Conflicts: doc/CHANGES.md
| * | | Populate admin public body forms based on a change request.Louise Crow2014-01-13-0/+29
| | | | | | | | | | | | | | | | | | | | Also add editable text for an email to be sent to the person requesting the change.
| * | | Form and models for asking for a public body change.Louise Crow2014-01-13-0/+110
| | |/ | |/|
* | | Merge branch 'feature/cache-request-lists' into rails-3-developLouise Crow2014-01-28-0/+96
|\ \ \
| * | | Cache frequently accessed request lists.Louise Crow2013-12-19-0/+96
| |/ / | | | | | | | | | Make specs a bit more focused, remove view specs - they're not relevant to the new code in their current form and don't seem to merit updating.
* | | Merge branch 'feature/1269-improve-quoting-recognition' into rails-3-developLouise Crow2014-01-27-2/+2
|\ \ \
| * | | Tighten up expectation, make expected files consistent.Louise Crow2014-01-17-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Just expecting the parsed file to include the expected one would mean success in the case where nothing has been folded. Tighten up the expectation, and add quoting placeholders to expected files that didn't have them.
* | | | Merge branch 'feature/fix-profile-photo-errors' into rails-3-developLouise Crow2014-01-27-7/+15
|\ \ \ \ | |/ / / |/| | |
| * | | Make custom error messages translated.Louise Crow2014-01-08-7/+15
| |/ /
* / / Add further tests for creation of the internal admin bodyMark Longair2014-01-09-0/+31
|/ / | | | | | | | | | | | | | | The internal admin body should be created automatically if it doesn't exist on calls to PublicBody.internal_admin_body; we've seen errors (#1001) where this fails after the default locale changes. (Although these tests don't actually replicate that problem.)
* | Merge branch 'feature/locale-underscore-fixes' into rails-3-developLouise Crow2013-12-09-0/+18
|\ \
| * | Make sure globalize uses the right locale version when updating.Louise Crow2013-12-05-0/+9
| | |
| * | Search for bodies using the underscore version of the locale.Louise Crow2013-12-05-0/+9
| |/
* / Fix the command-line CSV importer under Ruby 1.9Mark Longair2013-12-03-0/+14
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under Ruby 1.8.7, you can parse a CSV file with the following code (Example A): require 'csv' CSV.parse('foo.csv') do |row| puts "got row: #{row.inspect}" end Rather confusingly, under Ruby 1.8.7, CSV.parse can also take a string representation of the contents of the file as its parameter, so this also works (Example B): require 'csv' CSV.parse("1,hello,red\n2,goodbye,green") do |row| puts "got row: #{row.inspect}" end However under Ruby 1.9.3, CSV.parse only expects a string representation of the contents of the CSV file, so only Example B works; Example B fails silently (interpreting the filename as a single cell CSV file, typically). The import:import_csv rake task unfortunately relied on both A and B working. This commit fixes this by adding PublicBody.import_csv_from_file, and refactoring PublicBody.import_csv to use the newly added class method, and adds a test to check for any regression in this behaviour. (This means that the usage of import_csv in the admin public body controller's import_csv action could now be changed to use PublicBody.import_csv_from_file directly from the uploaded file, which would be more efficient and cope with larger files without using lots of memory.) Fixes #1229
* Merge branch 'move-plugins-out-of-vendor-plugins' into rails-3-developMark Longair2013-12-03-1/+1
|\
| * Move acts_as_xapian out of vendor/pluginsMark Longair2013-11-29-1/+1
| | | | | | | | | | This includes making making sure that xapiandbs directory is moved with this version of the code.
* | Move getting recent requests into a helper method.Louise Crow2013-11-25-0/+37
| |
* | Move getting similar requests to the InfoRequest model.Louise Crow2013-11-25-2/+19
|/
* Don't include public bodies tagged 'test' in public body statisticsMark Longair2013-11-07-0/+44
| | | | | | | | | | In the initial release of public body statistics to WhatDoTheyKnow a public body only intended for testing ("mySociety Test Quango") was included in the statistics. This commit causes public bodies tagged with "test" to be excluded from the public body statistics page. Fixes #1115.
* For percentage stats, exclude hidden or unclassified requestsMark Longair2013-11-05-0/+30
| | | | | | | | The WDTK volunteers pointed out that it's not fair to include hidden requests in the denominator, since they're typically hidden for a good reason (e.g. being vexatious, spam, etc.), and we have no information about those that are awaiting_description (i.e. unclassified) so they should be excluded as well.
* Add a info_requests_visible_classified_count column to PublicBodyMark Longair2013-11-05-20/+21
| | | | | | This counts only those info requests that have prominence 'normal' (i.e. are not hidden) and are not 'awaiting_description' (i.e. that they have had some basic status classification).
* Update the helpful model schema annotationsMark Longair2013-11-01-19/+22
| | | | These are regenerated with "bundle exec annotate"
* Add data to test example given in #1143Louise Crow2013-10-21-11/+14
| | | | This causes several specs to fail.
* Merge remote-tracking branch 'origin/fix-aborted-transaction' into ↵Louise Crow2013-10-07-19/+4
|\ | | | | | | rails-3-develop
| * Factor out a 'with_duplicate_xapian_job_creation' helperMark Longair2013-10-07-19/+4
| | | | | | | | | | | | | | | | | | | | In a subsequent commit, we will want to wrap an additional section of code with the addition and removal of a hook that creates a duplicate xapian job, so it's useful for this to be factored out. This commit introduces a 'with_duplicate_xapian_job_creation' method that can be passed a block which will be run with the forced duplicate xapian job creation.