diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/admin_raw_email_controller_spec.rb | 14 | ||||
-rw-r--r-- | spec/controllers/admin_request_controller_spec.rb | 28 | ||||
-rw-r--r-- | spec/integration/admin_spec.rb | 59 |
3 files changed, 53 insertions, 48 deletions
diff --git a/spec/controllers/admin_raw_email_controller_spec.rb b/spec/controllers/admin_raw_email_controller_spec.rb new file mode 100644 index 000000000..c1e939ee1 --- /dev/null +++ b/spec/controllers/admin_raw_email_controller_spec.rb @@ -0,0 +1,14 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe AdminRawEmailController do + + describe :show do + + it 'renders the show template' do + raw_email = FactoryGirl.create(:incoming_message).raw_email + get :show, :id => raw_email.id + end + + end + +end diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 0d84c6146..51e4a6dbe 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -77,34 +77,6 @@ describe AdminRequestController, "when administering the holding pen" do load_raw_emails_data end - it "shows a rejection reason for an incoming message from an invalid address" do - ir = info_requests(:fancy_dog_request) - ir.allow_new_responses_from = 'authority_only' - ir.handle_rejected_responses = 'holding_pen' - ir.save! - receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "frob@nowhere.com") - get :show_raw_email, :id => InfoRequest.holding_pen_request.get_last_public_response.raw_email.id - response.should contain "Only the authority can reply to this request" - end - - it "guesses a misdirected request" do - ir = info_requests(:fancy_dog_request) - ir.handle_rejected_responses = 'holding_pen' - ir.allow_new_responses_from = 'authority_only' - ir.save! - mail_to = "request-#{ir.id}-asdfg@example.com" - receive_incoming_mail('incoming-request-plain.email', mail_to) - interesting_email = InfoRequest.holding_pen_request.get_last_public_response.raw_email.id - # now we add another message to the queue, which we're not interested in - receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "") - InfoRequest.holding_pen_request.incoming_messages.length.should == 2 - get :show_raw_email, :id => interesting_email - response.should contain "Could not identify the request" - assigns[:info_requests][0].should == ir - end - - - it "shows a suitable default 'your email has been hidden' message" do ir = info_requests(:fancy_dog_request) get :show, :id => ir.id diff --git a/spec/integration/admin_spec.rb b/spec/integration/admin_spec.rb index ceb010143..c9135336d 100644 --- a/spec/integration/admin_spec.rb +++ b/spec/integration/admin_spec.rb @@ -5,17 +5,15 @@ describe "When administering the site" do before do AlaveteliConfiguration.stub!(:skip_admin_auth).and_return(false) + confirm(:admin_user) + @admin = login(:admin_user) end it "allows an admin to log in as another user" do - # First log in as Joe Admin - confirm(:admin_user) - admin = login(:admin_user) - - # Now fetch the "log in as" link to log in as Bob - admin.get_via_redirect "/en/admin/user/login_as/#{users(:bob_smith_user).id}" - admin.response.should be_success - admin.session[:user_id].should == users(:bob_smith_user).id + # post to the "log in as" url to log in as Bob + @admin.post_via_redirect "/en/admin/users/#{users(:bob_smith_user).id}/login_as" + @admin.response.should be_success + @admin.session[:user_id].should == users(:bob_smith_user).id end it 'does not allow a non-admin user to login as another user' do @@ -26,8 +24,6 @@ describe "When administering the site" do end it "allows redelivery of an incoming message to a closed request" do - confirm(:admin_user) - admin = login(:admin_user) ir = info_requests(:fancy_dog_request) close_request(ir) InfoRequest.holding_pen_request.incoming_messages.length.should == 0 @@ -36,10 +32,9 @@ describe "When administering the site" do InfoRequest.holding_pen_request.incoming_messages.length.should == 1 new_im = InfoRequest.holding_pen_request.incoming_messages[0] ir.incoming_messages.length.should == 1 - post_params = {'redeliver_incoming_message_id' => new_im.id, - 'url_title' => ir.url_title} - admin.post '/en/admin/incoming/redeliver', post_params - admin.response.location.should == 'http://www.example.com/en/admin/requests/101' + post_params = { 'url_title' => ir.url_title } + @admin.post "/en/admin/incoming_messages/#{new_im.id}/redeliver", post_params + @admin.response.location.should == 'http://www.example.com/en/admin/requests/101' ir = InfoRequest.find_by_url_title(ir.url_title) ir.incoming_messages.length.should == 2 @@ -47,8 +42,6 @@ describe "When administering the site" do end it "allows redelivery of an incoming message to more than one request" do - confirm(:admin_user) - admin = login(:admin_user) ir1 = info_requests(:fancy_dog_request) close_request(ir1) @@ -60,15 +53,41 @@ describe "When administering the site" do InfoRequest.holding_pen_request.incoming_messages.length.should == 1 new_im = InfoRequest.holding_pen_request.incoming_messages[0] - post_params = {'redeliver_incoming_message_id' => new_im.id, - 'url_title' => "#{ir1.url_title},#{ir2.url_title}"} - admin.post '/en/admin/incoming/redeliver', post_params + post_params = { 'url_title' => "#{ir1.url_title},#{ir2.url_title}" } + @admin.post "/en/admin/incoming_messages/#{new_im.id}/redeliver", post_params ir1.reload ir1.incoming_messages.length.should == 2 ir2.reload ir2.incoming_messages.length.should == 2 - admin.response.location.should == 'http://www.example.com/en/admin/requests/106' + @admin.response.location.should == 'http://www.example.com/en/admin/requests/106' InfoRequest.holding_pen_request.incoming_messages.length.should == 0 end + describe 'when administering the holding pen' do + + it "shows a rejection reason for an incoming message from an invalid address" do + ir = FactoryGirl.create(:info_request, :allow_new_responses_from => 'authority_only', + :handle_rejected_responses => 'holding_pen') + receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "frob@nowhere.com") + raw_email = InfoRequest.holding_pen_request.get_last_public_response.raw_email + @admin.get "/en/admin/raw_emails/#{raw_email.id}" + @admin.response.should contain "Only the authority can reply to this request" + end + + it "guesses a misdirected request" do + ir = FactoryGirl.create(:info_request, :allow_new_responses_from => 'authority_only', + :handle_rejected_responses => 'holding_pen') + mail_to = "request-#{ir.id}-asdfg@example.com" + receive_incoming_mail('incoming-request-plain.email', mail_to) + interesting_email = InfoRequest.holding_pen_request.get_last_public_response.raw_email + # now we add another message to the queue, which we're not interested in + receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "") + InfoRequest.holding_pen_request.incoming_messages.length.should == 2 + @admin.get "/en/admin/raw_emails/#{interesting_email.id}" + @admin.response.should contain "Could not identify the request" + @admin.response.should contain ir.title + end + + + end end |