Browse Source

fixed failing test

pull/627/head
JG 4 years ago
parent
commit
0126840ccd
  1. 6
      app/components/search_component.rb
  2. 2
      app/views/organisations/users.html.erb
  3. 2
      spec/requests/organisations_controller_spec.rb

6
app/components/search_component.rb

@ -9,10 +9,12 @@ class SearchComponent < ViewComponent::Base
end end
def path(current_user) def path(current_user)
if request.path.include?("users") if request.path.include?("organisations") && request.path.include?("users")
user_path(current_user) request.path
elsif request.path.include?("organisations") && request.path.include?("logs") elsif request.path.include?("organisations") && request.path.include?("logs")
request.path request.path
elsif request.path.include?("users")
user_path(current_user)
elsif request.path.include?("organisations") elsif request.path.include?("organisations")
organisations_path organisations_path
elsif request.path.include?("logs") elsif request.path.include?("logs")

2
app/views/organisations/users.html.erb

@ -1,6 +1,6 @@
<% item_label = @pagy.count > 1 ? "users" : "user" %> <% item_label = @pagy.count > 1 ? "users" : "user" %>
<% if @searched.present? %> <% if @searched.present? %>
<% title = "Your organisation (#{@pagy.count} #{item_label} matching ‘#{@searched}’ of #{@total_count} total logs)" %> <% title = "Your organisation (#{@pagy.count} #{item_label} matching ‘#{@searched}’ of #{@total_count} total users)" %>
<% else %> <% else %>
<% title = "Your organisation (User)" %> <% title = "Your organisation (User)" %>
<% end %> <% end %>

2
spec/requests/organisations_controller_spec.rb

@ -617,7 +617,9 @@ RSpec.describe OrganisationsController, type: :request do
end end
context "when our search term matches an email and a name" do context "when our search term matches an email and a name" do
let!(:matching_user) { FactoryBot.create(:user, organisation: user.organisation, name: "Matching", email: "some@example.com") }
let!(:other_matching_user) { FactoryBot.create(:user, organisation: user.organisation, name: "matching", email: "foobar@example.com") } let!(:other_matching_user) { FactoryBot.create(:user, organisation: user.organisation, name: "matching", email: "foobar@example.com") }
let(:org_user_count) { User.where(organisation: user.organisation).count }
let(:search_param) { "matching" } let(:search_param) { "matching" }
it "returns only matching results" do it "returns only matching results" do

Loading…
Cancel
Save