Browse Source

Add active status

pull/976/head
Kat 3 years ago
parent
commit
7b8f1020b5
  1. 2
      app/helpers/tag_helper.rb
  2. 5
      app/models/location.rb
  3. 2
      app/views/locations/show.html.erb
  4. 1
      spec/features/schemes_spec.rb
  5. 1
      spec/models/location_spec.rb

2
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 = [])

5
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

2
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 %>

1
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

1
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)

Loading…
Cancel
Save