txgh-server 1.0.0 → 1.1.0
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/txgh-server/version.rb +1 -1
- data/lib/txgh-server/webhooks/github/delete_attributes.rb +50 -0
- data/lib/txgh-server/webhooks/github/delete_handler.rb +12 -4
- data/lib/txgh-server/webhooks/github/ping_handler.rb +4 -1
- data/lib/txgh-server/webhooks/github/push_attributes.rb +77 -0
- data/lib/txgh-server/webhooks/github/push_handler.rb +23 -61
- data/lib/txgh-server/webhooks/github/request_handler.rb +45 -51
- data/lib/txgh-server/webhooks/github.rb +7 -5
- data/lib/txgh-server/webhooks/transifex/hook_handler.rb +1 -1
- data/spec/application_spec.rb +8 -4
- data/spec/integration/hooks_spec.rb +1 -15
- data/spec/webhooks/github/delete_attributes_spec.rb +30 -0
- data/spec/webhooks/github/delete_handler_spec.rb +5 -6
- data/spec/webhooks/github/ping_handler_spec.rb +2 -1
- data/spec/webhooks/github/push_attributes_spec.rb +54 -0
- data/spec/webhooks/github/push_handler_spec.rb +8 -41
- metadata +7 -5
- data/lib/txgh-server/webhooks/github/handler.rb +0 -20
- data/spec/integration/cassettes/github_l10n_hook_endpoint.yml +0 -536
|
@@ -9,12 +9,11 @@ describe PushHandler do
|
|
|
9
9
|
include StandardTxghSetup
|
|
10
10
|
|
|
11
11
|
let(:handler) do
|
|
12
|
-
PushHandler.new(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
12
|
+
PushHandler.new(transifex_project, github_repo, logger, attributes)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
let(:attributes) do
|
|
16
|
+
PushAttributes.from_webhook_payload(payload.to_h)
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
let(:payload) do
|
|
@@ -24,7 +23,7 @@ describe PushHandler do
|
|
|
24
23
|
let(:modified_files) do
|
|
25
24
|
file_sha = 'def456'
|
|
26
25
|
tx_config.resources.map do |resource|
|
|
27
|
-
{
|
|
26
|
+
{ path: resource.source_file, sha: file_sha.next! }
|
|
28
27
|
end
|
|
29
28
|
end
|
|
30
29
|
|
|
@@ -32,7 +31,7 @@ describe PushHandler do
|
|
|
32
31
|
|
|
33
32
|
before(:each) do
|
|
34
33
|
payload.add_commit(
|
|
35
|
-
modified: modified_files.map { |f| f[
|
|
34
|
+
modified: modified_files.map { |f| f[:path] }
|
|
36
35
|
)
|
|
37
36
|
|
|
38
37
|
allow(Txgh::ResourceUpdater).to receive(:new).and_return(updater)
|
|
@@ -41,19 +40,12 @@ describe PushHandler do
|
|
|
41
40
|
it 'correctly uploads modified resources to transifex' do
|
|
42
41
|
tx_config.resources.each do |resource|
|
|
43
42
|
expect(updater).to(
|
|
44
|
-
receive(:update_resource) do |resource,
|
|
43
|
+
receive(:update_resource) do |resource, categories|
|
|
45
44
|
expect(resource.project_slug).to eq(project_name)
|
|
46
45
|
expect(resource.resource_slug).to eq(resource_slug)
|
|
47
|
-
expect(sha).to eq(payload.head_commit[:id])
|
|
48
46
|
expect(categories).to eq('author' => 'Test User')
|
|
49
47
|
end
|
|
50
48
|
)
|
|
51
|
-
|
|
52
|
-
expect(github_api).to(
|
|
53
|
-
receive(:get_ref).with(repo_name, ref).and_return(
|
|
54
|
-
object: { sha: payload.head_commit[:id] }
|
|
55
|
-
)
|
|
56
|
-
)
|
|
57
49
|
end
|
|
58
50
|
|
|
59
51
|
response = handler.execute
|
|
@@ -61,31 +53,6 @@ describe PushHandler do
|
|
|
61
53
|
expect(response.body).to eq(true)
|
|
62
54
|
end
|
|
63
55
|
|
|
64
|
-
context 'with an L10N branch' do
|
|
65
|
-
let(:ref) { 'tags/L10N_my_branch' }
|
|
66
|
-
|
|
67
|
-
it 'creates an L10N tag' do
|
|
68
|
-
expect(updater).to receive(:update_resource)
|
|
69
|
-
|
|
70
|
-
# this is what we actually care about in this test
|
|
71
|
-
expect(github_api).to(
|
|
72
|
-
receive(:create_ref).with(
|
|
73
|
-
repo_name, 'heads/L10N', payload.head_commit[:id]
|
|
74
|
-
)
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
expect(github_api).to(
|
|
78
|
-
receive(:get_ref).with(repo_name, ref).and_return(
|
|
79
|
-
object: { sha: payload.head_commit[:id] }
|
|
80
|
-
)
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
response = handler.execute
|
|
84
|
-
expect(response.status).to eq(200)
|
|
85
|
-
expect(response.body).to eq(true)
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
56
|
context 'with a deleted branch' do
|
|
90
57
|
let(:before) { nil }
|
|
91
58
|
let(:after) { '0' * 40 }
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: txgh-server
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthew Jackowski
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2016-
|
|
12
|
+
date: 2016-09-21 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: mime-types
|
|
@@ -112,9 +112,10 @@ files:
|
|
|
112
112
|
- lib/txgh-server/version.rb
|
|
113
113
|
- lib/txgh-server/webhooks.rb
|
|
114
114
|
- lib/txgh-server/webhooks/github.rb
|
|
115
|
+
- lib/txgh-server/webhooks/github/delete_attributes.rb
|
|
115
116
|
- lib/txgh-server/webhooks/github/delete_handler.rb
|
|
116
|
-
- lib/txgh-server/webhooks/github/handler.rb
|
|
117
117
|
- lib/txgh-server/webhooks/github/ping_handler.rb
|
|
118
|
+
- lib/txgh-server/webhooks/github/push_attributes.rb
|
|
118
119
|
- lib/txgh-server/webhooks/github/push_handler.rb
|
|
119
120
|
- lib/txgh-server/webhooks/github/request_handler.rb
|
|
120
121
|
- lib/txgh-server/webhooks/transifex.rb
|
|
@@ -126,7 +127,6 @@ files:
|
|
|
126
127
|
- spec/github_request_auth_spec.rb
|
|
127
128
|
- spec/helpers/github_payload_builder.rb
|
|
128
129
|
- spec/helpers/integration_setup.rb
|
|
129
|
-
- spec/integration/cassettes/github_l10n_hook_endpoint.yml
|
|
130
130
|
- spec/integration/cassettes/pull.yml
|
|
131
131
|
- spec/integration/cassettes/push.yml
|
|
132
132
|
- spec/integration/cassettes/transifex_hook_endpoint.yml
|
|
@@ -139,8 +139,10 @@ files:
|
|
|
139
139
|
- spec/spec_helper.rb
|
|
140
140
|
- spec/tgz_stream_response_spec.rb
|
|
141
141
|
- spec/transifex_request_auth_spec.rb
|
|
142
|
+
- spec/webhooks/github/delete_attributes_spec.rb
|
|
142
143
|
- spec/webhooks/github/delete_handler_spec.rb
|
|
143
144
|
- spec/webhooks/github/ping_handler_spec.rb
|
|
145
|
+
- spec/webhooks/github/push_attributes_spec.rb
|
|
144
146
|
- spec/webhooks/github/push_handler_spec.rb
|
|
145
147
|
- spec/webhooks/transifex/hook_handler_spec.rb
|
|
146
148
|
- spec/zip_stream_response_spec.rb
|
|
@@ -164,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
164
166
|
version: '0'
|
|
165
167
|
requirements: []
|
|
166
168
|
rubyforge_project:
|
|
167
|
-
rubygems_version: 2.
|
|
169
|
+
rubygems_version: 2.6.6
|
|
168
170
|
signing_key:
|
|
169
171
|
specification_version: 4
|
|
170
172
|
summary: An HTTP server for interacting with txgh.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'logger'
|
|
2
|
-
|
|
3
|
-
module TxghServer
|
|
4
|
-
module Webhooks
|
|
5
|
-
module Github
|
|
6
|
-
class Handler
|
|
7
|
-
include ResponseHelpers
|
|
8
|
-
|
|
9
|
-
attr_reader :project, :repo, :payload, :logger
|
|
10
|
-
|
|
11
|
-
def initialize(options = {})
|
|
12
|
-
@project = options.fetch(:project)
|
|
13
|
-
@repo = options.fetch(:repo)
|
|
14
|
-
@payload = options.fetch(:payload)
|
|
15
|
-
@logger = options.fetch(:logger) { Logger.new(STDOUT) }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|