Browse Source

Rubocop

pull/600/head
baarkerlounger 3 years ago
parent
commit
917ed378e7
  1. 4
      app/controllers/organisations_controller.rb
  2. 4
      app/controllers/users_controller.rb
  3. 41
      spec/requests/users_controller_spec.rb

4
app/controllers/organisations_controller.rb

@ -59,9 +59,9 @@ class OrganisationsController < ApplicationController
private private
def filtered_users def filtered_users
if search_param = params["user-search-field"] if (search_param = params["user-search-field"])
User.search_by(search_param) User.search_by(search_param)
else else
User.all User.all
end.filter_by_active end.filter_by_active
end end

4
app/controllers/users_controller.rb

@ -78,9 +78,9 @@ class UsersController < ApplicationController
private private
def filtered_users def filtered_users
if search_param = params["user-search-field"] if (search_param = params["user-search-field"])
User.search_by(search_param) User.search_by(search_param)
else else
User.all User.all
end.filter_by_active end.filter_by_active
end end

41
spec/requests/users_controller_spec.rb

@ -811,36 +811,33 @@ RSpec.describe UsersController, type: :request do
expect(page).not_to have_content(other_org_user.name) expect(page).not_to have_content(other_org_user.name)
end end
end end
context "when our search term matches an email" do context "when our search term matches an email" do
let(:search_param) { "other_org@other_example.com" } let(:search_param) { "other_org@other_example.com" }
it "returns only matching result" do it "returns only matching result" do
expect(page).not_to have_content(user.name) expect(page).not_to have_content(user.name)
expect(page).not_to have_content(other_user.name) expect(page).not_to have_content(other_user.name)
expect(page).not_to have_content(inactive_user.name) expect(page).not_to have_content(inactive_user.name)
expect(page).to have_content(other_org_user.name) expect(page).to have_content(other_org_user.name)
end
end 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!(:other_user) { FactoryBot.create(:user, organisation: user.organisation, name: "joe", email: "other@example.com") } let!(:other_user) { FactoryBot.create(:user, organisation: user.organisation, name: "joe", email: "other@example.com") }
let!(:other_org_user) { FactoryBot.create(:user, name: "User 4", email: "joe@other_example.com") } let!(:other_org_user) { FactoryBot.create(:user, name: "User 4", email: "joe@other_example.com") }
let(:search_param) { "joe" } let(:search_param) { "joe" }
it "returns any results including joe" do it "returns any results including joe" do
expect(page).to have_content(other_user.name) expect(page).to have_content(other_user.name)
expect(page).not_to have_content(inactive_user.name) expect(page).not_to have_content(inactive_user.name)
expect(page).to have_content(other_org_user.name) expect(page).to have_content(other_org_user.name)
expect(page).not_to have_content(user.name) expect(page).not_to have_content(user.name)
end
end end
end end
end end
end end
end
describe "CSV download" do describe "CSV download" do
let(:headers) { { "Accept" => "text/csv" } } let(:headers) { { "Accept" => "text/csv" } }

Loading…
Cancel
Save