Skip to content

Commit

Permalink
spec for returning distinct API users ransack search result
Browse files Browse the repository at this point in the history
  • Loading branch information
hefan committed Jul 1, 2020
1 parent 12944a1 commit 42a5d46
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions api/spec/requests/spree/api/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ module Spree
expect(response.status).to eq(422)
expect(json_response).to eq({ "error" => "Cannot delete record." })
end

it "returns distinct search results" do
distinct_user = create(:user, email: 'distinct_test@solidus.com')
distinct_user.addresses << create(:address)
distinct_user.addresses << create(:address)
get spree.api_users_path, params: {
q: {
m: 'or',
email_start: 'distinct_test',
firstname_or_lastname_start: 'distinct_test'
}
}
expect(json_response['count']).to eq(1)
expect(json_response['users'].first['email']).to eq distinct_user.email
end
end
end
end

0 comments on commit 42a5d46

Please sign in to comment.