diff options
author | francis <francis> | 2008-01-10 01:13:27 +0000 |
---|---|---|
committer | francis <francis> | 2008-01-10 01:13:27 +0000 |
commit | cbf8f251f85b13256de045ded55fcc191d980007 (patch) | |
tree | ae90b305a337424944bd2aee4be0eaadda886b82 | |
parent | d6c6623f26b4c18db7fe80498c2d08c9bfd83e4f (diff) |
Let original requester send followup messages.
-rw-r--r-- | app/controllers/request_controller.rb | 50 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 15 | ||||
-rw-r--r-- | app/models/info_request.rb | 4 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 6 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 47 | ||||
-rw-r--r-- | app/models/post_redirect.rb | 4 | ||||
-rw-r--r-- | app/models/public_body.rb | 4 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 13 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/views/request/_classify.rhtml | 3 | ||||
-rw-r--r-- | app/views/request/_correspondence.rhtml | 23 | ||||
-rw-r--r-- | app/views/request/_followup.rhtml | 38 | ||||
-rw-r--r-- | app/views/request/show.rhtml | 4 | ||||
-rw-r--r-- | app/views/request/show_response.rhtml | 10 | ||||
-rw-r--r-- | app/views/request_mailer/followup.rhtml | 8 | ||||
-rw-r--r-- | db/migrate/025_add_followup_to_outgoing_message.rb | 9 | ||||
-rw-r--r-- | db/schema.rb | 17 | ||||
-rw-r--r-- | public/stylesheets/main.css | 5 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 6 | ||||
-rw-r--r-- | todo.txt | 1 |
20 files changed, 204 insertions, 67 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index eb4418d60..ad809f716 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_controller.rb,v 1.35 2008-01-09 19:56:41 francis Exp $ +# $Id: request_controller.rb,v 1.36 2008-01-10 01:13:27 francis Exp $ class RequestController < ApplicationController @@ -73,7 +73,7 @@ class RequestController < ApplicationController end end - # Show an individual incoming message, and let the user classify it. + # Show an individual incoming message def show_response @incoming_message = IncomingMessage.find(params[:incoming_message_id]) @info_request = @incoming_message.info_request @@ -84,7 +84,8 @@ class RequestController < ApplicationController raise sprintf("Incoming message %d does not belong to request %d", @incoming_message.info_request_id, params[:id]) end - if params[:incoming_message] + if !params[:submitted_classify].nil? + # Let the user classify it. if not authenticated_as_user?(@info_request.user, :web => "To classify the response to this FOI request", :email => "Then you can classify the FOI response you have got from " + @info_request.public_body.name + ".", @@ -94,6 +95,12 @@ class RequestController < ApplicationController # do nothing - as "authenticated?" has done the redirect to signin page for us end + if !params[:incoming_message] + flash[:error] = "Please choose whether or not you got some of the information that you wanted." + render :action => 'show_response' + return + end + contains_information = (params[:incoming_message][:contains_information] == 'true' ? true : false) @incoming_message.contains_information = contains_information @incoming_message.user_classified = true @@ -101,14 +108,37 @@ class RequestController < ApplicationController flash[:notice] = "Thank you for classifying the response." redirect_to show_request_url(:id => @info_request) return - end - if params[:commit] - # Case when didn't choose radio option, but did submit form - flash[:error] = "Please choose whether or not you got some of the information that you wanted." + elsif !params[:submitted_followup].nil? + # Send a follow up message + @outgoing_message = OutgoingMessage.new(params[:outgoing_message].merge({ + :status => 'ready', + :message_type => 'followup' + })) + @info_request.outgoing_messages << @outgoing_message + @outgoing_message.info_request = @info_request + @outgoing_message.incoming_message_followup = @incoming_message + + # See if values were valid or not + if !@info_request.valid? + render :action => 'show_response' + elsif authenticated_as_user?(@info_request.user, + :web => "To send a follow up message about your FOI request", + :email => "Then you can send a follow up message to " + @info_request.public_body.name + ".", + :email_subject => "Send a follow up message to " + @info_request.public_body.name + " regarding your FOI request" + ) + # This automatically saves dependent objects, such as @outgoing_message, in the same transaction + @info_request.save! + @outgoing_message.send_message + flash[:notice] = "Your follow up message has been created and sent on its way." + redirect_to show_request_url(:id => @info_request) + else + # do nothing - as "authenticated?" has done the redirect to signin page for us + end + else + @outgoing_message = OutgoingMessage.new(params[:outgoing_message]) + # render default show_response template end end - - private - + private end diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 427059b15..a6a869769 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 24 +# Schema version: 25 # # Table name: incoming_messages # @@ -20,7 +20,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: incoming_message.rb,v 1.25 2008-01-07 15:08:59 francis Exp $ +# $Id: incoming_message.rb,v 1.26 2008-01-10 01:13:28 francis Exp $ class IncomingMessage < ActiveRecord::Base belongs_to :info_request @@ -30,6 +30,8 @@ class IncomingMessage < ActiveRecord::Base has_many :rejection_reasons + has_many :outgoing_message_followups, :class_name => OutgoingMessage + # Return the structured TMail::Mail object # Documentation at http://i.loveruby.net/en/projects/tmail/doc/ def mail @@ -155,6 +157,15 @@ class IncomingMessage < ActiveRecord::Base return text end + # Returns the name of the person the incoming message is from, or nil if there isn't one + # or if there is only an email address. + def safe_mail_from + if self.mail.from and (not self.mail.friendly_from.include?('@')) + return self.mail.friendly_from + else + return nil + end + end end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index d86614f1d..198c6a30f 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 24 +# Schema version: 25 # # Table name: info_requests # @@ -17,7 +17,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request.rb,v 1.25 2008-01-09 15:35:40 francis Exp $ +# $Id: info_request.rb,v 1.26 2008-01-10 01:13:28 francis Exp $ require 'digest/sha1' diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 6c0ccc585..706db9d20 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 24 +# Schema version: 25 # # Table name: info_request_events # @@ -15,14 +15,14 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request_event.rb,v 1.4 2008-01-07 13:26:46 francis Exp $ +# $Id: info_request_event.rb,v 1.5 2008-01-10 01:13:28 francis Exp $ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request validates_presence_of :info_request validates_presence_of :event_type - validates_inclusion_of :event_type, :in => ['sent', 'resent', 'edit_outgoing'] + validates_inclusion_of :event_type, :in => ['sent', 'resent', 'followup_sent', 'followup_resent', 'edit_outgoing'] # We store YAML version of parameters in the database def params=(params) diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index cd28d7ae0..a8d9425c5 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -1,16 +1,17 @@ # == Schema Information -# Schema version: 24 +# Schema version: 25 # # Table name: outgoing_messages # -# id :integer not null, primary key -# info_request_id :integer -# body :text -# status :string(255) -# message_type :string(255) -# created_at :datetime -# updated_at :datetime -# last_sent_at :datetime +# id :integer not null, primary key +# info_request_id :integer +# body :text +# status :string(255) +# message_type :string(255) +# created_at :datetime +# updated_at :datetime +# last_sent_at :datetime +# incoming_message_followup_id :integer # # models/outgoing_message.rb: @@ -20,16 +21,18 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: outgoing_message.rb,v 1.18 2008-01-04 11:19:18 francis Exp $ +# $Id: outgoing_message.rb,v 1.19 2008-01-10 01:13:28 francis Exp $ class OutgoingMessage < ActiveRecord::Base belongs_to :info_request validates_presence_of :info_request - validates_presence_of :body, :message => "^Please enter your letter requesting information." + validates_presence_of :body, :message => "^Please enter your letter requesting information" + validates_inclusion_of :status, :in => ['ready', 'sent', 'failed'] + validates_inclusion_of :message_type, :in => ['initial_request', 'followup' ] #, 'complaint'] - validates_inclusion_of :message_type, :in => ['initial_request'] #, 'complaint'] + belongs_to :incoming_message_followup, :foreign_key => 'incoming_message_followup_id', :class_name => 'IncomingMessage' # Set default letter def after_initialize @@ -52,20 +55,26 @@ class OutgoingMessage < ActiveRecord::Base # Note: You can test this from script/console with, say: # InfoRequest.find(1).outgoing_messages[0].send_message def send_message(log_event_type = 'sent') - if self.message_type == 'initial_request' - if self.status == 'ready' + if self.status == 'ready' + if self.message_type == 'initial_request' RequestMailer.deliver_initial_request(self.info_request, self) self.last_sent_at = Time.now self.status = 'sent' self.save! self.info_request.log_event(log_event_type, { :email => self.info_request.recipient_email, :outgoing_message_id => self.id }) - elsif self.status == 'sent' - raise "Message id #{self.id} has already been sent" + elsif self.message_type == 'followup' + RequestMailer.deliver_followup(self.info_request, self, self.incoming_message_followup) + self.last_sent_at = Time.now + self.status = 'sent' + self.save! + self.info_request.log_event('followup_' + log_event_type, { :email => self.info_request.recipient_email, :outgoing_message_id => self.id }) else - raise "Message id #{self.id} not in state for send_message" + raise "Message id #{self.id} has type '#{self.message_type}' which send_message can't handle" end + elsif self.status == 'sent' + raise "Message id #{self.id} has already been sent" else - raise "Message id #{self.id} has type '#{self.message_type}' which send_message can't handle" + raise "Message id #{self.id} not in state for send_message" end end @@ -75,7 +84,7 @@ class OutgoingMessage < ActiveRecord::Base self.status = 'ready' send_message('resent') else - raise "Message id #{self.id} has type '#{self.message_type}' status '#{self.status}' " + raise "Message id #{self.id} has type '#{self.message_type}' status '#{self.status}' which resend_message can't handle" end end diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb index ba9d0946f..c190562b5 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 24 +# Schema version: 25 # # Table name: post_redirects # @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: post_redirect.rb,v 1.10 2008-01-09 17:47:31 francis Exp $ +# $Id: post_redirect.rb,v 1.11 2008-01-10 01:13:28 francis Exp $ require 'openssl' # for random bytes function diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 53d5dd0b3..99b829b0f 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 24 +# Schema version: 25 # # Table name: public_bodies # @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: public_body.rb,v 1.12 2008-01-04 11:19:18 francis Exp $ +# $Id: public_body.rb,v 1.13 2008-01-10 01:13:28 francis Exp $ class PublicBody < ActiveRecord::Base validates_presence_of :name diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index f6b34c120..6d5e6b0cd 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_mailer.rb,v 1.15 2008-01-09 19:34:07 francis Exp $ +# $Id: request_mailer.rb,v 1.16 2008-01-10 01:13:28 francis Exp $ class RequestMailer < ActionMailer::Base @@ -17,6 +17,17 @@ class RequestMailer < ActionMailer::Base :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') } end + def followup(info_request, outgoing_message, incoming_message_followup) + @from = info_request.incoming_email + headers 'Sender' => info_request.envelope_email + @recipients = incoming_message_followup.mail.from + @subject = 'Re: Freedom of Information Request - ' + info_request.title + @body = {:info_request => info_request, :outgoing_message => outgoing_message, + :incoming_message_followup => incoming_message_followup, + :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') } + + end + def bounced_message(email) @from = MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') @recipients = @from diff --git a/app/models/user.rb b/app/models/user.rb index dc07afe47..a6e3bc434 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 24 +# Schema version: 25 # # Table name: users # @@ -19,7 +19,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user.rb,v 1.16 2008-01-04 11:19:18 francis Exp $ +# $Id: user.rb,v 1.17 2008-01-10 01:13:28 francis Exp $ require 'digest/sha1' diff --git a/app/views/request/_classify.rhtml b/app/views/request/_classify.rhtml index 167cb0d90..f48c53f3d 100644 --- a/app/views/request/_classify.rhtml +++ b/app/views/request/_classify.rhtml @@ -1,4 +1,4 @@ -<% form_for(:incoming_message, @info_request ) do |f| %> +<% form_for(:incoming_message, @info_request) do |f| %> <h2>Got what you wanted?</h2> <p>Does this response contain any of the information that you requested?</p> <p> @@ -9,6 +9,7 @@ <label for="incoming_message_contains_information_false">No, this response does not contain any of the information.</label> </p> + <%= hidden_field_tag 'submitted_classify', 1 %> <%= submit_tag "Update" %> <p> diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.rhtml index d087aa87a..8b8fbc7c9 100644 --- a/app/views/request/_correspondence.rhtml +++ b/app/views/request/_correspondence.rhtml @@ -7,8 +7,8 @@ <%= render :partial => 'bubble', :locals => { :body => incoming_message.get_body_for_display(@collapse_quotes) } %> <p class="event_bubble"> - <% if incoming_message.mail.from and (not incoming_message.mail.friendly_from.include?('@')) %> - <%= incoming_message.mail.friendly_from %> of + <% if !incoming_message.safe_mail_from.nil? %> + <%= incoming_message.safe_mail_from %> of <% end %> <%= public_body_link(@info_request.public_body) %> <% if incoming_message.contains_information %> @@ -25,21 +25,32 @@ </p> <% elsif (correspondence.class.to_s == 'InfoRequestEvent') info_request_event = correspondence - if info_request_event.event_type == 'sent' + if info_request_event.event_type == 'sent' || info_request_event.event_type == 'followup_sent' outgoing_message = OutgoingMessage.find(info_request_event.params[:outgoing_message_id]) %> <%= render :partial => 'bubble', :locals => { :body => outgoing_message.get_body_for_display() } %> <p class="event_bubble"> <%= user_link(@info_request.user) %> - <% if outgoing_message.message_type == 'initial_request' %> - sent the initial request <% if outgoing_message.status == 'sent' %> + sent the initial request to <%= public_body_link(@info_request.public_body) %> on <strong><%= simple_date(info_request_event.sent_at) %></strong> <% elsif outgoing_message.status == 'ready' %> - it has <strong>not yet been sent</strong> + wrote the initial request, but it has <strong>not yet been sent</strong> + <% else raise "unknown outgoing_message.status" %> + <% end %> + <% elsif outgoing_message.message_type == 'followup' %> + <% if outgoing_message.status == 'sent' %> + wrote to + <% if !outgoing_message.incoming_message_followup.safe_mail_from.nil? %> + <%= outgoing_message.incoming_message_followup.safe_mail_from %> of + <% end %> + <%= public_body_link(@info_request.public_body) %> + on <strong><%= simple_date(info_request_event.sent_at) %></strong> + <% elsif outgoing_message.status == 'ready' %> + wrote a follow up message, but it has <strong>not yet been sent</strong> <% else raise "unknown outgoing_message.status" %> <% end %> <% else raise "unknown outgoing_message.message_type" %> diff --git a/app/views/request/_followup.rhtml b/app/views/request/_followup.rhtml new file mode 100644 index 000000000..ef2f566fe --- /dev/null +++ b/app/views/request/_followup.rhtml @@ -0,0 +1,38 @@ +<div id="followup"> + +<% if (correspondence.class.to_s == 'IncomingMessage') + incoming_message = correspondence%> + + <h2>Send a follow up message + <% if !incoming_message.safe_mail_from.nil? %> + to <%= incoming_message.safe_mail_from %> + <% end %> + </h2> + + <p>If the public body has asked for clarifications about your request, + you can respond to them here. + + <% form_for(:outgoing_message, @outgoing_message) do |o| %> + <p> + <%= o.text_area :body, :rows => 10, :cols => 55 %> + </p> + + <p> + <strong>Privacy warning:</strong> Your follow up message, and any response + to it, will also be displayed publically on this website. + </p> + + <%= hidden_field_tag 'submitted_followup', 1 %> + <%= submit_tag "Send >>" %> + <% end %> + + <p> + <% if not @is_owning_user %> + (You will be asked to sign in as <%= user_link(@info_request.user) %>) + <% end %> + </p> + +<% end %> + +</div> + diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml index dd0dbd63b..6ab31321b 100644 --- a/app/views/request/show.rhtml +++ b/app/views/request/show.rhtml @@ -11,8 +11,8 @@ <p id="request_status"> <% if @status == 'awaiting' %> - Currently <strong>waiting for a response</strong> from <%= public_body_link(@info_request.public_body) %>. - Response must be made by <strong><%= simple_date(@date_response_required_by) %></strong>. + Currently <strong>waiting for a response</strong> from <%= public_body_link(@info_request.public_body) %>, + due by <strong><%= simple_date(@date_response_required_by) %></strong>. <% elsif @status == 'overdue' %> Currently <strong>overdue a response</strong> from <%= public_body_link(@info_request.public_body) %>. The diff --git a/app/views/request/show_response.rhtml b/app/views/request/show_response.rhtml index a7fa90e6f..98760440e 100644 --- a/app/views/request/show_response.rhtml +++ b/app/views/request/show_response.rhtml @@ -1,11 +1,15 @@ <% @title = "View and classify FOI response" %> -<%= foi_error_messages_for :incoming_message %> +<%= foi_error_messages_for :incoming_message, :outgoing_message %> <div id="show_response_view"> -<h2>New response to your request '<%= request_link @info_request %>'</h2> + <h2>New response to your request '<%= request_link @info_request %>'</h2> -<%= render :partial => 'correspondence', :locals => { :correspondence => @incoming_message } %> + <%= render :partial => 'correspondence', :locals => { :correspondence => @incoming_message } %> + + <div id="show_response_followup"> + <%= render :partial => 'followup', :locals => { :correspondence => @incoming_message } %> + </div> </div> <% if not @incoming_message.user_classified %> diff --git a/app/views/request_mailer/followup.rhtml b/app/views/request_mailer/followup.rhtml new file mode 100644 index 000000000..6de4b0397 --- /dev/null +++ b/app/views/request_mailer/followup.rhtml @@ -0,0 +1,8 @@ +<%= @outgoing_message.body %> + +-- + +Disclaimer: This message and all responses to it are public. Any reply that you +make will be published on the Internet. + +Sent using GovernmentSpy, a project of UKCOD, registered charity number 1076346. diff --git a/db/migrate/025_add_followup_to_outgoing_message.rb b/db/migrate/025_add_followup_to_outgoing_message.rb new file mode 100644 index 000000000..10fc7adcb --- /dev/null +++ b/db/migrate/025_add_followup_to_outgoing_message.rb @@ -0,0 +1,9 @@ +class AddFollowupToOutgoingMessage < ActiveRecord::Migration + def self.up + add_column :outgoing_messages, :incoming_message_followup_id, :integer + end + + def self.down + drop_column :outgoing_messages, :incoming_message_followup_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 30c9570ec..3632942d1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,7 +2,7 @@ # migrations feature of ActiveRecord to incrementally modify your database, and # then regenerate this schema definition. -ActiveRecord::Schema.define(:version => 24) do +ActiveRecord::Schema.define(:version => 25) do create_table "incoming_messages", :force => true do |t| t.column "info_request_id", :integer @@ -30,13 +30,14 @@ ActiveRecord::Schema.define(:version => 24) do end create_table "outgoing_messages", :force => true do |t| - t.column "info_request_id", :integer - t.column "body", :text - t.column "status", :string - t.column "message_type", :string - t.column "created_at", :datetime - t.column "updated_at", :datetime - t.column "last_sent_at", :datetime + t.column "info_request_id", :integer + t.column "body", :text + t.column "status", :string + t.column "message_type", :string + t.column "created_at", :datetime + t.column "updated_at", :datetime + t.column "last_sent_at", :datetime + t.column "incoming_message_followup_id", :integer end create_table "post_redirects", :force => true do |t| diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index 364a641dd..a0e317926 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -17,7 +17,7 @@ a:link { color: #0000ff; } a:visited { - color: #000099; + color: #551a8b; } a:active { color: #ff0000; @@ -291,6 +291,9 @@ table#list_requests .odd { float: right; width: 60%; } +#show_response_followup { + margin-top: 3em; +} /* / - about page */ diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 383be79f0..65a01ef09 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -158,21 +158,21 @@ describe RequestController, "when classifying an individual response" do fixtures :info_requests, :public_bodies, :users, :incoming_messages, :outgoing_messages # all needed as integrating views it "should require login" do - post :show_response, :incoming_message => { :contains_information => true }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message) + post :show_response, :incoming_message => { :contains_information => true }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message), :submitted_classify => 1 post_redirect = PostRedirect.get_last_post_redirect response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token) end it "should not classify response if logged in as wrong user" do session[:user_id] = users(:silly_name_user).id - post :show_response, :incoming_message => { :contains_information => true }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message) + post :show_response, :incoming_message => { :contains_information => true }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message), :submitted_classify => 1 response.should render_template('user/wrong_user') end it "should successfully classify response if logged in as user controlling request" do incoming_messages(:useless_incoming_message).user_classified.should == false session[:user_id] = users(:bob_smith_user).id - post :show_response, :incoming_message => { :contains_information => true }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message) + post :show_response, :incoming_message => { :contains_information => true }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message), :submitted_classify => 1 response.should redirect_to(:controller => 'request', :action => 'show', :id => info_requests(:fancy_dog_request)) incoming_messages(:useless_incoming_message).reload incoming_messages(:useless_incoming_message).user_classified.should == true @@ -20,6 +20,7 @@ Next ==== Let requester send follow-ups - but to which email address???!! aargh + - and how do we cope Alert somewhere if working days table not up to date Test it works if exim is down - e.g. not accepting connections |