Browse Source

Remove memoization (#998)

These variables seemed to be memoized across users
pull/1000/head
Jack S 2 years ago committed by GitHub
parent
commit
200a382138
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/form/lettings/questions/housing_provider.rb
  2. 2
      app/models/form/lettings/questions/managing_organisation.rb
  3. 10
      spec/features/lettings_log_spec.rb

2
app/models/form/lettings/questions/housing_provider.rb

@ -59,7 +59,7 @@ private
end
def housing_providers_answer_options
@housing_providers_answer_options ||= if current_user.support?
if current_user.support?
Organisation
else
current_user.organisation.housing_providers

2
app/models/form/lettings/questions/managing_organisation.rb

@ -65,7 +65,7 @@ private
end
def managing_organisations_answer_options
@managing_organisations_answer_options ||= if current_user.support?
if current_user.support?
log.owning_organisation
else
current_user.organisation

10
spec/features/lettings_log_spec.rb

@ -99,7 +99,7 @@ RSpec.describe "Lettings Log Features" do
end
context "when the signed is user is not a Support user" do
let(:support_user) { create(:user) }
let(:user) { create(:user) }
let(:devise_notify_mailer) { DeviseNotifyMailer.new }
let(:notify_client) { instance_double(Notifications::Client) }
@ -108,8 +108,8 @@ RSpec.describe "Lettings Log Features" do
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client)
allow(notify_client).to receive(:send_email).and_return(true)
visit("/account/sign-in")
fill_in("user[email]", with: support_user.email)
fill_in("user[password]", with: support_user.password)
fill_in("user[email]", with: user.email)
fill_in("user[password]", with: user.password)
click_button("Sign in")
end
@ -121,8 +121,8 @@ RSpec.describe "Lettings Log Features" do
log_id = page.current_path.scan(/\d/).join
expect(page).to have_current_path("/lettings-logs/#{log_id}/needs-type")
visit("lettings-logs/#{log_id}/setup/check-answers")
expect(page).not_to have_content("Owning organisation #{support_user.organisation.name}")
expect(page).not_to have_content("User #{support_user.name}")
expect(page).not_to have_content("Owning organisation #{user.organisation.name}")
expect(page).not_to have_content("User #{user.name}")
expect(page).to have_content("You have answered 0 of 6 questions")
end
end

Loading…
Cancel
Save