gds_zendesk 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +10 -0
- data/.github/workflows/ci.yml +35 -0
- data/.gitignore +0 -15
- data/.rubocop.yml +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +5 -0
- data/README.md +3 -0
- data/Rakefile +1 -5
- data/gds_zendesk.gemspec +6 -4
- data/lib/gds_zendesk/client.rb +4 -3
- data/lib/gds_zendesk/version.rb +1 -1
- data/lib/generators/gds_zendesk/install/install_generator.rb +1 -1
- data/spec/gds_zendesk/client_spec.rb +27 -28
- data/spec/gds_zendesk/dummy_client_spec.rb +8 -8
- data/spec/gds_zendesk/users_spec.rb +25 -27
- metadata +30 -23
- data/Jenkinsfile +0 -7
- /data/{LICENCE.txt → LICENCE} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1806a756294d190c9e4d338680319a62d49b1f6df2cf0baa0ea889b798fd0eaf
|
4
|
+
data.tar.gz: b2e7543717d7211fc9f84b8805b9c78c135a984668c64ea11ace577190f99012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3720fe9f23d27c3213b2999454aa734bece0bb255dd0d5adb9685f042b3809b0e65a4cc1b402d497e55f9f02201317f91e2dae49d29573de2a09e3990d97f991
|
7
|
+
data.tar.gz: da36985b5c8ebdcb65ab3864b85af2d3190f944176c09cda0bf6c280e3c94a7b0424601bf4cfa85c9ab10f72eb09a6e4dd4d888a65cd4ba45c340f50bc9825df
|
@@ -0,0 +1,35 @@
|
|
1
|
+
on: [push, pull_request]
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
test_matrix:
|
5
|
+
strategy:
|
6
|
+
fail-fast: false
|
7
|
+
matrix:
|
8
|
+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
9
|
+
ruby: ['3.0', 3.1, 3.2]
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v3
|
13
|
+
- uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: ${{ matrix.ruby }}
|
16
|
+
bundler-cache: true
|
17
|
+
- run: bundle exec rake
|
18
|
+
|
19
|
+
# Branch protection rules cannot directly depend on status checks from matrix jobs.
|
20
|
+
# So instead we define `test` as a dummy job which only runs after the preceding `test_matrix` checks have passed.
|
21
|
+
# Solution inspired by: https://github.community/t/status-check-for-a-matrix-jobs/127354/3
|
22
|
+
test:
|
23
|
+
needs: test_matrix
|
24
|
+
runs-on: ubuntu-latest
|
25
|
+
steps:
|
26
|
+
- run: echo "All matrix tests have passed 🚀"
|
27
|
+
|
28
|
+
publish:
|
29
|
+
needs: test
|
30
|
+
if: ${{ github.ref == 'refs/heads/main' }}
|
31
|
+
permissions:
|
32
|
+
contents: write
|
33
|
+
uses: alphagov/govuk-infrastructure/.github/workflows/publish-rubygem.yml@main
|
34
|
+
secrets:
|
35
|
+
GEM_HOST_API_KEY: ${{ secrets.ALPHAGOV_RUBYGEMS_API_KEY }}
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/gds_zendesk.gemspec
CHANGED
@@ -11,16 +11,18 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.summary = "Client and models for communicating with Zendesk"
|
12
12
|
gem.homepage = "https://github.com/alphagov/gds_zendesk"
|
13
13
|
|
14
|
+
gem.required_ruby_version = ">= 3.0"
|
15
|
+
|
14
16
|
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
15
17
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
16
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
19
|
gem.require_paths = %w[lib]
|
18
20
|
|
19
21
|
gem.add_dependency "null_logger", "~> 0"
|
20
|
-
gem.add_dependency "zendesk_api", "
|
22
|
+
gem.add_dependency "zendesk_api", ">= 1.37", "< 3.0"
|
21
23
|
|
22
|
-
gem.add_development_dependency "rake"
|
24
|
+
gem.add_development_dependency "rake"
|
23
25
|
gem.add_development_dependency "rspec", "~> 3"
|
24
|
-
gem.add_development_dependency "rubocop-govuk", "
|
25
|
-
gem.add_development_dependency "webmock", "
|
26
|
+
gem.add_development_dependency "rubocop-govuk", "4.10.0"
|
27
|
+
gem.add_development_dependency "webmock", ">= 2"
|
26
28
|
end
|
data/lib/gds_zendesk/client.rb
CHANGED
@@ -6,9 +6,6 @@ require "gds_zendesk/users"
|
|
6
6
|
|
7
7
|
module GDSZendesk
|
8
8
|
class Client
|
9
|
-
extend Forwardable
|
10
|
-
def_delegators :@zendesk_client, :ticket
|
11
|
-
|
12
9
|
attr_accessor :config_options
|
13
10
|
attr_reader :zendesk_client
|
14
11
|
|
@@ -33,6 +30,10 @@ module GDSZendesk
|
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
33
|
+
def ticket
|
34
|
+
@zendesk_client.ticket
|
35
|
+
end
|
36
|
+
|
36
37
|
protected
|
37
38
|
|
38
39
|
def logger
|
data/lib/gds_zendesk/version.rb
CHANGED
@@ -15,60 +15,59 @@ module GDSZendesk
|
|
15
15
|
Client.new(valid_credentials.merge(options))
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
19
|
-
expect {
|
20
|
-
|
18
|
+
it "raises an error if no username is provided" do
|
19
|
+
expect { described_class.new(password: "abc") }
|
20
|
+
.to raise_error(ArgumentError, /username not provided/)
|
21
21
|
end
|
22
22
|
|
23
|
-
it "
|
24
|
-
expect {
|
25
|
-
|
23
|
+
it "raises an error if no password or token is provided" do
|
24
|
+
expect { described_class.new(username: "abc") }
|
25
|
+
.to raise_error(ArgumentError, /password or token not provided/)
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
29
|
-
expect {
|
30
|
-
|
28
|
+
it "raises an error if token and password are provided" do
|
29
|
+
expect { described_class.new(username: "abc", token: "def", password: "ghi") }
|
30
|
+
.to raise_error(ArgumentError, /Provide only one of token or password/)
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
34
|
-
expect {
|
35
|
-
/password or token not provided/)
|
33
|
+
it "does not raise an error if token is provided without password" do
|
34
|
+
expect { described_class.new(username: "abc", token: "def") }.not_to raise_error
|
36
35
|
end
|
37
36
|
|
38
|
-
it "
|
39
|
-
expect {
|
40
|
-
/password or token not provided/)
|
37
|
+
it "does not raise an error if password is provided without token" do
|
38
|
+
expect { described_class.new(username: "abc", password: "def") }.not_to raise_error
|
41
39
|
end
|
42
40
|
|
43
|
-
it "
|
41
|
+
it "uses a null logger if no logger has been provided" do
|
44
42
|
expect(client.config_options[:logger]).to be_an_instance_of(NullLogger::Logger)
|
45
43
|
end
|
46
44
|
|
47
|
-
it "
|
48
|
-
custom_logger =
|
45
|
+
it "uses the passed logger if one has been provided" do
|
46
|
+
custom_logger = instance_double("Logger")
|
49
47
|
|
50
48
|
expect(client(logger: custom_logger).config_options[:logger]).to eq(custom_logger)
|
51
49
|
end
|
52
50
|
|
53
|
-
it "
|
51
|
+
it "uses the default url if no url is provided" do
|
54
52
|
expect(client.config_options[:url]).to eq "https://govuk.zendesk.com/api/v2/"
|
55
53
|
end
|
56
54
|
|
57
|
-
it "
|
58
|
-
expect(
|
55
|
+
it "uses the token if provided" do
|
56
|
+
expect(described_class.new(username: "test_user", token: "test_token").config_options[:token]).to eq "test_token"
|
59
57
|
end
|
60
58
|
|
61
|
-
it "
|
62
|
-
expect(
|
59
|
+
it "uses the password if provided" do
|
60
|
+
expect(described_class.new(username: "test_user", password: "test_password").config_options[:password]).to eq "test_password"
|
63
61
|
end
|
64
62
|
|
65
|
-
it "
|
66
|
-
|
63
|
+
it "uses the configured url if provided" do
|
64
|
+
instance = described_class.new(username: "test_user", password: "test_pass", url: "https://example.com")
|
65
|
+
expect(instance.config_options[:url]).to eq "https://example.com"
|
67
66
|
end
|
68
67
|
|
69
|
-
it "
|
68
|
+
it "raises tickets in Zendesk" do
|
70
69
|
self.valid_zendesk_credentials = valid_credentials
|
71
|
-
post_stub = stub_zendesk_ticket_creation(some: "data")
|
70
|
+
post_stub = stub_zendesk_ticket_creation(some: "data", comment: nil)
|
72
71
|
|
73
72
|
client.ticket.create(some: "data")
|
74
73
|
|
@@ -79,7 +78,7 @@ module GDSZendesk
|
|
79
78
|
self.valid_zendesk_credentials = valid_credentials
|
80
79
|
post_stub = stub_request(:post, "#{zendesk_endpoint}/tickets").to_return(status: 302)
|
81
80
|
|
82
|
-
expect { client.ticket.create!(some: "data") }.to raise_error
|
81
|
+
expect { client.ticket.create!(some: "data") }.to raise_error(ZendeskAPI::Error::NetworkError)
|
83
82
|
expect(post_stub).to have_been_requested
|
84
83
|
end
|
85
84
|
end
|
@@ -5,17 +5,17 @@ module GDSZendesk
|
|
5
5
|
context "when a ticket has been raised" do
|
6
6
|
let(:ticket_options) { { opt1: "val1" } }
|
7
7
|
|
8
|
-
it "
|
9
|
-
logger =
|
8
|
+
it "logs the ticket details" do
|
9
|
+
logger = instance_double("Logger")
|
10
10
|
expect(logger).to receive(:info).with("Zendesk ticket created: #{ticket_options.inspect}")
|
11
11
|
|
12
|
-
client =
|
12
|
+
client = described_class.new(logger: logger)
|
13
13
|
client.ticket.create!(ticket_options)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "can simulate failures, triggered by a specific description or comment" do
|
17
|
-
logger =
|
18
|
-
client =
|
17
|
+
logger = instance_double("Logger")
|
18
|
+
client = described_class.new(logger: logger)
|
19
19
|
expect(logger).to receive(:info).with(/Simulating Zendesk ticket creation failure/).twice
|
20
20
|
|
21
21
|
expect {
|
@@ -31,11 +31,11 @@ module GDSZendesk
|
|
31
31
|
context "when a user has been created" do
|
32
32
|
let(:options) { { email: "a@b.com" } }
|
33
33
|
|
34
|
-
it "
|
35
|
-
logger =
|
34
|
+
it "logs the user details" do
|
35
|
+
logger = instance_double("Logger")
|
36
36
|
expect(logger).to receive(:info).with("Zendesk user created or updated: #{options.inspect}")
|
37
37
|
|
38
|
-
client =
|
38
|
+
client = described_class.new(logger: logger)
|
39
39
|
client.users.create_or_update_user(options)
|
40
40
|
end
|
41
41
|
end
|
@@ -4,57 +4,55 @@ require "gds_zendesk/client"
|
|
4
4
|
require "gds_zendesk/users"
|
5
5
|
require "gds_zendesk/test_helpers"
|
6
6
|
|
7
|
+
# rubocop:disable RSpec/VerifiedDoubles -- It's unclear that the user classes can be verified doubles
|
7
8
|
module GDSZendesk
|
8
9
|
describe Users do
|
9
10
|
include GDSZendesk::TestHelpers
|
10
11
|
|
11
12
|
let(:users) { Client.new(valid_zendesk_credentials).users }
|
12
13
|
|
13
|
-
context "existing
|
14
|
+
context "when there is an existing user" do
|
14
15
|
before do
|
15
16
|
zendesk_has_user(email: "test@test.com", id: 123)
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
users.create_or_update_user(double("requested user", email: "test@test.com", phone: "12345", job: "Developer"))
|
19
|
+
it "can update the user" do
|
20
|
+
stub_post = stub_zendesk_user_update(123, phone: "12345", details: "Job title: Developer")
|
21
|
+
users.create_or_update_user(double("requested user", email: "test@test.com", phone: "12345", job: "Developer"))
|
22
22
|
|
23
|
-
|
24
|
-
end
|
23
|
+
expect(stub_post).to have_been_requested
|
25
24
|
end
|
26
25
|
|
27
|
-
it "
|
26
|
+
it "knows whether the user is suspended or not" do
|
28
27
|
zendesk_has_user(email: "test@test.com", id: 123, suspended: "true")
|
29
|
-
expect(users.
|
28
|
+
expect(users).to be_suspended("test@test.com")
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
|
-
context "
|
32
|
+
context "when a user doesn't exist" do
|
34
33
|
before do
|
35
34
|
zendesk_has_no_user_with_email("test@test.com")
|
36
35
|
end
|
37
36
|
|
38
|
-
it "
|
39
|
-
expect(users).
|
37
|
+
it "doesn't have any suspended users" do
|
38
|
+
expect(users).not_to be_suspended("test@test.com")
|
40
39
|
end
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
expect(stub_post).to have_been_requested
|
56
|
-
end
|
41
|
+
it "can create that user" do
|
42
|
+
stub_post = stub_zendesk_user_creation(
|
43
|
+
verified: true,
|
44
|
+
name: "Abc",
|
45
|
+
email: "test@test.com",
|
46
|
+
phone: "12345",
|
47
|
+
details: "Job title: Developer",
|
48
|
+
)
|
49
|
+
user_being_requested = double("requested user",
|
50
|
+
name: "Abc", email: "test@test.com", phone: "12345", job: "Developer")
|
51
|
+
|
52
|
+
users.create_or_update_user(user_being_requested)
|
53
|
+
expect(stub_post).to have_been_requested
|
57
54
|
end
|
58
55
|
end
|
59
56
|
end
|
60
57
|
end
|
58
|
+
# rubocop:enable RSpec/VerifiedDoubles
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds_zendesk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: null_logger
|
@@ -28,30 +28,36 @@ dependencies:
|
|
28
28
|
name: zendesk_api
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.37'
|
34
|
+
- - "<"
|
32
35
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
36
|
+
version: '3.0'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.37'
|
44
|
+
- - "<"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
46
|
+
version: '3.0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: rake
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - "
|
51
|
+
- - ">="
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
53
|
+
version: '0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - "
|
58
|
+
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
60
|
+
version: '0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rspec
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,28 +76,28 @@ dependencies:
|
|
70
76
|
name: rubocop-govuk
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
|
-
- -
|
79
|
+
- - '='
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
81
|
+
version: 4.10.0
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
|
-
- -
|
86
|
+
- - '='
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
88
|
+
version: 4.10.0
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: webmock
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
|
-
- - "
|
93
|
+
- - ">="
|
88
94
|
- !ruby/object:Gem::Version
|
89
95
|
version: '2'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
|
-
- - "
|
100
|
+
- - ">="
|
95
101
|
- !ruby/object:Gem::Version
|
96
102
|
version: '2'
|
97
103
|
description: Client and models for communicating with Zendesk
|
@@ -101,13 +107,14 @@ executables: []
|
|
101
107
|
extensions: []
|
102
108
|
extra_rdoc_files: []
|
103
109
|
files:
|
110
|
+
- ".github/dependabot.yml"
|
111
|
+
- ".github/workflows/ci.yml"
|
104
112
|
- ".gitignore"
|
105
113
|
- ".rubocop.yml"
|
106
114
|
- ".ruby-version"
|
107
115
|
- CHANGELOG.md
|
108
116
|
- Gemfile
|
109
|
-
-
|
110
|
-
- LICENCE.txt
|
117
|
+
- LICENCE
|
111
118
|
- README.md
|
112
119
|
- Rakefile
|
113
120
|
- gds_zendesk.gemspec
|
@@ -125,7 +132,7 @@ files:
|
|
125
132
|
homepage: https://github.com/alphagov/gds_zendesk
|
126
133
|
licenses: []
|
127
134
|
metadata: {}
|
128
|
-
post_install_message:
|
135
|
+
post_install_message:
|
129
136
|
rdoc_options: []
|
130
137
|
require_paths:
|
131
138
|
- lib
|
@@ -133,15 +140,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
140
|
requirements:
|
134
141
|
- - ">="
|
135
142
|
- !ruby/object:Gem::Version
|
136
|
-
version: '0'
|
143
|
+
version: '3.0'
|
137
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
145
|
requirements:
|
139
146
|
- - ">="
|
140
147
|
- !ruby/object:Gem::Version
|
141
148
|
version: '0'
|
142
149
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
150
|
+
rubygems_version: 3.2.33
|
151
|
+
signing_key:
|
145
152
|
specification_version: 4
|
146
153
|
summary: Client and models for communicating with Zendesk
|
147
154
|
test_files:
|
data/Jenkinsfile
DELETED
/data/{LICENCE.txt → LICENCE}
RENAMED
File without changes
|