From 4a0c1ac214675f470ac225709d5edaa1bf6731ec Mon Sep 17 00:00:00 2001 From: Ted Date: Mon, 9 May 2022 12:32:17 +0100 Subject: [PATCH] add tests --- .../organisations/_organisation_list.html.erb | 2 +- spec/features/user_spec.rb | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/views/organisations/_organisation_list.html.erb b/app/views/organisations/_organisation_list.html.erb index 72ed027f1..f0680d7ab 100644 --- a/app/views/organisations/_organisation_list.html.erb +++ b/app/views/organisations/_organisation_list.html.erb @@ -1,5 +1,5 @@
- +
<%= pagy.count %> total <%= title.downcase %> diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 6e197f07d..da83101ee 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -549,5 +549,28 @@ RSpec.describe "User Features" do end end end + context "when the user is logged in as a support user" do + let!(:support_user) { FactoryBot.create(:user, :support) } + + before do + allow(SecureRandom).to receive(:random_number).and_return(otp) + visit("/logs") + fill_in("user[email]", with: support_user.email) + fill_in("user[password]", with: "pAssword1") + click_button("Sign in") + fill_in("code", with: otp) + click_button("Submit") + end + + it "they should see organisations instead of your organisations in the navigation bar" do + visit("/organisations") + expect(page).to have_selector("h1", text: "Organisations") + end + + it "they should see all organisations listed in the organisations page" do + visit("/organisations") + expect(page).to have_css('#all-organisations-table') + end + end end end