diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/admin_request_controller_spec.rb | 5 | ||||
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 14 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/fixtures/info_request_events.yml | 35 | ||||
-rw-r--r-- | spec/fixtures/info_requests.yml | 10 | ||||
-rw-r--r-- | spec/fixtures/outgoing_messages.yml | 11 | ||||
-rw-r--r-- | spec/helpers/link_to_helper_spec.rb | 32 | ||||
-rw-r--r-- | spec/integration/create_request_spec.rb | 12 | ||||
-rw-r--r-- | spec/lib/public_body_categories_spec.rb | 42 | ||||
-rw-r--r-- | spec/models/public_body_spec.rb | 64 |
10 files changed, 158 insertions, 69 deletions
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 252818452..8a3934685 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -21,6 +21,11 @@ describe AdminRequestController, "when administering requests" do get :show, :id => info_requests(:fancy_dog_request) end + it 'shows an external public body with no username' do + get :show, :id => info_requests(:anonymous_external_request) + response.should be_success + end + it "edits a public body" do get :edit, :id => info_requests(:fancy_dog_request) end diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index df2c139bd..de8dd8422 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -9,7 +9,7 @@ describe GeneralController, "when trying to show the blog" do FakeWeb.clean_registry end - it "should fail silently if the blog is returning an error" do + it "should fail silently if the blog is returning an error" do FakeWeb.register_uri(:get, %r|.*|, :body => "Error", :status => ["500", "Error"]) get :blog response.status.should == "200 OK" @@ -76,7 +76,7 @@ describe GeneralController, "when searching" do response.should redirect_to(:action => 'search', :combined => "mouse", :view => "all") # URL /search/:query/all end - describe "when using different locale settings" do + describe "when using different locale settings" do home_link_regex = /href=".*\/en\// it "should generate URLs with a locale prepended when there's more than one locale set" do get :frontpage @@ -117,7 +117,7 @@ describe GeneralController, "when searching" do I18n.available_locales = old_i18n_available_locales end end - + describe 'when constructing the list of recent requests' do before(:each) do load_raw_emails_data @@ -127,7 +127,7 @@ describe GeneralController, "when searching" do it 'should list the newest successful request first' do # Make sure the newest is listed first even if an older one # has a newer comment or was reclassified more recently: - # https://github.com/sebbacon/alaveteli/issues/370 + # https://github.com/mysociety/alaveteli/issues/370 # # This is a deliberate behaviour change, in that the # previous behaviour (showing more-recently-reclassified @@ -135,7 +135,7 @@ describe GeneralController, "when searching" do get :frontpage assigns[:request_events].first.info_request.should == info_requests(:another_boring_request) end - + it 'should coalesce duplicate requests' do get :frontpage assigns[:request_events].map(&:info_request).select{|x|x.url_title =~ /^spam/}.length.should == 1 @@ -231,7 +231,7 @@ describe GeneralController, "when searching" do u.email_confirmed = true u.save! update_xapian_index - + get :search, :combined => ["unconfirmed", "users"] response.should render_template('search') assigns[:xapian_users].results.map{|x|x[:model]}.should == [u] @@ -239,7 +239,7 @@ describe GeneralController, "when searching" do it "should show tracking links for requests-only searches" do get :search, :combined => ['"bob"', "requests"] - response.body.should include('Track this search') + response.body.should include('Track this search') end end diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 0ff795029..b8425613c 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -522,7 +522,7 @@ describe RequestController, "when showing one request" do # error-handling path, causing the wrong sort of error response to be returned in the # case where the integer prefix referred to the wrong request.) # - # https://github.com/sebbacon/alaveteli/issues/351 + # https://github.com/mysociety/alaveteli/issues/351 it "should return 404 for ugly URLs containing a request id that isn't an integer" do ir = info_requests(:fancy_dog_request) receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) diff --git a/spec/fixtures/info_request_events.yml b/spec/fixtures/info_request_events.yml index e3e8a4460..c1a00ad47 100644 --- a/spec/fixtures/info_request_events.yml +++ b/spec/fixtures/info_request_events.yml @@ -16,7 +16,7 @@ silly_outgoing_message_event: created_at: 2007-10-14 10:41:12.686264 described_state: outgoing_message_id: 2 -useless_incoming_message_event: +useless_incoming_message_event: id: 902 params_yaml: "--- \n\ :incoming_message_id: 1\n" @@ -25,18 +25,18 @@ useless_incoming_message_event: created_at: 2007-11-13 18:09:20.042061 described_state: incoming_message_id: 1 -silly_comment_event: +silly_comment_event: id: 903 params_yaml: "--- \n\ :comment_id: 1\n" - incoming_message_id: - last_described_at: - described_state: + incoming_message_id: + last_described_at: + described_state: info_request_id: 101 comment_id: 1 - calculated_state: + calculated_state: event_type: comment - outgoing_message_id: + outgoing_message_id: created_at: 2008-08-12 23:05:12.500942 badger_outgoing_message_event: id: 904 @@ -98,11 +98,11 @@ another_comment_event: comment_id: 2 params_yaml: "--- \n\ :comment_id: 2\n" - incoming_message_id: - outgoing_message_id: - last_described_at: - described_state: - calculated_state: + incoming_message_id: + outgoing_message_id: + last_described_at: + described_state: + calculated_state: event_type: comment created_at: 2008-08-12 12:05:12.879634 @@ -160,3 +160,14 @@ external_outgoing_message_event: created_at: 2009-01-02 02:23:45.6789100 described_state: waiting_response calculated_state: waiting_response + +anonymous_external_outgoing_message_event: + id: 915 + params_yaml: "--- \n\ + :outgoing_message_id: 9\n" + outgoing_message_id: 9 + info_request_id: 110 + event_type: sent + created_at: 2009-01-03 02:23:45.6789100 + described_state: waiting_response + calculated_state: waiting_response diff --git a/spec/fixtures/info_requests.yml b/spec/fixtures/info_requests.yml index e4f2287c0..079a44cd0 100644 --- a/spec/fixtures/info_requests.yml +++ b/spec/fixtures/info_requests.yml @@ -88,3 +88,13 @@ external_request: described_state: waiting_response awaiting_description: false idhash: a1234567 +anonymous_external_request: + id: 110 + title: Anonymous request + url_title: anonymous_request + external_user_name: + external_url: http://www.example.org/request/anonymous_requesr + public_body_id: 2 + described_state: waiting_response + awaiting_description: false + idhash: 7654321a
\ No newline at end of file diff --git a/spec/fixtures/outgoing_messages.yml b/spec/fixtures/outgoing_messages.yml index 32b322bd7..55df8473e 100644 --- a/spec/fixtures/outgoing_messages.yml +++ b/spec/fixtures/outgoing_messages.yml @@ -97,3 +97,14 @@ external_outgoing_message: updated_at: 2009-01-12 01:56:58.586598 what_doing: normal_sort +anonymous_external_outgoing_message: + id: 9 + info_request_id: 110 + message_type: initial_request + status: sent + body: "I do not wish to reveal my name, but would like all your information." + last_sent_at: 2009-01-12 01:57:58.586598 + created_at: 2009-01-12 01:56:58.586598 + updated_at: 2009-01-12 01:56:58.586598 + what_doing: normal_sort + diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb index f11f2b5bb..9ec0afce1 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -1,11 +1,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -describe LinkToHelper do - +describe LinkToHelper do + include LinkToHelper - - describe 'when creating a url for a request' do - + + describe 'when creating a url for a request' do + before do @mock_request = mock_model(InfoRequest, :url_title => 'test_title') @old_filters = ActionController::Routing::Routes.filters @@ -15,15 +15,15 @@ describe LinkToHelper do ActionController::Routing::Routes.filters = @old_filters end - - it 'should return a path like /request/test_title' do + + it 'should return a path like /request/test_title' do request_url(@mock_request).should == '/request/test_title' end - - it 'should return a path including any extra parameters passed' do + + it 'should return a path including any extra parameters passed' do request_url(@mock_request, {:update_status => 1}).should == '/request/test_title?update_status=1' end - + end describe "when appending something to a URL" do @@ -37,5 +37,15 @@ describe LinkToHelper do main_url('/a?z=9%', '.json').should == 'http://test.host/a?z=9%' end end - + + describe 'when displaying a user admin link for a request' do + + it 'should return the text "An anonymous user (external)" in the case where there is no external username' do + info_request = mock_model(InfoRequest, :external_user_name => nil, + :is_external? => true) + user_admin_link_for_request(info_request).should == 'Anonymous user (external)' + end + + end + end diff --git a/spec/integration/create_request_spec.rb b/spec/integration/create_request_spec.rb index 6f336d406..56757c7e0 100644 --- a/spec/integration/create_request_spec.rb +++ b/spec/integration/create_request_spec.rb @@ -2,14 +2,14 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "When creating requests" do it "should associate the request with the requestor, even if it is approved by an admin" do - # This is a test for https://github.com/sebbacon/alaveteli/issues/446 - + # This is a test for https://github.com/mysociety/alaveteli/issues/446 + params = { :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id, :title => "Why is your quango called Geraldine?", :tag_string => "" }, :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." }, :submitted_new_request => 1, :preview => 0 } - + # Initially we are not logged in. Try to create a new request. post "/new", params # We expect to be redirected to the login page @@ -17,13 +17,13 @@ describe "When creating requests" do response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token) follow_redirect! response.should render_template("user/sign") - + # Now log in as an unconfirmed user. post "/profile/sign_in", :user_signin => {:email => users(:unconfirmed_user).email, :password => "jonespassword"}, :token => post_redirect.token # This will trigger a confirmation mail. Get the PostRedirect for later. response.should render_template("user/confirm") post_redirect = PostRedirect.get_last_post_redirect - + # Now log in as an admin user, then follow the confirmation link in the email that was sent to the unconfirmed user admin_user = users(:admin_user) admin_user.email_confirmed = true @@ -37,7 +37,7 @@ describe "When creating requests" do url_title = $1 info_request = InfoRequest.find_by_url_title(url_title) info_request.should_not be_nil - + # Make sure the request is still owned by the user who made it, not the admin who confirmed it info_request.user_id.should == users(:unconfirmed_user).id end diff --git a/spec/lib/public_body_categories_spec.rb b/spec/lib/public_body_categories_spec.rb new file mode 100644 index 000000000..e53d9a028 --- /dev/null +++ b/spec/lib/public_body_categories_spec.rb @@ -0,0 +1,42 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe PublicBodyCategories do + + before do + load_test_categories + end + + describe 'when asked for categories with headings' do + + it 'should return a list of headings as plain strings, each followed by n tag specifications as + lists in the form: + ["tag_to_use_as_category", "Sub category title", "Instance description"]' do + expected_categories = ["Local and regional", ["local_council", + "Local councils", + "a local council"], + "Miscellaneous", ["other", + "Miscellaneous", + "miscellaneous"]] + PublicBodyCategories::get().with_headings().should == expected_categories + end + + end + + describe 'when asked for headings' do + + it 'should return a list of headings' do + PublicBodyCategories::get().headings().should == ['Local and regional', 'Miscellaneous'] + end + + end + + describe 'when asked for tags by headings' do + + it 'should return a hash of tags keyed by heading' do + PublicBodyCategories::get().by_heading().should == {'Local and regional' => ['local_council'], + 'Miscellaneous' => ['other']} + end + + end + +end
\ No newline at end of file diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index e30916dff..8ff6afde3 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -1,6 +1,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -describe PublicBody, " using tags" do +describe PublicBody, " using tags" do before do @public_body = PublicBody.new(:name => 'Aardvark Monitoring Service', :short_name => 'AMS', @@ -9,7 +9,7 @@ describe PublicBody, " using tags" do :last_edit_comment => '') end - it 'should correctly convert a tag string into tags' do + it 'should correctly convert a tag string into tags' do @public_body.tag_string = 'stilton emmental' @public_body.tag_string.should == 'stilton emmental' @@ -56,7 +56,7 @@ describe PublicBody, " using tags" do end end -describe PublicBody, " using machine tags" do +describe PublicBody, " using machine tags" do before do @public_body = PublicBody.new(:name => 'Aardvark Monitoring Service', :short_name => 'AMS', @@ -114,22 +114,22 @@ describe PublicBody, "when finding_by_tags" do end end -describe PublicBody, " when making up the URL name" do +describe PublicBody, " when making up the URL name" do before do @public_body = PublicBody.new end - it 'should remove spaces, and make lower case' do + it 'should remove spaces, and make lower case' do @public_body.name = 'Some Authority' @public_body.url_name.should == 'some_authority' end - it 'should not allow a numeric name' do + it 'should not allow a numeric name' do @public_body.name = '1234' @public_body.url_name.should == 'body' end end - + describe PublicBody, " when saving" do before do @public_body = PublicBody.new @@ -157,14 +157,14 @@ describe PublicBody, " when saving" do @public_body.last_edit_comment = "This is a test" @public_body.save! end - + it "should update first_letter" do @public_body.name = "Testing Public Body" @public_body.short_name = "TPB" @public_body.request_email = "request@localhost" @public_body.last_edit_editor = "*test*" @public_body.last_edit_comment = "This is a test" - + @public_body.first_letter.should be_nil @public_body.save! @public_body.first_letter.should == 'T' @@ -208,14 +208,14 @@ describe PublicBody, "when searching" do body.id.should == 3 body.class.to_s.should == 'PublicBody' end - + it "should cope with same url_name across multiple locales" do PublicBody.with_locale(:es) do # use the unique spanish name to retrieve and edit body = PublicBody.find_by_url_name_with_historic('etgq') body.short_name = 'tgq' # Same as english version - body.save! - + body.save! + # now try to retrieve it body = PublicBody.find_by_url_name_with_historic('tgq') body.id.should == public_bodies(:geraldine_public_body).id @@ -242,7 +242,7 @@ describe PublicBody, " when loading CSV files" do # depending on the tag used. By accessing it here before every test, it doesn't disturb our checks later on PublicBody.internal_admin_body end - + it "should import even if no email is provided" do errors, notes = PublicBody.import_csv("1,aBody", '', 'replace', true, 'someadmin') # true means dry run errors.should == [] @@ -250,7 +250,7 @@ describe PublicBody, " when loading CSV files" do notes[0].should == "line 1: creating new authority 'aBody' (locale: en):\n\t{\"name\":\"aBody\"}" notes[1].should =~ /Notes: Some bodies are in database, but not in CSV file:\n( [A-Za-z ]+\n)*You may want to delete them manually.\n/ end - + it "should do a dry run successfully" do original_count = PublicBody.count @@ -259,8 +259,8 @@ describe PublicBody, " when loading CSV files" do errors.should == [] notes.size.should == 4 notes[0..2].should == [ - "line 1: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\"\}", - "line 2: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\"\}", + "line 1: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\"\}", + "line 2: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\"\}", "line 3: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\"\}", ] notes[3].should =~ /Notes: Some bodies are in database, but not in CSV file:\n( [A-Za-z ]+\n)*You may want to delete them manually.\n/ @@ -276,8 +276,8 @@ describe PublicBody, " when loading CSV files" do errors.should == [] notes.size.should == 4 notes[0..2].should == [ - "line 1: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\"\}", - "line 2: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\"\}", + "line 1: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\"\}", + "line 2: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\"\}", "line 3: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\"\}", ] notes[3].should =~ /Notes: Some bodies are in database, but not in CSV file:\n( [A-Za-z ]+\n)*You may want to delete them manually.\n/ @@ -287,14 +287,14 @@ describe PublicBody, " when loading CSV files" do it "should do imports without a tag successfully" do original_count = PublicBody.count - + csv_contents = load_file_fixture("fake-authority-type.csv") errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', false, 'someadmin') # false means real run errors.should == [] notes.size.should == 4 notes[0..2].should == [ - "line 1: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\"\}", - "line 2: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\"\}", + "line 1: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\"\}", + "line 2: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\"\}", "line 3: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\"\}", ] notes[3].should =~ /Notes: Some bodies are in database, but not in CSV file:\n( [A-Za-z ]+\n)*You may want to delete them manually.\n/ @@ -309,15 +309,15 @@ describe PublicBody, " when loading CSV files" do errors.should == [] notes.size.should == 4 notes[0..2].should == [ - "line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"\}", - "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\",\"tag_string\":\"scottish\"\}", + "line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"\}", + "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\",\"tag_string\":\"scottish\"\}", "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\",\"tag_string\":\"fake aTag\"\}", ] notes[3].should =~ /Notes: Some bodies are in database, but not in CSV file:\n( [A-Za-z ]+\n)*You may want to delete them manually.\n/ PublicBody.count.should == original_count end - + it "should import tags successfully when the import tag is not set" do csv_contents = load_file_fixture("fake-authority-type-with-field-names.csv") errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', false, 'someadmin') # false means real run @@ -344,11 +344,11 @@ describe PublicBody, " when loading CSV files" do PublicBody.find_by_name('North West Fake Authority').tag_array_for_search.should == ['fake'] PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['fake', 'scottish'] PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['aTag', 'fake'] - + # Import again to check the 'replace' tag functionality works new_tags_file = load_file_fixture('fake-authority-add-tags.rb') errors, notes = PublicBody.import_csv(new_tags_file, 'fake', 'replace', false, 'someadmin') # false means real run - + # Check tags were added successfully PublicBody.find_by_name('North West Fake Authority').tag_array_for_search.should == ['aTag'] PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['aTag'] @@ -363,8 +363,8 @@ describe PublicBody, " when loading CSV files" do errors.should == [] notes.size.should == 7 notes[0..5].should == [ - "line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"}", - "line 2: creating new authority 'North West Fake Authority' (locale: es):\n\t{\"name\":\"Autoridad del Nordeste\"}", + "line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"}", + "line 2: creating new authority 'North West Fake Authority' (locale: es):\n\t{\"name\":\"Autoridad del Nordeste\"}", "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\",\"tag_string\":\"scottish\"}", "line 3: creating new authority 'Scottish Fake Authority' (locale: es):\n\t{\"name\":\"Autoridad Escocesa\"}", "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\",\"tag_string\":\"fake aTag\"}", @@ -373,8 +373,8 @@ describe PublicBody, " when loading CSV files" do notes[6].should =~ /Notes: Some bodies are in database, but not in CSV file:\n( [A-Za-z ]+\n)*You may want to delete them manually.\n/ PublicBody.count.should == original_count + 3 - - # XXX Not sure why trying to do a PublicBody.with_locale fails here. Seems related to + + # XXX Not sure why trying to do a PublicBody.with_locale fails here. Seems related to # the way categories are loaded every time from the PublicBody class. For now we just # test some translation was done. body = PublicBody.find_by_name('North West Fake Authority') @@ -387,13 +387,13 @@ describe PublicBody, " when loading CSV files" do csv_contents = load_file_fixture("fake-authority-type-with-field-names.csv") # Depending on the runtime environment (Ruby version? OS?) the list of available locales # is made of strings or symbols, so we use 'en' here as a string to test both scenarios. - # See https://github.com/sebbacon/alaveteli/issues/193 + # See https://github.com/mysociety/alaveteli/issues/193 errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', true, 'someadmin', ['en', :xx]) # true means dry run errors.should == [] notes.size.should == 4 notes[0..2].should == [ "line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"}", - "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\",\"tag_string\":\"scottish\"}", + "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\",\"tag_string\":\"scottish\"}", "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\",\"tag_string\":\"fake aTag\"}", ] notes[3].should =~ /Notes: Some bodies are in database, but not in CSV file:\n( [A-Za-z ]+\n)*You may want to delete them manually.\n/ |