aboutsummaryrefslogtreecommitdiffstats
path: root/spec
Commit message (Collapse)AuthorAgeLines
* Merge branch 'document-pdf-fix' into rails-3-developMark Longair2013-12-09-0/+116
|\
| * Treat any document/pdf attachment as if it were application/pdfMark Longair2013-12-03-0/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a fix for issue #1232. Richard Taylor pointed out that some PDF attachments had the non-standard content-type document/pdf, and that these weren't being treated as PDFs. (Ganesh Sittampalam discovered that all of these PDFs were generated by a Lexmark X945e, according to the PDF metadata.) This commit adds an extra case to normalise_content_type to map document/pdf to application/pdf. In fact, since the upgrade of the Mail gem in ccebe3c3d6d4dc5f81 the behaviour when handling the non-standard content-type document/pdf was much better, but this commit also means that you get the right icon for the attachment, and can be cherry-picked onto older versions to fix #1232.
* | Merge branch 'fix-command-line-csv' into rails-3-developMark Longair2013-12-09-0/+14
|\ \
| * | 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
* / Use a better subject line than "Fake Response" for uploaded responsesMark Longair2013-12-06-0/+21
|/ | | | | | | | | | | The subject line wasn't being explicitly specified in RequestMailer.fake_response and a default of "Fake Response" (somehow based on the method name) was being used instead; this subject line would sometimes be visible to users and authorities and caused alarm to them. Instead, we use the standard subject lines for followup emails for the InfoRequest. Fixes #1105.
* Merge branch 'move-plugins-out-of-vendor-plugins' into rails-3-developMark Longair2013-12-03-1/+5
|\
| * Move themes from vendor/plugins to lib/themesMark Longair2013-12-03-0/+1
| | | | | | | | | | | | | | | | | | | | These are essentially required in exactly the same way as before, but from lib/themes rather than vendor/plugins. This is the simplest possible change in order make the themes work outside vendor/plugins, I think, but it's not necessarily ideal. It would be worth considering whether these should be changed to Rails engines, as described here: http://guides.rubyonrails.org/engines.html
| * Move acts_as_xapian out of vendor/pluginsMark Longair2013-11-29-1/+2
| | | | | | | | | | This includes making making sure that xapiandbs directory is moved with this version of the code.
| * Move has_tag_string out of vendor/pluginsMark Longair2013-11-29-0/+1
| |
| * Move strip_attributes out of vendor/pluginsMark Longair2013-11-29-0/+1
| |
* | Add timestamps to public_body_translation fixtures.Louise Crow2013-11-29-0/+20
| | | | | | | | | | | | | | | | | | | | Between rails 3.2.0 and 4.0.1rc4, timestamps were constrained to be non-null. As globalize creates the public_body_translation table with timestamps, this means there are errors in the tests when trying to insert the fixture data, which doesn't have timestamps. These errors were only appearing on Travis because locally the test database is cloned from the development structure rather than being created by running the migrations.
* | Merge remote-tracking branch 'origin/merged-rails-3-2-assset-pipeline' into ↵Louise Crow2013-11-29-90/+2
|\| | | | | | | | | | | | | rails-3-develop Conflicts: Gemfile.lock
| * Merge branch 'feature/rails-3-2-upgrade-spike' into ↵Mark Longair2013-11-29-90/+2
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | feature/switch-to-asset-pipeline Conflicts: Gemfile.lock app/assets/images/admin-theme/ui-bg_flat_0_aaaaaa_40x100.png app/assets/images/admin-theme/ui-bg_flat_55_fbf9ee_40x100.png app/assets/images/admin-theme/ui-bg_flat_65_ffffff_40x100.png app/assets/images/admin-theme/ui-bg_flat_75_cccccc_40x100.png app/assets/images/admin-theme/ui-bg_flat_75_dadada_40x100.png app/assets/images/admin-theme/ui-bg_flat_75_e6e6e6_40x100.png app/assets/images/admin-theme/ui-bg_flat_75_ffffff_40x100.png app/assets/images/admin-theme/ui-bg_inset-soft_95_fef1ec_1x100.png app/assets/images/admin-theme/ui-icons_222222_256x240.png app/assets/images/admin-theme/ui-icons_2e83ff_256x240.png app/assets/images/admin-theme/ui-icons_454545_256x240.png app/assets/images/admin-theme/ui-icons_888888_256x240.png app/assets/images/admin-theme/ui-icons_cd0a0a_256x240.png app/assets/javascripts/admin.js app/assets/javascripts/admin/jquery-ui.min.js app/assets/javascripts/application.js app/assets/javascripts/jquery-ui.min.js app/assets/javascripts/jquery.flot.errorbars.min.js app/assets/javascripts/jquery.flot.min.js app/assets/javascripts/stats.js app/assets/stylesheets/application.css app/assets/stylesheets/fonts.scss app/views/general/_stylesheet_includes.html.erb app/views/layouts/admin.html.erb app/views/layouts/default.html.erb app/views/public_body/statistics.html.erb config/application.rb config/environments/development.rb
| | * Update spec to match upgraded mail gem behaviour.Louise Crow2013-11-12-1/+1
| | | | | | | | | | | | | | | The new name value doesn't escape a double quote within single quotes, which seems more correct.
| | * Remove obsolete test.Louise Crow2013-11-12-88/+0
| | |
| | * Mock methods need to call mail() to generate a proper mail.Louise Crow2013-11-12-1/+1
| | |
* | | Move getting recent requests into a helper method.Louise Crow2013-11-25-42/+37
| | |
* | | Move getting similar requests to the InfoRequest model.Louise Crow2013-11-25-2/+19
|/ /
* | 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
| | |
* | | Add a helper method for temporarily setting I18n.default_localeMark Longair2013-11-19-0/+8
| | | | | | | | | | | | | | | | | | Although the I18n library has an I18n.with_locale helper, there's no equivalent for I18n.default_locale. This method will make a couple of our tests clearer and less brittle.
* | | Insert cookie stripping at correct point in middleware stack.Louise Crow2013-11-18-0/+12
| | |
* | | Session keys are stored as strings in Rails 3.Louise Crow2013-11-18-28/+28
|/ / | | | | | | Update our session-stripping code.
* | 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.
* | | 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.
* | | 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
| | |
* | | For percentage stats, exclude hidden or unclassified requestsMark Longair2013-11-05-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | 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-40/+49
|/ / | | | | | | | | | | 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-38/+44
| | | | | | | | These are regenerated with "bundle exec annotate"
* | Merge branch 'switch-theme-script' into rails-3-developMark Longair2013-10-30-0/+25
|\ \ | | | | | | | | | | | | Conflicts: config/initializers/alaveteli.rb
| * | Make theme URL to theme name mapping consistentMark Longair2013-10-15-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code that extracted the theme name from each entry in THEME_URLS (in order to require code from a directory whose leaf name is the theme name) only supported git URLs that ended in '.git'. However, the themes:install rake task usefully supports a wider range of git URLs - for example, all of the following were supported: /home/whoever/themes/blah-theme => blah-theme /home/whoever/themes/blah-theme/ => blah-theme git://wherever/blah-theme.git => blah-theme ssh://wherever/blah-theme.git// => blah-theme This commit factors out a theme_url_to_theme_name method, adds tests for it, and uses that method in both: lib/tasks/themes.rake config/initializers/theme_loader.rb ... so that a wider range of theme URLs are consistently supported.
* | | Merge branch 'hotfix/0.14.0.3' into rails-3-developLouise Crow2013-10-24-0/+40
|\ \ \
| * | | Add factory to support new specs.0.14.0.2hotfix/0.14.0.2Louise Crow2013-10-03-0/+7
| | | |
| * | | Don't allow redirects to another host.Louise Crow2013-10-02-0/+33
| | | |
| * | | Handle salutations with regexp special characters.0.14.0.1Louise Crow2013-09-30-0/+10
| | | | | | | | | | | | | | | | Fixes #1104.
* | | | Add data to test example given in #1143Louise Crow2013-10-21-11/+16
| |/ / |/| | | | | | | | This causes several specs to fail.
* | | Merge remote-tracking branch 'origin/fix-aborted-transaction' into ↵Louise Crow2013-10-07-19/+34
|\ \ \ | | | | | | | | | | | | rails-3-develop
| * | | 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.
| * | | Factor out a 'with_duplicate_xapian_job_creation' helperMark Longair2013-10-07-19/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | Merge branch 'feature/email-subject-cleanup' into rails-3-developLouise Crow2013-10-07-0/+10
|\ \ \ \ | |/ / / |/| | |
| * | | Move special case to whatdotheyknow-themeLouise Crow2013-10-04-0/+10
| | |/ | |/| | | | | | | | | | Apart from anything else, we don't want translators to have to worry about the special case text. See https://github.com/mysociety/whatdotheyknow-theme/commit/2078febca5181ce3b1a9c0fae0123ae5f6448718 for the corresponding change to whatdotheyknow-theme.
* | | Fix upcasing of a non-US-ASCII first letter under Ruby 1.8Mark Longair2013-10-04-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | In the rare circumstance that someone created a public body whose name started with a lower case letter outside [a-z] with Alaveteli running under Ruby 1.8, the letter would not be upcased correctly before saving to the first_letter column. This commit fixes that by using a Unicode-aware upcase function.
* | | 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-8/+39
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 '.'.
* | Fix typoLouise Crow2013-09-19-1/+1
| |