6 changed files with 44 additions and 22 deletions
@ -0,0 +1,25 @@
|
||||
module TagHelper |
||||
include GovukComponentsHelper |
||||
|
||||
TEXT = { |
||||
not_started: "Not started", |
||||
cannot_start_yet: "Cannot start yet", |
||||
in_progress: "In progress", |
||||
completed: "Completed", |
||||
}.freeze |
||||
|
||||
COLOUR = { |
||||
not_started: "grey", |
||||
cannot_start_yet: "grey", |
||||
in_progress: "blue", |
||||
completed: "green", |
||||
}.freeze |
||||
|
||||
def status_tag(status, classes = []) |
||||
govuk_tag( |
||||
classes:, |
||||
colour: COLOUR[status.to_sym], |
||||
text: TEXT[status.to_sym], |
||||
) |
||||
end |
||||
end |
@ -0,0 +1,16 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe TagHelper do |
||||
let(:empty_case_log) { FactoryBot.create(:case_log) } |
||||
let(:case_log) { FactoryBot.create(:case_log, :in_progress) } |
||||
|
||||
describe "get the status tag" do |
||||
it "returns tag with correct status text and colour" do |
||||
expect(status_tag(case_log.status)).to eq("<strong class=\"govuk-tag govuk-tag--blue\">In progress</strong>") |
||||
end |
||||
|
||||
it "returns tag with correct status text and colour and custom class" do |
||||
expect(status_tag("not_started", "app-tag--small")).to eq("<strong class=\"govuk-tag app-tag--small govuk-tag--grey\">Not started</strong>") |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue