aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
Commit message (Collapse)AuthorAgeLines
* Merge branch 'binary-or-utf8-attachment-bodies' into developLouise Crow2015-06-23-11/+121
|\
| * Add body_as_text, default_body.Louise Crow2015-06-22-0/+74
| | | | | | | | | | | | Main intent here is to be more explicit about what form you're getting the attachment body in - valid UTF-8 or binary, and has it been cleaned up in order to be UTF-8?
| * Use ASCII-8BIT for replacement patterns when handling binary data.Louise Crow2015-06-22-11/+47
| | | | | | | | Also be explicit about using UTF-8 when handling text data.
* | Prevent PublicBody#set_api_key call if unrequiredGareth Rees2015-06-15-1/+37
| | | | | | | | | | Don't call the method unless we need to. Adds #set_api_key! to set a new API key even if there's an existing one.
* | Move updating of derived attributes to a concern.Louise Crow2015-06-12-0/+25
|/ | | | | | Add spec to demonstrate that admin-added bodies aren't getting derived attributes. Add a spec to demonstrate the problem setting the first letter for translations. Demonstrate failure to update derived attributes in translations.
* Merge branch '2288-public-body-page-performance' into developGareth Rees2015-06-04-2/+1
|\
| * Simplify InfoRequestEvent#is_incoming_message?Gareth Rees2015-06-04-2/+1
| | | | | | | | | | | | | | | | Just check if there's an associated InfoRequest. user system total real old 0.010000 0.000000 0.010000 ( 0.012269) new 0.000000 0.000000 0.000000 ( 0.000101)
* | Merge branch 'hotfix/0.21.0.36' into developGareth Rees2015-06-04-0/+29
|\ \ | |/ |/|
| * 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 'hotfix/0.21.0.33' into rails-3-developLouise Crow2015-05-28-99/+42
|\|
| * 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""
* | Merge remote-tracking branch 'jpmckinney_github/parentheses' into ↵Louise Crow2015-05-22-34/+34
|\ \ | | | | | | | | | rails-3-develop
| * | Remove all optional parentheses for method calls in RubyJames McKinney2015-05-21-34/+34
| | |
* | | Add specs for :has_body_as_html?Louise Crow2015-05-22-0/+12
| | | | | | | | | | | | | | | Cleaned up by @jpmckinney in 4329ffa27cf83c00e03a0b0600ee54ce06056ee3, so adding a couple of regression specs.
* | | Cleanup specsLouise Crow2015-05-22-34/+36
|/ / | | | | | | | | | | Don't call load_raw_emails for all specs - only needed for one. Don't call update_display_size! explicitly - the point of the test is that body= should set it as a side effect.
* | Merge branch 'set-file-encodings' into rails-3-developLouise Crow2015-05-15-5/+32
|\ \
| * | Add source file encoding for all ruby files.Louise Crow2015-05-15-5/+32
| | | | | | | | | | | | | | | | | | This is important under ruby 1.9 in order to determine the encoding that will be used for new strings created in the code in the file.
* | | Merge branch 'multibyte-safe-slice' into rails-3-developLouise Crow2015-05-15-0/+12
|\ \ \
| * | | Use mb_chars to prevent slicing multibyte chars under ruby 1.8Louise Crow2015-05-12-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""
* | | Merge branch '2241-admin-summary-performance' into rails-3-developGareth Rees2015-05-13-12/+17
|\ \ \
| * | | Use database attributes to find public_response_eventsGareth Rees2015-05-12-12/+17
| | | | | | | | | | | | | | | | | | | | | | | | user system total real old 1.070000 0.280000 1.350000 ( 1.657773) new 0.560000 0.120000 0.680000 ( 0.743485)
* | | | Merge branch 'initial_request_text-2' into rails-3-developGareth Rees2015-05-12-21/+124
|\ \ \ \ | |_|_|/ |/| | |
| * | | Allow optional censor rules to be passed to #bodyGareth Rees2015-05-12-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If we’re in the context of an InfoRequest and want the OutgoingMessage#body, we can pass the rules in explicitly to avoid looking up the info request again. Otherwise it falls back to the existing behaviour.
| * | | Add a non-mutating #apply_to_textGareth Rees2015-05-12-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | Still need to `return nil if text_to_censor.nil?` because `gsub!` returns `nil` rather than the original text if it does not make a substitution.
| * | | Improve OutgoingMessage#body specsGareth Rees2015-05-12-21/+70
| |/ /
* / / Remove debug lineLouise Crow2015-05-12-1/+0
|/ /
* | Merge branch 'version-dependent-caching' into rails-3-developLouise Crow2015-05-07-1/+15
|\ \
| * | Force the encoding of values returned from YAML.Louise Crow2015-05-07-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is a workaround for an issue where YAML in ruby 1.8 tags UTF-8 heavy strings as binary, resulting in them being retrieved under 1.9 as ASCII-8BIT which can't be concatenated with UTF-8. Described as "Deep deep YAML oddness" in https://www.zendesk.com/blog/upgrade-the-road-to-1-9/.
* | | Don't load PublicBody when initalizing InfoRequestGareth Rees2015-05-07-2/+21
| | | | | | | | | | | | | | | Doesn't need to try to set the default law_used once it's persisted, so we save a query each time we find an InfoRequest
* | | Add InfoRequest#move_to_public_bodyGareth Rees2015-05-07-0/+92
|/ /
* | Merge branch 'hotfix/0.21.0.24' into rails-3-developGareth Rees2015-04-30-4/+18
|\|
| * 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
* | Merge branch 'add-widget' into rails-3-developLouise Crow2015-04-28-0/+53
|\ \
| * | Use factory for widget voteLouise Crow2015-04-28-1/+1
| | |
| * | Validate the uniqueness of cookies within the scope of info requests.Louise Crow2015-04-27-0/+16
| | |
| * | Add some specs for widget vote validation.Louise Crow2015-04-27-0/+37
| | |
* | | Make sure raw emails exist - the tests assume they doLouise Crow2015-04-23-0/+1
|/ /
* | Change PublicBody behaviour to not override blank request emailsHenare Degan2015-04-21-2/+2
| | | | | | | | | | This is so if you're overriding the request email you can still observe how Alaveteli behaves when there's no request email set.
* | Describe current PublicBody#request_email behaviour in testsHenare Degan2015-04-21-0/+27
| |
* | Merge branch 'issues/556-info_request_destroy' into rails-3-developLouise Crow2015-04-16-0/+16
|\ \
| * | Destroy associated censor rules and comments.Louise Crow2015-04-13-0/+16
| |/