diff --git a/app/views/case_logs/_log_filters.erb b/app/views/case_logs/_log_filters.erb
index 45354fb40..23f581ccd 100644
--- a/app/views/case_logs/_log_filters.erb
+++ b/app/views/case_logs/_log_filters.erb
@@ -4,7 +4,7 @@
Filters
- <%= form_with url: "/logs", html: { method: :get } do |f| %>
+ <%= form_with html: { method: :get } do |f| %>
<% years = {"2021": "2021/22", "2022": "2022/23"} %>
<% all_or_yours = {"all": { label: "All" }, "yours": { label: "Yours" } } %>
<%= render partial: "filters/checkbox_filter", locals: { f: f, options: years, label: "Collection year", category: "years" } %>
diff --git a/spec/features/organisation_spec.rb b/spec/features/organisation_spec.rb
index ef54ff2a2..3eb481fd2 100644
--- a/spec/features/organisation_spec.rb
+++ b/spec/features/organisation_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe "User Features" do
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client)
allow(Devise).to receive(:friendly_token).and_return(confirmation_token)
allow(notify_client).to receive(:send_email).and_return(true)
- sign_in user
+ # sign_in user
end
context "when user is a data coordinator" do
@@ -80,4 +80,35 @@ RSpec.describe "User Features" do
end
end
end
+
+ context "when user is support user" do
+ context "when viewing logs for specific organisation" do
+ let(:user) { FactoryBot.create(:user, :support) }
+ let(:number_of_case_logs) { 4 }
+ let(:first_log) {organisation.case_logs.first}
+ let(:otp) { "999111" }
+
+ before do
+ FactoryBot.create_list(:case_log, number_of_case_logs, owning_organisation_id: organisation.id, managing_organisation_id: organisation.id)
+ first_log.update!(startdate: Time.utc(2022, 6, 2, 10, 36, 49))
+
+ allow(SecureRandom).to receive(:random_number).and_return(otp)
+ sign_in user
+ fill_in("code", with: otp)
+ click_button("Submit")
+ visit("/organisations/#{org_id}/logs")
+ end
+
+ it "can filter case logs" do
+ expect(page).to have_content("#{number_of_case_logs} total logs")
+ organisation.case_logs.map(&:id).each do |case_log_id|
+ expect(page).to have_link case_log_id.to_s, href: "/logs/#{case_log_id}"
+ end
+ check("years-2022-field")
+ click_button("Apply filters")
+ expect(page).to have_current_path("/organisations/#{org_id}/logs?years[]=&years[]=2022&status[]=&user=all&organisation_select=all&organisation=")
+ expect(page).not_to have_link first_log.id.to_s, href: "/logs/#{first_log.id}"
+ end
+ end
+ end
end