Browse Source

better names and rubo

pull/608/head
JG 3 years ago
parent
commit
97134a7e93
  1. 42
      spec/features/log_spec.rb
  2. 6
      spec/requests/case_logs_controller_spec.rb

42
spec/features/log_spec.rb

@ -4,9 +4,9 @@ RSpec.describe "Log Features" do
context "when searching for specific logs" do context "when searching for specific logs" do
context "when I am logged in and there are logs in the database" do context "when 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_to_search) { FactoryBot.create(:case_log, owning_organisation: user.organisation, tenancy_code: "111") } let!(:log_to_search) { FactoryBot.create(:case_log, owning_organisation: user.organisation, tenancy_code: "111") }
let(:same_organisation_log) { FactoryBot.create(:case_log, owning_organisation: user.organisation, tenancy_code: "222") } let!(:same_organisation_log) { FactoryBot.create(:case_log, owning_organisation: user.organisation, tenancy_code: "222") }
let(:another_organisation_log) { FactoryBot.create(:case_log, tenancy_code: "333") } let!(:another_organisation_log) { FactoryBot.create(:case_log, tenancy_code: "333") }
before do before do
visit("/logs") visit("/logs")
@ -15,6 +15,12 @@ RSpec.describe "Log Features" do
click_button("Sign in") click_button("Sign in")
end end
it "I see logs belonging to the same organisation" do
expect(page).to have_content(log_to_search.id)
expect(page).to have_content(same_organisation_log.id)
expect(page).not_to have_content(another_organisation_log.id)
end
context "when I search for a specific log" do context "when I search for a specific log" do
it "there is a search bar with a message and search button for logs" do it "there is a search bar with a message and search button for logs" do
expect(page).to have_field("search") expect(page).to have_field("search")
@ -22,12 +28,30 @@ RSpec.describe "Log Features" do
expect(page).to have_button("Search") expect(page).to have_button("Search")
end end
it "displays log matching the log ID" do context "when I fill in search information and press the search button" do
fill_in("search", with: log_to_search.id) before do
click_button("Search") fill_in("search", with: log_to_search.id)
expect(page).to have_content(log_to_search.id) click_button("Search")
expect(page).not_to have_content(same_organisation_log.id) end
expect(page).not_to have_content(another_organisation_log.id)
it "displays log matching the log ID" do
expect(page).to have_content(log_to_search.id)
expect(page).not_to have_content(same_organisation_log.id)
expect(page).not_to have_content(another_organisation_log.id)
end
context "when I want to clear results" do
it "there is link to clear the search results" do
expect(page).to have_link("Clear search")
end
it "I see logs belonging to the same organisation" do
click_link("Clear search")
expect(page).to have_content(log_to_search.id)
expect(page).to have_content(same_organisation_log.id)
expect(page).not_to have_content(another_organisation_log.id)
end
end
end end
end end
end end

6
spec/requests/case_logs_controller_spec.rb

@ -332,7 +332,7 @@ RSpec.describe CaseLogsController, type: :request do
expect(page).not_to have_content(logs[2].id) expect(page).not_to have_content(logs[2].id)
end end
it "it has search results in the title" do it "has search results in the title" do
get "/logs?search=#{logs[0].id}", headers: headers, params: {} get "/logs?search=#{logs[0].id}", headers: headers, params: {}
expect(page).to have_content("Logs (search results for ‘#{logs[0].id}’) - Submit social housing and sales data (CORE) - GOV.UK") expect(page).to have_content("Logs (search results for ‘#{logs[0].id}’) - Submit social housing and sales data (CORE) - GOV.UK")
end end
@ -340,12 +340,12 @@ RSpec.describe CaseLogsController, type: :request do
context "when there are more than 1 page of search results" do context "when there are more than 1 page of search results" do
let(:logs) { FactoryBot.create_list(:case_log, 30, :completed, owning_organisation: user.organisation, postcode_full: "XX1 1YY") } let(:logs) { FactoryBot.create_list(:case_log, 30, :completed, owning_organisation: user.organisation, postcode_full: "XX1 1YY") }
it "it has title with pagination details for page 1" do it "has title with pagination details for page 1" do
get "/logs?search=#{logs[0].postcode_full}", headers: headers, params: {} get "/logs?search=#{logs[0].postcode_full}", headers: headers, params: {}
expect(page).to have_content("Logs (search results for ‘#{logs[0].postcode_full}’, page 1 of 2) - Submit social housing and sales data (CORE) - GOV.UK") expect(page).to have_content("Logs (search results for ‘#{logs[0].postcode_full}’, page 1 of 2) - Submit social housing and sales data (CORE) - GOV.UK")
end end
it "it has title with pagination details for page 2" do it "has title with pagination details for page 2" do
get "/logs?search=#{logs[0].postcode_full}&page=2", headers: headers, params: {} get "/logs?search=#{logs[0].postcode_full}&page=2", headers: headers, params: {}
expect(page).to have_content("Logs (search results for ‘#{logs[0].postcode_full}’, page 2 of 2) - Submit social housing and sales data (CORE) - GOV.UK") expect(page).to have_content("Logs (search results for ‘#{logs[0].postcode_full}’, page 2 of 2) - Submit social housing and sales data (CORE) - GOV.UK")
end end

Loading…
Cancel
Save