aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/foi_attachment_spec.rb13
-rw-r--r--spec/models/incoming_message_spec.rb7
-rw-r--r--spec/models/info_request_spec.rb54
3 files changed, 46 insertions, 28 deletions
diff --git a/spec/models/foi_attachment_spec.rb b/spec/models/foi_attachment_spec.rb
index 9d44957e4..537a3363c 100644
--- a/spec/models/foi_attachment_spec.rb
+++ b/spec/models/foi_attachment_spec.rb
@@ -30,6 +30,17 @@ describe FoiAttachment, " when calculating due date" do
main.delete_cached_file!
main = im.get_main_body_text_part
main.body.should == orig_body
-
+
end
end
+
+describe FoiAttachment, "when ensuring a filename is present" do
+
+ it 'should create a filename for an instance with a blank filename' do
+ attachment = FoiAttachment.new
+ attachment.filename = ''
+ attachment.ensure_filename!
+ attachment.filename.should == 'attachment.bin'
+ end
+
+end
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index 6fc0ff3cc..f53a5856a 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -148,6 +148,13 @@ describe IncomingMessage, " folding quoted parts of emails" do
@incoming_message.remove_lotus_quoting(text).should match(/FOLDED_QUOTED_SECTION/)
end
+ it 'should not error when trying to fold lotus notes quoted parts on a request with no user_name' do
+ text = "hello"
+ @incoming_message = IncomingMessage.new()
+ @incoming_message.stub_chain(:info_request, :user_name).and_return(nil)
+ @incoming_message.remove_lotus_quoting(text).should == 'hello'
+ end
+
it "cope with [ in user names properly" do
@incoming_message = IncomingMessage.new()
@incoming_message.stub_chain(:info_request, :user_name).and_return("Sir [ Bobble")
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index 544852f91..4112a2baa 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -454,6 +454,33 @@ describe InfoRequest do
end
+ describe 'when an instance is asked if all can view it' do
+
+ before do
+ @info_request = InfoRequest.new
+ end
+
+ it 'should return true if its prominence is normal' do
+ @info_request.prominence = 'normal'
+ @info_request.all_can_view?.should == true
+ end
+
+ it 'should return true if its prominence is backpage' do
+ @info_request.prominence = 'backpage'
+ @info_request.all_can_view?.should == true
+ end
+
+ it 'should return false if its prominence is hidden' do
+ @info_request.prominence = 'hidden'
+ @info_request.all_can_view?.should == false
+ end
+
+ it 'should return false if its prominence is requester_only' do
+ @info_request.prominence = 'requester_only'
+ @info_request.all_can_view?.should == false
+ end
+ end
+
describe 'when applying censor rules' do
before do
@@ -537,32 +564,5 @@ describe InfoRequest do
end
- describe 'when an instance is asked if all can view it' do
-
- before do
- @info_request = InfoRequest.new
- end
-
- it 'should return true if its prominence is normal' do
- @info_request.prominence = 'normal'
- @info_request.all_can_view?.should == true
- end
-
- it 'should return true if its prominence is backpage' do
- @info_request.prominence = 'backpage'
- @info_request.all_can_view?.should == true
- end
-
- it 'should return false if its prominence is hidden' do
- @info_request.prominence = 'hidden'
- @info_request.all_can_view?.should == false
- end
-
- it 'should return false if its prominence is requester_only' do
- @info_request.prominence = 'requester_only'
- @info_request.all_can_view?.should == false
- end
-
- end
end