aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/public_body_spec.rb
Commit message (Collapse)AuthorAgeLines
* Fix translating Public BodiesGareth Rees2015-03-18-98/+87
|
* 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.
* 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 test failures in PublicBody overrideable CSV import specsSteven Day2014-08-22-2/+2
|
* Make csv import fields a class attribute that can be overridenSteven Day2014-08-22-0/+52
|
* Merge branch 'issues/1415-bulk-update-public-bodies' into rails-3-developGareth Rees2014-06-25-0/+14
|\
| * Move PublicBody domain logic from controllerGareth Rees2014-06-06-0/+14
| | | | | | | | | | | | Moves the magic 'site_administration' tag logic to the PublicBody model. Easier to make the string passed to `PublicBody#has_tag?` configurable if we want to allow this to be set per install.
* | Rename XXX comments with TODO:Gareth Rees2014-06-10-1/+1
|/ | | | Picks these up in `rake notes` and adds semantic meaning
* 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-1/+1
| | | | | Should have been run after related migrations. Could automate this to always run after migrations.
* 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
* 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-17/+20
| | | | 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.
* 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.
* Add to fixtures a public body with an accented initial letterMark Longair2013-10-04-7/+7
| | | | | | | | | | | | | | | | | 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 '.'.
* Merge branch 'feature/hide-individual-responses' into rails-3-developLouise Crow2013-09-17-0/+23
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: Gemfile app/views/admin_request/edit_outgoing.html.erb config/packages doc/CHANGES.md doc/INSTALL.md spec/models/info_request_spec.rb spec/models/public_body_spec.rb
| * Re-annotate models with database fieldsLouise Crow2013-09-16-0/+23
| |
* | Don't dirty every attribute in checking for whitespace.Louise Crow2013-09-05-15/+31
| | | | | | | | | | | | | | Check to see if the stripped version is different before setting it on the record. If we don't do this, the subsequent call to write_attribute in Globalize3 which uses attribute_will_change! means we're storing versions when there hasn't really been any change.
* | Update tests for changes to fixture file.Louise Crow2013-08-14-14/+18
|/
* Use AlaveteliConfiguration wrapper in test so we can be more specific about ↵Louise Crow2013-07-23-1/+1
| | | | the method to be stubbed and avoid side effects.
* Add a test that exposes a problem we have with renaming attributesHenare Degan2013-02-07-0/+8
|
* Set locale with I18n rather than through globalizeMatthew Landauer2013-01-17-3/+3
|
* Extract methodMatthew Landauer2012-09-27-1/+1
|