txgh-queue 2.1.0 → 3.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/txgh-queue/application.rb +6 -0
  3. data/lib/txgh-queue/error_handlers/gitlab.rb +39 -0
  4. data/lib/txgh-queue/error_handlers.rb +1 -0
  5. data/lib/txgh-queue/job.rb +20 -3
  6. data/lib/txgh-queue/supervisor.rb +1 -0
  7. data/lib/txgh-queue/version.rb +1 -1
  8. data/lib/txgh-queue/webhooks/gitlab/request_handler.rb +26 -0
  9. data/lib/txgh-queue/webhooks/gitlab.rb +7 -0
  10. data/lib/txgh-queue/webhooks.rb +1 -0
  11. data/spec/application_spec.rb +34 -4
  12. data/spec/backends/sqs/config_spec.rb +4 -6
  13. data/spec/backends/sqs/consumer_spec.rb +3 -6
  14. data/spec/backends/sqs/history_sequence_spec.rb +1 -4
  15. data/spec/backends/sqs/job_spec.rb +21 -24
  16. data/spec/backends/sqs/message_attributes_spec.rb +3 -6
  17. data/spec/backends/sqs/producer_spec.rb +1 -3
  18. data/spec/backends/sqs/queue_spec.rb +1 -3
  19. data/spec/backends/sqs/retry_logic_spec.rb +11 -14
  20. data/spec/backends/sqs_spec.rb +5 -7
  21. data/spec/backends_spec.rb +1 -3
  22. data/spec/error_handlers/github_spec.rb +2 -4
  23. data/spec/error_handlers/gitlab_spec.rb +39 -0
  24. data/spec/error_handlers/network_errors_spec.rb +5 -7
  25. data/spec/error_handlers/server_response_spec.rb +5 -7
  26. data/spec/error_handlers/standard_errors_spec.rb +3 -5
  27. data/spec/error_handlers/transifex_spec.rb +4 -6
  28. data/spec/error_handlers/txgh_errors_spec.rb +1 -3
  29. data/spec/job_spec.rb +6 -8
  30. data/spec/result_spec.rb +3 -5
  31. data/spec/status_spec.rb +1 -3
  32. data/spec/supervisor_spec.rb +6 -8
  33. data/spec/webhooks/github/request_handler_spec.rb +6 -8
  34. data/spec/webhooks/gitlab/request_handler_spec.rb +144 -0
  35. data/spec/webhooks/transifex/request_handler_spec.rb +1 -3
  36. data/txgh-queue.gemspec +2 -3
  37. metadata +15 -10
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- include TxghQueue
4
-
5
- describe Backends do
3
+ describe TxghQueue::Backends do
6
4
  describe '.register' do
7
5
  it 'associates the name of a backend with a class' do
8
6
  # use a string just for testing purposes; second argument should be a class
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- include TxghQueue
4
-
5
- describe ErrorHandlers::Github do
3
+ describe TxghQueue::ErrorHandlers::Github do
6
4
  describe '.can_handle?' do
7
5
  it 'can reply to all configured error classes' do
8
6
  described_class::ERROR_CLASSES.keys.each do |klass|
@@ -24,7 +22,7 @@ describe ErrorHandlers::Github do
24
22
 
25
23
  it 'replies to all unconfigured errors with fail' do
26
24
  # i.e. if octokit raises an error we didn't account for
27
- expect(described_class.status_for(StandardError.new)).to eq(Status.fail)
25
+ expect(described_class.status_for(StandardError.new)).to eq(TxghQueue::Status.fail)
28
26
  end
29
27
  end
30
28
  end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe TxghQueue::ErrorHandlers::Gitlab do
