errbit_github_plugin 0.2.0 → 0.3.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
  SHA1:
3
- metadata.gz: afa68dc7f2ff60cfa5bca4d26fd9889a36bca7ad
4
- data.tar.gz: f80c19060d3f571fe4882b3c62efbe6bc585ad42
3
+ metadata.gz: 03e8b522abb3f21ad344c7fc8daa4f3488858567
4
+ data.tar.gz: 14c8b3453aa7376a0addec27428516d261c8ad67
5
5
  SHA512:
6
- metadata.gz: e6101c37634049d1a0cdba1fad9c4f272f70ce64fa4e925265272974ad21d4fed6b61f91c4c133b957215931d40dc600ab81d4dccb715879a6a671023c0e1ef1
7
- data.tar.gz: f3af3a3f80dda0814de880fd94b40a0497ecc7960f98df2c8bfb9063a078acd4c2ae73d91ba137130d2368c1432c0bcc4d9d0c1de836ae0b60153a3fb5e874cd
6
+ metadata.gz: cbb84ca9d1757a665200ce84e57f87d6be39f9ca3f949e90a66b5ad961e691195512da8401b83322e0bb901d8c5205ea0f8c634325bed4b9c7728e0af2cc1f51
7
+ data.tar.gz: 82c69cfe8522e76c4eb4a0e53fa0b4b62af7763a0c2cccfa7fe39cfe0ec4fcd9032e0ec96eecd68a339ce4aacdb0812730905c1f72f991a0ec1943038778df42
data/.gitignore CHANGED
@@ -15,3 +15,6 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ *.swp
19
+ .rspec
20
+ vendor/bundle
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+ - 2.2
5
+ - 2.3.0
6
+ sudo: false
7
+ cache: bundler
8
+ script:
9
+ - bundle exec rspec
data/Gemfile CHANGED
@@ -1,10 +1,2 @@
1
1
  source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in errbit_github_plugin.gemspec
4
2
  gemspec
5
-
6
- gem 'errbit_plugin', :git => 'https://github.com/errbit/errbit_plugin.git'
7
- gem 'rspec'
8
- gem 'guard'
9
- gem 'guard-rspec'
10
- gem 'coveralls', :require => false
data/README.md CHANGED
@@ -1,29 +1,7 @@
1
- # ErrbitGithubPlugin
1
+ # Errbit Github Plugin [![TravisCI][travis-img-url]][travis-ci-url]
2
2
 
3
- TODO: Write a gem description
3
+ [travis-img-url]: https://travis-ci.org/errbit/errbit_github_plugin.svg?branch=master
4
+ [travis-ci-url]: http://travis-ci.org/errbit/errbit_github_plugin
4
5
 
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'errbit_github_plugin'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install errbit_github_plugin
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Contributing
24
-
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
6
+ This plugin provides GitHub issue tracker integration for Errbit and it is the
7
+ only plugin included by default in Errbit.
@@ -4,24 +4,29 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'errbit_github_plugin/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "errbit_github_plugin"
7
+ spec.name = 'errbit_github_plugin'
8
8
  spec.version = ErrbitGithubPlugin::VERSION
9
- spec.authors = ["Stephen Crosby", "Cyril Mougel"]
10
- spec.email = ["stevecrozz@gmail.com", "cyril.mougel@gmail.com"]
9
+ spec.authors = ['Stephen Crosby']
10
+ spec.email = ['stevecrozz@gmail.com']
11
11
 
12
12
  spec.description = %q{GitHub integration for Errbit}
13
13
  spec.summary = %q{GitHub integration for Errbit}
