aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/public_body_controller_spec.rb
Commit message (Collapse)AuthorAgeLines
* Limit the number of pages of requests shown for public bodies.Louise Crow2015-04-07-0/+7
| | | | Needs to be restored as part of https://github.com/mysociety/alaveteli/issues/2137.
* Add a “Back to search results” linkGareth Rees2015-01-13-0/+23
| | | | | | | | | | | | | | | | | | | Store the search parameters in the flash when a search is made via the select_authority_path page. Stores the parameters for both POST and AJAX typeahead searches. The presence of stored search params renders the link on the PublicBodyController#show template. “keep”s the search params in PublicBodyController#show so that if the user clicks the browser’s back button the “Back to search results” link can still be rendered on the next search result they click. “keep”s all flash keys in ServicesController#other_country_message as it’s called through AJAX and ends up sweeping the flash. [1] [1] More details about this: http://mikenaberezny.com/2007/09/08/keep-the-flash-and-test-it-too/
* Remove stubs of removed methodGareth Rees2014-11-18-5/+0
| | | | | | | PublicBodyCategory#load_categories no longer exists, so don't try to stub it. Fixes https://github.com/mysociety/alaveteli/issues/1970
* fixup! Replace existing PublicBodyCategories functionality with db models ↵Louise Crow2014-09-24-8/+11
| | | | PublicBodyCategory and PublicBodyHeading
* Reinstate automatic loading of categories on get if no categories definedlizconlan2014-09-22-0/+5
|
* Add PublicBodyController#list_all_csv specsGareth Rees2014-06-06-0/+17
| | | | | - Shouldn't include non-visible bodies - Shouldn't include internal admin bodies
* Support simple searching of bodies by short_nameGareth Rees2014-05-28-0/+5
|
* 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-7/+7
|/
* 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
|
* 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.)
* 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
* | 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
|/
* 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.
* Switch routing-filter (which takes locale out of the params and puts it in ↵Louise Crow2013-07-18-20/+4
| | | | the URL) off by default in model, controller, and helper tests. This means we can supply the locale as a param. Turn it on specifically for a couple of controller tests that test routing, and change other url localization tests into integration tests.
* Respond to a (currently unsupported) json request for a public body list ↵Louise Crow2013-06-20-1/+4
| | | | with a 406, not a 500 caused by a missing template.
* We've added a new fixture since the last mergeHenare Degan2013-03-15-3/+6
|
* Use a real example instead of a helperHenare Degan2013-03-15-1/+1
|
* Merge remote-tracking branch 'mysociety/develop' into rails-3-developHenare Degan2013-03-14-0/+5
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Gemfile Gemfile.lock app/controllers/admin_request_controller.rb app/controllers/admin_track_controller.rb app/controllers/request_controller.rb app/controllers/services_controller.rb app/helpers/link_to_helper.rb app/mailers/request_mailer.rb app/models/application_mailer.rb app/models/info_request.rb app/views/admin_censor_rule/edit.html.erb app/views/admin_censor_rule/new.html.erb app/views/admin_public_body/_form.html.erb app/views/admin_public_body/_locale_selector.html.erb app/views/admin_public_body/_one_list.html.erb app/views/admin_public_body/edit.html.erb app/views/admin_public_body/list.html.erb app/views/admin_public_body/new.html.erb app/views/admin_request/_incoming_message_actions.html.erb app/views/admin_request/edit.html.erb app/views/admin_request/edit_comment.html.erb app/views/admin_request/edit_outgoing.html.erb app/views/admin_request/list.html.erb app/views/admin_request/list_old_unclassified.html.erb app/views/admin_request/show.html.erb app/views/admin_track/_some_tracks.html.erb app/views/admin_track/list.html.erb app/views/admin_user/edit.html.erb app/views/admin_user/list.html.erb app/views/admin_user/show.html.erb app/views/general/_footer.html.erb app/views/general/exception_caught.html.erb app/views/help/contact.html.erb app/views/layouts/default.html.erb app/views/public_body/_alphabet.html.erb app/views/request/_request_listing_single.html.erb app/views/request/_sidebar.html.erb app/views/request/new.html.erb app/views/request/show.html.erb app/views/request_mailer/external_response.rhtml app/views/request_mailer/fake_response.rhtml config/environment.rb config/environments/production.rb config/routes.rb spec/controllers/admin_censor_rule_controller_spec.rb spec/controllers/request_controller_spec.rb spec/controllers/track_controller_spec.rb spec/helpers/link_to_helper_spec.rb spec/mailers/request_mailer_spec.rb spec/models/info_request_spec.rb spec/spec_helper.rb spec/views/public_body/show.html.erb_spec.rb spec/views/request/show.html.erb_spec.rb vendor/plugins/rails_xss/lib/rails_xss/erubis.rb
| * Retain filter settings when redirecting a public body to its canonical urlMatthew Landauer2013-02-12-0/+5
| |
* | Test result of test with examples rather than another implementationMatthew Landauer2013-01-31-5/+14
| |
* | Merge branch 'i18n_rails3_preparation' into rails-3-spikeMatthew Landauer2013-01-31-9/+5
|\ \ | | | | | | | | | | | | | | | | | | | | | Conflicts: Gemfile.lock app/controllers/general_controller.rb app/controllers/public_body_controller.rb spec/controllers/public_body_controller_spec.rb
| * | Set locale with I18n rather than through globalizeMatthew Landauer2013-01-17-2/+2
| | |
| * | Set locale in controller test by passing parameter in getMatthew Landauer2013-01-16-9/+5
| |/ | | | | | | Also using I18n.locale to pass the current locale around.
* | Disable routing filter in tests by using RoutingFilter.active rather than ↵Matthew Landauer2013-01-25-3/+2
| | | | | | | | writing to ActionController::Routing::Routes.filters
* | integrate_views is render_views RSpec 2Henare Degan2012-12-11-3/+3
| |
* | The with_locale has been removed in Globalize3Henare Degan2012-12-11-4/+4
| | | | | | | | | | | | I think Globalize is supposed to pick up the locale from I18n anyway so I don't know if these are needed. I think I still haven't done the right thing but it's time to move on.
* | Switch to new method nameHenare Degan2012-12-11-4/+4
|/
* Use new function that copies existing xapian index in spec setup where a ↵Louise Crow2012-11-21-9/+9
| | | | clean copy of the xapian index with fixtures loaded is required.
* add magic encoding comment to specsJames McKinney2012-10-10-0/+1
|
* Merge jpmckinney/bundlerSeb Bacon2012-02-15-2/+0
|
* Load all fixtures for all testsRobin Houston2012-01-31-6/+0
| | | | | | | | | The ad hoc specification of fixtures has been an ongoing source of bugs in the tests. The straw that broke the camel’s back is that 7c6eb09 requires the fixtures to be loaded in order (i.e. children before their parents), and it would have been a painful process to reorder all the dozens of different fixture lists, but the test system ought to be more reliable this way.
* Make better wording at the top of the page listing subsets of public bodies. ↵Seb Bacon2012-01-30-1/+4
| | | | At the same time, cause the tests not to rely on WDTK data. Fixes #396
* Test duplicate requests are coalescedRobin Houston2012-01-29-1/+0
| | | | Test that duplicate requests are coalesced on the front page.
* More test data, and fix testsRobin Houston2012-01-29-5/+10
| | | | | | Add some more test data, and fix the tests to accommodate both this new test data and the fact that raw emails are now correctly loaded into the test environment.
* Load all raw emails for testingRobin Houston2012-01-29-1/+1
| | | | | | | | | | | Previously there was just one raw email, and the test code relied on that fact. Generalise it to handle multiple raw emails. This change causes a number of tests to fail, because it exposes failures that should have happened when the second raw email was added but were masked by the fact that the text of this second raw email was never loaded. These failures will be fixed in the next commit.
* More test data and a new testRobin Houston2012-01-27-1/+4
| | | | | This is a test for what I thought issue #370 might be. However this test is passing, so it isn’t that.
* Refactor test code so new test data can be addedRobin Houston2012-01-26-10/+20
| | | | | | | | Previously many of the tests made assumptions about the global structure of the test data set: the total number of requests, for example, or the names of all public bodies. This makes it difficult to add to the test data. This change is intended to make the test data easier to extend by eliminating such global assumptions.
* Be sure to restore RoutingFiltersRobin Houston2012-01-20-1/+5
| | | | | | There were some order-dependent test failures that turned out to be caused by the fact that the RoutingFilters were cleared and not subsequently restored, by some tests.
* Fix paging bug for type ahead search. This wasn't caught because the spec ↵Seb Bacon2012-01-18-0/+3
| | | | didn't call "integrate_views", so the rendering part was mocked by RSpec instead of executed.
* Fix bug introduced in cec2c545e0a10e0641c4ee67839c88d872b394b8, related to ↵Seb Bacon2012-01-13-0/+7
| | | | issue #343.