4
+ let(:gitlab_error_response) do
5
+ OpenStruct.new({
6
+ code: 404,
7
+ request: double(base_uri: 'https://gitlab.com/api/v3', path: '/foo'),
8
+ parsed_response: ::Gitlab::ObjectifiedHash.new(
9
+ error_description: 'Displayed error_description',
10
+ error: 'also will not be displayed'
11
+ )
12
+ })
13
+ end
14
+
15
+ describe '.can_handle?' do
16
+ it 'can reply to all configured error classes' do
17
+ described_class::ERROR_CLASSES.keys.each do |klass|
18
+ expect(described_class.can_handle?(klass.new(gitlab_error_response))).to eq(true)
19
+ end
20
+ end
21
+
22
+ it "can't reply to unsupported error classes" do
23
+ expect(described_class.can_handle?(StandardError.new)).to eq(false)
24
+ end
25
+ end
26
+
27
+ describe '.status_for' do
28
+ it 'replies to all configured errors correctly' do
29
+ described_class::ERROR_CLASSES.each_pair do |klass, expected_response|
30
+ expect(described_class.status_for(klass.new(gitlab_error_response))).to eq(expected_response)
31
+ end
32
+ end
33
+
34
+ it 'replies to all unconfigured errors with fail' do
35
+ # i.e. if gitlab raises an error we didn't account for
36
+ expect(described_class.status_for(StandardError.new)).to eq(TxghQueue::Status.fail)
37
+ end
38
+ end
39
+ end
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- include TxghQueue
4
-
5
- describe ErrorHandlers::NetworkErrors do
3
+ describe TxghQueue::ErrorHandlers::NetworkErrors do
6
4
  describe '.can_handle?' do
7
5
  it 'can reply to faraday connection errors' do
8
6
  error = Faraday::ConnectionFailed.new(StandardError.new)
@@ -28,22 +26,22 @@ describe ErrorHandlers::NetworkErrors do
28
26
  describe '.status_for' do
29
27
  it 'retries with delay on faraday connection error' do
30
28
  error = Faraday::ConnectionFailed.new(StandardError.new)
31
- expect(described_class.status_for(error)).to eq(Status.retry_with_delay)
29
+ expect(described_class.status_for(error)).to eq(TxghQueue::Status.retry_with_delay)
32
30
  end
33
31
 
34
32
  it 'retries with delay on faraday timeout error' do
35
33
  error = Faraday::TimeoutError.new
36
- expect(described_class.status_for(error)).to eq(Status.retry_with_delay)
34
+ expect(described_class.status_for(error)).to eq(TxghQueue::Status.retry_with_delay)
37
35
  end
38
36
 
39
37
  it 'retries with delay on ruby open timeout error' do
40
38
  error = Net::OpenTimeout.new
41
- expect(described_class.status_for(error)).to eq(Status.retry_with_delay)
39
+ expect(described_class.status_for(error)).to eq(TxghQueue::Status.retry_with_delay)
42
40
  end
43
41
 
44
42
  it 'retries with delay on ruby read timeout error' do
45
43
  error = Net::ReadTimeout.new
46
- expect(described_class.status_for(error)).to eq(Status.retry_with_delay)
44
+ expect(described_class.status_for(error)).to eq(TxghQueue::Status.retry_with_delay)
47
45
  end
48
46
  end
49
47
  end
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- include TxghQueue
4
-
5
- describe ErrorHandlers::ServerResponse do
3
+ describe TxghQueue::ErrorHandlers::ServerResponse do
6
4
  describe '.can_handle?' do
7
5
  it 'can reply to TxghServer responses' do
8
6
  server_response = TxghServer::Response.new(200, 'Ok')
@@ -18,25 +16,25 @@ describe ErrorHandlers::ServerResponse do
18
16
  it 'replies with ok if the status code is in the 200 range' do
19
17
  server_response = TxghServer::Response.new(201, 'Created')
20
18
  reply = described_class.status_for(server_response)
21
- expect(reply).to eq(Status.ok)
19
+ expect(reply).to eq(TxghQueue::Status.ok)
22
20
  end
23
21
 
24
22
  it 'replies with ok if the status code is in the 300 range' do
25
23
  server_response = TxghServer::Response.new(304, 'Not modified')
26
24
  reply = described_class.status_for(server_response)
27
- expect(reply).to eq(Status.ok)
25
+ expect(reply).to eq(TxghQueue::Status.ok)
28
26
  end
29
27
 
30
28
  it 'replies with fail if the status code is in the 400 range' do
31
29
  server_response = TxghServer::Response.new(404, 'Not found')
32
30
  reply = described_class.status_for(server_response)
33
- expect(reply).to eq(Status.fail)
31
+ expect(reply).to eq(TxghQueue::Status.fail)
34
32
  end
35
33
 
36
34
  it 'replies with fail if the status code is in the 500 range' do
37
35
  server_response = TxghServer::Response.new(502, 'Bad gateway')
38
36
  reply = described_class.status_for(server_response)
39
- expect(reply).to eq(Status.fail)
37
+ expect(reply).to eq(TxghQueue::Status.fail)
40
38
  end
41
39
  end
42
40
  end
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- include TxghQueue
4
-
5
- describe ErrorHandlers::StandardErrors do
3
+ describe TxghQueue::ErrorHandlers::StandardErrors do
6
4
  describe '.can_handle?' do
7
5
  it 'can reply to StandardError' do
8
6
  expect(described_class.can_handle?(StandardError.new)).to eq(true)
@@ -15,8 +13,8 @@ describe ErrorHandlers::StandardErrors do
15
13
 
16
14
  describe '.status_for' do
17
15
  it 'always responds with fail' do
18
- expect(described_class.status_for(StandardError.new)).to eq(Status.fail)
19
- expect(described_class.status_for('foo')).to eq(Status.fail)
16
+ expect(described_class.status_for(StandardError.new)).to eq(TxghQueue::Status.fail)
17
+ expect(described_class.status_for('foo')).to eq(TxghQueue::Status.fail)
20
18
  end
21
19
  end
22
20
  end
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- include TxghQueue
4
-
5
- describe ErrorHandlers::Transifex do
3
+ describe TxghQueue::ErrorHandlers::Transifex do
6
4
  describe '.can_handle?' do
7
5
  it 'can reply to transifex api errors' do
8
6
  error = Txgh::TransifexApiError.new(500, 'Internal error')
@@ -27,17 +25,17 @@ describe ErrorHandlers::Transifex do
27
25
  describe '.status_for' do
28
26
  it 'retries with delay on api error' do
29
27
  error = Txgh::TransifexApiError.new(500, 'Internal error')
30
- expect(described_class.status_for(error)).to eq(Status.retry_with_delay)
28
+ expect(described_class.status_for(error)).to eq(TxghQueue::Status.retry_with_delay)
31
29
  end
32
30
 
33
31
  it 'fails on not found error' do
34
32
  error = Txgh::TransifexNotFoundError.new
35
- expect(described_class.status_for(error)).to eq(Status.fail)
33
+ expect(described_class.status_for(error)).to eq(TxghQueue::Status.fail)
36
34
  end
37
35
 
38
36
  it 'fails on unauthorized error' do
39
37
  error = Txgh::TransifexUnauthorizedError.new
40
- expect(described_class.status_for(error)).to eq(Status.fail)
38
+ expect(described_class.status_for(error)).to eq(TxghQueue::Status.fail)
41
39
  end
42
40
  end
43
41
  end
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- include TxghQueue
4
-
5
- describe ErrorHandlers::TxghErrors do
3
+ describe TxghQueue::ErrorHandlers::TxghErrors do
6
4
  describe '.can_handle?' do
7
5
  it 'can reply to all configured error classes' do
8
6
  described_class::ERROR_CLASSES.keys.each do |klass|
data/spec/job_spec.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- include TxghQueue
4
-
5
- describe Job, auto_configure: true do
3
+ describe TxghQueue::Job, auto_configure: true do
6
4
  let(:logger) { NilLogger.new }
7
5
  let(:repo_name) { 'my_repo' }
8
- let(:txgh_config) { Txgh::Config::ConfigPair.new(:github_repo, :transifex_project) }
6
+ let(:txgh_config) { Txgh::Config::ConfigPair.new(:git_repo, :transifex_project) }
9
7
  let(:job) { described_class.new(logger) }
10
8
 
11
9
  before(:each) do
@@ -19,14 +17,14 @@ describe Job, auto_configure: true do
19
17
  server_response = TxghServer::Response.new(200, 'Ok')
20
18
  expect(handler).to receive(:execute).and_return(server_response)
21
19
  result = job.process(payload)
22
- expect(result.status).to eq(Status.ok)
20
+ expect(result.status).to eq(TxghQueue::Status.ok)
23
21
  expect(result.response).to eq(server_response)
24
22
  end
25
23
 
26
24
  it 'responds appropriately when an error is raised' do
27
25
  expect(handler).to receive(:execute).and_raise(StandardError)
28
26
  result = job.process(payload)
29
- expect(result.status).to eq(Status.fail)
27
+ expect(result.status).to eq(TxghQueue::Status.fail)
30
28
  expect(result.error).to be_a(StandardError)
31
29
  end
32
30
 
@@ -34,7 +32,7 @@ describe Job, auto_configure: true do
34
32
  server_response = TxghServer::Response.new(404, 'Not found')
35
33
  expect(handler).to receive(:execute).and_return(server_response)
36
34
  result = job.process(payload)
37
- expect(result.status).to eq(Status.fail)
35
+ expect(result.status).to eq(TxghQueue::Status.fail)
38
36
  expect(result.response).to eq(server_response)
39
37
  end
40
38
  end
@@ -102,7 +100,7 @@ describe Job, auto_configure: true do
102
100
  describe '#process' do
103
101
  it 'responds with fail' do
104
102
  result = job.process(payload)
105
- expect(result.status).to eq(Status.fail)
103
+ expect(result.status).to eq(TxghQueue::Status.fail)
106
104
  expect(result.response.status).to eq(400)
107
105
  expect(result.response.body).to eq([error: 'Unexpected event type'])
108
106
  end
data/spec/result_spec.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- include TxghQueue
4
-
5
- describe Result do
3
+ describe TxghQueue::Result do
6
4
  context 'with a response' do
7
5
  let(:response) { TxghServer::Response.new(200, 'Ok') }
8
- let(:result) { Result.new(Status.ok, response) }
6
+ let(:result) { described_class.new(TxghQueue::Status.ok, response) }
9
7
 
10
8
  describe 'has_response?' do
11
9
  it 'does have a response' do
@@ -34,7 +32,7 @@ describe Result do
34
32
 
35
33
  context 'with an error' do
36
34
  let(:error) { StandardError.new }
37
- let(:result) { Result.new(Status.fail, error) }
35
+ let(:result) { described_class.new(TxghQueue::Status.fail, error) }
38
36
 
39
37
  describe 'has_response?' do
40
38
  it 'does not have a response' do
data/spec/status_spec.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- include TxghQueue
4
-
5
- describe Status do
3
+ describe TxghQueue::Status do
6
4
  describe '.retry_without_delay' do
7
5
  it 'returns the same object' do
8
6
  expect(described_class.retry_without_delay.object_id).to eq(
@@ -1,19 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
- include TxghQueue
4
-
5
- describe Supervisor do
3
+ describe TxghQueue::Supervisor do
6
4
  describe '.supervise' do
7
5
  it 'provides a handy shortcut to wrap a block with supervising' do
8
6
  response = described_class.supervise { raise StandardError }
9
- expect(response.status).to eq(Status.fail)
7
+ expect(response.status).to eq(TxghQueue::Status.fail)
10
8
  end
11
9
  end
12
10
 
13
11
  describe '#execute' do
14
12
  it 'handles errors generated by the given block' do
15
13
  responder = described_class.new { raise StandardError }
16
- expect(responder.execute.status).to eq(Status.fail)
14
+ expect(responder.execute.status).to eq(TxghQueue::Status.fail)
17
15
  end
18
16
 
19
17
  it 'handles error responses generated by the given block' do
@@ -21,7 +19,7 @@ describe Supervisor do
21
19
  TxghServer::Response.new(401, 'Unauthorized')
22
20
  end
23
21
 
24
- expect(responder.execute.status).to eq(Status.fail)
22
+ expect(responder.execute.status).to eq(TxghQueue::Status.fail)
25
23
  end
26
24
 
27
25
  it 'handles non-error responses generated by the given block' do
@@ -29,12 +27,12 @@ describe Supervisor do
29
27
  TxghServer::Response.new(200, 'Ok')
30
28
  end
31
29
 
32
- expect(responder.execute.status).to eq(Status.ok)
30
+ expect(responder.execute.status).to eq(TxghQueue::Status.ok)
33
31
  end
34
32
 
35
33
  it "raises an error if error handling logic can't be determined" do
36
34
  responder = described_class.new { 'unexpected response' }
37
- expect { responder.execute }.to raise_error(UnexpectedResponse)
35
+ expect { responder.execute }.to raise_error(TxghQueue::UnexpectedResponse)
38
36
  end
39
37
  end
40
38
  end
@@ -4,9 +4,7 @@ require 'helpers/nil_logger'
4
4
  require 'helpers/standard_txgh_setup'
5
5
  require 'helpers/test_request'
6
6
 
7
- include TxghQueue::Webhooks
8
-
9
- describe Github::RequestHandler, auto_configure: true do
7
+ describe TxghQueue::Webhooks::Github::RequestHandler, auto_configure: true do
10
8
  include StandardTxghSetup
11
9
 
12
10
  let(:logger) { NilLogger.new }
@@ -18,7 +16,7 @@ describe Github::RequestHandler, auto_configure: true do
18
16
 
19
17
  describe '#handle_request' do
20
18
  let(:queue_config) { {} }
21
- let(:payload) { { repository: { full_name: repo_name } } }
19
+ let(:payload) { { repository: { full_name: github_repo_name } } }
22
20
  let(:event) { 'push' }
23
21
 
24
22
  it "responds with an error when a queue backend isn't configured" do
@@ -47,7 +45,7 @@ describe Github::RequestHandler, auto_configure: true do
47
45
 
48
46
  context 'push event' do
49
47
  let(:event) { 'push' }
50
- let(:payload) { GithubPayloadBuilder.push_payload(repo_name, ref).tap { |p| p.add_commit } }
48
+ let(:payload) { GithubPayloadBuilder.push_payload(github_repo_name, ref).tap { |p| p.add_commit } }
51
49
 
52
50
  it 'does not enqueue if unauthorized' do
53
51
  expect { handler.handle_request }.to_not(
@@ -78,7 +76,7 @@ describe Github::RequestHandler, auto_configure: true do
78
76
  event: 'push',
79
77
  txgh_event: 'github.push',
80
78
  ref: "refs/#{ref}",
81
- repo_name: repo_name
79
+ repo_name: github_repo_name
82
80
  )
83
81
  end
84
82
 
@@ -91,7 +89,7 @@ describe Github::RequestHandler, auto_configure: true do
91
89
 
92
90
  context 'delete event' do
93
91
  let(:event) { 'delete' }
94
- let(:payload) { GithubPayloadBuilder.delete_payload(repo_name, ref) }
92
+ let(:payload) { GithubPayloadBuilder.delete_payload(github_repo_name, ref) }
95
93
 
96
94
  it 'does not enqueue if unauthorized' do
97
95
  expect { handler.handle_request }.to_not change { producer.enqueued_jobs.size }
@@ -120,7 +118,7 @@ describe Github::RequestHandler, auto_configure: true do
120
118
  event: 'delete',
121
119
  txgh_event: 'github.delete',
122
120
  ref: "refs/#{ref}",
123
- repo_name: repo_name
121
+ repo_name: github_repo_name
124
122
  )
125
123
  end
126
124
 
@@ -0,0 +1,144 @@
1
+ require 'spec_helper'
2
+ require 'helpers/gitlab_payload_builder'
3
+ require 'helpers/nil_logger'
4
+ require 'helpers/standard_txgh_setup'
5
+ require 'helpers/test_request'
6
+
7
+ describe TxghQueue::Webhooks::Gitlab::RequestHandler, auto_configure: true do
8
+ include StandardTxghSetup
9
+
10
+ let(:logger) { NilLogger.new }
11
+ let(:ref) { 'heads/my_ref' }
12
+ let(:headers) { { 'HTTP_X_GITLAB_EVENT' => hook_event } }
13
+ let(:body) { payload.to_json }
14
+ let(:request) { TestRequest.new(body: body, headers: headers) }
15
+ let(:handler) { described_class.new(request, logger) }
16
+ let(:hook_event) { 'Push Hook' }
17
+
18
+ describe '#handle_request' do
19
+ let(:queue_config) { {} }
20
+ let(:payload) { GitlabPayloadBuilder.push_payload(gitlab_repo_name, ref) }
21
+ let(:txgh_event) { 'push' }
22
+
23
+ it "responds with an error when a queue backend isn't configured" do
24
+ allow(handler).to receive(:authentic_request?).and_return(true)
25
+ response = handler.handle_request
26
+
27
+ expect(response.body.first[:error]).to(
28
+ eq('Internal server error: No queue backend has been configured')
29
+ )
30
+
31
+ expect(response.status).to eq(500)
32
+ end
33
+
34
+ context 'with a queue configured' do
35
+ let(:queue_config) do
36
+ {
37
+ backend: 'test',
38
+ options: {
39
+ queues: %w(test-queue)
40
+ }
41
+ }
42
+ end
43
+
44
+ let(:backend) { TxghQueue::Config.backend }
45
+ let(:producer) { backend.producer_for("gitlab.#{txgh_event}") }
46
+
47
+ context 'push event' do
48
+ let(:txgh_event) { 'push' }
49
+ let(:payload) { GitlabPayloadBuilder.push_payload(gitlab_repo_name, ref).tap { |p| p.add_commit } }
50
+
51
+ it 'does not enqueue if unauthorized' do
52
+ expect { handler.handle_request }.to_not(
53
+ change { producer.enqueued_jobs.size }
54
+ )
55
+ end
56
+
57
+ it 'responds with an unauthorized status' do
58
+ response = handler.handle_request
59
+ expect(response.status).to eq(401)
60
+ end
61
+
62
+ context 'with an authentic request' do
63
+ before(:each) do
64
+ allow(handler).to receive(:authentic_request?).and_return(true)
65
+ end
66
+
67
+ it 'enqueues the job' do
68
+ expect { handler.handle_request }.to(
69
+ change { producer.enqueued_jobs.size }.from(0).to(1)
70
+ )
71
+ end
72
+
73
+ it 'enqueues with the correct parameters' do
74
+ handler.handle_request
75
+ params = producer.enqueued_jobs.first
76
+ expect(params[:payload]).to include(
77
+ event: 'push',
78
+ txgh_event: 'gitlab.push',
79
+ ref: "refs/#{ref}",
80
+ repo_name: gitlab_repo_name.split('/').last
81
+ )
82
+ end
83
+
84
+ it 'responds with an ok status code' do
85
+ response = handler.handle_request
86
+ expect(response.status).to eq(202)
87
+ end
88
+ end
89
+ end
90
+
91
+ context 'delete event' do
92
+ let(:txgh_event) { 'delete' }
93
+ let(:payload) { GitlabPayloadBuilder.delete_payload(gitlab_repo_name, ref) }
94
+
95
+ it 'does not enqueue if unauthorized' do
96
+ expect { handler.handle_request }.to_not change { producer.enqueued_jobs.size }
97
+ end
98
+
99
+ it 'responds with an unauthorized status' do
100
+ response = handler.handle_request
101
+ expect(response.status).to eq(401)
102
+ end
103
+
104
+ context 'with an authentic request' do
105
+ before(:each) do
106
+ allow(handler).to receive(:authentic_request?).and_return(true)
107
+ end
108
+
109
+ it 'enqueues the job' do
110
+ expect { handler.handle_request }.to(
111
+ change { producer.enqueued_jobs.size }.from(0).to(1)
112
+ )
113
+ end
114
+
115
+ it 'enqueues with the correct parameters' do
116
+ handler.handle_request
117
+ params = producer.enqueued_jobs.first
118
+ expect(params[:payload]).to include(
119
+ event: 'delete',
120
+ txgh_event: 'gitlab.delete',
121
+ ref: "refs/#{ref}",
122
+ repo_name: gitlab_repo_name.split('/').last
123
+ )
124
+ end
125
+
126
+ it 'responds with an ok status code' do
127
+ response = handler.handle_request
128
+ expect(response.status).to eq(202)
129
+ end
130
+ end
131
+ end
132
+
133
+ context 'unrecognized event' do
134
+ let(:hook_event) { 'foo' }
135
+
136
+ it 'responds with a 400' do
137
+ allow(handler).to receive(:authentic_request?).and_return(true)
138
+ response = handler.handle_request
139
+ expect(response.status).to eq(400)
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
@@ -4,9 +4,7 @@ require 'helpers/standard_txgh_setup'
4
4
  require 'helpers/test_request'
5
5
  require 'helpers/test_backend'
6
6
 
7
- include TxghQueue::Webhooks
8
-
9
- describe Transifex::RequestHandler, auto_configure: true do
7
+ describe TxghQueue::Webhooks::Transifex::RequestHandler, auto_configure: true do
10
8
  include StandardTxghSetup
11
9
 
12
10
  let(:logger) { NilLogger.new }
data/txgh-queue.gemspec CHANGED
@@ -11,11 +11,10 @@ Gem::Specification.new do |s|
11
11
  s.description = s.summary = 'Queue worker for processing Txgh webhooks.'
12
12
 
13
13
  s.platform = Gem::Platform::RUBY
14
- s.has_rdoc = true
15
14
 
16
15
  s.add_dependency 'aws-sdk', '~> 2.0'
17
- s.add_dependency 'txgh', '~> 6.0'
18
- s.add_dependency 'txgh-server', '~> 3.0'
16
+ s.add_dependency 'txgh', '7.0.0.beta'
17
+ s.add_dependency 'txgh-server', '~> 4.0.0.beta'
19
18
  s.add_dependency 'sinatra', '~> 1.4'
20
19
  s.add_dependency 'sinatra-contrib', '~> 1.4'
21
20
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: txgh-queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-22 00:00:00.000000000 Z
11
+ date: 2020-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -28,30 +28,30 @@ dependencies:
28
28
  name: txgh
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '6.0'
33
+ version: 7.0.0.beta
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: '6.0'
40
+ version: 7.0.0.beta
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: txgh-server
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: 4.0.0.beta
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: 4.0.0.beta
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sinatra
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -103,6 +103,7 @@ files:
103
103
  - lib/txgh-queue/config.rb
104
104
  - lib/txgh-queue/error_handlers.rb
105
105
  - lib/txgh-queue/error_handlers/github.rb
106
+ - lib/txgh-queue/error_handlers/gitlab.rb
106
107
  - lib/txgh-queue/error_handlers/network_errors.rb
107
108
  - lib/txgh-queue/error_handlers/server_response.rb
108
109
  - lib/txgh-queue/error_handlers/standard_errors.rb
@@ -116,6 +117,8 @@ files:
116
117
  - lib/txgh-queue/webhooks.rb
117
118
  - lib/txgh-queue/webhooks/github.rb
118
119
  - lib/txgh-queue/webhooks/github/request_handler.rb
120
+ - lib/txgh-queue/webhooks/gitlab.rb
121
+ - lib/txgh-queue/webhooks/gitlab/request_handler.rb
119
122
  - lib/txgh-queue/webhooks/transifex.rb
120
123
  - lib/txgh-queue/webhooks/transifex/request_handler.rb
121
124
  - spec/application_spec.rb
@@ -131,6 +134,7 @@ files:
131
134
  - spec/backends_spec.rb
132
135
  - spec/config_spec.rb
133
136
  - spec/error_handlers/github_spec.rb
137
+ - spec/error_handlers/gitlab_spec.rb
134
138
  - spec/error_handlers/network_errors_spec.rb
135
139
  - spec/error_handlers/server_response_spec.rb
136
140
  - spec/error_handlers/standard_errors_spec.rb
@@ -146,6 +150,7 @@ files:
146
150
  - spec/status_spec.rb
147
151
  - spec/supervisor_spec.rb
148
152
  - spec/webhooks/github/request_handler_spec.rb
153
+ - spec/webhooks/gitlab/request_handler_spec.rb
149
154
  - spec/webhooks/transifex/request_handler_spec.rb
150
155
  - txgh-queue.gemspec
151
156
  homepage: https://github.com/lumoslabs/txgh
@@ -162,9 +167,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
167
  version: '0'
163
168
  required_rubygems_version: !ruby/object:Gem::Requirement
164
169
  requirements:
165
- - - ">="
170
+ - - ">"
166
171
  - !ruby/object:Gem::Version
167
- version: '0'
172
+ version: 1.3.1
168
173
  requirements: []
169
174
  rubyforge_project:
170
175
  rubygems_version: 2.7.6