Skip to content

Commit

Permalink
Add allow list for management report
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-s-ccs committed May 2, 2023
1 parent 58aa17c commit ab35050
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def self.call(start_date, end_date)
end

def self.find_procurements(start_date, end_date)
Procurement.where(created_at: (start_date..(end_date + 1))).order(created_at: :desc)
Procurement.where(created_at: (start_date..(end_date + 1))).where.not(user_id: test_user_ids).order(created_at: :desc)
end

# rubocop:disable Metrics/AbcSize
Expand Down Expand Up @@ -104,5 +104,9 @@ def self.shortlisted_suppliers(procurement)
def self.helpers
@helpers ||= ActionController::Base.helpers
end

def self.test_user_ids
User.where(email: ENV.fetch('TEST_USER_EMAILS', '').split(',')).pluck(:id)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Feature: Service and selection and annual contract cost result in correct sub lot
Feature: Service selection and annual contract cost result in correct sub lot

Background: Navigate to the services page
Given I sign in and navigate to my account for 'RM6232'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,14 @@ Feature: Results validations
And I click on 'Continue'
Then I am on the 'Results' page

Scenario Outline: Contract name is blank
Given I click on '<save_button>'
Scenario: Contract name is blank
Given I click on 'Save and continue'
Then I should see the following error messages:
| Enter your contract name |

Examples:
| save_button |
| Save and continue |
# | Save and return to procurements dashboard |

Scenario: Contract name is taken
Given I have a procurement with the name 'Taken contract name'
And I enter 'Taken contract name' into the contract name field
And I click on 'Save and continue'
Then I should see the following error messages:
| This contract name is already in use |

# Some steps are commented out due to us not showing the state on the dahsboard anymore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
end

describe 'generate_csv' do
let(:test_users) { '' }
let(:user_1) { create(:user, :with_detail) }
let(:user_2) { create(:user) }

Expand All @@ -61,6 +62,7 @@
let(:generated_csv) { CSV.parse(management_report.management_report_csv.download, headers: true) }

before do
ENV['TEST_USER_EMAILS'] = test_users
buyer_detail
procurement_1
procurement_2
Expand Down Expand Up @@ -128,5 +130,23 @@
end
# rubocop:enable RSpec/MultipleExpectations
end

context 'when the buyer email is in the TEST_USER_EMAILS list' do
let(:test_users) { user_2.email }
let(:start_date) { 5.days.ago }
let(:end_date) { Time.zone.now }

let(:generated_csv) { CSV.parse(management_report.management_report_csv.download) }

it 'has the correct headers' do
expect(generated_csv.first).to eq ['Reference number', 'Contract name', 'Date created', 'Buyer organisation', 'Buyer organisation address', 'Buyer sector', 'Buyer contact name', 'Buyer contact job title', 'Buyer contact email address', 'Buyer contact telephone number', 'Buyer opted in to be contacted', 'Services', 'Regions', 'Annual contract cost', 'Lot', 'Shortlisted Suppliers']
end

it 'has the correct data' do
expect(generated_csv.length).to eq 3
expect(generated_csv[1][0..1] + generated_csv[1][3..]).to eq ['RM6232-000003-2022', 'Procurement 3', 'MyString', 'MyString, MyString, MyString, MyString SW1W 9SZ', 'Defence and Security', 'MyString', 'MyString', user_1.email, '="07500404040"', 'Yes', "E.1 Mechanical and Electrical Engineering Maintenance;\nG.1 Hard Landscaping Services;\nJ.1 Mail Services;\n", "UKI4 Inner London - East;\nUKI5 Outer London - East and North East;\n", '50,000,000.00', '1c', "Berge-Koepp;\nBernier, Luettgen and Bednar;\nBins, Yost and Donnelly;\nBlick, O'Kon and Larkin;\nBreitenberg-Mante;\nCummerata, Lubowitz and Ebert;\nGoyette Group;\nHarris LLC;\nHeidenreich Inc;\nLind, Stehr and Dickinson;\nLowe, Abernathy and Toy;\nMiller, Walker and Leffler;\nMuller Inc;\nRohan-Windler;\nSatterfield LLC;\nSchmeler Inc;\nSchmeler-Leffler;\nSchultz-Wilkinson;\nTerry-Greenholt;\nYost LLC;\nZboncak and Sons"]
expect(generated_csv[2][0..1] + generated_csv[2][3..]).to eq ['RM6232-000001-2022', 'Procurement 1', 'MyString', 'MyString, MyString, MyString, MyString SW1W 9SZ', 'Defence and Security', 'MyString', 'MyString', user_1.email, '="07500404040"', 'Yes', "E.1 Mechanical and Electrical Engineering Maintenance;\nE.2 Ventilation and air conditioning systems maintenance;\n", "UKI4 Inner London - East;\nUKI5 Outer London - East and North East;\n", '12,345.00', '2a', "Abshire, Schumm and Farrell;\nBrakus, Lueilwitz and Blanda;\nConn, Hayes and Lakin;\nDach Inc;\nFeest Group;\nHarber LLC;\nHudson, Spinka and Schuppe;\nJenkins, Price and White;\nKirlin-Glover;\nMetz Inc;\nMoore Inc;\nO'Reilly, Emmerich and Reichert;\nRoob-Kessler;\nSchulist-Wuckert;\nSkiles LLC;\nTorphy Inc;\nTremblay, Jacobi and Kozey;\nTurner-Pouros"]
end
end
end
end

0 comments on commit ab35050

Please sign in to comment.