Skip to content

Commit

Permalink
Applys decommision filter to exports.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Scherz committed Jun 18, 2024
1 parent 0ab7e6f commit 9a3e179
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions exports/software_records.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
class SoftwareRecords < ApplicationRecord
def software_records
file = "#{Dir.pwd}/public/software_records.csv"
# software_records = SoftwareRecords.all
# software_records = SoftwareRecords.all
software_records = SoftwareRecord.joins(:status).where.not(statuses: { status_type: 'Decommissioned' })

headers = [
'Software Record', 'Description', 'Status', 'Created on', 'Software Type',
'Authentication Type', 'Vendor Record', 'Departments', 'Date Implemented',
Expand Down
17 changes: 14 additions & 3 deletions spec/controllers/software_records_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,29 @@ def sign_in_user(admin)
end
end

# context 'when filter_by is software_types and software_type_filter is provided' do
# it 'assigns filtered software records to @software_records' do
# software_record = SoftwareRecord.create! valid_attributes
# get :list_road_map, params: { filter_by: 'software_types', software_type_filter: SoftwareType.first.id }, session: valid_session
# expect(assigns(:software_records)).to include(software_record)
# end
# end

context 'when filter_by is software_types and software_type_filter is provided' do
let!(:software_type) { SoftwareType.create!(title: 'Test Type', status_type: 'Decommissioned') }

let!(:software_record) { SoftwareRecord.create!(valid_attributes.merge(software_type:)) }

it 'assigns filtered software records to @software_records' do
software_record = SoftwareRecord.create! valid_attributes
get :list_road_map, params: { filter_by: 'software_types', software_type_filter: SoftwareType.first.id }
get :list_road_map, params: { filter_by: 'software_types', software_type_filter: software_type.id }
expect(assigns(:software_records)).to include(software_record)
end
end

context 'when filter_by is not software_types' do
it 'assigns all software records to @software_records' do
software_record = SoftwareRecord.create! valid_attributes
get :list_road_map, params: { filter_by: 'other_filter' }
get :list_road_map, params: { filter_by: 'other_filter' }, session: valid_session
expect(assigns(:software_records)).to include(software_record)
end
end
Expand Down

0 comments on commit 9a3e179

Please sign in to comment.