From 735078a7f522c20cb90439461161fc94f13e4c71 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 14 Oct 2024 12:00:06 +0100 Subject: [PATCH 1/2] fix: correctly label Submission state --- app/helpers/page_helper.rb | 4 ++-- app/views/application/_submission_item.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/page_helper.rb b/app/helpers/page_helper.rb index 49f774667..11e5ba153 100644 --- a/app/helpers/page_helper.rb +++ b/app/helpers/page_helper.rb @@ -52,8 +52,8 @@ def jumbotron(jumbotron_id = nil, options = {}, &) # eg. state_badge('pending') # Pending - def state_badge(state) - tag.span(state.titleize, class: "state-badge #{state}", title: 'Labware State', data: { toggle: 'tooltip' }) + def state_badge(state, title: 'Labware State') + tag.span(state.titleize, class: "state-badge #{state}", title: title, data: { toggle: 'tooltip' }) end # eg. count_badge(0) diff --git a/app/views/application/_submission_item.html.erb b/app/views/application/_submission_item.html.erb index b6145c676..f09a8da9b 100644 --- a/app/views/application/_submission_item.html.erb +++ b/app/views/application/_submission_item.html.erb @@ -1,3 +1,3 @@
  • - <%= state_badge(submission_item.state) %> <%= submission_item.name %> + <%= state_badge(submission_item.state, title: 'Submission State') %> <%= submission_item.name %>
  • From 5642ec310b4c1c157a7312a0c4f531ea99e9a685 Mon Sep 17 00:00:00 2001 From: Stephen Hulme Date: Mon, 21 Oct 2024 11:29:40 +0100 Subject: [PATCH 2/2] tests: add tests for state_badge --- spec/helpers/page_helper_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/helpers/page_helper_spec.rb b/spec/helpers/page_helper_spec.rb index 9bc98a951..5c8f2d44e 100644 --- a/spec/helpers/page_helper_spec.rb +++ b/spec/helpers/page_helper_spec.rb @@ -22,4 +22,18 @@ expect(count_badge(0, 'test')).to eq('0') end end + + describe '::state_badge' do + it 'returns a badge with the given state and default title' do + expect(state_badge('pending')).to eq( + 'Pending' + ) + end + + it 'returns a badge with the given state and title' do + expect(state_badge('passed', title: 'Submission State')).to eq( + 'Passed' + ) + end + end end