aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Chard <ian@mysociety.org>2013-08-01 14:02:57 +0100
committerIan Chard <ian@mysociety.org>2013-08-01 14:02:57 +0100
commitc43deed5550583ee8a304e80ae248f18b271be9f (patch)
tree40c54a3c23c5a6569aba80c9e4ebc1f765d65838
parent5c7e6392dd5c0209fb9ac85c03110628933ebb94 (diff)
parentc6743d1e4c05f4104b811660b5c2769d96dfab03 (diff)
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/alaveteli
-rw-r--r--spec/models/public_body_spec.rb32
1 files changed, 18 insertions, 14 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index bc693b4da..e17cf8e63 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -1,3 +1,4 @@
+# encoding: UTF-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PublicBody, " using tags" do
@@ -266,16 +267,17 @@ describe PublicBody, " when loading CSV files" do
it "should do a dry run successfully" do
original_count = PublicBody.count
- csv_contents = load_file_fixture("fake-authority-type.csv")
+ csv_contents = normalize_string_to_utf8(load_file_fixture("fake-authority-type.csv"))
errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', true, 'someadmin') # true means dry run
errors.should == []
- notes.size.should == 4
- notes[0..2].should == [
+ notes.size.should == 5
+ notes[0..3].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 3: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\"\}",
+ "line 4: creating new authority 'Gobierno de Aragón' (locale: en):\n\t\{\"name\":\"Gobierno de Arag\\u00f3n\",\"request_email\":\"spain_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/
+ notes[4].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
@@ -283,34 +285,36 @@ describe PublicBody, " when loading CSV files" do
it "should do full run successfully" do
original_count = PublicBody.count
- csv_contents = load_file_fixture("fake-authority-type.csv")
+ csv_contents = normalize_string_to_utf8(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 == [
+ notes.size.should == 5
+ notes[0..3].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 3: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\"\}",
+ "line 4: creating new authority 'Gobierno de Aragón' (locale: en):\n\t\{\"name\":\"Gobierno de Arag\\u00f3n\",\"request_email\":\"spain_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/
+ notes[4].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
+ PublicBody.count.should == original_count + 4
end
it "should do imports without a tag successfully" do
original_count = PublicBody.count
- csv_contents = load_file_fixture("fake-authority-type.csv")
+ csv_contents = normalize_string_to_utf8(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 == [
+ notes.size.should == 5
+ notes[0..3].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 3: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\"\}",
+ "line 4: creating new authority 'Gobierno de Aragón' (locale: en):\n\t\{\"name\":\"Gobierno de Arag\\u00f3n\",\"request_email\":\"spain_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/
- PublicBody.count.should == original_count + 3
+ notes[4].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 + 4
end
it "should handle a field list and fields out of order" do