|
|
@ -842,7 +842,11 @@ RSpec.describe UsersController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "updates the table caption" do |
|
|
|
it "updates the table caption" do |
|
|
|
expect(page).to have_content("1 user found matching ‘Danny’ of 4 total users.") |
|
|
|
expect(page).to have_content("1 user found matching ‘#{search_param}’ of 4 total users.") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "includes the search term in the CSV download link" do |
|
|
|
|
|
|
|
expect(page).to have_link("Download (CSV)", href: "/users.csv?search=#{search_param}") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -895,6 +899,10 @@ RSpec.describe UsersController, type: :request do |
|
|
|
before do |
|
|
|
before do |
|
|
|
FactoryBot.create_list(:user, 25) |
|
|
|
FactoryBot.create_list(:user, 25) |
|
|
|
sign_in user |
|
|
|
sign_in user |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when there is no search param" do |
|
|
|
|
|
|
|
before do |
|
|
|
get "/users", headers:, params: {} |
|
|
|
get "/users", headers:, params: {} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -915,6 +923,19 @@ RSpec.describe UsersController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when there is a search param" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
FactoryBot.create(:user, name: "Unusual name") |
|
|
|
|
|
|
|
get "/users?search=unusual", headers:, params: {} |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "downloads only the matching records" do |
|
|
|
|
|
|
|
csv = CSV.parse(response.body) |
|
|
|
|
|
|
|
expect(csv.count).to eq(2) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "#show" do |
|
|
|
describe "#show" do |
|
|
|
context "when the current user matches the user ID" do |
|
|
|
context "when the current user matches the user ID" do |
|
|
|
before do |
|
|
|
before do |
|
|
|