From 414bbb3c419bc91f8f7afb489786b54e31cbd695 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 26 Jul 2022 15:22:08 +0100 Subject: [PATCH] update tests --- spec/features/schemes_spec.rb | 7 ++++--- spec/requests/schemes_controller_spec.rb | 7 +++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 63e530ec9..5b3ef7020 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -120,10 +120,11 @@ RSpec.describe "Schemes scheme Features" do end it "returns results with no location" do - scheme_to_search.locations.each { |location| location.destroy } - scheme_to_search.reload + scheme_without_location = FactoryBot.create(:scheme) + visit "/schemes" + fill_in("search", with: scheme_without_location.id_to_display) click_button("Search") - expect(page).to have_content(scheme_to_search.id_to_display) + expect(page).to have_content(scheme_without_location.id_to_display) end it "allows clearing the search results" do diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index b082d6683..8549d79f0 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -180,10 +180,9 @@ RSpec.describe SchemesController, type: :request do end it "returns results with no location" do - searched_scheme.locations.each { |location| location.destroy } - searched_scheme.reload - get "/schemes?search=#{search_param}" - expect(page).to have_content(searched_scheme.id_to_display) + scheme_without_location = FactoryBot.create(:scheme) + get "/schemes?search=#{scheme_without_location.id}" + expect(page).to have_content(scheme_without_location.id_to_display) schemes.each do |scheme| expect(page).not_to have_content(scheme.id_to_display) end