Skip to content

Commit

Permalink
Show 5 most recent comments, like the app, instead of 12
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanTG committed Dec 23, 2024
1 parent 708f124 commit 20cf51a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/models/machine_condition.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class MachineCondition < ApplicationRecord
MAX_HISTORY_SIZE_TO_DISPLAY = 12
MAX_HISTORY_SIZE_TO_DISPLAY = 5

has_paper_trail

Expand Down
15 changes: 5 additions & 10 deletions spec/features/location_machine_xrefs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,37 +302,32 @@
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

visit "/#{@region.name}/?by_location_id=#{@location.id}"

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')
page.find("input#save_machine_condition_#{@lmx.id}").click

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
Expand Down

0 comments on commit 20cf51a

Please sign in to comment.