Skip to content

Commit

Permalink
Show patient flags without a feature flag
Browse files Browse the repository at this point in the history
This is in scope for the 1.1.1 release, so we can remove the feature
flag, merge in to `main` and then it's ready for the testers.
  • Loading branch information
thomasleese committed Dec 17, 2024
1 parent 3350460 commit b47a22c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 54 deletions.
34 changes: 16 additions & 18 deletions app/components/app_patient_card_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@ class AppPatientCardComponent < ViewComponent::Base
<%= render AppCardComponent.new do |card| %>
<% card.with_heading { "Child record" } %>
<% if Flipper.enabled?(:"v1.2.0") %>
<% if @patient.date_of_death.present? %>
<%= render AppNoticeStatusComponent.new(
text: "Record updated with child’s date of death"
) %>
<% end %>
<% if @patient.invalidated? %>
<%= render AppNoticeStatusComponent.new(
text: "Record flagged as invalid"
) %>
<% end %>
<% if @patient.restricted? %>
<%= render AppNoticeStatusComponent.new(
text: "Record flagged as sensitive"
) %>
<% end %>
<% if @patient.date_of_death.present? %>
<%= render AppNoticeStatusComponent.new(
text: "Record updated with child’s date of death"
) %>
<% end %>
<% if @patient.invalidated? %>
<%= render AppNoticeStatusComponent.new(
text: "Record flagged as invalid"
) %>
<% end %>
<% if @patient.restricted? %>
<%= render AppNoticeStatusComponent.new(
text: "Record flagged as sensitive"
) %>
<% end %>
<%= render AppPatientSummaryComponent.new(
Expand Down
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Faker::Config.locale = "en-GB"

def set_feature_flags
%i[dev_tools mesh_jobs cis2 v1.2.0].each do |feature_flag|
%i[dev_tools mesh_jobs cis2].each do |feature_flag|
Flipper.add(feature_flag) unless Flipper.exist?(feature_flag)
end
end
Expand Down
39 changes: 4 additions & 35 deletions spec/components/app_patient_card_component_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

describe AppPatientCardComponent do
subject(:rendered) { render_inline(component) }
subject { render_inline(component) }

let(:component) { described_class.new(patient) }

Expand All @@ -16,49 +16,18 @@
context "with a deceased patient" do
let(:patient) { create(:patient, :deceased) }

context "with feature flag enabled" do
before { Flipper.enable(:"v1.2.0") }
after { Flipper.enable(:"v1.2.0") }

it { should have_content("Record updated with child’s date of death") }
end

context "without feature flag enabled" do
it do
expect(rendered).not_to have_content(
"Record updated with child’s date of death"
)
end
end
it { should have_content("Record updated with child’s date of death") }
end

context "with an invalidated patient" do
let(:patient) { create(:patient, :invalidated) }

context "with feature flag enabled" do
before { Flipper.enable(:"v1.2.0") }
after { Flipper.enable(:"v1.2.0") }

it { should have_content("Record flagged as invalid") }
end

context "without feature flag enabled" do
it { should_not have_content("Record flagged as invalid") }
end
it { should have_content("Record flagged as invalid") }
end

context "with a restricted patient" do
let(:patient) { create(:patient, :restricted) }

context "with feature flag enabled" do
before { Flipper.enable(:"v1.2.0") }
after { Flipper.enable(:"v1.2.0") }

it { should have_content("Record flagged as sensitive") }
end

context "without feature flag enabled" do
it { should_not have_content("Record flagged as sensitive") }
end
it { should have_content("Record flagged as sensitive") }
end
end

0 comments on commit b47a22c

Please sign in to comment.