aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2012-10-30 15:42:12 +0000
committerLouise Crow <louise.crow@gmail.com>2012-10-30 15:42:12 +0000
commit0fdc192db473ae022cbc4c129e0d9b0599adcf0e (patch)
tree618237bef5d65106ce16f92f5116e1bf6834d89b /spec/controllers
parent08d958981182aeb44eec5174e455ab41f60f9a10 (diff)
Pull out a bit of shared setup code.
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/admin_public_body_controller_spec.rb24
1 files changed, 11 insertions, 13 deletions
diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb
index be33802c5..c8563e0a4 100644
--- a/spec/controllers/admin_public_body_controller_spec.rb
+++ b/spec/controllers/admin_public_body_controller_spec.rb
@@ -166,6 +166,13 @@ describe AdminPublicBodyController, "when administering public bodies and paying
config['SKIP_ADMIN_AUTH'] = true
end
+ def setup_emergency_credentials(username, password)
+ config = MySociety::Config.load_default()
+ config['SKIP_ADMIN_AUTH'] = false
+ config['ADMIN_USERNAME'] = username
+ config['ADMIN_PASSWORD'] = password
+ @request.env["HTTP_AUTHORIZATION"] = ""
+ end
it "disallows non-authenticated users to do anything" do
@request.env["HTTP_AUTHORIZATION"] = ""
@@ -180,19 +187,14 @@ describe AdminPublicBodyController, "when administering public bodies and paying
config = MySociety::Config.load_default()
config['SKIP_ADMIN_AUTH'] = true
@request.env["HTTP_AUTHORIZATION"] = ""
-
n = PublicBody.count
post :destroy, { :id => public_bodies(:forlorn_public_body).id }
PublicBody.count.should == n - 1
session[:using_admin].should == 1
end
- it "doesn't let people with bad credentials log in" do
- config = MySociety::Config.load_default()
- config['SKIP_ADMIN_AUTH'] = false
- config['ADMIN_USERNAME'] = 'biz'
- config['ADMIN_PASSWORD'] = 'fuz'
- @request.env["HTTP_AUTHORIZATION"] = ""
+ it "doesn't let people with bad emergency account credentials log in" do
+ setup_emergency_credentials('biz', 'fuz')
n = PublicBody.count
basic_auth_login(@request, "baduser", "badpassword")
post :destroy, { :id => public_bodies(:forlorn_public_body).id }
@@ -201,12 +203,8 @@ describe AdminPublicBodyController, "when administering public bodies and paying
session[:using_admin].should == nil
end
- it "allows people with good credentials log in using HTTP Basic Auth" do
- config = MySociety::Config.load_default()
- config['SKIP_ADMIN_AUTH'] = false
- config['ADMIN_USERNAME'] = 'biz'
- config['ADMIN_PASSWORD'] = 'fuz'
- @request.env["HTTP_AUTHORIZATION"] = ""
+ it "allows people with good emergency account credentials log in using HTTP Basic Auth" do
+ setup_emergency_credentials('biz', 'fuz')
n = PublicBody.count
basic_auth_login(@request, "biz", "fuz")
post :show, { :id => public_bodies(:humpadink_public_body).id, :emergency => 1}