Browse Source

fix: update status names

pull/980/head
natdeanlewissoftwire 2 years ago
parent
commit
9b5b07aa88
  1. 8
      app/helpers/tag_helper.rb
  2. 2
      app/models/location.rb
  3. 2
      app/models/scheme.rb
  4. 4
      spec/models/location_spec.rb
  5. 2
      spec/models/scheme_spec.rb

8
app/helpers/tag_helper.rb

@ -8,8 +8,8 @@ module TagHelper
completed: "Completed",
active: "Active",
incomplete: "Incomplete",
deactivates_soon: "Deactivates soon",
reactivates_soon: "Reactivates soon",
deactivating_soon: "Deactivating soon",
reactivating_soon: "Reactivating soon",
deactivated: "Deactivated",
}.freeze
@ -20,8 +20,8 @@ module TagHelper
completed: "green",
active: "green",
incomplete: "red",
deactivates_soon: "yellow",
reactivates_soon: "blue",
deactivating_soon: "yellow",
reactivating_soon: "blue",
deactivated: "grey",
}.freeze

2
app/models/location.rb

@ -374,7 +374,7 @@ class Location < ApplicationRecord
def status
return :active if deactivation_date.blank?
return :deactivates_soon if Time.zone.now < deactivation_date
return :deactivating_soon if Time.zone.now < deactivation_date
return :deactivated if Time.zone.now >= deactivation_date
end

2
app/models/scheme.rb

@ -216,7 +216,7 @@ class Scheme < ApplicationRecord
def status
return :active if deactivation_date.blank?
return :deactivates_soon if Time.zone.now < deactivation_date
return :deactivating_soon if Time.zone.now < deactivation_date
return :deactivated if Time.zone.now >= deactivation_date
end

4
spec/models/location_spec.rb

@ -125,10 +125,10 @@ RSpec.describe Location, type: :model do
expect(location.status).to eq(:active)
end
it "returns deactivates soon if deactivation_date is in the future" do
it "returns deactivating soon if deactivation_date is in the future" do
location.deactivation_date = Time.zone.local(2022, 8, 8)
location.save!
expect(location.status).to eq(:deactivates_soon)
expect(location.status).to eq(:deactivating_soon)
end
it "returns deactivated if deactivation_date is in the past" do

2
spec/models/scheme_spec.rb

@ -108,7 +108,7 @@ RSpec.describe Scheme, type: :model do
it "returns deactivating soon if deactivation_date is in the future" do
scheme.deactivation_date = Time.zone.local(2022, 8, 8)
scheme.save!
expect(scheme.status).to eq(:deactivates_soon)
expect(scheme.status).to eq(:deactivating_soon)
end
it "returns deactivated if deactivation_date is in the past" do

Loading…
Cancel
Save