aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/request_controller_spec.rb8
-rw-r--r--spec/fixtures/foi_attachments.yml5
-rw-r--r--spec/models/incoming_message_spec.rb13
-rw-r--r--spec/models/info_request_event_spec.rb5
-rw-r--r--spec/models/info_request_spec.rb2
-rw-r--r--spec/models/xapian_spec.rb1
-rw-r--r--spec/spec_helper.rb5
7 files changed, 22 insertions, 17 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 459667b9d..9eddbc294 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -173,7 +173,7 @@ describe RequestController, "when showing one request" do
# re-parse...
lambda {
get :get_attachment_as_html, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt.baz.html'], :skip_cache => 1
- }.should raise_error(RuntimeError)
+ }.should raise_error(ActiveRecord::RecordNotFound)
attachment = IncomingMessage.get_attachment_by_url_part_number(ir.incoming_messages[1].get_attachments_for_display, 2)
attachment.body.should have_text(/Second hello/)
@@ -995,7 +995,6 @@ describe RequestController, "when sending a followup message" do
before(:each) do
load_raw_emails_data(raw_emails)
- info_requests(:fancy_dog_request).incoming_messages.each{|x| x.parse_raw_email!}
end
it "should require login" do
@@ -1346,9 +1345,10 @@ end
describe RequestController, "authority uploads a response from the web interface" do
+ integrate_views
fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
- before(:all) do
+ before(:each) do
# domain after the @ is used for authentication of FOI officers, so to test it
# we need a user which isn't at localhost.
@normal_user = User.new(:name => "Mr. Normal", :email => "normal-user@flourish.org",
@@ -1402,7 +1402,7 @@ describe RequestController, "authority uploads a response from the web interface
# How do I test a file upload in rails?
# http://stackoverflow.com/questions/1178587/how-do-i-test-a-file-upload-in-rails
- it "should let the requester upload a file" do
+ it "should let the authority upload a file" do
@ir = info_requests(:fancy_dog_request)
incoming_before = @ir.incoming_messages.size
session[:user_id] = @foi_officer_user.id
diff --git a/spec/fixtures/foi_attachments.yml b/spec/fixtures/foi_attachments.yml
index 2a08e8a35..8b1378917 100644
--- a/spec/fixtures/foi_attachments.yml
+++ b/spec/fixtures/foi_attachments.yml
@@ -1,4 +1 @@
-useless_attachment:
- incoming_message_id: 1
- content_type: text/plain
- filename: foo.txt
+
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index 4d64206e1..417a9b06c 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -336,16 +336,13 @@ describe IncomingMessage, " when uudecoding bad messages" do
mail_body = load_file_fixture('incoming-request-bad-uuencoding.email')
mail = TMail::Mail.parse(mail_body)
mail.base64_decode
-
im = incoming_messages(:useless_incoming_message)
im.stub!(:mail).and_return(mail)
-
-require 'ruby-debug'
-debugger
im.extract_attachments!
- attachments = im.get_main_body_text_uudecode_attachments
- attachments.size.should == 1
- attachments[0].filename.should == 'moo.txt'
+ attachments = im.foi_attachments
+ attachments.size.should == 2
+ attachments[1].filename.should == 'moo.txt'
+ im.get_attachments_for_display.size.should == 1
end
it "should apply censor rules" do
@@ -365,7 +362,7 @@ debugger
ir.censor_rules << @censor_rule
im.extract_attachments!
- attachments = im.get_main_body_text_uudecode_attachments
+ attachments = im.get_attachments_for_display
attachments.size.should == 1
attachments[0].display_filename.should == 'bah.txt'
end
diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb
index 055965c23..3229284cc 100644
--- a/spec/models/info_request_event_spec.rb
+++ b/spec/models/info_request_event_spec.rb
@@ -54,6 +54,11 @@ describe InfoRequestEvent do
describe "doing search/index stuff" do
fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
+ before(:each) do
+ load_raw_emails_data(raw_emails)
+ parse_all_incoming_messages
+ end
+
it 'should get search text for outgoing messages' do
event = info_request_events(:useless_outgoing_message_event)
message = outgoing_messages(:useless_outgoing_message).body
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index 409d48ede..b1baa66a2 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -143,8 +143,8 @@ describe InfoRequest do
end
it "should cope with indexing after item is deleted" do
+ IncomingMessage.find(:all).each{|x| x.parse_raw_email!}
rebuild_xapian_index
-
# delete event from underneath indexing; shouldn't cause error
info_request_events(:useless_incoming_message_event).save!
info_request_events(:useless_incoming_message_event).destroy
diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb
index cf9ea5fbd..ec11c944b 100644
--- a/spec/models/xapian_spec.rb
+++ b/spec/models/xapian_spec.rb
@@ -4,6 +4,7 @@ describe User, " when indexing users with Xapian" do
fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
it "should search by name" do
+ parse_all_incoming_messages
rebuild_xapian_index
# def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page)
xapian_object = InfoRequest.full_search([User], "Silly", 'created_at', true, nil, 100, 1)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index e5a42f1a9..5c5cd9a7f 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -78,6 +78,7 @@ def load_file_fixture(file_name)
end
def rebuild_xapian_index(terms = true, values = true, texts = true, dropfirst = true)
+ parse_all_incoming_messages
if dropfirst
begin
ActsAsXapian.readable_init
@@ -168,3 +169,7 @@ def load_raw_emails_data(raw_emails)
end
raw_email.data = load_file_fixture("useless_raw_email.email")
end
+
+def parse_all_incoming_messages
+ IncomingMessage.find(:all).each{|x| x.parse_raw_email!}
+end