Skip to content

Commit

Permalink
Merge branch 'stub-spec-config' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Mar 13, 2024
2 parents 41b57aa + 7b68df6 commit 90217d6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
27 changes: 12 additions & 15 deletions spec/controllers/admin_public_body_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -753,21 +753,18 @@

describe "when administering public bodies and paying attention to authentication" do
before do
config = MySociety::Config.load_default
config['SKIP_ADMIN_AUTH'] = false
allow(AlaveteliConfiguration).to receive(:skip_admin_auth).
and_return(false)
basic_auth_login @request
end

after do
config = MySociety::Config.load_default
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
allow(AlaveteliConfiguration).to receive(:skip_admin_auth).
and_return(false)
allow(AlaveteliConfiguration).to receive(:admin_username).
and_return(username)
allow(AlaveteliConfiguration).to receive(:admin_password).
and_return(password)
@request.env["HTTP_AUTHORIZATION"] = ""
end

Expand All @@ -782,8 +779,8 @@ def setup_emergency_credentials(username, password)
end

it "skips admin authorisation when SKIP_ADMIN_AUTH set" do
config = MySociety::Config.load_default
config['SKIP_ADMIN_AUTH'] = true
allow(AlaveteliConfiguration).to receive(:skip_admin_auth).
and_return(true)
@request.env["HTTP_AUTHORIZATION"] = ""
n = PublicBody.count
post :destroy, params: { id: public_bodies(:forlorn_public_body).id }
Expand Down Expand Up @@ -871,8 +868,8 @@ def setup_emergency_credentials(username, password)
end

it 'returns the REMOTE_USER value from the request environment when skipping admin auth' do
config = MySociety::Config.load_default
config['SKIP_ADMIN_AUTH'] = true
allow(AlaveteliConfiguration).to receive(:skip_admin_auth).
and_return(true)
@request.env["HTTP_AUTHORIZATION"] = ""
@request.env["REMOTE_USER"] = "i_am_admin"
post :show, params: { id: public_bodies(:humpadink_public_body).id }
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/general_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
end

it "should render the front page with default language and ignore the browser setting" do
config = MySociety::Config.load_default
config['USE_DEFAULT_BROWSER_LANGUAGE'] = false
allow(AlaveteliConfiguration).to receive(:use_default_browser_language).
and_return(false)
accept_language = "en-GB,en-US;q=0.8,en;q=0.6"
request.env['HTTP_ACCEPT_LANGUAGE'] = accept_language
with_default_locale("es") do
Expand All @@ -126,8 +126,8 @@
end

it "should render the front page with browser-selected language when there's no default set" do
config = MySociety::Config.load_default
config['USE_DEFAULT_BROWSER_LANGUAGE'] = true
allow(AlaveteliConfiguration).to receive(:use_default_browser_language).
and_return(true)
accept_language = "es-ES,en-GB,en-US;q=0.8,en;q=0.6"
request.env['HTTP_ACCEPT_LANGUAGE'] = accept_language
get :frontpage
Expand Down
7 changes: 4 additions & 3 deletions spec/integration/statistics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

RSpec.describe "Site statistics" do
before :each do
config = MySociety::Config.load_default
config['MINIMUM_REQUESTS_FOR_STATISTICS'] = 1
config['PUBLIC_BODY_STATISTICS_PAGE'] = true
allow(AlaveteliConfiguration).to receive(:minimum_requests_for_statistics).
and_return(1)
allow(AlaveteliConfiguration).to receive(:public_body_statistics_page).
and_return(true)
end

describe "for public bodies" do
Expand Down
6 changes: 2 additions & 4 deletions spec/lib/alaveteli_text_masker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@

context 'applying masks to PDF' do
def pdf_replacement_test(use_ghostscript_compression)
config = MySociety::Config.load_default
previous = config['USE_GHOSTSCRIPT_COMPRESSION']
config['USE_GHOSTSCRIPT_COMPRESSION'] = use_ghostscript_compression
allow(AlaveteliConfiguration).to receive(:use_ghostscript_compression).
and_return(use_ghostscript_compression)
orig_pdf = load_file_fixture('tfl.pdf')
pdf = orig_pdf.dup

Expand All @@ -100,7 +99,6 @@ def pdf_replacement_test(use_ghostscript_compression)
masked_text = MailHandler.get_attachment_text_one_file('application/pdf', result)
expect(masked_text).not_to match(/foi@tfl.gov.uk/)
expect(masked_text).to match(/xxx@xxx.xxx.xx/)
config['USE_GHOSTSCRIPT_COMPRESSION'] = previous
end

it "replaces everything in PDF files using pdftk" do
Expand Down

0 comments on commit 90217d6

Please sign in to comment.