aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/views/request/show.rhtml16
-rw-r--r--spec/controllers/request_controller_spec.rb116
2 files changed, 114 insertions, 18 deletions
diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml
index 0da4d9827..cf1f971d9 100644
--- a/app/views/request/show.rhtml
+++ b/app/views/request/show.rhtml
@@ -50,7 +50,7 @@
<p id="request_status" class="request_icon_line icon_<%= @info_request.calculate_status %>">
<% if @info_request.awaiting_description %>
- <% if @is_owning_user %>
+ <% if @is_owning_user && !@info_request.is_external? %>
<%= _('Please <strong>answer the question above</strong> so we know whether the ')%>
<%= MySociety::Format.fancy_pluralize(@new_responses_count, 'recent response contains', 'recent responses contain') %> <%= _('useful information.') %>
<% else %>
@@ -87,8 +87,10 @@
<%= _('Response to this request is <strong>long overdue</strong>.') %>
<%= _('By law, under all circumstances, {{public_body_link}} should have responded by now',:public_body_link => public_body_link(@info_request.public_body)) %>
(<%= _('<a href="%s">details</a>') % [help_requesting_path + '#quickly_response'] %>).
- <%= _('You can <strong>complain</strong> by') %>
- <%= link_to _("requesting an internal review"), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "?internal_review=1#followup" %>.
+ <% if !@info_request.is_external? %>
+ <%= _('You can <strong>complain</strong> by') %>
+ <%= link_to _("requesting an internal review"), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "?internal_review=1#followup" %>.
+ <% end %>
<% elsif @status == 'not_held' %>
<%= public_body_link(@info_request.public_body) %> <%= _('<strong>did not have</strong> the information requested.') %>
<% elsif @status == 'rejected' %>
@@ -98,14 +100,16 @@
<% elsif @status == 'partially_successful' %>
<%= _('The request was <strong>partially successful</strong>.') %>
<% elsif @status == 'waiting_clarification' %>
- <% if @is_owning_user %>
+ <% if @is_owning_user && !@info_request.is_external? %>
<%=h @info_request.public_body.name %> <%= _('is <strong>waiting for your clarification</strong>.') %>
<%= _('Please') %>
<%= link_to _("send a follow up message"), respond_to_last_url(@info_request) + '#followup' %>.
<% else %>
<%= _('The request is <strong>waiting for clarification</strong>.') %>
- <%= _('If you are {{user_link}}, please',:user_link=>user_link_for_request(@info_request)) %>
- <%= link_to _("sign in"), signin_url(:r => request.request_uri) %> <%= _('to send a follow up message.') %>
+ <% if !@info_request.is_external? %>
+ <%= _('If you are {{user_link}}, please',:user_link=>user_link_for_request(@info_request)) %>
+ <%= link_to _("sign in"), signin_url(:r => request.request_uri) %> <%= _('to send a follow up message.') %>
+ <% end %>
<% end %>
<% elsif @status == 'gone_postal' %>
<%= _('The authority would like to / has <strong>responded by post</strong> to this request.') %>
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index c0dfffc74..0ff795029 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -238,18 +238,63 @@ describe RequestController, "when showing one request" do
response.should have_tag('div#owner_actions')
end
- describe 'if the request is awaiting description' do
+ describe 'when the request is being viewed by an admin' do
+
+ describe 'if the request is awaiting description' do
+
+ before do
+ dog_request = info_requests(:fancy_dog_request)
+ dog_request.awaiting_description = true
+ dog_request.save!
+ end
+
+ it 'should show the describe state form' do
+ get :show, { :url_title => 'why_do_you_have_such_a_fancy_dog' },
+ { :user_id => users(:admin_user).id }
+ response.should have_tag('div.describe_state_form')
+ end
+
+ it 'should ask the user to use the describe state from' do
+ get :show, { :url_title => 'why_do_you_have_such_a_fancy_dog' },
+ { :user_id => users(:admin_user).id }
+ response.should have_tag('p#request_status', :text => /answer the question above/)
+ end
- before do
- dog_request = info_requests(:fancy_dog_request)
- dog_request.awaiting_description = true
- dog_request.save!
end
- it 'should show the describe state form' do
- get :show, { :url_title => 'why_do_you_have_such_a_fancy_dog' },
- { :user_id => users(:admin_user).id }
- response.should have_tag('div.describe_state_form')
+ describe 'if the request is waiting for a response and very overdue' do
+
+ before do
+ dog_request = info_requests(:fancy_dog_request)
+ dog_request.awaiting_description = false
+ dog_request.described_state = 'waiting_response'
+ dog_request.save!
+ dog_request.calculate_status.should == 'waiting_response_very_overdue'
+ end
+
+ it 'should give a link to requesting an internal review' do
+ get :show, { :url_title => 'why_do_you_have_such_a_fancy_dog' },
+ { :user_id => users(:admin_user).id }
+ response.should have_tag('p#request_status', :text =>/requesting an internal review/)
+ end
+
+ end
+
+ describe 'if the request is waiting clarification' do
+
+ before do
+ dog_request = info_requests(:fancy_dog_request)
+ dog_request.awaiting_description = false
+ dog_request.described_state = 'waiting_clarification'
+ dog_request.save!
+ dog_request.calculate_status.should == 'waiting_clarification'
+ end
+
+ it 'should give a link to make a followup' do
+ get :show, { :url_title => 'why_do_you_have_such_a_fancy_dog' },
+ { :user_id => users(:admin_user).id }
+ response.should have_tag('p#request_status a', :text =>/send a follow up message/)
+ end
end
end
@@ -270,10 +315,14 @@ describe RequestController, "when showing one request" do
end
- describe 'when viewing as an admin user' do
+ describe 'when the request is being viewed by an admin' do
- it 'should be successful' do
+ def make_request
get :show, { :url_title => 'balalas' }, { :user_id => users(:admin_user).id }
+ end
+
+ it 'should be successful' do
+ make_request
response.should be_success
end
@@ -286,10 +335,53 @@ describe RequestController, "when showing one request" do
end
it 'should not show the describe state form' do
- get :show, { :url_title => 'balalas' }, { :user_id => users(:admin_user).id }
+ make_request
response.should_not have_tag('div.describe_state_form')
end
+ it 'should not ask the user to use the describe state form' do
+ make_request
+ response.should_not have_tag('p#request_status', :text => /answer the question above/)
+ end
+
+ end
+
+ describe 'if the request is waiting for a response and very overdue' do
+
+ before do
+ external_request = info_requests(:external_request)
+ external_request.awaiting_description = false
+ external_request.described_state = 'waiting_response'
+ external_request.save!
+ external_request.calculate_status.should == 'waiting_response_very_overdue'
+ end
+
+ it 'should not give a link to requesting an internal review' do
+ make_request
+ response.should_not have_tag('p#request_status', :text =>/requesting an internal review/)
+ end
+ end
+
+ describe 'if the request is waiting clarification' do
+
+ before do
+ external_request = info_requests(:external_request)
+ external_request.awaiting_description = false
+ external_request.described_state = 'waiting_clarification'
+ external_request.save!
+ external_request.calculate_status.should == 'waiting_clarification'
+ end
+
+ it 'should not give a link to make a followup' do
+ make_request
+ response.should_not have_tag('p#request_status a', :text =>/send a follow up message/)
+ end
+
+ it 'should not give a link to sign in (in the request status paragraph)' do
+ make_request
+ response.should_not have_tag('p#request_status a', :text => /sign in/)
+ end
+
end
end