From 20cf51a882b8161412013aa29fb8a45d4fb8421a Mon Sep 17 00:00:00 2001 From: RyanTG Date: Mon, 23 Dec 2024 14:11:44 -0800 Subject: [PATCH] Show 5 most recent comments, like the app, instead of 12 --- app/models/machine_condition.rb | 2 +- .../location_machine_xrefs_controller_spec.rb | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/models/machine_condition.rb b/app/models/machine_condition.rb index e534b791..98c35b27 100644 --- a/app/models/machine_condition.rb +++ b/app/models/machine_condition.rb @@ -1,5 +1,5 @@ class MachineCondition < ApplicationRecord - MAX_HISTORY_SIZE_TO_DISPLAY = 12 + MAX_HISTORY_SIZE_TO_DISPLAY = 5 has_paper_trail diff --git a/spec/features/location_machine_xrefs_controller_spec.rb b/spec/features/location_machine_xrefs_controller_spec.rb index 3be33100..093fff1e 100644 --- a/spec/features/location_machine_xrefs_controller_spec.rb +++ b/spec/features/location_machine_xrefs_controller_spec.rb @@ -302,10 +302,10 @@ expect(find("#show_conditions_lmx_#{@lmx.id}")).to have_content("Test Comment\nDELETED USER\n#{@lmx.created_at.strftime('%b %d, %Y')}") end - it 'only displays the 12 most recent descriptions' do + it 'only displays the 5 most recent descriptions' do login - 12.times do |i| + 7.times do |i| FactoryBot.create(:machine_condition, location_machine_xref: @lmx.reload, comment: "Condition #{i + 1} words.", created_at: "199#{i + 1}-01-01") end @@ -313,18 +313,13 @@ page.find("div#machine_tools_lmx_banner_#{@lmx.id}").click - expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 12 words.') - expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 11 words.') - expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 10 words.') - expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 9 words.') - expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 8 words.') expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 7 words.') expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 6 words.') expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 5 words.') expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 4 words.') expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 3 words.') - expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 2 words.') - expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to have_content('Condition 1 words.') + expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to_not have_content('Condition 2 words.') + expect(find("div#show_conditions_lmx_#{@lmx.id}.show_conditions_lmx")).to_not have_content('Condition 1 words.') page.find("div#machine_condition_lmx_#{@lmx.id}.machine_condition_lmx .add_condition").click fill_in("new_machine_condition_#{@lmx.id}", with: 'This is a new condition') @@ -332,7 +327,7 @@ sleep 1 - expect(page).to_not have_content('Condition 1 words.') + expect(page).to_not have_content('Condition 3 words.') end it 'should add past conditions when you add a new condition and a condition exists' do