aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/admin_public_body_categories_controller_spec.rb2
-rw-r--r--spec/lib/alaveteli_text_masker_spec.rb17
-rw-r--r--spec/models/info_request_spec.rb16
3 files changed, 34 insertions, 1 deletions
diff --git a/spec/controllers/admin_public_body_categories_controller_spec.rb b/spec/controllers/admin_public_body_categories_controller_spec.rb
index 1131b3c0b..c15ee77f1 100644
--- a/spec/controllers/admin_public_body_categories_controller_spec.rb
+++ b/spec/controllers/admin_public_body_categories_controller_spec.rb
@@ -310,7 +310,7 @@ describe AdminPublicBodyCategoriesController do
post :update, :id => category.id,
:public_body_category => category.serializable_hash.except(:title, :description)
- expect(assigns(:tagged_public_bodies)).to eq(expected_bodies)
+ expect(assigns(:tagged_public_bodies)).to match_array(expected_bodies)
end
it "saves edits to a public body category's heading associations" do
diff --git a/spec/lib/alaveteli_text_masker_spec.rb b/spec/lib/alaveteli_text_masker_spec.rb
index 1a4782a83..102d2582e 100644
--- a/spec/lib/alaveteli_text_masker_spec.rb
+++ b/spec/lib/alaveteli_text_masker_spec.rb
@@ -92,6 +92,23 @@ describe AlaveteliTextMasker do
pdf.should_not == ""
end
+ it 'should keep the uncensored original if uncompression of a PDF fails' do
+ orig_pdf = load_file_fixture('tfl.pdf')
+ pdf = orig_pdf.dup
+ stub!(:uncompress_pdf).and_return nil
+ apply_masks!(pdf, "application/pdf")
+ pdf.should == orig_pdf
+ end
+
+ it 'should use the uncompressed PDF text if re-compression of a compressed PDF fails' do
+ orig_pdf = load_file_fixture('tfl.pdf')
+ pdf = orig_pdf.dup
+ stub!(:uncompress_pdf).and_return "something about foi@tfl.gov.uk"
+ stub!(:compress_pdf).and_return nil
+ apply_masks!(pdf, "application/pdf")
+ pdf.should match "something about xxx@xxx.xxx.xx"
+ end
+
it "should apply hard-coded privacy rules to HTML files" do
data = "http://test.host/c/cheese"
apply_masks!(data, 'text/html')
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index 70947584b..c8bd2c338 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -1313,4 +1313,20 @@ describe InfoRequest do
end
+
+ describe 'when destroying a message' do
+
+ it 'can destroy a request with comments and censor rules' do
+ info_request = FactoryGirl.create(:info_request)
+ censor_rule = FactoryGirl.create(:censor_rule, :info_request => info_request)
+ comment = FactoryGirl.create(:comment, :info_request => info_request)
+ info_request.reload
+ info_request.fully_destroy
+
+ InfoRequest.where(:id => info_request.id).should be_empty
+ CensorRule.where(:id => censor_rule.id).should be_empty
+ Comment.where(:id => comment.id).should be_empty
+ end
+
+ end
end