aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/admin_request_controller_spec.rb4
-rw-r--r--spec/controllers/general_controller_spec.rb18
-rw-r--r--spec/controllers/request_controller_spec.rb44
-rw-r--r--spec/lib/mail_handler/mail_handler_spec.rb2
4 files changed, 34 insertions, 34 deletions
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb
index 6d7ab611e..d16235717 100644
--- a/spec/controllers/admin_request_controller_spec.rb
+++ b/spec/controllers/admin_request_controller_spec.rb
@@ -90,7 +90,7 @@ describe AdminRequestController, "when administering the holding pen" do
ir.save!
receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "frob@nowhere.com")
get :show_raw_email, :id => InfoRequest.holding_pen_request.get_last_response.raw_email.id
- response.should have_text(/Only the authority can reply to this request/)
+ response.should contain "Only the authority can reply to this request"
end
it "allows redelivery even to a closed request" do
@@ -154,7 +154,7 @@ describe AdminRequestController, "when administering the holding pen" do
receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "")
InfoRequest.holding_pen_request.incoming_messages.length.should == 2
get :show_raw_email, :id => interesting_email
- response.should have_text(/Could not identify the request/)
+ response.should contain "Could not identify the request"
assigns[:info_requests][0].should == ir
end
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index 152943121..c7d9b5ce3 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -120,13 +120,13 @@ describe GeneralController, "when showing the frontpage" do
it 'should generate URLs without a locale prepended' do
get :frontpage
- response.should_not have_text(@default_lang_home_link)
+ response.should_not contain @default_lang_home_link
end
it 'should render the front page in the default language when no locale param
is present and the session locale is not the default' do
get(:frontpage, {}, {:locale => 'es'})
- response.should_not have_text(@other_lang_home_link)
+ response.should_not contain @other_lang_home_link
end
end
@@ -134,7 +134,7 @@ describe GeneralController, "when showing the frontpage" do
INCLUDE_DEFAULT_LOCALE_IN_URLS is true' do
set_default_locale_in_urls(true)
get :frontpage
- response.should have_text(@default_lang_home_link)
+ response.body.should match /#{@default_lang_home_link}/
end
after do
@@ -150,28 +150,28 @@ describe GeneralController, "when showing the frontpage" do
it "should generate URLs with a locale prepended when there's more than one locale set" do
get :frontpage
- response.should have_text(home_link_regex)
+ response.body.should match home_link_regex
end
it "should use our test PO files rather than the application one" do
I18n.default_locale = :es
get :frontpage
- response.should have_text(/XOXO/)
+ response.body.should match /XOXO/
I18n.default_locale = :en
end
it "should generate URLs that include the locale when using one that includes an underscore" do
I18n.default_locale = :"en_GB"
get :frontpage
- response.should have_text(/href="\/en_GB\//)
+ response.body.should match /href="\/en_GB\//
I18n.default_locale = :en
end
it "should fall back to the language if the territory is unknown" do
I18n.default_locale = :"en_US"
get :frontpage
- response.should have_text(/href="\/en\//)
- response.should_not have_text(/href="\/en_US\//)
+ response.body.should match /href="\/en\//
+ response.body.should_not match /href="\/en_US\//
I18n.default_locale = :en
end
@@ -181,7 +181,7 @@ describe GeneralController, "when showing the frontpage" do
FastGettext.default_available_locales = I18n.available_locales = ['en']
get :frontpage
- response.should_not have_text(home_link_regex)
+ response.should_not contain home_link_regex
FastGettext.default_available_locales = old_fgt_available_locales
I18n.available_locales = old_i18n_available_locales
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 36af1cd96..5f9ead973 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -481,11 +481,11 @@ describe RequestController, "when showing one request" do
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt'], :skip_cache => 1
response.content_type.should == "text/plain"
- response.should have_text(/Second hello/)
+ response.should contain "Second hello"
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 3, :file_name => ['hello.txt'], :skip_cache => 1
response.content_type.should == "text/plain"
- response.should have_text(/First hello/)
+ response.should contain "First hello"
end
it 'should cache an attachment on a request with normal prominence' do
@@ -504,7 +504,7 @@ describe RequestController, "when showing one request" do
ir = info_requests(:fancy_dog_request)
receive_incoming_mail('iso8859_2_raw_email.email', ir.incoming_email)
get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
- response.should have_text(/tënde/u)
+ response.should contain "tënde"
end
it "should generate valid HTML verson of plain text attachments" do
@@ -513,7 +513,7 @@ describe RequestController, "when showing one request" do
ir.reload
get :get_attachment_as_html, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt.html'], :skip_cache => 1
response.content_type.should == "text/html"
- response.should have_text(/Second hello/)
+ response.should contain "Second hello"
end
# This is a regression test for a bug where URLs of this form were causing 500 errors
@@ -578,7 +578,7 @@ describe RequestController, "when showing one request" do
ir.reload
get :get_attachment_as_html, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['fs_50379341.pdf.html'], :skip_cache => 1
response.content_type.should == "text/html"
- response.should have_text(/Walberswick Parish Council/)
+ response.should contain "Walberswick Parish Council"
end
it "should not cause a reparsing of the raw email, even when the result would be a 404" do
@@ -586,7 +586,7 @@ describe RequestController, "when showing one request" do
receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
ir.reload
attachment = IncomingMessage.get_attachment_by_url_part_number(ir.incoming_messages[1].get_attachments_for_display, 2)
- attachment.body.should have_text(/Second hello/)
+ attachment.body.should contain "Second hello"
# change the raw_email associated with the message; this only be reparsed when explicitly asked for
ir.incoming_messages[1].raw_email.data = ir.incoming_messages[1].raw_email.data.sub("Second", "Third")
@@ -598,19 +598,19 @@ describe RequestController, "when showing one request" do
}.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/)
+ attachment.body.should contain "Second hello"
# ...nor should asking for it by its correct filename...
get :get_attachment_as_html, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt.html'], :skip_cache => 1
- response.should_not have_text(/Third hello/)
+ response.should_not contain "Third hello"
# ...but if we explicitly ask for attachments to be extracted, then they should be
force = true
ir.incoming_messages[1].parse_raw_email!(force)
attachment = IncomingMessage.get_attachment_by_url_part_number(ir.incoming_messages[1].get_attachments_for_display, 2)
- attachment.body.should have_text(/Second hello/)
+ attachment.body.should contain "Second hello"
get :get_attachment_as_html, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt.html'], :skip_cache => 1
- response.should have_text(/Third hello/)
+ response.should contain "Third hello"
end
it "should treat attachments with unknown extensions as binary" do
@@ -620,7 +620,7 @@ describe RequestController, "when showing one request" do
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.qwglhm'], :skip_cache => 1
response.content_type.should == "application/octet-stream"
- response.should have_text(/an unusual sort of file/)
+ response.should contain "an unusual sort of file"
end
it "should not download attachments with wrong file name" do
@@ -648,7 +648,7 @@ describe RequestController, "when showing one request" do
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt'], :skip_cache => 1
response.content_type.should == "text/plain"
- response.should have_text(/xxxxxx hello/)
+ response.should contain "xxxxxx hello"
ensure
ir.censor_rules.clear
end
@@ -670,7 +670,7 @@ describe RequestController, "when showing one request" do
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt'], :skip_cache => 1
response.content_type.should == "text/plain"
- response.should have_text(/xxxxxx hello/)
+ response.should contain "xxxxxx hello"
ensure
ir.user.censor_rules.clear
end
@@ -733,17 +733,17 @@ describe RequestController, "when showing one request" do
ir = info_requests(:fancy_dog_request)
session[:user_id] = ir.user.id # bob_smith_user
get :download_entire_request, :url_title => title
- assigns[:url_path].should have_text(/#{title}.zip$/)
+ assigns[:url_path].should contain /#{title}.zip$/
old_path = assigns[:url_path]
- response.location.should have_text(/#{assigns[:url_path]}$/)
+ response.location.should contain /#{assigns[:url_path]}$/
zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", old_path)) { |zipfile|
zipfile.count.should == 1 # just the message
}
receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
get :download_entire_request, :url_title => title
- assigns[:url_path].should have_text(/#{title}.zip$/)
+ assigns[:url_path].should contain /#{title}.zip$/
old_path = assigns[:url_path]
- response.location.should have_text(/#{assigns[:url_path]}$/)
+ response.location.should contain /#{assigns[:url_path]}$/
zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", old_path)) { |zipfile|
zipfile.count.should == 3 # the message plus two "hello.txt" files
}
@@ -754,9 +754,9 @@ describe RequestController, "when showing one request" do
sleep 1
receive_incoming_mail('incoming-request-attachment-unknown-extension.email', ir.incoming_email)
get :download_entire_request, :url_title => title
- assigns[:url_path].should have_text(/#{title}.zip$/)
+ assigns[:url_path].should contain /#{title}.zip$/
assigns[:url_path].should_not == old_path
- response.location.should have_text(/#{assigns[:url_path]}/)
+ response.location.should contain assigns[:url_path]
zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", assigns[:url_path])) { |zipfile|
zipfile.count.should == 4 # the message, two hello.txt plus the unknown attachment
}
@@ -766,7 +766,7 @@ describe RequestController, "when showing one request" do
info_request = info_requests(:external_request)
get :download_entire_request, { :url_title => info_request.url_title },
{ :user_id => users(:bob_smith_user) }
- response.location.should have_text(/#{assigns[:url_path]}$/)
+ response.location.should contain /#{assigns[:url_path]}$/
end
end
end
@@ -855,14 +855,14 @@ describe RequestController, "when changing prominence of a request" do
:part => 2,
:skip_cache => 1
response.content_type.should == "text/html"
- response.should_not have_text(/Second hello/)
+ response.should_not contain "Second hello"
response.should render_template('request/hidden')
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id,
:id => ir.id,
:part => 3,
:skip_cache => 1
response.content_type.should == "text/html"
- response.should_not have_text(/First hello/)
+ response.should_not contain "First hello"
response.should render_template('request/hidden')
response.code.should == '410'
end
diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb
index 48c32e2bc..79b779687 100644
--- a/spec/lib/mail_handler/mail_handler_spec.rb
+++ b/spec/lib/mail_handler/mail_handler_spec.rb
@@ -22,7 +22,7 @@ describe 'when creating a mail object from raw data' do
it 'should convert an iso8859 email to utf8' do
mail = get_fixture_mail('iso8859_2_raw_email.email')
- mail.subject.should have_text(/gjatë/u)
+ mail.subject.should match /gjatë/u
MailHandler.get_part_body(mail).is_utf8?.should == true
end