From bb1f1988ca8f595d270b0c2cf80898b2830bd2a8 Mon Sep 17 00:00:00 2001 From: JG Date: Mon, 13 Jun 2022 09:55:43 +0100 Subject: [PATCH] added steps to view links to indiividual schemes --- spec/features/schemes_spec.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index b1fe131fe..092dc3226 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -75,4 +75,39 @@ RSpec.describe "Supported housing scheme Features" do end end end + + context "when viewing particular scheme" do + context "when I am signed as a support user in there are schemes in the database" do + let(:user) { FactoryBot.create(:user, :support, last_sign_in_at: Time.zone.now) } + let!(:schemes) { FactoryBot.create_list(:scheme, 5) } + let(:notify_client) { instance_double(Notifications::Client) } + let(:confirmation_token) { "MCDH5y6Km-U7CFPgAMVS" } + let(:devise_notify_mailer) { DeviseNotifyMailer.new } + let(:otp) { "999111" } + + before do + allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer) + 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) + allow(SecureRandom).to receive(:random_number).and_return(otp) + visit("/logs") + fill_in("user[email]", with: user.email) + fill_in("user[password]", with: user.password) + click_button("Sign in") + fill_in("code", with: otp) + click_button("Submit") + end + + context "when I visit supported housing page" do + before { visit("supported-housing") } + + it "shows list of links to schemes" do + schemes.each do |scheme| + expect(page).to have_content(scheme.code) + end + end + end + end + end end