magnum-payload 0.4.0 → 0.4.1

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
  SHA1:
3
- metadata.gz: 21782a6d2a38628f608ef49f52e416e50b4c1473
4
- data.tar.gz: 0442f0409b8795ad1e41296b77d1b6689f2d94b0
3
+ metadata.gz: b8f355e4af0da303d451c791184ef2db4ea963cf
4
+ data.tar.gz: ba6b8d1a4d1af1d9148fbf9ae99b95d4c1b7466d
5
5
  SHA512:
6
- metadata.gz: 986c4c308614292ea17242ba2287be2228600811879473116d11f6a0ebd27055fbeb2cfac12763ceea96729836000abccaba0d5de07ae00330282ffed1084b78
7
- data.tar.gz: 6a25dae5724ab131d193046cf275e2f571a01c01567e915cb7ceafc75f490c91deec60235a53615b459b74e5453300198460d5b1e939b96299653f62871f8ac6
6
+ metadata.gz: 44f535e0fb242a222eb22eb11bf876c1a71acee4bebcf8fd39346da76879beda8ea443a8847c88bceabb76f43f3560b02462c0f0dd09f790587dee74c586266d
7
+ data.tar.gz: d95b1dab33bf627bbf07c27d137bf50da1485baf99c9d849cf517a5a22541d61c5c1743fc36aafdbc4e0cafe2c196bbb9eb049fb2abb1f10bfdd017b48303d9a
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2013-2014 Dan Sosedoff, dan.sosedoff@gmail.com
3
+ Copyright (c) 2013-2014 Magnum CI
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -91,17 +91,8 @@ To execute test suite run:
91
91
  rake test
