zendesk2 1.5.14 → 1.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/zendesk2/client/requests/search_user.rb +11 -2
- data/lib/zendesk2/version.rb +1 -1
- data/spec/users_spec.rb +15 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e823cea0adfb5da98e4a120de30bc3519dff8e84
|
4
|
+
data.tar.gz: baf13f4e2729391fa5f1861435dd0a623478560d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76ef365c7f1943c5a90143137a2008e065d28797b6b2c4aea704a1d300384373e7df30bf5a179deb0609203d35b2ee6e0ebafdbc2ab0796448c22b6634436741
|
7
|
+
data.tar.gz: 438f9bdd820f2bb9a9a1ac3d688aa11b1afcd256e4695425b9e72fcfc1e418d71493b736434e3b0caba9cb110178dbc00e1cb3d9fd625723ac3e5af2832f3511
|
@@ -27,7 +27,7 @@ class Zendesk2::Client::SearchUser < Zendesk2::Client::Request
|
|
27
27
|
|
28
28
|
# create a copy of each user mapped to a specific user identity
|
29
29
|
collection = collection.map do |user|
|
30
|
-
self.data[:identities].values.select{|i| i["type"] == "email" && i["user_id"] == user["id"]}.map do |identity|
|
30
|
+
self.data[:identities].values.select { |i| i["type"] == "email" && i["user_id"] == user["id"] }.map do |identity|
|
31
31
|
user.merge("email" => identity["value"])
|
32
32
|
end
|
33
33
|
end.flatten
|
@@ -55,12 +55,21 @@ class Zendesk2::Client::SearchUser < Zendesk2::Client::Request
|
|
55
55
|
r.merge(term => condition)
|
56
56
|
end
|
57
57
|
|
58
|
-
|
58
|
+
munged_results = collection.select do |v|
|
59
59
|
compiled_terms.all? do |term, condition|
|
60
60
|
condition.is_a?(Regexp) ? condition.match(v[term.to_s]) : v[term.to_s].to_s == condition.to_s
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
# return the unmunged data
|
65
|
+
results = munged_results.map { |u|
|
66
|
+
identities = self.data[:identities].values.select { |i| i["user_id"] == u["id"] }
|
67
|
+
|
68
|
+
if identity = identities.find { |i| i["type"] == "email" && i["primary"] } || identities.find { |i| i["type"] == "email" }
|
69
|
+
u.merge!("email" => identity["value"])
|
70
|
+
end
|
71
|
+
}
|
72
|
+
|
64
73
|
page(results, params: {"query" => query}, root: "results")
|
65
74
|
end
|
66
75
|
end
|
data/lib/zendesk2/version.rb
CHANGED
data/spec/users_spec.rb
CHANGED
@@ -44,8 +44,8 @@ describe "users" do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
describe "#search" do
|
48
|
-
it "should find a user based on details criteria with wildcards and by organization name"
|
47
|
+
describe "#search", :mock_only do
|
48
|
+
it "should find a user based on details criteria with wildcards and by organization name" do
|
49
49
|
# detached user
|
50
50
|
client.users.create!(email: mock_email, name: mock_uuid)
|
51
51
|
|
@@ -59,6 +59,19 @@ describe "users" do
|
|
59
59
|
expect(client.users.search(details: "*michelle*", organization: org.name)).to contain_exactly(user)
|
60
60
|
expect(client.users.search(details: "*michelle*", organization: org.name[0..6])).to include(user)
|
61
61
|
end
|
62
|
+
|
63
|
+
context "when a user has multiple identities and searching by email" do
|
64
|
+
it "should display the primary email in the results" do
|
65
|
+
user = client.users.create!(email: (primary = mock_email), name: mock_uuid)
|
66
|
+
|
67
|
+
# create some extra identities
|
68
|
+
user.identities.create!(value: mock_email, type: "email")
|
69
|
+
user.identities.create!(value: (target = mock_email), type: "email")
|
70
|
+
|
71
|
+
# primary email should be returned in the results
|
72
|
+
expect(client.users.search(email: target).first.email).to eq(primary)
|
73
|
+
end
|
74
|
+
end
|
62
75
|
end
|
63
76
|
|
64
77
|
context "with a user" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zendesk2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cistern
|