aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/admin_spam_addresses_controller_spec.rb4
-rw-r--r--spec/controllers/request_controller_spec.rb20
-rw-r--r--spec/controllers/user_controller_spec.rb12
-rw-r--r--spec/factories/outgoing_messages.rb10
-rw-r--r--spec/fixtures/info_request_events.yml4
-rw-r--r--spec/models/info_request_spec.rb11
6 files changed, 50 insertions, 11 deletions
diff --git a/spec/controllers/admin_spam_addresses_controller_spec.rb b/spec/controllers/admin_spam_addresses_controller_spec.rb
index da1e9bb5a..a1e434159 100644
--- a/spec/controllers/admin_spam_addresses_controller_spec.rb
+++ b/spec/controllers/admin_spam_addresses_controller_spec.rb
@@ -37,7 +37,7 @@ describe AdminSpamAddressesController do
it 'redirects to the index action if successful' do
SpamAddress.any_instance.stub(:save).and_return(true)
post :create, :spam_address => spam_params
- expect(response).to redirect_to(spam_addresses_path)
+ expect(response).to redirect_to(admin_spam_addresses_path)
end
it 'notifies the admin the spam address has been created' do
@@ -83,7 +83,7 @@ describe AdminSpamAddressesController do
end
it 'redirects to the index action' do
- expect(response).to redirect_to(spam_addresses_path)
+ expect(response).to redirect_to(admin_spam_addresses_path)
end
end
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/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index e4854fe6b..413d395c5 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -21,7 +21,8 @@ describe UserController, "when redirecting a show request to a canonical url" do
it 'should not redirect a long canonical name that has a numerical suffix' do
User.stub!(:find).with(:first, anything()).and_return(mock_model(User,
:url_name => 'bob_smithbob_smithbob_smithbob_s_2',
- :name => 'Bob Smith Bob Smith Bob Smith Bob Smith'))
+ :name => 'Bob Smith Bob Smith Bob Smith Bob Smith',
+ :info_requests => []))
User.stub!(:find).with(:all, anything()).and_return([])
get :show, :url_name => 'bob_smithbob_smithbob_smithbob_s_2'
response.should be_success
@@ -107,6 +108,15 @@ describe UserController, "when showing a user" do
]
end
+ it 'filters by the given request status' do
+ get :show, :url_name => 'bob_smith',
+ :user_query => 'money',
+ :request_latest_status => 'waiting_response'
+ assigns[:xapian_requests].results.map{|x|x[:model].info_request}.should =~ [
+ info_requests(:naughty_chicken_request)
+ ]
+ end
+
it "should not show unconfirmed users" do
begin
get :show, :url_name => "unconfirmed_user"
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/fixtures/info_request_events.yml b/spec/fixtures/info_request_events.yml
index b2f40cc37..23ef80cc2 100644
--- a/spec/fixtures/info_request_events.yml
+++ b/spec/fixtures/info_request_events.yml
@@ -31,8 +31,10 @@ silly_outgoing_message_event:
info_request_id: 103
event_type: sent
created_at: 2007-10-14 10:41:12.686264
- described_state:
outgoing_message_id: 2
+ calculated_state: waiting_response
+ described_state: waiting_response
+ last_described_at: 2007-10-14 10:41:12.686264
useless_incoming_message_event:
id: 902
params_yaml: "--- \n\
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')