fourchette 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Guardfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +10 -0
- data/Rakefile +3 -3
- data/bin/fourchette +5 -5
- data/fourchette.gemspec +18 -18
- data/lib/fourchette.rb +10 -11
- data/lib/fourchette/fork.rb +44 -19
- data/lib/fourchette/github.rb +29 -22
- data/lib/fourchette/heroku.rb +32 -28
- data/lib/fourchette/logger.rb +1 -1
- data/lib/fourchette/pgbackups.rb +18 -9
- data/lib/fourchette/pull_request.rb +4 -4
- data/lib/fourchette/tarball.rb +6 -5
- data/lib/fourchette/version.rb +1 -1
- data/lib/fourchette/web.rb +1 -1
- data/lib/fourchette/web/hooks.rb +3 -3
- data/lib/fourchette/web/tarball.rb +6 -3
- data/spec/lib/fourchette/fork_spec.rb +27 -22
- data/spec/lib/fourchette/github_spec.rb +44 -44
- data/spec/lib/fourchette/heroku_spec.rb +82 -49
- data/spec/lib/fourchette/logger_spec.rb +1 -1
- data/spec/lib/fourchette/pull_request_spec.rb +37 -12
- data/spec/lib/fourchette/tarball_spec.rb +24 -18
- data/spec/lib/web/hooks_spec.rb +10 -10
- data/spec/lib/web/tarball_spec.rb +14 -15
- data/spec/spec_helper.rb +1 -1
- data/spec/support/silent-logger.rb +2 -2
- data/spec/support/sinatra_helper.rb +1 -1
- data/templates/Gemfile +1 -1
- data/templates/Rakefile +1 -1
- data/templates/callbacks.rb +4 -4
- data/templates/config/puma.rb +1 -1
- metadata +5 -5
@@ -2,42 +2,67 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Fourchette::PullRequest do
|
4
4
|
describe '#perform' do
|
5
|
-
let
|
5
|
+
let(:fork) { double('fork') }
|
6
6
|
subject { described_class.new }
|
7
7
|
|
8
8
|
after do
|
9
|
-
Fourchette::Fork.
|
9
|
+
allow(Fourchette::Fork).to receive(:new).and_return(fork)
|
10
10
|
subject.perform(params)
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'action == synchronize' do
|
14
|
-
let
|
14
|
+
let(:params) do
|
15
|
+
{
|
16
|
+
'action' => 'synchronize',
|
17
|
+
'pull_request' => { 'title' => 'Test Me' }
|
18
|
+
}
|
19
|
+
end
|
15
20
|
|
16
|
-
it { fork.
|
21
|
+
it { expect(fork).to receive(:update) }
|
17
22
|
end
|
18
23
|
|
19
24
|
context 'action == closed' do
|
20
|
-
let
|
25
|
+
let(:params) do
|
26
|
+
{
|
27
|
+
'action' => 'closed',
|
28
|
+
'pull_request' => { 'title' => 'Test Me' }
|
29
|
+
}
|
30
|
+
end
|
21
31
|
|
22
|
-
it { fork.
|
32
|
+
it { expect(fork).to receive(:delete) }
|
23
33
|
end
|
24
34
|
|
25
35
|
context 'action == reopened' do
|
26
|
-
let
|
36
|
+
let(:params) do
|
37
|
+
{
|
38
|
+
'action' => 'reopened',
|
39
|
+
'pull_request' => { 'title' => 'Test Me' }
|
40
|
+
}
|
41
|
+
end
|
27
42
|
|
28
|
-
it { fork.
|
43
|
+
it { expect(fork).to receive(:create) }
|
29
44
|
end
|
30
45
|
|
31
46
|
context 'action == opened' do
|
32
|
-
let
|
47
|
+
let(:params) do
|
48
|
+
{
|
49
|
+
'action' => 'opened',
|
50
|
+
'pull_request' => { 'title' => 'Test Me' }
|
51
|
+
}
|
52
|
+
end
|
33
53
|
|
34
|
-
it { fork.
|
54
|
+
it { expect(fork).to receive(:create) }
|
35
55
|
end
|
36
56
|
|
37
57
|
context 'title includes [qa skip]' do
|
38
|
-
let
|
58
|
+
let(:params) do
|
59
|
+
{
|
60
|
+
'action' => 'opened',
|
61
|
+
'pull_request' => { 'title' => 'Skip Me [QA Skip]' }
|
62
|
+
}
|
63
|
+
end
|
39
64
|
|
40
|
-
it { fork.
|
65
|
+
it { expect(fork).not_to receive(:create) }
|
41
66
|
end
|
42
67
|
end
|
43
68
|
end
|
@@ -9,36 +9,42 @@ describe Fourchette::Tarball do
|
|
9
9
|
let(:branch_name) { 'feature/something-new' }
|
10
10
|
|
11
11
|
before do
|
12
|
-
subject.
|
13
|
-
subject.
|
14
|
-
subject.
|
15
|
-
subject.
|
16
|
-
stub_const('ENV',
|
17
|
-
SecureRandom.
|
12
|
+
allow(subject).to receive(:expiration_timestamp).and_return('123')
|
13
|
+
allow(subject).to receive(:clone)
|
14
|
+
allow(subject).to receive(:tar).and_return('tmp/1234567/123.tar.gz')
|
15
|
+
allow(subject).to receive(:system)
|
16
|
+
stub_const('ENV', 'FOURCHETTE_APP_URL' => 'http://example.com')
|
17
|
+
allow(SecureRandom).to receive(:uuid).and_return('1234567')
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
it do
|
21
|
+
expect(
|
22
|
+
subject.url(git_repo_url, branch_name, github_repo)
|
23
|
+
).to eq 'http://example.com/jipiboily/fourchette/1234567/123'
|
24
|
+
end
|
25
25
|
|
26
26
|
it 'clones the repo and checkout the branch' do
|
27
|
-
subject.
|
27
|
+
allow(subject).to receive(:clone).and_call_original
|
28
28
|
git_instance = double
|
29
|
-
Git.
|
30
|
-
|
29
|
+
expect(Git).to receive(:clone).with(
|
30
|
+
git_repo_url, 'tmp/1234567', recursive: true
|
31
|
+
).and_return(git_instance)
|
32
|
+
expect(git_instance).to receive(:checkout).with(branch_name)
|
31
33
|
subject.url(git_repo_url, branch_name, github_repo)
|
32
34
|
end
|
33
35
|
|
34
36
|
it 'creates the tarball' do
|
35
|
-
subject.
|
36
|
-
subject.
|
37
|
+
allow(subject).to receive(:tar).and_call_original
|
38
|
+
expect(subject).to receive(:system).with(
|
39
|
+
'tar -zcf tmp/1234567/123.tar.gz -C tmp/1234567 .'
|
40
|
+
)
|
37
41
|
subject.url(git_repo_url, branch_name, github_repo)
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
45
|
describe '#filepath' do
|
42
|
-
it
|
46
|
+
it 'should return the correct filepath' do
|
47
|
+
expect(subject.filepath('1234567', '123')).to eq 'tmp/1234567/123.tar.gz'
|
48
|
+
end
|
43
49
|
end
|
44
|
-
end
|
50
|
+
end
|
data/spec/lib/web/hooks_spec.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/sinatra_helper'
|
3
|
+
require 'sucker_punch/testing/inline'
|
4
4
|
|
5
|
-
describe
|
6
|
-
it
|
7
|
-
expected_param = {
|
8
|
-
Fourchette::PullRequest
|
9
|
-
.
|
5
|
+
describe 'GitHub web hooks receiver' do
|
6
|
+
it 'kicks an async job doing all the work' do
|
7
|
+
expected_param = { 'something' => 'ok' }
|
8
|
+
expect_any_instance_of(Fourchette::PullRequest)
|
9
|
+
.to receive(:perform)
|
10
10
|
.with(expected_param)
|
11
11
|
|
12
|
-
post
|
12
|
+
post '/hooks',
|
13
13
|
expected_param.to_json,
|
14
|
-
|
14
|
+
'CONTENT_TYPE' => 'application/json'
|
15
15
|
end
|
16
16
|
end
|
@@ -1,29 +1,28 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/sinatra_helper'
|
3
3
|
|
4
|
-
describe
|
5
|
-
context
|
6
|
-
it
|
4
|
+
describe 'web tarball serving' do
|
5
|
+
context 'valid and not expired URL' do
|
6
|
+
it 'returns the file' do
|
7
7
|
expire_in_2_secs = Time.now.to_i + 2
|
8
|
-
Fourchette::Tarball
|
9
|
-
.
|
10
|
-
.with(
|
11
|
-
.and_return { "#{Dir.pwd}/spec/factories/fake_file" }
|
8
|
+
expect_any_instance_of(Fourchette::Tarball)
|
9
|
+
.to receive(:filepath)
|
10
|
+
.with('1234567', expire_in_2_secs.to_s) { "#{Dir.pwd}/spec/factories/fake_file" }
|
12
11
|
|
13
12
|
get "/jipiboily/fourchette/1234567/#{expire_in_2_secs}"
|
14
|
-
expect(last_response.headers[
|
15
|
-
expect(last_response.body).to eq
|
13
|
+
expect(last_response.headers['Content-Type']).to eq 'application/x-tgz'
|
14
|
+
expect(last_response.body).to eq 'some content...'
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
context
|
20
|
-
it
|
18
|
+
context 'expired URL' do
|
19
|
+
it 'does NOT returns the file if it is expired' do
|
21
20
|
expired_one_sec_ago = Time.now.to_i - 1
|
22
21
|
get "/jipiboily/fourchette/1234567/#{expired_one_sec_ago}"
|
23
22
|
expect(last_response).not_to be_ok
|
24
|
-
expect(last_response.body).not_to eq(
|
23
|
+
expect(last_response.body).not_to eq('Hello World')
|
25
24
|
expect(last_response.status).to eq(404)
|
26
|
-
subject.
|
25
|
+
expect(subject).not_to receive(:send_file)
|
27
26
|
end
|
28
27
|
end
|
29
28
|
end
|
data/spec/spec_helper.rb
CHANGED
data/templates/Gemfile
CHANGED
data/templates/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'fourchette/rake_tasks'
|
1
|
+
require 'fourchette/rake_tasks'
|
data/templates/callbacks.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
# This is a sample file to see how the really, really basic callback system
|
2
|
-
# See the README for me or just dive in.
|
1
|
+
# This is a sample file to see how the really, really basic callback system
|
2
|
+
# works. See the README for me or just dive in.
|
3
3
|
class Fourchette::Callbacks
|
4
4
|
include Fourchette::Logger
|
5
5
|
|
6
|
-
def initialize
|
6
|
+
def initialize(params)
|
7
7
|
@params = params
|
8
8
|
end
|
9
9
|
|
@@ -14,4 +14,4 @@ class Fourchette::Callbacks
|
|
14
14
|
def after_all
|
15
15
|
logger.info 'Placeholder for after steps... (see callbacks.rb to override)'
|
16
16
|
end
|
17
|
-
end
|
17
|
+
end
|
data/templates/config/puma.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fourchette
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Philippe Boily
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -184,14 +184,14 @@ dependencies:
|
|
184
184
|
requirements:
|
185
185
|
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
187
|
+
version: 3.1.0
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
194
|
+
version: 3.1.0
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: guard-rspec
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -309,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
309
309
|
version: '0'
|
310
310
|
requirements: []
|
311
311
|
rubyforge_project:
|
312
|
-
rubygems_version: 2.
|
312
|
+
rubygems_version: 2.4.5
|
313
313
|
signing_key:
|
314
314
|
specification_version: 4
|
315
315
|
summary: Your new best friend for isolated testing environments on Heroku.
|