Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show patient flags without a feature flag #2773

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading