Browse Source

refactored feature and added searching by tenancy code

pull/608/head
JG 3 years ago
parent
commit
84aee61cac
  1. 31
      spec/features/log_spec.rb

31
spec/features/log_spec.rb

@ -2,10 +2,11 @@ require "rails_helper"
RSpec.describe "Log Features" do RSpec.describe "Log Features" do
context "Searching for specific logs" do context "Searching for specific logs" do
context "I am logged in" do context "I am logged in and there are logs in the database" do
let!(:user) { FactoryBot.create(:user, last_sign_in_at: Time.zone.now) } let!(:user) { FactoryBot.create(:user, last_sign_in_at: Time.zone.now) }
let!(:log) { FactoryBot.create(:case_log, owning_organisation: user.organisation) } let!(:log_to_search) { FactoryBot.create(:case_log, owning_organisation: user.organisation, tenancy_code: "111") }
let!(:unwanted_logs) { FactoryBot.create_list(:case_log, 4, owning_organisation: user.organisation) } let!(:same_orgsanisation_log) { FactoryBot.create(:case_log, owning_organisation: user.organisation, tenancy_code: "222") }
let!(:another_orgsanisation_log) { FactoryBot.create(:case_log, tenancy_code: "333") }
before do before do
visit("/logs") visit("/logs")
@ -21,11 +22,25 @@ RSpec.describe "Log Features" do
expect(page).to have_button("Search") expect(page).to have_button("Search")
end end
it "displays log matching the search" do context "using log ID" do
fill_in("search-field", with: log.id) it "it displays log matching the log ID" do
click_button("Search") fill_in("search-field", with: log_to_search.id)
expect(page).to have_content(log.id) click_button("Search")
expect(page).not_to have_content(unwanted_logs.first.id) expect(page).to have_content(log_to_search.id)
expect(page).not_to have_content(same_orgsanisation_log.id)
expect(page).not_to have_content(another_orgsanisation_log.id)
end
end
context "using log tenancy_code" do
it "it displays log matching the tenancy code" do
visit("/logs")
fill_in("search-field", with: log_to_search.tenancy_code)
click_button("Search")
expect(page).to have_content(log_to_search.id)
expect(page).not_to have_content(same_orgsanisation_log.id)
expect(page).not_to have_content(another_orgsanisation_log.id)
end
end end
end end
end end

Loading…
Cancel
Save