14
- spec.homepage = "https://github.com/brandedcrate/errbit_github_plugin"
15
- spec.license = "MIT"
14
+ spec.homepage = 'https://github.com/errbit/errbit_github_plugin'
15
+ spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files`.split($/)
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
21
 
22
- spec.add_dependency "errbit_plugin"
23
- spec.add_dependency "octokit"
22
+ spec.add_dependency 'errbit_plugin'
23
+ spec.add_dependency 'octokit'
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.3"
26
- spec.add_development_dependency "rake"
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'guard'
27
+ spec.add_development_dependency 'guard-rspec'
28
+ spec.add_development_dependency 'coveralls'
29
+ spec.add_development_dependency 'bundler'
30
+ spec.add_development_dependency 'rake'
31
+ spec.add_development_dependency 'activesupport'
27
32
  end
@@ -82,5 +82,23 @@ module ErrbitGithubPlugin
82
82
  rescue Octokit::Unauthorized
83
83
  raise ErrbitGithubPlugin::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password."
84
84
  end
85
+
86
+ def close_issue(url, user: {})
87
+ if user['github_login'] && user['github_oauth_token']
88
+ github_client = Octokit::Client.new(
89
+ login: user['github_login'], access_token: user['github_oauth_token'])
90
+ else
91
+ github_client = Octokit::Client.new(
92
+ login: options['username'], password: options['password'])
93
+ end
94
+ # It would be better to get the number from issue.number when we create the issue,
95
+ # however, since we only have the url, get the number from it.
96
+ # ex: "https://github.com/octocat/Hello-World/issues/1347"
97
+ issue_number = url.split("/").last
98
+ issue = github_client.close_issue(repo, issue_number)
99
+ issue.html_url
100
+ rescue Octokit::Unauthorized
101
+ raise ErrbitGithubPlugin::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password."
102
+ end
85
103
  end
86
104
  end
@@ -1,3 +1,3 @@
1
1
  module ErrbitGithubPlugin
2
- VERSION = "0.2.0"
2
+ VERSION = '0.3.0'
3
3
  end
@@ -0,0 +1,156 @@
1
+ describe ErrbitGithubPlugin::IssueTracker do
2
+ describe '.label' do
3
+ it 'return LABEL' do
4
+ expect(described_class.label).to eq described_class::LABEL
5
+ end
6
+ end
7
+
8
+ describe '.note' do
9
+ it 'return NOTE' do
10
+ expect(described_class.note).to eq described_class::NOTE
11
+ end
12
+ end
13
+
14
+ describe '.fields' do
15
+ it 'return FIELDS' do
16
+ expect(described_class.fields).to eq described_class::FIELDS
17
+ end
18
+ end
19
+
20
+ describe '.icons' do
21
+
22
+ it 'puts create icon onto the icons' do
23
+ expect(described_class.icons[:create][0]).to eq 'image/png'
24
+ expect(
25
+ described_class.icons[:create][1]
26
+ ).to eq ErrbitGithubPlugin.read_static_file('github_create.png')
27
+ end
28
+
29
+ it 'puts goto icon onto the icons' do
30
+ expect(described_class.icons[:goto][0]).to eq 'image/png'
31
+ expect(
32
+ described_class.icons[:goto][1]
33
+ ).to eq ErrbitGithubPlugin.read_static_file('github_goto.png')
34
+ end
35
+
36
+ it 'puts inactive icon onto the icons' do
37
+ expect(described_class.icons[:inactive][0]).to eq 'image/png'
38
+ expect(
39
+ described_class.icons[:inactive][1]
40
+ ).to eq ErrbitGithubPlugin.read_static_file('github_inactive.png')
41
+ end
42
+ end
43
+
44
+ let(:tracker) { described_class.new(options) }
45
+
46
+ describe '#configured?' do
47
+ context 'with errors' do
48
+ let(:options) { { invalid_key: '' } }
49
+ it 'return false' do
50
+ expect(tracker.configured?).to eq false
51
+ end
52
+ end
53
+ context 'without errors' do
54
+ let(:options) do
55
+ { username: 'foo', password: 'bar', github_repo: 'user/repos' }
56
+ end
57
+ it 'return true' do
58
+ expect(tracker.configured?).to eq true
59
+ end
60
+ end
61
+ end
62
+
63
+ describe '#url' do
64
+ let(:options) { { github_repo: 'repo' } }
65
+ it 'returns issues url' do
66
+ expect(tracker.url).to eq 'https://github.com/repo/issues'
67
+ end
68
+ end
69
+
70
+ describe '#errors' do
71
+ subject { tracker.errors }
72
+ context 'without username' do
73
+ let(:options) { { username: '', password: 'bar', github_repo: 'repo' } }
74
+ it { is_expected.not_to be_empty }
75
+ end
76
+ context 'without password' do
77
+ let(:options) do
78
+ { username: '', password: 'bar', github_repo: 'repo' }
79
+ end
80
+ it { is_expected.not_to be_empty }
81
+ end
82
+ context 'without github_repo' do
83
+ let(:options) do
84
+ { username: 'foo', password: 'bar', github_repo: '' }
85
+ end
86
+ it { is_expected.not_to be_empty }
87
+ end
88
+ context 'with completed options' do
89
+ let(:options) do
90
+ { username: 'foo', password: 'bar', github_repo: 'repo' }
91
+ end
92
+ it { is_expected.to be_empty }
93
+ end
94
+ end
95
+
96
+ describe '#repo' do
97
+ let(:options) { { github_repo: 'baz' } }
98
+ it 'returns github repo' do
99
+ expect(tracker.repo).to eq 'baz'
100
+ end
101
+ end
102
+
103
+ describe '#create_issue' do
104
+ subject { tracker.create_issue('title', 'body', user: user) }
105
+ let(:options) do
106
+ { username: 'foo', password: 'bar', github_repo: 'user/repos' }
107
+ end
108
+ let(:fake_github_client) do
109
+ double('Fake GitHub Client').tap do |github_client|
110
+ github_client.stub(:create_issue).and_return(fake_issue)
111
+ end
112
+ end
113
+ let(:fake_issue) do
114
+ double('Fake Issue').tap do |issue|
115
+ issue.stub(:html_url).and_return('http://github.com/user/repos/issues/878')
116
+ end
117
+ end
118
+
119
+ context 'signed in with token' do
120
+ let(:user) do
121
+ {
122
+ 'github_login' => 'bob',
123
+ 'github_oauth_token' => 'valid_token'
124
+ }
125
+ end
126
+ it 'return issue url' do
127
+ Octokit::Client.stub(:new).with(
128
+ login: user['github_login'], access_token: user['github_oauth_token']
129
+ ).and_return(fake_github_client)
130
+ expect(subject).to eq fake_issue.html_url
131
+ end
132
+ end
133
+
134
+ context 'signed in with password' do
135
+ let(:user) { {} }
136
+ it 'return issue url' do
137
+ (Octokit::Client).stub(:new).with(
138
+ login: options['username'], password: options['password']
139
+ ).and_return(fake_github_client)
140
+ expect(subject).to eq fake_issue.html_url
141
+ end
142
+ end
143
+
144
+ context 'when unauthentication error' do
145
+ let(:user) do
146
+ { 'github_login' => 'alice', 'github_oauth_token' => 'invalid_token' }
147
+ end
148
+ it 'raise AuthenticationError' do
149
+ (Octokit::Client).stub(:new).with(
150
+ login: user['github_login'], access_token: user['github_oauth_token']
151
+ ).and_raise(Octokit::Unauthorized)
152
+ expect { subject }.to raise_error
153
+ end
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,28 @@
1
+ if ENV['COVERAGE']
2
+ require 'simplecov'
3
+ if ENV['CI']
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
10
+ end
11
+
12
+ SimpleCov.start
13
+ end
14
+
15
+ require 'errbit_plugin'
16
+ require 'errbit_github_plugin'
17
+ require 'active_support/all'
18
+
19
+ RSpec.configure do |config|
20
+ config.run_all_when_everything_filtered = true
21
+ config.filter_run :focus
22
+
23
+ # Run specs in random order to surface order dependencies. If you find an
24
+ # order dependency and want to debug it, you can fix the order by providing
25
+ # the seed, which is printed after each run.
26
+ # --seed 1234
27
+ config.order = 'random'
28
+ end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: errbit_github_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Crosby
8
- - Cyril Mougel
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2016-03-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: errbit_plugin
@@ -39,20 +38,76 @@ dependencies:
39
38
  - - ">="
40
39
  - !ruby/object:Gem::Version
41
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
42
97
  - !ruby/object:Gem::Dependency
43
98
  name: bundler
44
99
  requirement: !ruby/object:Gem::Requirement
45
100
  requirements:
46
- - - "~>"
101
+ - - ">="
47
102
  - !ruby/object:Gem::Version
48
- version: '1.3'
103
+ version: '0'
49
104
  type: :development
50
105
  prerelease: false
51
106
  version_requirements: !ruby/object:Gem::Requirement
52
107
  requirements:
53
- - - "~>"
108
+ - - ">="
54
109
  - !ruby/object:Gem::Version
55
- version: '1.3'
110
+ version: '0'
56
111
  - !ruby/object:Gem::Dependency
57
112
  name: rake
58
113
  requirement: !ruby/object:Gem::Requirement
@@ -67,15 +122,30 @@ dependencies:
67
122
  - - ">="
68
123
  - !ruby/object:Gem::Version
69
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: activesupport
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
70
139
  description: GitHub integration for Errbit
71
140
  email:
72
141
  - stevecrozz@gmail.com
73
- - cyril.mougel@gmail.com
74
142
  executables: []
75
143
  extensions: []
76
144
  extra_rdoc_files: []
77
145
  files:
78
146
  - ".gitignore"
147
+ - ".rspec"
148
+ - ".travis.yml"
79
149
  - Gemfile
80
150
  - LICENSE.txt
81
151
  - README.md
@@ -85,12 +155,14 @@ files:
85
155
  - lib/errbit_github_plugin/error.rb
86
156
  - lib/errbit_github_plugin/issue_tracker.rb
87
157
  - lib/errbit_github_plugin/version.rb
158
+ - spec/issue_tracker_spec.rb
159
+ - spec/spec_helper.rb
88
160
  - static/github_create.png
89
161
  - static/github_goto.png
90
162
  - static/github_inactive.png
91
163
  - vendor/assets/images/github_create.png
92
164
  - vendor/assets/images/github_inactive.png
93
- homepage: https://github.com/brandedcrate/errbit_github_plugin
165
+ homepage: https://github.com/errbit/errbit_github_plugin
94
166
  licenses:
95
167
  - MIT
96
168
  metadata: {}
@@ -114,5 +186,7 @@ rubygems_version: 2.2.2
114
186
  signing_key:
115
187
  specification_version: 4
116
188
  summary: GitHub integration for Errbit
117
- test_files: []
189
+ test_files:
190
+ - spec/issue_tracker_spec.rb
191
+ - spec/spec_helper.rb
118
192
  has_rdoc: