qiita_team_services 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/locales/en.yml +11 -0
- data/config/locales/ja.yml +11 -0
- data/lib/qiita/team/services/hooks/slack_v2.rb +4 -1
- data/lib/qiita/team/services/hooks/webhook.rb +5 -1
- data/lib/qiita/team/services/version.rb +1 -1
- data/qiita_team_services.gemspec +1 -0
- data/spec/hooks/chatwork_v1_spec.rb +1 -1
- data/spec/hooks/hipchat_v1_spec.rb +1 -1
- data/spec/hooks/slack_v1_spec.rb +2 -2
- data/spec/hooks/slack_v2_spec.rb +22 -2
- data/spec/hooks/webhook_spec.rb +37 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/helpers/slack_hook_helper.rb +5 -5
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d4c5b560eeb0143ee323479dd0ca493af868401
|
4
|
+
data.tar.gz: 76b0e85c196621822b0450b9a60f35cdeb54a84f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dec92fbde534b8681234212e2166d45ac262c6e1610ddd701113c3b46e7261e9060f037a4c33a7a8a5c20ef4ed6f0a0261385cf4ad7f8564da91da6358770d01
|
7
|
+
data.tar.gz: 658d390c292f958e6ea41ca29eb69262db05e3de447fa965150570cb586f5928bb02864f189596ae012369dd0d3b97938737d459e8b15a295f87af9d8f5aac87
|
data/config/locales/en.yml
CHANGED
@@ -32,3 +32,14 @@ en:
|
|
32
32
|
webhook:
|
33
33
|
url: URL
|
34
34
|
token: Token
|
35
|
+
activemodel:
|
36
|
+
errors:
|
37
|
+
models:
|
38
|
+
qiita/team/services/hooks/slack_v2:
|
39
|
+
attributes:
|
40
|
+
webhook_url:
|
41
|
+
not_slack_url: is not a valid Slack hook url.
|
42
|
+
qiita/team/services/hooks/webhook:
|
43
|
+
attributes:
|
44
|
+
url:
|
45
|
+
invalid_scheme: must be a http or https url.
|
data/config/locales/ja.yml
CHANGED
@@ -33,3 +33,14 @@ ja:
|
|
33
33
|
webhook:
|
34
34
|
url: URL
|
35
35
|
token: トークン
|
36
|
+
activemodel:
|
37
|
+
errors:
|
38
|
+
models:
|
39
|
+
qiita/team/services/hooks/slack_v2:
|
40
|
+
attributes:
|
41
|
+
webhook_url:
|
42
|
+
not_slack_url: は正しいSlack URLではありません。
|
43
|
+
qiita/team/services/hooks/webhook:
|
44
|
+
attributes:
|
45
|
+
url:
|
46
|
+
invalid_scheme: はhttpかhttpsでなければなりません。
|
@@ -8,7 +8,10 @@ module Qiita::Team::Services
|
|
8
8
|
|
9
9
|
define_property :webhook_url
|
10
10
|
|
11
|
-
validates :webhook_url, presence: true
|
11
|
+
validates :webhook_url, presence: true,
|
12
|
+
format: { with: %r{\Ahttps://hooks\.slack\.com},
|
13
|
+
message: :not_slack_url,
|
14
|
+
allow_blank: true }
|
12
15
|
|
13
16
|
private
|
14
17
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "activemodel-url_validator"
|
1
2
|
require "securerandom"
|
2
3
|
|
3
4
|
require "qiita/team/services/hooks/base"
|
@@ -11,7 +12,10 @@ module Qiita::Team::Services
|
|
11
12
|
define_property :token
|
12
13
|
|
13
14
|
validates :token, format: %r{\A[A-Za-z0-9+/=]{20,40}\z}
|
14
|
-
validates :url, presence: true
|
15
|
+
validates :url, presence: true,
|
16
|
+
url: { scheme: ['http', 'https'],
|
17
|
+
message: :invalid_scheme,
|
18
|
+
allow_blank: true }
|
15
19
|
|
16
20
|
# @note Override {Qiita::Team::Services::Hooks::Base.service_name}.
|
17
21
|
def self.service_name
|
data/qiita_team_services.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.files = `git ls-files -z`.split("\x0")
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
+
spec.add_dependency "activemodel-url_validator"
|
25
26
|
spec.add_dependency "faraday", "~> 0.9"
|
26
27
|
spec.add_dependency "faraday_middleware", "~> 0.10"
|
27
28
|
spec.add_dependency "rails", "~> 4.2"
|
data/spec/hooks/slack_v1_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe Qiita::Team::Services::Hooks::SlackV1 do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
subject(:hook) do
|
25
25
|
described_class.new(properties)
|
26
26
|
end
|
27
27
|
|
@@ -51,5 +51,5 @@ describe Qiita::Team::Services::Hooks::SlackV1 do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it_behaves_like "hook"
|
54
|
-
it_behaves_like "Slack hook"
|
54
|
+
it_behaves_like "Slack hook", hook: :hook
|
55
55
|
end
|
data/spec/hooks/slack_v2_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe Qiita::Team::Services::Hooks::SlackV2 do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
subject(:hook) do
|
25
25
|
described_class.new(properties)
|
26
26
|
end
|
27
27
|
|
@@ -46,5 +46,25 @@ describe Qiita::Team::Services::Hooks::SlackV2 do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it_behaves_like "hook"
|
49
|
-
it_behaves_like "Slack hook"
|
49
|
+
it_behaves_like "Slack hook", hook: :hook
|
50
|
+
|
51
|
+
describe "#valid?" do
|
52
|
+
subject { hook.valid? }
|
53
|
+
|
54
|
+
context "when url starts with https://hooks.slack.com/" do
|
55
|
+
let(:webhook_url) do
|
56
|
+
"https://hooks.slack.com/services/foo/bar"
|
57
|
+
end
|
58
|
+
|
59
|
+
it { should be true }
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when url does not start with https://hooks.slack.com/" do
|
63
|
+
let(:webhook_url) do
|
64
|
+
"http://hooks.slack.com/services/foo/bar"
|
65
|
+
end
|
66
|
+
|
67
|
+
it { should be false }
|
68
|
+
end
|
69
|
+
end
|
50
70
|
end
|
data/spec/hooks/webhook_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Qiita::Team::Services::Hooks::Webhook, :versioning do
|
2
|
-
|
2
|
+
subject(:hook) do
|
3
3
|
described_class.new(properties)
|
4
4
|
end
|
5
5
|
|
@@ -462,4 +462,40 @@ describe Qiita::Team::Services::Hooks::Webhook, :versioning do
|
|
462
462
|
expect(request).to have_been_made
|
463
463
|
end
|
464
464
|
end
|
465
|
+
|
466
|
+
describe "#valid?" do
|
467
|
+
subject { hook.valid? }
|
468
|
+
|
469
|
+
context "when url is http" do
|
470
|
+
let(:url) do
|
471
|
+
FFaker::Internet.uri(:http)
|
472
|
+
end
|
473
|
+
|
474
|
+
it { should be true }
|
475
|
+
end
|
476
|
+
|
477
|
+
context "when url is http" do
|
478
|
+
let(:url) do
|
479
|
+
FFaker::Internet.uri(:https)
|
480
|
+
end
|
481
|
+
|
482
|
+
it { should be true }
|
483
|
+
end
|
484
|
+
|
485
|
+
context "when url is ftp" do
|
486
|
+
let(:url) do
|
487
|
+
FFaker::Internet.uri(:ftp)
|
488
|
+
end
|
489
|
+
|
490
|
+
it { should be false }
|
491
|
+
end
|
492
|
+
|
493
|
+
context "when url is not a URI" do
|
494
|
+
let(:url) do
|
495
|
+
"example.com"
|
496
|
+
end
|
497
|
+
|
498
|
+
it { should be false }
|
499
|
+
end
|
500
|
+
end
|
465
501
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -29,7 +29,7 @@ module Qiita::Team::Services
|
|
29
29
|
].freeze
|
30
30
|
|
31
31
|
included do
|
32
|
-
shared_examples "Slack hook" do
|
32
|
+
shared_examples "Slack hook" do |hook:|
|
33
33
|
describe ".service_name" do
|
34
34
|
subject do
|
35
35
|
described_class.service_name
|
@@ -48,11 +48,11 @@ module Qiita::Team::Services
|
|
48
48
|
|
49
49
|
describe "#ping" do
|
50
50
|
subject do
|
51
|
-
hook.ping
|
51
|
+
send(hook).ping
|
52
52
|
end
|
53
53
|
|
54
54
|
it "sends message with proper attachments" do
|
55
|
-
expect(hook).to receive(:send_message) do |request_body|
|
55
|
+
expect(send(hook)).to receive(:send_message) do |request_body|
|
56
56
|
expect(request_body).to match_slack_attachments_request
|
57
57
|
end.once
|
58
58
|
subject
|
@@ -74,11 +74,11 @@ module Qiita::Team::Services
|
|
74
74
|
EXPECTED_AVAILABLE_EVENT_NAMES.each do |event_name|
|
75
75
|
describe "##{event_name}" do
|
76
76
|
subject do
|
77
|
-
hook.public_send(event_name, public_send("#{event_name}_event"))
|
77
|
+
send(hook).public_send(event_name, public_send("#{event_name}_event"))
|
78
78
|
end
|
79
79
|
|
80
80
|
it "sends message with proper attachments" do
|
81
|
-
expect(hook).to receive(:send_message) do |request_body|
|
81
|
+
expect(send(hook)).to receive(:send_message) do |request_body|
|
82
82
|
expect(request_body).to match_slack_attachments_request
|
83
83
|
end.once
|
84
84
|
subject
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiita_team_services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuku Takahashi
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel-url_validator
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: faraday
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|