From 7b8f1020b55c08770e4376be41fe6dca09e25ac2 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 8 Nov 2022 14:50:46 +0000 Subject: [PATCH] Add active status --- app/helpers/tag_helper.rb | 2 ++ app/models/location.rb | 5 +++++ app/views/locations/show.html.erb | 2 +- spec/features/schemes_spec.rb | 1 + spec/models/location_spec.rb | 1 + 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/helpers/tag_helper.rb b/app/helpers/tag_helper.rb index 1937394b0..08b6180b3 100644 --- a/app/helpers/tag_helper.rb +++ b/app/helpers/tag_helper.rb @@ -6,6 +6,7 @@ module TagHelper cannot_start_yet: "Cannot start yet", in_progress: "In progress", completed: "Completed", + active: "Active", }.freeze COLOUR = { @@ -13,6 +14,7 @@ module TagHelper cannot_start_yet: "grey", in_progress: "blue", completed: "green", + active: "green", }.freeze def status_tag(status, classes = []) diff --git a/app/models/location.rb b/app/models/location.rb index 96a9da9da..9abae85e1 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -369,6 +369,7 @@ class Location < ApplicationRecord { name: "Mobility type", value: mobility_type }, { name: "Code", value: location_code }, { name: "Availability", value: "Available from #{available_from.to_formatted_s(:govuk_date)}" }, + { name: "Status", value: status }, ] end @@ -402,4 +403,8 @@ private def available_from startdate || created_at end + + def status + "active" + end end diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb index 96d8fd25d..5fbd4bb04 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/locations/show.html.erb @@ -17,7 +17,7 @@ <% @location.display_attributes.each do |attr| %> <%= summary_list.row do |row| %> <% row.key { attr[:name] } %> - <% row.value { details_html(attr) } %> + <% row.value { attr[:name].eql?("Status") ? status_tag(attr[:value]) : details_html(attr) } %> <% row.action(text: "Change", href: location_edit_name_path(location_id: @location.id, id: @scheme.id)) if attr[:edit] %> <% end %> <% end %> diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 8a0805a9e..eda4a63c4 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -767,6 +767,7 @@ RSpec.describe "Schemes scheme Features" do expect(page).to have_content(location.mobility_type) expect(page).to have_content(location.location_code) expect(page).to have_content("Available from 4 April 2022") + expect(page).to have_content("Active") end it "only allows to edit the location name" do diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb index 10f60ca5d..5c332fd61 100644 --- a/spec/models/location_spec.rb +++ b/spec/models/location_spec.rb @@ -125,6 +125,7 @@ RSpec.describe Location, type: :model do { name: "Mobility type", value: location.mobility_type }, { name: "Code", value: location.location_code }, { name: "Availability", value: "Available from 8 August 2022" }, + { name: "Status", value: "active" }, ] expect(location.display_attributes).to eq(attributes)