diff options
-rwxr-xr-x | app/helpers/link_to_helper.rb | 2 | ||||
-rw-r--r-- | app/views/admin_request/show.rhtml | 28 | ||||
-rw-r--r-- | spec/controllers/admin_request_controller_spec.rb | 5 | ||||
-rw-r--r-- | spec/fixtures/info_request_events.yml | 35 | ||||
-rw-r--r-- | spec/fixtures/info_requests.yml | 10 | ||||
-rw-r--r-- | spec/fixtures/outgoing_messages.yml | 11 | ||||
-rw-r--r-- | spec/helpers/link_to_helper_spec.rb | 32 |
7 files changed, 88 insertions, 35 deletions
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 16e37277b..cae17ebd3 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -118,7 +118,7 @@ module LinkToHelper def user_admin_link_for_request(request, external_text=nil, internal_text=nil) if request.is_external? - text = external_text ? external_text : request.user_name + " (external)" + text = external_text ? external_text : (request.external_user_name || _("Anonymous user")) + " (external)" else text = internal_text ? internal_text : request.user.name link_to(h(text), user_admin_url(request.user)) diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml index aac68ad2e..9d939eb35 100644 --- a/app/views/admin_request/show.rhtml +++ b/app/views/admin_request/show.rhtml @@ -11,14 +11,20 @@ <% if column.name == 'described_state' %> <strong>Calculated status:</strong> <%= @info_request.calculate_status %> <br/><strong>Initial request last sent at:</strong> <%=@info_request.date_initial_request_last_sent_at.to_date %> - <strong>Date response required by:</strong> <%= @info_request.date_response_required_by %> + <strong>Date response required by:</strong> <%= @info_request.date_response_required_by %> <strong>Very overdue after:</strong> <%= @info_request.date_very_overdue_after %> <% end %> <% if ![ 'allow_new_responses_from' ].include?(column.name) %> <br/> <% end %> <% end %> - <strong>Created by:</strong> <%= user_both_links(@info_request.user) %> + <strong>Created by:</strong> + <% if @info_request.is_external? %> + <%= @info_request.public_body.name %> on behalf of <%= (@info_request.user_name || _('an anonymous user'))%> (using API) + <% else %> + <%= user_both_links(@info_request.user) %> + <% end %> + <span> <span> (<%= link_to_function("move...", "$(this).up(1).childElements().invoke('toggle')") %>) @@ -30,7 +36,7 @@ </span> </span> <br> -<strong>Public authority:</strong> <%= public_body_both_links(@info_request.public_body) %> +<strong>Public authority:</strong> <%= public_body_both_links(@info_request.public_body) %> <span> <span> (<%= link_to_function("move...", "$(this).up(1).childElements().invoke('toggle')") %>) @@ -63,7 +69,7 @@ <% end %> <th>Actions</th> </tr> - + <% for info_request_event in @info_request.info_request_events.find(:all, :order => "created_at, id") %> <tr class="<%= cycle('odd', 'even') %>"> <td><%=h info_request_event.id %></td> @@ -102,7 +108,7 @@ <% end %> <th>Actions</th> </tr> - + <% for outgoing_message in @info_request.outgoing_messages.find(:all, :order => 'created_at') %> <tr class="<%= cycle('odd', 'even') %>"> <td><%=h outgoing_message.id %></td> @@ -110,8 +116,8 @@ <% if column == 'body' %> <td> - <div><%= simple_format( truncate(outgoing_message.body, :length => 400, - :omission => link_to_function("...", "$(this).up('td').childElements().invoke('toggle')") + <div><%= simple_format( truncate(outgoing_message.body, :length => 400, + :omission => link_to_function("...", "$(this).up('td').childElements().invoke('toggle')") )) %></div> <div style="display:none;"><%= simple_format( outgoing_message.body ) %></div> </td> @@ -143,15 +149,15 @@ <% end %> <th>Actions</th> </tr> - + <% for incoming_message in @info_request.incoming_messages.find(:all, :order => 'created_at') %> <tr class="<%= cycle('odd', 'even') %>" id="incoming-<%=incoming_message.id.to_s%>"> <td><%=h incoming_message.id %></td> <% for column in IncomingMessage.content_columns.map { |c| c.name } %> <% if column =~ /^cached_.*?$/ %> <td> - <div><%= simple_format( truncate(incoming_message.send(column), :length => 400, - :omission => link_to_function("...", "$(this).up('td').childElements().invoke('toggle')") + <div><%= simple_format( truncate(incoming_message.send(column), :length => 400, + :omission => link_to_function("...", "$(this).up('td').childElements().invoke('toggle')") )) %></div> <div style="display:none;"><%= simple_format( incoming_message.send(column) ) %></div> </td> @@ -183,7 +189,7 @@ <% end %> <th>Actions</th> </tr> - + <% for comment in @info_request.comments %> <tr class="<%= cycle('odd', 'even') %>"> <td><%=h comment.id %></td> diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 252818452..8a3934685 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -21,6 +21,11 @@ describe AdminRequestController, "when administering requests" do get :show, :id => info_requests(:fancy_dog_request) end + it 'shows an external public body with no username' do + get :show, :id => info_requests(:anonymous_external_request) + response.should be_success + end + it "edits a public body" do get :edit, :id => info_requests(:fancy_dog_request) end diff --git a/spec/fixtures/info_request_events.yml b/spec/fixtures/info_request_events.yml index e3e8a4460..c1a00ad47 100644 --- a/spec/fixtures/info_request_events.yml +++ b/spec/fixtures/info_request_events.yml @@ -16,7 +16,7 @@ silly_outgoing_message_event: created_at: 2007-10-14 10:41:12.686264 described_state: outgoing_message_id: 2 -useless_incoming_message_event: +useless_incoming_message_event: id: 902 params_yaml: "--- \n\ :incoming_message_id: 1\n" @@ -25,18 +25,18 @@ useless_incoming_message_event: created_at: 2007-11-13 18:09:20.042061 described_state: incoming_message_id: 1 -silly_comment_event: +silly_comment_event: id: 903 params_yaml: "--- \n\ :comment_id: 1\n" - incoming_message_id: - last_described_at: - described_state: + incoming_message_id: + last_described_at: + described_state: info_request_id: 101 comment_id: 1 - calculated_state: + calculated_state: event_type: comment - outgoing_message_id: + outgoing_message_id: created_at: 2008-08-12 23:05:12.500942 badger_outgoing_message_event: id: 904 @@ -98,11 +98,11 @@ another_comment_event: comment_id: 2 params_yaml: "--- \n\ :comment_id: 2\n" - incoming_message_id: - outgoing_message_id: - last_described_at: - described_state: - calculated_state: + incoming_message_id: + outgoing_message_id: + last_described_at: + described_state: + calculated_state: event_type: comment created_at: 2008-08-12 12:05:12.879634 @@ -160,3 +160,14 @@ external_outgoing_message_event: created_at: 2009-01-02 02:23:45.6789100 described_state: waiting_response calculated_state: waiting_response + +anonymous_external_outgoing_message_event: + id: 915 + params_yaml: "--- \n\ + :outgoing_message_id: 9\n" + outgoing_message_id: 9 + info_request_id: 110 + event_type: sent + created_at: 2009-01-03 02:23:45.6789100 + described_state: waiting_response + calculated_state: waiting_response diff --git a/spec/fixtures/info_requests.yml b/spec/fixtures/info_requests.yml index e4f2287c0..079a44cd0 100644 --- a/spec/fixtures/info_requests.yml +++ b/spec/fixtures/info_requests.yml @@ -88,3 +88,13 @@ external_request: described_state: waiting_response awaiting_description: false idhash: a1234567 +anonymous_external_request: + id: 110 + title: Anonymous request + url_title: anonymous_request + external_user_name: + external_url: http://www.example.org/request/anonymous_requesr + public_body_id: 2 + described_state: waiting_response + awaiting_description: false + idhash: 7654321a
\ No newline at end of file diff --git a/spec/fixtures/outgoing_messages.yml b/spec/fixtures/outgoing_messages.yml index 32b322bd7..55df8473e 100644 --- a/spec/fixtures/outgoing_messages.yml +++ b/spec/fixtures/outgoing_messages.yml @@ -97,3 +97,14 @@ external_outgoing_message: updated_at: 2009-01-12 01:56:58.586598 what_doing: normal_sort +anonymous_external_outgoing_message: + id: 9 + info_request_id: 110 + message_type: initial_request + status: sent + body: "I do not wish to reveal my name, but would like all your information." + last_sent_at: 2009-01-12 01:57:58.586598 + created_at: 2009-01-12 01:56:58.586598 + updated_at: 2009-01-12 01:56:58.586598 + what_doing: normal_sort + diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb index f11f2b5bb..9ec0afce1 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -1,11 +1,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -describe LinkToHelper do - +describe LinkToHelper do + include LinkToHelper - - describe 'when creating a url for a request' do - + + describe 'when creating a url for a request' do + before do @mock_request = mock_model(InfoRequest, :url_title => 'test_title') @old_filters = ActionController::Routing::Routes.filters @@ -15,15 +15,15 @@ describe LinkToHelper do ActionController::Routing::Routes.filters = @old_filters end - - it 'should return a path like /request/test_title' do + + it 'should return a path like /request/test_title' do request_url(@mock_request).should == '/request/test_title' end - - it 'should return a path including any extra parameters passed' do + + it 'should return a path including any extra parameters passed' do request_url(@mock_request, {:update_status => 1}).should == '/request/test_title?update_status=1' end - + end describe "when appending something to a URL" do @@ -37,5 +37,15 @@ describe LinkToHelper do main_url('/a?z=9%', '.json').should == 'http://test.host/a?z=9%' end end - + + describe 'when displaying a user admin link for a request' do + + it 'should return the text "An anonymous user (external)" in the case where there is no external username' do + info_request = mock_model(InfoRequest, :external_user_name => nil, + :is_external? => true) + user_admin_link_for_request(info_request).should == 'Anonymous user (external)' + end + + end + end |