Skip to content

Commit

Permalink
Merge pull request #1989 from sanger/sh51/repair-incorrect-tooltip
Browse files Browse the repository at this point in the history
fix: correctly label Submission state
  • Loading branch information
StephenHulme authored Oct 21, 2024
2 parents d988432 + 5642ec3 commit 40ef006
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/helpers/page_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def jumbotron(jumbotron_id = nil, options = {}, &)

# eg. state_badge('pending')
# <span class="state-badge-pending">Pending</span>
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)
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_submission_item.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<li>
<%= state_badge(submission_item.state) %> <%= submission_item.name %>
<%= state_badge(submission_item.state, title: 'Submission State') %> <%= submission_item.name %>
</li>
14 changes: 14 additions & 0 deletions spec/helpers/page_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,18 @@
expect(count_badge(0, 'test')).to eq('<span class="badge badge-pill badge-secondary" id="test">0</span>')
end
end

describe '::state_badge' do
it 'returns a badge with the given state and default title' do
expect(state_badge('pending')).to eq(
'<span class="state-badge pending" title="Labware State" data-toggle="tooltip">Pending</span>'
)
end

it 'returns a badge with the given state and title' do
expect(state_badge('passed', title: 'Submission State')).to eq(
'<span class="state-badge passed" title="Submission State" data-toggle="tooltip">Passed</span>'
)
end
end
end

0 comments on commit 40ef006

Please sign in to comment.