aboutsummaryrefslogtreecommitdiffstats
path: root/spec/integration/admin_spec.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-06-20 10:46:57 +0100
committerSeb Bacon <seb.bacon@gmail.com>2012-06-20 10:46:57 +0100
commit6c4c822ef7a4491bf821326af779e5be9118c0a1 (patch)
tree39cf3564b1b2fb6be26499eda2a41be7ba59ad65 /spec/integration/admin_spec.rb
parentea977a0b9e86bc99a84de8577fa4ce1d304ac489 (diff)
parent08dac0261325cd757b7146f9626f3c7b48cc672c (diff)
Merge branch 'release/0.6'0.6
Conflicts: locale/bs/app.po locale/ca/app.po locale/cs/app.po locale/cy/app.po locale/de/app.po locale/en_IE/app.po locale/es/app.po locale/eu/app.po locale/fr/app.po locale/ga_IE/app.po locale/gl/app.po locale/hu_HU/app.po locale/id/app.po locale/pt_BR/app.po locale/sq/app.po locale/sr@latin/app.po spec/fixtures/locale/en/app.po
Diffstat (limited to 'spec/integration/admin_spec.rb')
-rw-r--r--spec/integration/admin_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/integration/admin_spec.rb b/spec/integration/admin_spec.rb
new file mode 100644
index 000000000..caf741749
--- /dev/null
+++ b/spec/integration/admin_spec.rb
@@ -0,0 +1,23 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+require "base64"
+
+describe "When administering the site" do
+ it "allows an admin to log in as another user" do
+ # First log in as Joe Admin
+ admin_user = users(:admin_user)
+ admin_user.email_confirmed = true
+ admin_user.save!
+ post_via_redirect "/profile/sign_in", :user_signin => {:email => admin_user.email, :password => "jonespassword"}
+ response.should be_success
+
+ # Now fetch the "log in as" link to log in as Bob
+ admin_username = MySociety::Config.get('ADMIN_USERNAME')
+ admin_password = MySociety::Config.get('ADMIN_PASSWORD')
+ get_via_redirect "/admin/user/login_as/#{users(:bob_smith_user).id}", nil, {
+ "Authorization" => "Basic " + Base64.encode64("#{admin_username}:#{admin_password}").strip
+ }
+ response.should be_success
+ session[:user_id].should == users(:bob_smith_user).id
+ end
+end