92
92
  ```
93
93
 
94
- ## Contact
95
-
96
- Magnum CI
97
-
98
- - [https://magnum-ci.com](https://magnum-ci.com)
99
- - [https://github.com/magnumci](https://github.com/magnumci)
100
- - [https://twitter.com/ci_magnum](https://twitter.com/ci_magnum)
101
- - [support@magnum-ci.com](mailto:support@magnum-ci.com)
102
-
103
94
  ## License
104
95
 
105
96
  The MIT License (MIT)
106
97
 
107
- Copyright (c) 2013-2014 Dan Sosedoff, <dan.sosedoff@gmail.com>
98
+ Copyright (c) 2013-2014 Magnum CI
data/Rakefile CHANGED
@@ -1,10 +1,19 @@
1
- require 'bundler'
2
- require 'bundler/gem_tasks'
1
+ require "bundler"
2
+ require "bundler/gem_tasks"
3
3
  require "rspec/core/rake_task"
4
4
 
5
5
  RSpec::Core::RakeTask.new(:test) do |t|
6
- t.pattern = 'spec/**/*_spec.rb'
6
+ t.pattern = "spec/**/*_spec.rb"
7
7
  t.verbose = false
8
8
  end
9
9
 
10
+ task :console do
11
+ require "irb"
12
+ require "irb/completion"
13
+ require "magnum/payload"
14
+
15
+ ARGV.clear
16
+ IRB.start
17
+ end
18
+
10
19
  task :default => :test
@@ -4,6 +4,8 @@ require "hashr"
4
4
  module Magnum
5
5
  module Payload
6
6
  class Base
7
+ GIT_ZERO_SHA = /\A[0]{40}\z/
8
+
7
9
  include Magnum::Payload::MessageParser
8
10
 
9
11
  attr_reader :raw_data, :data
@@ -12,6 +12,11 @@ module Magnum
12
12
  private
13
13
 
14
14
  def parse_git!
15
+ if data.after =~ GIT_ZERO_SHA
16
+ @skip = true
17
+ return
18
+ end
19
+
15
20
  @commit = last_commit.id
16
21
  @branch = data.branch
17
22
  @message = last_commit.message
@@ -1,7 +1,5 @@
1
1
  module Magnum
2
2
  class Payload::Gitlab < Payload::Base
3
- ZERO_SHA = /\A[0]{40}\z/
4
-
5
3
  def parse!
6
4
  assign_payload unless skip_payload?
7
5
  end
@@ -32,7 +30,7 @@ module Magnum
32
30
  end
33
31
 
34
32
  def deleted?
35
- data.before !~ ZERO_SHA && data.after =~ ZERO_SHA
33
+ data.before !~ GIT_ZERO_SHA && data.after =~ GIT_ZERO_SHA
36
34
  end
37
35
  end
38
36
  end
@@ -1,5 +1,5 @@
1
1
  module Magnum
2
2
  module Payload
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
@@ -0,0 +1,20 @@
1
+ {
2
+ "branch": "feature-13914-activation-via-password-reset",
3
+ "ref": "refs/heads/feature-13914-activation-via-password-reset",
4
+ "before": "ad027019cdfd4a78e622feb87fb2c56627911d36",
5
+ "after": "0000000000000000000000000000000000000000",
6
+ "uri": "git@company.git.beanstalkapp.com:/repo.git",
7
+ "pusher_id": 12345,
8
+ "pusher_name": "John Doe",
9
+ "repository": {
10
+ "name": "repo",
11
+ "url": "http://company.beanstalkapp.com/repo",
12
+ "private": true,
13
+ "owner": {
14
+ "name": "John Doe",
15
+ "email": "owner@email.com"
16
+ }
17
+ },
18
+ "push_is_too_large": false,
19
+ "commits": []
20
+ }
@@ -1,59 +1,63 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Magnum::Payload::Base do
4
4
  let(:base) { described_class }
5
5
 
6
- before do
7
- Magnum::Payload::Base.any_instance.stub(:parse!)
8
- end
6
+ describe "#new" do
7
+ before do
8
+ Magnum::Payload::Base.any_instance.stub(:parse!)
9
+ end
9
10
 
10
- describe '#new' do
11
- it 'assigns raw data attribute' do
11
+ it "assigns raw data attribute" do
12
12
  Magnum::Payload::Base.any_instance.stub(:parse_payload)
13
13
 
14
14
  payload = base.new("raw data")
15
- payload.raw_data.should eq 'raw data'
15
+ expect(payload.raw_data).to eq "raw data"
16
16
  end
17
17
 
18
- it 'assigns data attribute' do
19
- payload = base.new({'foo' => 'bar'})
20
- payload.data.should be_a Hashr
18
+ it "assigns data attribute" do
19
+ payload = base.new({"foo" => "bar"})
20
+ expect(payload.data).to be_a Hashr
21
21
  end
22
22
 
23
- it 'accepts a String' do
23
+ it "accepts a string" do
24
24
  payload = base.new('{"foo":"bar"}')
25
- payload.data.should be_a Hashr
26
- payload.data.foo.should eq 'bar'
25
+
26
+ expect(payload.data).to be_a Hashr
27
+ expect(payload.data.foo).to eq "bar"
27
28
  end
28
29
 
29
- it 'accepts a Hash' do
30
- payload = base.new({'foo' => 'bar'})
31
- payload.data.should be_a Hashr
32
- payload.data.foo.should eq('bar')
30
+ it "accepts a hash" do
31
+ payload = base.new({"foo" => "bar"})
32
+
33
+ expect(payload.data).to be_a Hashr
34
+ expect(payload.data.foo).to eq "bar"
33
35
  end
34
36
 
35
- it 'raises error on invalid input type' do
37
+ it "raises error on invalid input type" do
36
38
  expect { base.new(nil) }.to raise_error "String or Hash required"
37
39
  end
38
40
 
39
- it 'raises error on invalid json' do
41
+ it "raises error on invalid json" do
40
42
  expect { base.new("invalid json") }.
41
43
  to raise_error Magnum::Payload::ParseError, "Valid JSON required"
42
44
  end
43
45
  end
44
46
 
45
- describe '#skip' do
47
+ describe "#skip" do
46
48
  before do
49
+ Magnum::Payload::Base.any_instance.stub(:parse!)
47
50
  Magnum::Payload::Base.any_instance.stub(:parse_payload)
48
51
  end
49
52
 
50
- it 'should be false' do
51
- base.new('data').skip.should eq false
53
+ it "returns false" do
54
+ expect(base.new("data").skip).to be_false
52
55
  end
53
56
  end
54
57
 
55
58
  describe "#skip?" do
56
59
  before do
60
+ Magnum::Payload::Base.any_instance.stub(:parse!)
57
61
  Magnum::Payload::Base.any_instance.stub(:parse_payload)
58
62
  Magnum::Payload::Base.any_instance.stub(:skip) { true }
59
63
  end
@@ -62,4 +66,35 @@ describe Magnum::Payload::Base do
62
66
  expect(base.new("data").skip?).to be_true
63
67
  end
64
68
  end
69
+
70
+ describe "#parse!" do
71
+ it "raises error" do
72
+ expect { described_class.new("foo" => "bar").parse! }.
73
+ to raise_error "Not implemented in base class"
74
+ end
75
+ end
76
+
77
+ describe "#attributes_hash" do
78
+ let(:hash) { described_class.new("foo" => "bar").attributes_hash }
79
+
80
+ before do
81
+ Magnum::Payload::Base.any_instance.stub(:parse!)
82
+ end
83
+
84
+ it "returns payload hash" do
85
+ expect(hash).to be_a Hash
86
+ end
87
+
88
+ it "it includes attributes" do
89
+ expect(hash.keys).to eq [
90
+ "commit",
91
+ "branch",
92
+ "author",
93
+ "committer",
94
+ "message",
95
+ "commit_url",
96
+ "compare_url"
97
+ ]
98
+ end
99
+ end
65
100
  end
@@ -46,6 +46,14 @@ describe Magnum::Payload::Beanstalk do
46
46
  expect(payload.test).to be_true
47
47
  end
48
48
  end
49
+
50
+ context "when deleted branch" do
51
+ let(:data) { fixture "beanstalk/git_branch_delete.json" }
52
+
53
+ it "sets skip to true" do
54
+ expect(payload.skip).to be_true
55
+ end
56
+ end
49
57
  end
50
58
 
51
59
  context "with svn payload" do
@@ -1,103 +1,111 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Magnum::Payload::Bitbucket do
4
- let(:data) { fixture('bitbucket/git.json') }
5
- let(:payload) { Magnum::Payload::Bitbucket.new(data) }
4
+ let(:data) { fixture("bitbucket/git.json") }
5
+ let(:payload) { described_class.new(data) }
6
6
 
7
- describe '#parse!' do
8
- context 'with git payload' do
9
- let(:data) { fixture('bitbucket/git.json') }
7
+ describe "#parse!" do
8
+ context "with git payload" do
9
+ let(:data) { fixture("bitbucket/git.json") }
10
10
 
11
- it 'sets commit SHA' do
12
- payload.commit.should eq 'f15566c42759198fd32a70963d2509f3f8309586'
11
+ it "sets commit SHA" do
12
+ expect(payload.commit).to eq "f15566c42759198fd32a70963d2509f3f8309586"
13
13
  end
14
14
 
15
- it 'sets commit branch' do
16
- payload.branch.should eq 'master'
15
+ it "sets commit branch" do
16
+ expect(payload.branch).to eq "master"
17
17
  end
18
18
 
19
- it 'sets commit message' do
20
- payload.message.should eq 'Commit Sat Jan 19 18:42:40 CST 2013'
19
+ it "sets commit message" do
20
+ expect(payload.message).to eq "Commit Sat Jan 19 18:42:40 CST 2013"
21
21
  end
22
22
 
23
- it 'sets author and committer' do
24
- payload.committer.should be_nil
25
- payload.committer_email.should be_nil
23
+ it "sets committer name" do
24
+ expect(payload.committer).to eq nil
25
+ end
26
+
27
+ it "sets committer email" do
28
+ expect(payload.committer_email).to eq nil
29
+ end
26
30
 
27
- payload.author.should eq 'Dan Sosedoff'
28
- payload.author_email.should eq 'dan.sosedoff@gmail.com'
31
+ it "sets author name" do
32
+ expect(payload.author).to eq "Dan Sosedoff"
29
33
  end
30
34
 
31
- it 'sets commit view url' do
32
- payload.commit_url.should eq 'https://bitbucket.org/sosedoff/test1/commits/f15566c42759198fd32a70963d2509f3f8309586'
35
+ it "sets author email" do
36
+ expect(payload.author_email).to eq "dan.sosedoff@gmail.com"
33
37
  end
34
38
 
35
- it 'sets compare url' do
36
- payload.compare_url.should eq 'https://bitbucket.org/sosedoff/test1/compare/e15c6013c0f6232153e53b003b97da51d338da3a..f15566c42759198fd32a70963d2509f3f8309586'
39
+ it "sets commit view url" do
40
+ expect(payload.commit_url).to eq "https://bitbucket.org/sosedoff/test1/commits/f15566c42759198fd32a70963d2509f3f8309586"
41
+ end
42
+
43
+ it "sets compare url" do
44
+ expect(payload.compare_url).to eq "https://bitbucket.org/sosedoff/test1/compare/e15c6013c0f6232153e53b003b97da51d338da3a..f15566c42759198fd32a70963d2509f3f8309586"
37
45
  end
38
46
 
39
47
  context "that does not have commits" do
40
48
  let(:data) { fixture("bitbucket/git_no_commits.json") }
41
49
 
42
50
  it "raises PayloadError exception" do
43
- expect { Magnum::Payload::Bitbucket.new(data) }.
51
+ expect { described_class.new(data) }.
44
52
  to raise_error Magnum::Payload::PayloadError, "Payload has no commits"
45
53
  end
46
54
  end
47
55
  end
48
56
 
49
- context 'with mercurial payload' do
50
- let(:data) { fixture('bitbucket/hg.json') }
57
+ context "with mercurial payload" do
58
+ let(:data) { fixture("bitbucket/hg.json") }
51
59
 
52
- it 'sets commit SHA' do
53
- payload.commit.should eq 4
60
+ it "sets commit SHA" do
61
+ expect(payload.commit).to eq 4
54
62
  end
55
63
 
56
- it 'sets commit branch' do
57
- payload.branch.should eq 'default'
64
+ it "sets commit branch" do
65
+ expect(payload.branch).to eq "default"
58
66
  end
59
67
 
60
- it 'sets commit message' do
61
- payload.message.should eq 'Commit 2'
68
+ it "sets commit message" do
69
+ expect(payload.message).to eq "Commit 2"
62
70
  end
63
71
 
64
- it 'sets author and committer' do
65
- payload.committer.should be_nil
66
- payload.committer_email.should be_nil
72
+ it "sets author name" do
73
+ payload.author.should eq "Dan Sosedoff"
74
+ end
67
75
 
68
- payload.author.should eq 'Dan Sosedoff'
69
- payload.author_email.should eq 'dan.sosedoff@gmail.com'
76
+ it "sets author email" do
77
+ expect(payload.author_email).to eq "dan.sosedoff@gmail.com"
70
78
  end
71
79
 
72
- it 'sets commit view url' do
73
- payload.commit_url.should eq 'https://bitbucket.org/sosedoff/mercurial-test/commits/4'
80
+ it "sets commit view url" do
81
+ expect(payload.commit_url).to eq "https://bitbucket.org/sosedoff/mercurial-test/commits/4"
74
82
  end
75
83
 
76
- it 'sets compare url' do
77
- payload.compare_url.should eq 'https://bitbucket.org/sosedoff/mercurial-test/compare/3..4'
84
+ it "sets compare url" do
85
+ expect(payload.compare_url).to eq "https://bitbucket.org/sosedoff/mercurial-test/compare/3..4"
78
86
  end
79
87
  end
80
88
  end
81
89
 
82
- describe '#site_url' do
83
- it 'returns website url without a path' do
84
- payload.site_url.should eq 'https://bitbucket.org'
90
+ describe "#site_url" do
91
+ it "returns website url without a path" do
92
+ expect(payload.site_url).to eq "https://bitbucket.org"
85
93
  end
86
94
  end
87
95
 
88
- describe '#repo_url' do
89
- it 'return relative repository path' do
90
- payload.repo_url.should eq '/sosedoff/test1/'
96
+ describe "#repo_url" do
97
+ it "return relative repository path" do
98
+ expect(payload.repo_url).to eq "/sosedoff/test1/"
91
99
  end
92
100
  end
93
101
 
94
- describe '#make_url' do
95
- it 'returns a full url to the repository' do
96
- payload.make_url.should eq 'https://bitbucket.org/sosedoff/test1/'
102
+ describe "#make_url" do
103
+ it "returns a full url to the repository" do
104
+ expect(payload.make_url).to eq "https://bitbucket.org/sosedoff/test1/"
97
105
  end
98
106
 
99
- it 'returns a full url to the repository action' do
100
- payload.make_url('commits/1234').should eq 'https://bitbucket.org/sosedoff/test1/commits/1234'
107
+ it "returns a full url to the repository action" do
108
+ expect(payload.make_url("commits/1234")).to eq "https://bitbucket.org/sosedoff/test1/commits/1234"
101
109
  end
102
110
  end
103
111
  end
@@ -17,13 +17,19 @@ describe Magnum::Payload::Github do
17
17
  expect(payload.message).to eq "Remove jruby from test matrix"
18
18
  end
19
19
 
20
- it "sets author" do
20
+ it "sets author name" do
21
21
  expect(payload.committer).to eq "Dan Sosedoff"
22
+ end
23
+
24
+ it "sets author email" do
22
25
  expect(payload.committer_email).to eq "dan.sosedoff@gmail.com"
23
26
  end
24
27
 
25
- it "sets committer" do
28
+ it "sets committer name" do
26
29
  expect(payload.author).to eq "Dan Sosedoff"
30
+ end
31
+
32
+ it "sets committer email" do
27
33
  expect(payload.author_email).to eq "dan.sosedoff@gmail.com"
28
34
  end
29
35
 
@@ -3,41 +3,44 @@ require "spec_helper"
3
3
  describe Magnum::Payload::MessageParser do
4
4
  let(:subject) { TestMessageParser.new }
5
5
 
6
- describe "#skip_message?" do
7
- it "returns true when message contains 'ci-skip'" do
8
- subject.stub(:message).and_return("Commit message [ci-skip]")
9
- expect(subject.skip_message?).to be_true
10
- end
11
-
12
- it "returns true when message contains 'ci skip'" do
13
- subject.stub(:message).and_return("Commit message [ci skip]")
14
- expect(subject.skip_message?).to be_true
15
- end
6
+ before do
7
+ subject.stub(:message) { message }
8
+ end
16
9
 
17
- it "returns true when message contains 'skip ci'" do
18
- subject.stub(:message).and_return("Commit message [skip ci]")
19
- expect(subject.skip_message?).to be_true
20
- end
10
+ describe "#skip_message?" do
11
+ context "when no skip points" do
12
+ let(:message) { "Commit message" }
21
13
 
22
- it "returns true when message contains 'skip-ci'" do
23
- subject.stub(:message).and_return("Commit message [skip-ci]")
24
- expect(subject.skip_message?).to be_true
14
+ it "returns false" do
15
+ expect(subject.skip_message?).to be_false
16
+ end
25
17
  end
26
-
27
- it "returns false if no skip points found" do
28
- subject.stub(:message).and_return("Commit message")
29
- expect(subject.skip_message?).to be_false
18
+
19
+ ["[ci-skip]", "[ci skip]", "[skip ci]", "[skip-ci]"].each do |val|
20
+ context "when message contains #{val}" do
21
+ let(:message) { val }
22
+
23
+ it "returns true" do
24
+ expect(subject.skip_message?).to be_true
25
+ end
26
+ end
30
27
  end
31
28
 
32
29
  context "with multi-line message" do
33
- it "returns true" do
34
- subject.stub(:message).and_return("Commit message [skip-ci]\nCommit comments")
35
- expect(subject.skip_message?).to be_true
30
+ context "when first line is a skip" do
31
+ let(:message) { "Commit message [skip-ci]\nCommit comments" }
32
+
33
+ it "returns true" do
34
+ expect(subject.skip_message?).to be_true
35
+ end
36
36
  end
37
37
 
38
- it "returns false" do
39
- subject.stub(:message).and_return("Commit message\nLets skip [ci-skip]")
40
- expect(subject.skip_message?).to be_false
38
+ context "when first lie is not a skip" do
39
+ let(:message) { "Commit message\nLets skip [ci-skip]" }
40
+
41
+ it "returns false" do
42
+ expect(subject.skip_message?).to be_false
43
+ end
41
44
  end
42
45
  end
43
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magnum-payload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Sosedoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-01 00:00:00.000000000 Z
11
+ date: 2014-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -106,6 +106,7 @@ files:
106
106
  - lib/magnum/payload/version.rb
107
107
  - magnum-payload.gemspec
108
108
  - spec/fixtures/beanstalk/git.json
109
+ - spec/fixtures/beanstalk/git_branch_delete.json
109
110
  - spec/fixtures/beanstalk/hg.json
110
111
  - spec/fixtures/beanstalk/svn.json
111
112
  - spec/fixtures/bitbucket/git.json
@@ -156,6 +157,7 @@ specification_version: 4
156
157
  summary: Code payload parser
157
158
  test_files:
158
159
  - spec/fixtures/beanstalk/git.json
160
+ - spec/fixtures/beanstalk/git_branch_delete.json
159
161
  - spec/fixtures/beanstalk/hg.json
160
162
  - spec/fixtures/beanstalk/svn.json
161
163
  - spec/fixtures/bitbucket/git.json