aboutsummaryrefslogtreecommitdiffstats
path: root/spec/integration
diff options
context:
space:
mode:
Diffstat (limited to 'spec/integration')
-rw-r--r--spec/integration/admin_public_body_edit_spec.rb10
-rw-r--r--spec/integration/admin_spec.rb61
-rw-r--r--spec/integration/alaveteli_dsl.rb19
-rw-r--r--spec/integration/download_request_spec.rb8
-rw-r--r--spec/integration/errors_spec.rb5
-rw-r--r--spec/integration/view_request_spec.rb2
6 files changed, 61 insertions, 44 deletions
diff --git a/spec/integration/admin_public_body_edit_spec.rb b/spec/integration/admin_public_body_edit_spec.rb
index 613793dd4..aeec3e65a 100644
--- a/spec/integration/admin_public_body_edit_spec.rb
+++ b/spec/integration/admin_public_body_edit_spec.rb
@@ -18,7 +18,7 @@ describe 'Editing a Public Body' do
end
it 'can edit the default locale' do
- @admin.visit admin_body_edit_path(@body)
+ @admin.visit edit_admin_body_path(@body)
@admin.fill_in 'public_body_name__en', :with => 'New Quango EN'
@admin.click_button 'Save'
@@ -29,7 +29,7 @@ describe 'Editing a Public Body' do
it 'can add a translation for a single locale' do
expect(@body.find_translation_by_locale('fr')).to be_nil
- @admin.visit admin_body_edit_path(@body)
+ @admin.visit edit_admin_body_path(@body)
@admin.fill_in 'public_body_translations_attributes_fr_name__fr', :with => 'New Quango FR'
@admin.click_button 'Save'
@@ -40,19 +40,19 @@ describe 'Editing a Public Body' do
end
it 'can add a translation for multiple locales', :focus => true do
- @admin.visit admin_body_edit_path(@body)
+ @admin.visit edit_admin_body_path(@body)
@admin.fill_in 'public_body_name__en', :with => 'New Quango EN'
@admin.click_button 'Save'
# Add FR translation
expect(@body.find_translation_by_locale('fr')).to be_nil
- @admin.visit admin_body_edit_path(@body)
+ @admin.visit edit_admin_body_path(@body)
@admin.fill_in 'public_body_translations_attributes_fr_name__fr', :with => 'New Quango FR'
@admin.click_button 'Save'
# Add ES translation
expect(@body.find_translation_by_locale('es')).to be_nil
- @admin.visit admin_body_edit_path(@body)
+ @admin.visit edit_admin_body_path(@body)
@admin.fill_in 'public_body_translations_attributes_es_name__es', :with => 'New Quango ES'
@admin.click_button 'Save'
diff --git a/spec/integration/admin_spec.rb b/spec/integration/admin_spec.rb
index 8e6351d2c..bdd6e9d8c 100644
--- a/spec/integration/admin_spec.rb
+++ b/spec/integration/admin_spec.rb
@@ -5,29 +5,25 @@ 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
robin = login(:robin_user)
- robin.get_via_redirect "/en/admin/user/login_as/#{users(:bob_smith_user).id}"
+ robin.post_via_redirect "/en/admin/users/#{users(:bob_smith_user).id}/login_as"
robin.response.should be_success
robin.session[:user_id].should_not == users(:bob_smith_user).id
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/request/show/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/request/show/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
diff --git a/spec/integration/alaveteli_dsl.rb b/spec/integration/alaveteli_dsl.rb
index 1d56abbdf..370628d98 100644
--- a/spec/integration/alaveteli_dsl.rb
+++ b/spec/integration/alaveteli_dsl.rb
@@ -21,7 +21,7 @@ module AlaveteliDsl
response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token)
follow_redirect!
response.should render_template("user/sign")
- response.body.should match(/To send your FOI request, please sign in or make a new account./)
+ response.body.should match(/To send your FOI request, create an account or sign in/)
end
end
@@ -33,15 +33,16 @@ def login(user)
sess.reset!
sess.extend(AlaveteliDsl)
- if user.is_a? User
- u = user
- else
- u = users(user)
- end
+ u = user.is_a?(User) ? user : users(user)
+
sess.visit signin_path
- sess.fill_in "Your e-mail:", :with => u.email
- sess.fill_in "Password:", :with => "jonespassword"
- sess.click_button "Sign in"
+
+ sess.within '#signin_form' do
+ sess.fill_in "Your e-mail:", :with => u.email
+ sess.fill_in "Password:", :with => "jonespassword"
+ sess.click_button "Sign in"
+ end
+
assert sess.session[:user_id] == u.id
end
end
diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb
index 638198cde..48b42b11d 100644
--- a/spec/integration/download_request_spec.rb
+++ b/spec/integration/download_request_spec.rb
@@ -56,7 +56,7 @@ describe 'when making a zipfile available' do
admin = login(FactoryGirl.create(:admin_user))
post_data = {:incoming_message => {:prominence => 'requester_only',
:prominence_reason => 'boring'}}
- admin.post_via_redirect "/en/admin/incoming/update/#{info_request.incoming_messages.first.id}", post_data
+ admin.put_via_redirect "/en/admin/incoming_messages/#{info_request.incoming_messages.first.id}", post_data
admin.response.should be_success
# Admin retains the requester only things
@@ -104,7 +104,7 @@ describe 'when making a zipfile available' do
post_data = {:outgoing_message => {:prominence => 'requester_only',
:prominence_reason => 'boring',
:body => 'Some information please'}}
- admin.post_via_redirect "/en/admin/outgoing/update/#{info_request.outgoing_messages.first.id}", post_data
+ admin.put_via_redirect "/en/admin/outgoing_messages/#{info_request.outgoing_messages.first.id}", post_data
admin.response.should be_success
# Admin retains the requester only things
@@ -237,7 +237,7 @@ describe 'when making a zipfile available' do
admin = login(FactoryGirl.create(:admin_user))
post_data = {:incoming_message => {:prominence => 'requester_only',
:prominence_reason => 'boring'}}
- admin.post_via_redirect "/en/admin/incoming/update/#{info_request.incoming_messages.first.id}", post_data
+ admin.put_via_redirect "/en/admin/incoming_messages/#{info_request.incoming_messages.first.id}", post_data
admin.response.should be_success
# Admin retains the requester only things
@@ -285,7 +285,7 @@ describe 'when making a zipfile available' do
post_data = {:outgoing_message => {:prominence => 'requester_only',
:prominence_reason => 'boring',
:body => 'Some information please'}}
- admin.post_via_redirect "/en/admin/outgoing/update/#{info_request.outgoing_messages.first.id}", post_data
+ admin.put_via_redirect "/en/admin/outgoing_messages/#{info_request.outgoing_messages.first.id}", post_data
admin.response.should be_success
# Admin retains the requester only things
diff --git a/spec/integration/errors_spec.rb b/spec/integration/errors_spec.rb
index 4fa12fb21..39f1279ce 100644
--- a/spec/integration/errors_spec.rb
+++ b/spec/integration/errors_spec.rb
@@ -59,7 +59,6 @@ describe "When errors occur" do
response.should render_template('general/exception_caught')
response.code.should == '404'
response.body.should match("Sorry, we couldn't find that page")
- response.body.should match(%Q(invalid value for Integer))
end
# it 'should handle non utf-8 parameters' do
@@ -76,7 +75,6 @@ describe "When errors occur" do
InfoRequest.stub!(:find_by_url_title!).and_raise("An example error")
get("/request/example")
response.should render_template('general/exception_caught')
- response.body.should match('An example error')
response.code.should == "500"
end
@@ -111,7 +109,6 @@ describe "When errors occur" do
get("/es/request/example")
response.should render_template('general/exception_caught')
response.body.should match('Lo sentimos, hubo un problema procesando esta página')
- response.body.should match('An example error')
end
it "should render a 403 with text body for attempts at directory listing for attachments" do
@@ -136,7 +133,7 @@ describe "When errors occur" do
it 'should show a full trace for general errors' do
InfoRequest.stub!(:find).and_raise("An example error")
- get("/admin/request/show/333")
+ get("/admin/requests/333")
response.body.should have_selector('div[id=traces]')
response.body.should match('An example error')
end
diff --git a/spec/integration/view_request_spec.rb b/spec/integration/view_request_spec.rb
index eecb984f5..4d04c97d7 100644
--- a/spec/integration/view_request_spec.rb
+++ b/spec/integration/view_request_spec.rb
@@ -33,7 +33,7 @@ describe "When viewing requests" do
# Admin makes the incoming message requester only
post_data = {:incoming_message => {:prominence => 'hidden',
:prominence_reason => 'boring'}}
- admin.post_via_redirect "/admin/incoming/update/#{info_request.incoming_messages.first.id}", post_data
+ admin.put_via_redirect "/admin/incoming_messages/#{info_request.incoming_messages.first.id}", post_data
admin.response.should be_success
cache_directories_exist?(info_request).should be_false