aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
Commit message (Collapse)AuthorAgeLines
* Correctly set uuencoded attachment file size2508-hotfix-bad-uudecodeGareth Rees2015-06-04-0/+1
|
* Use Ruby to decode uuencoded attachmentsGareth Rees2015-06-03-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Ruby can natively decode uuencoded text with String#unpack. [1] This avoids the uuencode program dependency and avoids writing tempfiles. The actual implementation is taken from mail [2]. The UnixToUnix module is not available in our bundled version of mail. This commit includes a spec to illustrate the failure of uuencode(1) to decode the particular attachment in incoming-request-bad-uuencoding-2. email. Parsing with uuencode returns the following error: External Command: Error from command "uudecode -o /dev/stdout /tmp/foiuu20150530-14811-u6j936": uudecode: /tmp/foiuu20150530-14811-u6j936: No `end' line The file _is_ created and appears to be OK, but the exit code is 1. This causes AlaveteliExternalCommand to fail and return nil. See #2508 [3] for the bug report. [1] http://ruby-doc.org/core-1.8.7/String.html#method-i-unpack [2] https://github.com/mikel/mail/blob/bc4c9bb9321e9d36a678692f2f562d3146b63f78/lib/mail/encodings/unix_to_unix.rb#L7 [3] https://github.com/mysociety/alaveteli/issues/2508
* Add spec for simple uuencoded attachmentGareth Rees2015-06-03-0/+14
| | | Inspired by https://github.com/mikel/mail/commit/bc4c9bb9321e9d36a678692f2f562d3146b63f78
* Merge branch 'handle-unparsed-email-as-binary' into hotfix/0.21.0.33Louise Crow2015-05-28-28/+43
|\
| * Handle unparsed email contents as binary.Louise Crow2015-05-26-9/+38
| | | | | | | | | | | | | | | | | | | | | | I think I was wrong in a83b379fd2d676172855825d0592937b234371e2 in assuming that all email gets properly encoded for transfer. Looking at the mail gem load method https://github.com/mikel/mail/blob/b159e0a542962fdd5e292a48cfffa560d7cf412e/lib/mail/mail.rb#L175a, it reads raw email content from a file in binary mode. So this commit makes both reading and writing the raw_email a binary mode operation and adds a data_as_text method for displaying the data in the admin interface that coerces it to valid utf-8.
| * Cleanup spec.Louise Crow2015-05-22-13/+14
| | | | | | | | Move setup to spec - not in common with other specs.
| * Remove obsolete testLouise Crow2015-05-22-19/+4
| | | | | | | | | | We don't write the data for a raw email to the database anymore. It's written to a file.
* | Add required setupLouise Crow2015-05-28-0/+1
| |
* | Move acts_as_xapian specs to own file.Louise Crow2015-05-26-71/+0
|/
* Use mb_chars to prevent slicing multibyte chars under ruby 1.8Louise Crow2015-05-15-0/+12
| | | | | | | | | | mb_chars provides a multibyte-aware wrapper for strings. It should have no effect on ruby 1.9.3 and above. Although ruby 1.8.7 wouldn't raise errors on a badly sliced multibyte string, on upgrading to ruby 1.9.3 and above, string operations such as gsub, match and join may produce ArgumentErrors with the message "invalid byte sequence in UTF-8". Additionally, a database with 'UTF-8' encoding may produce the error "PG::CharacterNotInRepertoire: ERROR: invalid byte sequence for encoding "UTF8""
* Rescue from Holidays::UnknownRegionErrorhotfix/0.21.0.24Gareth Rees2015-04-29-0/+7
| | | | | If you run an Alaveteli in a region where we can’t show holiday suggestions the holiday import page breaks. This commit rescues from an unavailable region so that we display a friendly error message.
* Remove confusing before blockGareth Rees2015-04-29-4/+11
| | | | | | Next commit adds a new spec; this before block was affecting the behaviour of the new spec. https://robots.thoughtbot.com/lets-not
* Fix translating Public Body HeadingsGareth Rees2015-03-18-0/+108
| | | | | Fixes submission of form containing both existing and new translations
* Fix translating Public Body CategoriesGareth Rees2015-03-18-0/+140
|
* Fix translating Public BodiesGareth Rees2015-03-18-98/+87
|
* Merge branch '59-localised-authority-links' into rails-3-developLouise Crow2015-03-05-106/+0
|\ | | | | | | | | Conflicts: app/views/public_body/show.html.erb
| * Use routing helper to generate localised urls.Louise Crow2015-03-05-71/+0
| |
| * Remove 'html' param.Louise Crow2015-03-05-43/+8
| | | | | | | | | | There's only one call to this function in the rest of the code. That has 'html' set to true.
* | Remove deprecated code. Fixes #2015.Louise Crow2015-02-26-49/+0
|/
* Add specs to AboutMeValidatorGareth Rees2015-02-24-0/+53
|
* Add User#banned?Gareth Rees2015-02-24-0/+18
| | | | | | | - Redefined User#public_banned? to User#banned? - Add specs for User#banned? - Deprecate User#public_banned? - Replace use of User#public_banned? with User#banned?
* Merge branch '2134-fix-same-attribute-value-across-locales' into rails-3-developLouise Crow2015-02-23-4/+289
|\
| * Use before methods for object setup, model existing behaviour.Louise Crow2015-02-23-50/+16
| | | | | | | | | | Existing behaviour seems to be that when a tag is specified, only bodies that already have that tag will be updated.
| * Create bodies in before call.Louise Crow2015-02-23-19/+25
| |
| * Include tag_string from csv in tags expected.Louise Crow2015-02-23-2/+2
| | | | | | | | | | As I understand it, the expectation is to replace any existing tags with both the tag from the UI and the tags from the csv.
| * Comprehensive specs for CSV Import tag_string fieldGareth Rees2015-02-23-0/+297
| |
| * Give example csv file .csv extensionLouise Crow2015-02-23-2/+2
| |
| * Refactor massive import method into smaller instance level methodsLouise Crow2015-02-23-2/+2
| |
| * Test localised value for import against existing localised valueLouise Crow2015-02-23-0/+16
| | | | | | | | | | | | | | | | | | Previously the call to public_body.send would return the value for the default locale if no value was set in the current locale, meaning that translations for attributes that were the same as the attribute values in the default locale were not being loaded. Fixes #2134.
* | Move logic to modelLouise Crow2015-02-20-0/+22
| |
* | Remove spec redundancy following code refactor.Louise Crow2015-02-20-30/+31
| |
* | Use correct method name in error.Louise Crow2015-02-20-1/+1
| |
* | Refactor common logicLouise Crow2015-02-20-6/+6
| |
* | Add some specs for current behaviourLouise Crow2015-02-20-0/+102
| |
* | Merge branch 'hotfix/0.20.0.6' into rails-3-developLouise Crow2015-02-05-0/+98
|\ \ | | | | | | | | | | | | Conflicts: spec/models/public_body_spec.rb
| * | Fix submission of form containing both existing and new translationsLouise Crow2015-02-03-25/+17
| | |
| * | Add specs for PublicBody#translated_versions=Gareth Rees2015-01-30-0/+110
| | | | | | | | | | | | | | | | | | | | | | | | Also fixes #empty_translation? to check for String and Symbol keys named 'locale'. Specs use a pre-change check to assert difference. For some reason rspec change matcher fails with 'nil is not a symbol'.
* | | Use map instead of creating empty arrayGareth Rees2015-02-04-0/+12
| | |
* | | Nicer capitalize first letter onlyGareth Rees2015-02-04-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | String#capitalize downcases remaining letters, so: > 'heLLo WorLd'.capitalize # => "Hello world" Our version only works on the first character of the String, preserving the case of the rest of the String: > 'heLLo WorLd'.sub(/\S/) { |m| Unicode.upcase(m) } # => 'HeLLo WorLd' Also handle unicode.
* | | Add PublicBody#type_of_authority specsGareth Rees2015-01-23-0/+87
| |/ |/|
* | Fix assumption of current year as 2014 in holiday import specsLouise Crow2015-01-05-3/+5
| |
* | Update table attribute metadataLouise Crow2014-12-23-13/+8
| | | | | | | | | | Some fields have moved to different models, or exist in translation tables.
* | Merge branch 'admin-public-holiday-interface' into rails-3-developLouise Crow2014-12-18-61/+227
|\ \
| * | Allow import of holidays from feed or built-in suggestionsLouise Crow2014-12-15-0/+155
| | |
| * | Add basic edit actionLouise Crow2014-12-15-1/+1
| | |
| * | Add validation for presence of day.Louise Crow2014-12-15-61/+72
| |/
* | Refactor the application of masks and censor rules to messages.Louise Crow2014-12-15-121/+58
| | | | | | | | | | | | | | | | | | | | Seems more logical to make this one method that figures out what to do based on file type. Plus, incoming message does so many things, it seemed like having these related methods be separate would make them easier to read and understand. Also, email, mobile and login substitution texts weren't being translated. Finally, I think passing the censor rules and masks as arguments is a first step in some more decoupling of models.
* | Only mark email_subject_request as HTML safe when used in email subject.Louise Crow2014-12-12-1/+1
|/ | | | It's also used in the web interface and needs to be escaped there.
* Validate the presence of the description.Louise Crow2014-12-01-0/+6
| | | | It's required in [PublicBody#type_of_authority]( https://github.com/mysociety/alaveteli/blob/rails-3-develop/app/models/public_body.rb#L343-L347)
* Add ChangeEmailValidator specGareth Rees2014-10-29-0/+124
|