From bb953daaf4502f4030109a1dc9866c88c1436e1c Mon Sep 17 00:00:00 2001 From: Thomas Scherz Date: Tue, 9 Jul 2024 11:58:05 -0400 Subject: [PATCH] Adds Decommissioned as a status. (#371) * Adds Decommissioned as a status. * Adds decommissioned filtering to exports. * Applys decommision filter to exports. * Updates rails to version 6.1.7.8 * Removes custome edit for decommission. * Adds test for decommissioned. * Improves test coverage for sofware_records. * Adds view to decommissioned list. --------- Co-authored-by: Thomas Scherz --- Gemfile.lock | 18 +-- app/controllers/front_controller.rb | 6 +- .../software_records_controller.rb | 48 ++++-- app/views/shared/_dashboard_menu.html.erb | 9 +- .../list_decommissioned.html.erb | 60 +++++++ app/views/statuses/_form.html.erb | 6 +- config/routes.rb | 3 + db/seeds.rb | 3 +- exports/software_records.rb | 3 +- lib/tasks/create_decommissioned.rake | 10 ++ .../software_records_controller_spec.rb | 146 +++++++++++++++--- spec/routing/software_records_routing_spec.rb | 8 + .../list_decommissioned.html.erb_spec.rb | 82 ++++++++++ 13 files changed, 355 insertions(+), 47 deletions(-) create mode 100644 app/views/software_records/list_decommissioned.html.erb create mode 100644 lib/tasks/create_decommissioned.rake create mode 100644 spec/views/software_records/list_decommissioned.html.erb_spec.rb diff --git a/Gemfile.lock b/Gemfile.lock index 4948064c..8d0cc90b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -176,11 +176,10 @@ GEM matrix (0.4.2) method_source (1.1.0) mini_mime (1.1.5) - minitest (5.24.0) + minitest (5.24.1) msgpack (1.7.2) - mutex_m (0.2.0) mysql2 (0.5.6) - net-imap (0.4.13) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) @@ -265,7 +264,7 @@ GEM responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.3.0) + rexml (3.3.1) strscan rspec-core (3.13.0) rspec-support (~> 3.13.0) @@ -299,12 +298,12 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.31.3) parser (>= 3.3.1.0) - rubocop-rails (2.25.0) + rubocop-rails (2.25.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (3.0.1) + rubocop-rspec (3.0.2) rubocop (~> 1.61) ruby-progressbar (1.13.0) rubyzip (2.3.2) @@ -359,15 +358,14 @@ GEM sqlite3 (1.7.3-x86-linux) sqlite3 (1.7.3-x86_64-darwin) sqlite3 (1.7.3-x86_64-linux) - sshkit (1.22.2) + sshkit (1.23.0) base64 - mutex_m net-scp (>= 1.1.2) net-sftp (>= 2.1.2) net-ssh (>= 2.8.0) strscan (3.1.0) thor (1.3.1) - tilt (2.3.0) + tilt (2.4.0) timeout (0.4.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) @@ -384,7 +382,7 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - websocket (1.2.10) + websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) diff --git a/app/controllers/front_controller.rb b/app/controllers/front_controller.rb index 15e45f93..859d015b 100644 --- a/app/controllers/front_controller.rb +++ b/app/controllers/front_controller.rb @@ -69,8 +69,10 @@ def search @parameter = params[:search].downcase search_term = "%#{@parameter}%" - software_records_columns = SoftwareRecord.columns.map { |column| "lower(#{column.name}) LIKE :search" } - @softwarerecords_results = SoftwareRecord.where(software_records_columns.join(' OR '), search: search_term) + software_records_columns = SoftwareRecord.columns.map { |column| "lower(software_records.#{column.name}) LIKE :search" } + @softwarerecords_results = SoftwareRecord.joins(:status) + .where.not(statuses: { status_type: 'Decommissioned' }) + .where(software_records_columns.join(' OR '), search: search_term) vendor_records_columns = VendorRecord.columns.map { |column| "lower(#{column.name}) LIKE :search" } @vendorrecords_results = VendorRecord.where(vendor_records_columns.join(' OR '), search: search_term) diff --git a/app/controllers/software_records_controller.rb b/app/controllers/software_records_controller.rb index ee95d904..fe0202a5 100644 --- a/app/controllers/software_records_controller.rb +++ b/app/controllers/software_records_controller.rb @@ -21,11 +21,14 @@ def index @params = request.query_parameters @software_records = if @params['filter_by'].to_s == 'software_types' && !@params['software_type_filter'].nil? && !@params['software_type_filter'].empty? - SoftwareRecord.where(software_type_id: @params['software_type_filter']).order("#{sort_column} #{sort_direction}") + SoftwareRecord.joins(:status).where(software_type_id: +@params['software_type_filter']).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_column} #{sort_direction}") elsif @params['filter_by'].to_s == 'vendor_records' && !@params['vendor_record_filter'].nil? && !@params['vendor_record_filter'].empty? - SoftwareRecord.where(vendor_record_id: @params['vendor_record_filter']).order("#{sort_column} #{sort_direction}") + SoftwareRecord.joins(:status).where(vendor_record_id: +@params['vendor_record_filter']).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_column} #{sort_direction}") else - SoftwareRecord.order("#{sort_column} #{sort_direction}") + SoftwareRecord.joins(:status).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_column} +#{sort_direction}") end @vendor_records = VendorRecord.all @software_types = SoftwareType.all @@ -158,16 +161,40 @@ def check_and_decrypt(sensitive_data) decrypt sensitive_data if sensitive_data.to_s.present? end + def list_decommissioned + $page_title = 'Decommissioned Software | UCL Application Portfolio' + @params = request.query_parameters + + @software_records = if @params['filter_by'].to_s == 'software_types' && !@params['software_type_filter'].nil? && + !@params['software_type_filter'].empty? + SoftwareRecord.joins(:status).where(software_type_id: @params['software_type_filter']).where(status: +'Decommissioned').order("#{sort_priority} #{sort_direction_priority}") + elsif @params['filter_by'].to_s == 'vendor_records' && !@params['vendor_record_filter'].nil? && + !@params['vendor_record_filter'].empty? + SoftwareRecord.joins(:status).where(vendor_record_id: @params['vendor_record_filter']).where(status: +'Decommissioned').order("#{sort_priority} #{sort_direction_priority}") + else + SoftwareRecord.joins(:status).where(statuses: { status_type: 'Decommissioned' }).order("#{sort_column} +#{sort_direction}") + end + @vendor_records = VendorRecord.all + @software_types = SoftwareType.all + @softwarerecords_count = SoftwareRecord.count + end + def list_upgrades $page_title = 'Maintenance Priority| UCL Application Portfolio' @params = request.query_parameters @software_records = if @params['filter_by'].to_s == 'software_types' && !@params['software_type_filter'].nil? && !@params['software_type_filter'].empty? - SoftwareRecord.where(software_type_id: @params['software_type_filter']).order("#{sort_priority} #{sort_direction_priority}") + SoftwareRecord.joins(:status).where(software_type_id: +@params['software_type_filter']).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_priority} #{sort_direction_priority}") elsif @params['filter_by'].to_s == 'vendor_records' && !@params['vendor_record_filter'].nil? && !@params['vendor_record_filter'].empty? - SoftwareRecord.where(vendor_record_id: @params['vendor_record_filter']).order("#{sort_priority} #{sort_direction_priority}") + SoftwareRecord.joins(:status).where(vendor_record_id: +@params['vendor_record_filter']).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_priority} #{sort_direction_priority}") else - SoftwareRecord.order("#{sort_priority} #{sort_direction_priority}") + SoftwareRecord.joins(:status).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_priority} +#{sort_direction_priority}") end @vendor_records = VendorRecord.all @software_types = SoftwareType.all @@ -179,12 +206,15 @@ def list_road_map @params = request.query_parameters @software_records = if @params['filter_by'].to_s == 'software_types' && !@params['software_type_filter'].nil? && !@params['software_type_filter'].empty? - SoftwareRecord.where(software_type_id: @params['software_type_filter']).order("#{sort_priority} #{sort_direction_priority}") + SoftwareRecord.joins(:status).where(software_type_id: @params['software_type_filter']).where.not(status: +'Decommissioned').order("#{sort_priority} #{sort_direction_priority}") elsif @params['filter_by'].to_s == 'vendor_records' && !@params['vendor_record_filter'].nil? && !@params['vendor_record_filter'].empty? - SoftwareRecord.where(vendor_record_id: @params['vendor_record_filter']).order("#{sort_priority} #{sort_direction_priority}") + SoftwareRecord.joins(:status).where(vendor_record_id: @params['vendor_record_filter']).where.not(status: +'Decommissioned').order("#{sort_priority} #{sort_direction_priority}") else - SoftwareRecord.order("#{sort_column} #{sort_direction}") + SoftwareRecord.joins(:status).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_column} +#{sort_direction}") end @vendor_records = VendorRecord.all @software_types = SoftwareType.all diff --git a/app/views/shared/_dashboard_menu.html.erb b/app/views/shared/_dashboard_menu.html.erb index 46124fe7..9416218e 100644 --- a/app/views/shared/_dashboard_menu.html.erb +++ b/app/views/shared/_dashboard_menu.html.erb @@ -19,8 +19,9 @@ View all Hosting Environments View all Change Requests
- Next Software Upgrades + Maintenance List Road Map List + Decommissioned List Manage all Users Import Data
@@ -47,9 +48,9 @@ View all Status View all Hosting Environments
- Next Software Upgrades + Maintenance List Road Map List - View all Change Requests + Change Request List
<% end %> @@ -65,7 +66,7 @@ View all Hosting Environments View all Change Request
- Next Software Upgrades + Maintenance List Road Map List
Export Software Records diff --git a/app/views/software_records/list_decommissioned.html.erb b/app/views/software_records/list_decommissioned.html.erb new file mode 100644 index 00000000..7626cf83 --- /dev/null +++ b/app/views/software_records/list_decommissioned.html.erb @@ -0,0 +1,60 @@ +
+
+
+
+

Decommissioned +List

+ Collection of all the software application that have been decommissioned.

+
+
+
+
+ +<% if @softwarerecords_count != 0 %> +
+
+ + + + + + <% if current_user.role.to_s == "viewer" %> + + <% elsif current_user.role.to_s == "owner" %> + + <% else %> + + <% end %> + + + + + <% @software_records.each do |software_record| %> + + + <% if current_user.role.to_s == "viewer" %> + + <% elsif current_user.role.to_s == "owner" %> + + + <% else %> + + + + <% end %> + + <% end %> + +
<%= sortable "title", "Title" %> + <% if params[:direction] == "asc" || params[:direction] == nil %> + + <% else %> + + <% end %>ActionsActionsActions
<%= software_record.title %><%= link_to 'View', software_record , { :class => "btn btn-success action-btn" }%><%= link_to 'View', software_record , { :class => "btn btn-success action-btn" }%><%= link_to 'Edit', edit_software_record_path(software_record), class: "btn btn-primary action-btn", style: +"white-space: nowrap;" %><%= link_to 'View', software_record , { :class => "btn btn-success action-btn" }%><%= link_to 'Edit', edit_software_record_path(software_record), class: "btn btn-primary action-btn", style: +"white-space: nowrap;" %>
+
+
+<% else %> +

No records found

+<% end %> diff --git a/app/views/statuses/_form.html.erb b/app/views/statuses/_form.html.erb index f8538bb5..03e3d735 100644 --- a/app/views/statuses/_form.html.erb +++ b/app/views/statuses/_form.html.erb @@ -20,9 +20,11 @@
<%= form.label :status_type %> <% if component.eql?("new") %> - <%= form.select :status_type, options_for_select(['Design', 'Production', 'Other'], :selected=>"Design"), {}, {:class => "form-control"} %> + <%= form.select :status_type, options_for_select(['Design', 'Production', 'Decommissioned', 'Development', 'Other'], :selected=>"Design"), +{}, {:class => "form-control"} %> <% else %> - <%= form.select :status_type, options_for_select(['Design', 'Production', 'Other'], :selected=>Status.find_by_id(params[:id]).status_type.to_s), {}, {:class => "form-control"} %> + <%= form.select :status_type, options_for_select(['Design', 'Production', 'Decommissioned', 'Development', 'Other'], +:selected=>Status.find_by_id(params[:id]).status_type.to_s), {}, {:class => "form-control"} %> <% end %>


diff --git a/config/routes.rb b/config/routes.rb index 7d476917..340f12a9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,8 @@ root 'front#index' get 'list_upgrades' => 'software_records#list_upgrades' get 'list_road_map' => 'software_records#list_road_map' + get 'list_decommissioned' => 'software_records#list_decommissioned' + resources :software_records do member do get 'edit_road_map' @@ -25,6 +27,7 @@ # get 'software_records/:id/edit_roadmap', to: 'software_records#edit_road_map', as: 'edit_road_map_software_record' get 'edit_road_map_software_records' => 'software_records#list_road_map' + get 'edit_decommissioned_software_records' => 'software_records#list_decommissioned' get 'about', to: 'front#about' get 'contact', to: 'front#contact' get 'request/new', to: 'front#new' diff --git a/db/seeds.rb b/db/seeds.rb index 6f6ac53f..0b8c6c26 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -33,7 +33,8 @@ # Create default status types status = { 'Available': 'Production', 'Development': 'Design', - 'Production': 'Production' } + 'Production': 'Production', + 'Decommissioned': 'Decommissioned' } status.each do |name, desc| Status.create(title: name, status_type: desc) diff --git a/exports/software_records.rb b/exports/software_records.rb index ca498b1a..fad5f335 100644 --- a/exports/software_records.rb +++ b/exports/software_records.rb @@ -8,7 +8,8 @@ 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', diff --git a/lib/tasks/create_decommissioned.rake b/lib/tasks/create_decommissioned.rake new file mode 100644 index 00000000..307b5ef8 --- /dev/null +++ b/lib/tasks/create_decommissioned.rake @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +namespace 'app_port' do + desc 'Creates Decommissioned Status' + task create_decom: :environment do + # NOTE: In order to see progress in the logs, you must have logging at :info or above + WorksResave.work_resave + Status.new(title: 'Decommissioned', status_type: 'Decommissioned') + end +end diff --git a/spec/controllers/software_records_controller_spec.rb b/spec/controllers/software_records_controller_spec.rb index 10adcc37..40e44176 100644 --- a/spec/controllers/software_records_controller_spec.rb +++ b/spec/controllers/software_records_controller_spec.rb @@ -104,6 +104,49 @@ } end + let(:decommissioned_attributes) do + { + title: 'Decommissioned Software', + description: 'A description', + status: Status.create!( + title: 'Decommissioned', + status_type: 'Decommissioned' + ), + software_type_id: SoftwareType.first.id, + vendor_record_id: VendorRecord.first.id, + created_by: 'Test Admin', + developers: %w[Tester Random], + tech_leads: ['Lead 1'], + product_owners: %w[Owner1 Owner2], + admin_users: %w[Admin1 Admin2], + hosting_environment_id: HostingEnvironment.first.id, + service: 'App Service', + installed_version: '4.5', + latest_version: '4.6', + proposed_version: '4.4', + last_upgrade_date: '2020-02-02', + upgrade_available: true, + vulnerabilities_reported: true, + vulnerabilities_fixed: true, + bug_fixes: true, + new_features: true, + breaking_changes: true, + end_of_life: true, + priority: '10', + upgrade_status: 'Review', + who: 'Test Admin', + semester: 'Fall Quarter 2023', + upgrade_docs: 'www.example.com', + road_map: 'Road Map', + qa_support_servers: 'server.example.com', + dev_support_servers: 'dev.example.com', + date_cert_expires: '2020-01-01', + monitor_certificates: 'yes', + themes: true, + modules: true + } + end + # This should return the minimal set of values that should be in the session # in order to pass any filters (e.g. authentication) defined in # SoftwareRecordsController. Be sure to keep this updated too. @@ -123,21 +166,32 @@ def sign_in_user(admin) get :list_road_map expect(response).to render_template(:list_road_map) 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 } - expect(assigns(:software_records)).to include(software_record) + context 'when filter_by is software_types and software_type_filter is provided' do + it 'assigns filtered software records to @software_records' do + SoftwareRecord.create! valid_attributes + SoftwareRecord.create! decommissioned_attributes + get :list_road_map, params: { filter_by: 'software_types', software_type_filter: SoftwareType.first.id }, session: valid_session + expect(response.body).not_to match('\b(Decommissioned.Software)\b') + end + end + + context 'when filtering by vendor records' do + it 'returns software records with the specified vendor record and not decommissioned' do + SoftwareRecord.create! valid_attributes + SoftwareRecord.create! decommissioned_attributes + get :list_road_map, params: { filter_by: 'vendor_records', vendor_record_filter: VendorRecord.first.id } + expect(response.body).not_to match('\b(Decommissioned.Software)\b') + end 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' } - expect(assigns(:software_records)).to include(software_record) + SoftwareRecord.create! valid_attributes + SoftwareRecord.create! decommissioned_attributes + get :list_road_map, params: { filter_by: 'other_filter' }, session: valid_session + expect(response.body).not_to match('\b(Decommissioned.Software)\b') end end @@ -146,17 +200,9 @@ def sign_in_user(admin) software_record = SoftwareRecord.create! valid_attributes get :list_road_map, params: { filter_by: 'software_types', software_type_filter: nil } expect(assigns(:software_records)).to include(software_record) - get :list_road_map, params: { filter_by: 'software_types', software_type_filter: '' } expect(assigns(:software_records)).to include(software_record) - end - end - - context 'when filtering by vendor_records' do - it 'assigns the filtered software records to @software_records' do - software_record = SoftwareRecord.create! valid_attributes - get :list_road_map, params: { filter_by: 'vendor_records', vendor_record_filter: VendorRecord.first.id } - expect(assigns(:software_records)).to match_array([software_record]) + expect(response.body).not_to match('\b(Decommissioned.Software)\b') end end @@ -166,6 +212,7 @@ def sign_in_user(admin) software_record2 = SoftwareRecord.create! valid_attributes get :list_road_map expect(assigns(:software_records)).to match_array([software_record1, software_record2]) + expect(response.body).not_to match('\b(Decommissioned.Software)\b') end end @@ -185,6 +232,31 @@ def sign_in_user(admin) end end + describe 'GET #list_decommissioned' do + it 'assigns the requested software records to @software_records' do + get :list_decommissioned + expect(response).to be_successful + end + + it 'renders the list_road_map template' do + get :list_decommissioned + expect(response).to render_template(:list_decommissioned) + end + + context 'when not filtering by software types or vendor records' do + it 'returns all decommissioned software records' do + software_record_decommissioned = SoftwareRecord.create! decommissioned_attributes + get :list_decommissioned + expect(assigns(:software_records)).to include(software_record_decommissioned) + end + end + + it 'sets the correct page title' do + get :list_decommissioned + expect(response.body).to match('\b(Decommissioned.List)\b') + end + end + describe 'PATCH/PUT #update_road_map' do context 'with valid attributes' do it 'updates the software record' do @@ -226,6 +298,44 @@ def sign_in_user(admin) expect(response.body).to match('\b(A.Good.Software)\b') expect(response.body).to_not have_content('In Development') end + + it 'does not include decommissioned software records' do + SoftwareRecord.create! valid_attributes + SoftwareRecord.create! decommissioned_attributes + get :index, params: {}, session: valid_session + expect(response.body).to match('\b(A.Good.Software)\b') + expect(response.body).not_to match('\b(Decommissioned.Software)\b') + end + + context 'when filtering by software types' do + it 'returns software records with the specified software type and not decommissioned' do + software_record_active = SoftwareRecord.create! valid_attributes + software_record_decommissioned = SoftwareRecord.create! decommissioned_attributes + get :index, params: { filter_by: 'software_types', software_type_filter: SoftwareType.first.id } + expect(assigns(:software_records)).to include(software_record_active) + expect(assigns(:software_records)).not_to include(software_record_decommissioned) + end + end + + context 'when filtering by vendor records' do + it 'returns software records with the specified vendor record and not decommissioned' do + software_record_active = SoftwareRecord.create! valid_attributes + software_record_decommissioned = SoftwareRecord.create! decommissioned_attributes + get :index, params: { filter_by: 'vendor_records', vendor_record_filter: VendorRecord.first.id } + expect(assigns(:software_records)).to include(software_record_active) + expect(assigns(:software_records)).not_to include(software_record_decommissioned) + end + end + + context 'when not filtering by software types or vendor records' do + it 'returns all software records that are not decommissioned' do + software_record_active = SoftwareRecord.create! valid_attributes + software_record_decommissioned = SoftwareRecord.create! decommissioned_attributes + get :index + expect(assigns(:software_records)).to include(software_record_active) + expect(assigns(:software_records)).not_to include(software_record_decommissioned) + end + end end describe 'GET #show' do diff --git a/spec/routing/software_records_routing_spec.rb b/spec/routing/software_records_routing_spec.rb index 6654cee1..0f753b7d 100644 --- a/spec/routing/software_records_routing_spec.rb +++ b/spec/routing/software_records_routing_spec.rb @@ -39,5 +39,13 @@ it 'routes to #list_upgrades' do expect(get: '/list_upgrades').to route_to('software_records#list_upgrades') end + + it 'routes to #list_decommissioned' do + expect(get: '/list_decommissioned').to route_to('software_records#list_decommissioned') + end + + it 'routes to #list_road_map' do + expect(get: '/list_road_map').to route_to('software_records#list_road_map') + end end end diff --git a/spec/views/software_records/list_decommissioned.html.erb_spec.rb b/spec/views/software_records/list_decommissioned.html.erb_spec.rb new file mode 100644 index 00000000..8b556578 --- /dev/null +++ b/spec/views/software_records/list_decommissioned.html.erb_spec.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'software_records/list_decommissioned', type: :view do + before(:each) do + VendorRecord.create!( + id: 311, + title: 'Vendor 122', + description: 'test vendor' + ) + VendorRecord.create!( + id: 411, + title: 'Vendor Filter', + description: 'test filter vendor' + ) + SoftwareType.create!( + id: 111, + title: 'Web app', + description: 'test software type' + ) + Status.create!( + title: 'Test', + status_type: 'Design' + ) + + Status.create!( + title: 'Decommissioned', + status_type: 'Decommissioned' + ) + + HostingEnvironment.create!( + title: 'Test Env.', + description: 'test env.' + ) + assign(:software_records, [ + SoftwareRecord.create!( + title: 'Title', + description: 'MyText', + status_id: Status.second.id, + hosting_environment_id: HostingEnvironment.first.id, + date_implemented: '2020-12-12', + road_map: 'Road map 1', + vendor_record_id: VendorRecord.first.id, + software_type_id: SoftwareType.first.id, + created_by: 'Test User', + priority: 10 + ), + SoftwareRecord.create!( + title: 'Title', + description: 'MyText', + road_map: 'Road map 2', + status_id: Status.second.id, + hosting_environment_id: HostingEnvironment.first.id, + date_implemented: '2020-12-12', + vendor_record_id: VendorRecord.first.id, + software_type_id: SoftwareType.first.id, + created_by: 'Test User' + ) + ]) + assign(:vendor_records, VendorRecord.all) + assign(:software_types, SoftwareType.all) + + allow(view).to(receive(:user_signed_in?) { true }) && allow(view).to(receive(:current_user) do + FactoryBot.build(:admin) + end) + end + + it 'renders a list of decommissioned software_records' do + render + assert_select 'td:nth-child(1)', text: 'Title'.to_s, count: 2 + expect(rendered).to_not have_text('Status') + end + + it 'displays the software records table' do + render + + expect(rendered).to have_content('Title') + expect(rendered).to have_link('Edit', href: edit_software_record_path(SoftwareRecord.first)) + expect(rendered).to have_link('Edit', href: edit_software_record_path(SoftwareRecord.second)) + end +end