aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/request_controller_spec.rb20
-rw-r--r--spec/factories/outgoing_messages.rb10
-rw-r--r--spec/integration/localisation_spec.rb29
-rw-r--r--spec/models/info_request_spec.rb11
4 files changed, 56 insertions, 14 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index f7c935af3..6c0f4573e 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1827,7 +1827,15 @@ describe RequestController, "when sending a followup message" do
# make the followup
session[:user_id] = users(:bob_smith_user).id
- post :show_response, :outgoing_message => { :body => "What a useless response! You suck.", :what_doing => 'normal_sort' }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message), :submitted_followup => 1
+
+ post :show_response,
+ :outgoing_message => {
+ :body => "What a useless response! You suck.",
+ :what_doing => 'normal_sort'
+ },
+ :id => info_requests(:fancy_dog_request).id,
+ :incoming_message_id => incoming_messages(:useless_incoming_message),
+ :submitted_followup => 1
# check it worked
deliveries = ActionMailer::Base.deliveries
@@ -1982,7 +1990,15 @@ describe RequestController, "sending overdue request alerts" do
:info_request_id => chicken_request.id,
:body => 'Some text',
:what_doing => 'normal_sort')
- outgoing_message.send_message
+
+ outgoing_message.sendable?
+ mail_message = OutgoingMailer.followup(
+ outgoing_message.info_request,
+ outgoing_message,
+ outgoing_message.incoming_message_followup
+ ).deliver
+ outgoing_message.record_email_delivery(mail_message.to_addrs.join(', '), mail_message.message_id)
+
outgoing_message.save!
chicken_request = InfoRequest.find(chicken_request.id)
diff --git a/spec/factories/outgoing_messages.rb b/spec/factories/outgoing_messages.rb
index 3887d3f48..e11cbdfb9 100644
--- a/spec/factories/outgoing_messages.rb
+++ b/spec/factories/outgoing_messages.rb
@@ -10,7 +10,9 @@ FactoryGirl.define do
body 'Some information please'
what_doing 'normal_sort'
end
+
end
+
factory :internal_review_request do
ignore do
status 'ready'
@@ -18,6 +20,7 @@ FactoryGirl.define do
body 'I want a review'
what_doing 'internal_review'
end
+
end
# FIXME: This here because OutgoingMessage has an after_initialize,
@@ -30,9 +33,14 @@ FactoryGirl.define do
:message_type => message_type,
:body => body,
:what_doing => what_doing }) }
+
after_create do |outgoing_message|
- outgoing_message.send_message
+ outgoing_message.sendable?
+ outgoing_message.record_email_delivery(
+ 'test@example.com',
+ 'ogm-14+537f69734b97c-1ebd@localhost')
end
+
end
end
diff --git a/spec/integration/localisation_spec.rb b/spec/integration/localisation_spec.rb
index 4f6b61ae1..037603ad5 100644
--- a/spec/integration/localisation_spec.rb
+++ b/spec/integration/localisation_spec.rb
@@ -24,14 +24,29 @@ describe "when generating urls" do
response.should_not contain @home_link_regex
end
- it 'should redirect requests for a public body in a locale to the canonical name in that locale' do
- get('/es/body/dfh')
- response.should redirect_to "/es/body/edfh"
- end
+ context 'when handling public body requests' do
+
+ before do
+ AlaveteliLocalization.set_locales(available_locales='es en', default_locale='en')
+ body = FactoryGirl.create(:public_body, :short_name => 'english_short')
+ I18n.with_locale(:es) do
+ body.short_name = 'spanish_short'
+ body.save!
+ end
+ end
+
+ it 'should redirect requests for a public body in a locale to the
+ canonical name in that locale' do
+ get('/es/body/english_short')
+ response.should redirect_to "/es/body/spanish_short"
+ end
- it 'should remember a filter view when redirecting a public body request to the canonical name' do
- get('/es/body/tgq/successful')
- response.should redirect_to "/es/body/etgq/successful"
+ it 'should remember a filter view when redirecting a public body
+ request to the canonical name' do
+ AlaveteliLocalization.set_locales(available_locales='es en', default_locale='en')
+ get('/es/body/english_short/successful')
+ response.should redirect_to "/es/body/spanish_short/successful"
+ end
end
describe 'when there is more than one locale' do
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index afb8e0949..9ad616ea5 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -848,9 +848,11 @@ describe InfoRequest do
context "a series of events on a request" do
it "should have sensible events after the initial request has been made" do
# An initial request is sent
- # The logic that changes the status when a message is sent is mixed up
- # in OutgoingMessage#send_message. So, rather than extract it (or call it)
- # let's just duplicate what it does here for the time being.
+ # FIXME: The logic that changes the status when a message
+ # is sent is mixed up in
+ # OutgoingMessage#record_email_delivery. So, rather than
+ # extract it (or call it) let's just duplicate what it does
+ # here for the time being.
request.log_event('sent', {})
request.set_described_state('waiting_response')
@@ -919,7 +921,8 @@ describe InfoRequest do
request.log_event("status_update", {})
request.set_described_state("waiting_response")
# A normal follow up is sent
- # This is normally done in OutgoingMessage#send_message
+ # This is normally done in
+ # OutgoingMessage#record_email_delivery
request.log_event('followup_sent', {})
request.set_described_state('waiting_response')