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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 212f75df35d4fbe686de231d98ea2bf37e38e135e58d80c92e1a650b4f393327
4
- data.tar.gz: ab77b135f4a7e10107eef99fff1d221409902ca8458d73caedd3b760e553221d
3
+ metadata.gz: 1806a756294d190c9e4d338680319a62d49b1f6df2cf0baa0ea889b798fd0eaf
4
+ data.tar.gz: b2e7543717d7211fc9f84b8805b9c78c135a984668c64ea11ace577190f99012
5
5
  SHA512:
6
- metadata.gz: fdaf04d4cdf2fa3fd2b5d7cc48f93130008a4cf134372e97bf622d38872d6d56655dfa7f232f3a52c0474e673b9dbd04c9571a72a2d04c7fbc139afb3284879b
7
- data.tar.gz: 94112efde5839d160cdac16d10aa50cc60e665d1e33ee5ddf219fca4bf3ec837e2c7d3f36c44b930910e4932a25836816510e839021f7c003cbebf9508a58afe
6
+ metadata.gz: 3720fe9f23d27c3213b2999454aa734bece0bb255dd0d5adb9685f042b3809b0e65a4cc1b402d497e55f9f02201317f91e2dae49d29573de2a09e3990d97f991
7
+ data.tar.gz: da36985b5c8ebdcb65ab3864b85af2d3190f944176c09cda0bf6c280e3c94a7b0424601bf4cfa85c9ab10f72eb09a6e4dd4d888a65cd4ba45c340f50bc9825df
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: /
5
+ schedule:
6
+ interval: daily
7
+ - package-ecosystem: "github-actions"
8
+ directory: /
9
+ schedule:
10
+ interval: daily
@@ -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
@@ -1,17 +1,2 @@
1
1
  *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
2
  Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
data/.rubocop.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  inherit_gem:
2
2
  rubocop-govuk:
3
3
  - config/default.yml
4
+ - config/rspec.yml
4
5
 
5
6
  inherit_mode:
6
7
  merge:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.6
1
+ 3.0.5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 3.4.0
2
+
3
+ * Drop support for Ruby 2.7 and below.
4
+ * Require a `zendesk_api` of ">= 1.37", "< 3.0"
5
+
1
6
  # 3.3.0
2
7
 
3
8
  * Allow access to Zendesk::Client from GDSZendesk::Client
data/README.md CHANGED
@@ -61,3 +61,6 @@ To run the tests, use the follow:
61
61
  ```
62
62
  bundle exec rake default
63
63
  ```
64
+ # Licence
65
+
66
+ [MIT License](LICENCE)
data/Rakefile CHANGED
@@ -6,8 +6,4 @@ require "rspec/core/rake_task"
6
6
  RuboCop::RakeTask.new
7
7
  RSpec::Core::RakeTask.new(:spec)
8
8
 
9
- desc "Linting for Ruby"
10
- task lint: %i[rubocop] do
11
- end
12
-
13
- task default: %i[lint spec]
9
+ task default: %i[rubocop spec]
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", "~> 1.27"
22
+ gem.add_dependency "zendesk_api", ">= 1.37", "< 3.0"
21
23
 
22
- gem.add_development_dependency "rake", "~> 10"
24
+ gem.add_development_dependency "rake"
23
25
  gem.add_development_dependency "rspec", "~> 3"
24
- gem.add_development_dependency "rubocop-govuk", "~> 3"
25
- gem.add_development_dependency "webmock", "~> 2"
26
+ gem.add_development_dependency "rubocop-govuk", "4.10.0"
27
+ gem.add_development_dependency "webmock", ">= 2"
26
28
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module GDSZendesk
2
- VERSION = "3.3.0".freeze
2
+ VERSION = "3.4.0".freeze
3
3
  end
@@ -2,7 +2,7 @@ INITIALIZER = <<~RUBY.freeze
2
2
  require 'yaml'
3
3
  require 'gds_zendesk/client'
4
4
  require 'gds_zendesk/dummy_client'
5
-
5
+
6
6
  GDS_ZENDESK_CLIENT = if Rails.env.development? || Rails.env.test?
7
7
  GDSZendesk::DummyClient.new(logger: Rails.logger)
8
8
  else
@@ -15,60 +15,59 @@ module GDSZendesk
15
15
  Client.new(valid_credentials.merge(options))
16
16
  end
17
17
 
18
- it "should raise an error if no username is provided" do
19
- expect { Client.new(password: "abc") }.to raise_error(ArgumentError,
20
- /username not provided/)
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 "should raise an error if no password or token is provided" do
24
- expect { Client.new(username: "abc") }.to raise_error(ArgumentError,
25
- /password or token not provided/)
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 "should raise an error if token and password are provided" do
29
- expect { Client.new(username: "abc", token: "def", password: "ghi") }.to raise_error(ArgumentError,
30
- /Provide only one of token or password/)
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 "should not raise an error if token is provided without password" do
34
- expect { Client.new(username: "abc", token: "def") }.not_to raise_error(ArgumentError,
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 "should not raise an error if password is provided without token" do
39
- expect { Client.new(username: "abc", password: "def") }.not_to raise_error(ArgumentError,
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 "should use a null logger if no logger has been provided" do
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 "should use the passed logger if one has been provided" do
48
- custom_logger = double("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 "should use the default url if no url is provided" do
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 "should use the token if provided" do
58
- expect(Client.new(username: "test_user", token: "test_token").config_options[:token]).to eq "test_token"
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 "should use the password if provided" do
62
- expect(Client.new(username: "test_user", password: "test_password").config_options[:password]).to eq "test_password"
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 "should use the configured url if provided" do
66
- expect(Client.new(username: "test_user", password: "test_pass", url: "https://example.com").config_options[:url]).to eq "https://example.com"
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 "should raise tickets in Zendesk" do
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 "should log the ticket details" do
9
- logger = double("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 = DummyClient.new(logger: logger)
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 = double("logger")
18
- client = DummyClient.new(logger: logger)
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 "should log the user details" do
35
- logger = double("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 = DummyClient.new(logger: logger)
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 users" do
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
- context "creating/updating a user" do
19
- it "should update the phone and job title if those are set" 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"))
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
- expect(stub_post).to have_been_requested
24
- end
23
+ expect(stub_post).to have_been_requested
25
24
  end
26
25
 
27
- it "should know whether the user is suspended or not" do
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.suspended?("test@test.com")).to be_truthy
28
+ expect(users).to be_suspended("test@test.com")
30
29
  end
31
30
  end
32
31
 
33
- context "non-existent users" do
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 "should not be suspended" do
39
- expect(users).to_not be_suspended("test@test.com")
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
- context "creating/updating" do
43
- it "should create that user" do
44
- stub_post = stub_zendesk_user_creation(
45
- verified: true,
46
- name: "Abc",
47
- email: "test@test.com",
48
- phone: "12345",
49
- details: "Job title: Developer",
50
- )
51
- user_being_requested = double("requested user",
52
- name: "Abc", email: "test@test.com", phone: "12345", job: "Developer")
53
-
54
- users.create_or_update_user(user_being_requested)
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.3.0
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: 2022-04-20 00:00:00.000000000 Z
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: '1.27'
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: '1.27'
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: '10'
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: '10'
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: '3'
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: '3'
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
- - Jenkinsfile
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.0.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
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env groovy
2
-
3
- library("govuk")
4
-
5
- node {
6
- govuk.buildProject()
7
- }
File without changes