hipchat 1.4.0 → 1.5.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/hipchat.gemspec +2 -1
- data/lib/hipchat.rb +3 -1
- data/lib/hipchat/api_version.rb +77 -14
- data/lib/hipchat/capistrano/tasks/hipchat.rake +2 -0
- data/lib/hipchat/capistrano2.rb +5 -1
- data/lib/hipchat/chef.rb +10 -9
- data/lib/hipchat/client.rb +7 -9
- data/lib/hipchat/file_helper.rb +42 -0
- data/lib/hipchat/rails3_tasks.rb +2 -2
- data/lib/hipchat/room.rb +49 -10
- data/lib/hipchat/user.rb +53 -12
- data/lib/hipchat/version.rb +1 -1
- data/spec/hipchat_api_v1_spec.rb +26 -30
- data/spec/hipchat_api_v2_spec.rb +133 -43
- data/spec/spec_helper.rb +6 -2
- data/spec/support/shared_contexts_for_hipchat.rb +36 -9
- metadata +44 -29
data/spec/spec_helper.rb
CHANGED
@@ -5,9 +5,13 @@ require 'rspec'
|
|
5
5
|
require 'rspec/autorun'
|
6
6
|
require 'json'
|
7
7
|
require 'webmock/rspec'
|
8
|
-
require 'coveralls'
|
9
8
|
|
10
|
-
|
9
|
+
begin
|
10
|
+
require 'coveralls'
|
11
|
+
Coveralls.wear!
|
12
|
+
rescue LoadError
|
13
|
+
warn 'warning: coveralls gem not found; skipping coverage'
|
14
|
+
end
|
11
15
|
|
12
16
|
Dir["./spec/support/**/*.rb"].each {|f| require f}
|
13
17
|
|
@@ -36,18 +36,19 @@ shared_context "HipChatV1" do
|
|
36
36
|
:headers => {'Accept' => 'application/json',
|
37
37
|
'Content-Type' => 'application/x-www-form-urlencoded'}).to_return(
|
38
38
|
:status => 200,
|
39
|
-
:body => '{"rooms":[{"
|
39
|
+
:body => '{"rooms":[{"room_id": "Hipchat", "links": {"self": "https://api.hipchat.com/v2/room/12345"}}]}',
|
40
40
|
:headers => {})
|
41
41
|
end
|
42
42
|
|
43
43
|
def mock_successful_history(options={})
|
44
|
-
options = { :date => 'recent', :timezone => 'UTC', :format => 'JSON' }.merge(options)
|
44
|
+
options = { :date => 'recent', :timezone => 'UTC', :format => 'JSON', :'max-results' => 100 }.merge(options)
|
45
45
|
canned_response = File.new(HISTORY_JSON_PATH)
|
46
46
|
stub_request(:get, "https://api.hipchat.com/v1/rooms/history").with(:query => {:auth_token => "blah",
|
47
|
-
:room_id
|
48
|
-
:date
|
49
|
-
:timezone
|
50
|
-
:
|
47
|
+
:room_id => "Hipchat",
|
48
|
+
:date => options[:date],
|
49
|
+
:timezone => options[:timezone],
|
50
|
+
:'max-results' => options[:'max-results'],
|
51
|
+
:format => options[:format]}).to_return(canned_response)
|
51
52
|
end
|
52
53
|
|
53
54
|
def mock_successful_room_creation(name, options={})
|
@@ -80,6 +81,14 @@ shared_context "HipChatV2" do
|
|
80
81
|
'Content-Type' => 'application/json'}).to_return(:status => 200, :body => "", :headers => {})
|
81
82
|
end
|
82
83
|
|
84
|
+
def mock_successful_file_send(from, message, file)
|
85
|
+
stub_request(:post, "https://api.hipchat.com/v2/room/Hipchat/share/file").with(
|
86
|
+
:query => {:auth_token => "blah"},
|
87
|
+
:body => "--sendfileboundary\nContent-Type: application/json; charset=UTF-8\nContent-Disposition: attachment; name=\"metadata\"\n\n{\"room_id\":\"Hipchat\",\"from\":\"Dude\",\"message\":\"Hello world\"}\n--sendfileboundary\nContent-Type: ; charset=UTF-8\nContent-Transfer-Encoding: base64\nContent-Disposition: attachment; name=\"file\"; filename=\"#{File.basename(file.path)}\"\n\ndGhlIGNvbnRlbnQ=\n\n--sendfileboundary--",
|
88
|
+
:headers => {'Accept' => 'application/json',
|
89
|
+
'Content-Type' => 'multipart/related; boundary=sendfileboundary'}).to_return(:status => 200, :body => "", :headers => {})
|
90
|
+
end
|
91
|
+
|
83
92
|
def mock_successful_topic_change(topic, options={})
|
84
93
|
options = {:from => 'API'}.merge(options)
|
85
94
|
stub_request(:put, "https://api.hipchat.com/v2/room/Hipchat/topic").with(
|
@@ -103,12 +112,13 @@ shared_context "HipChatV2" do
|
|
103
112
|
end
|
104
113
|
|
105
114
|
def mock_successful_history(options={})
|
106
|
-
options = { :date => 'recent', :timezone => 'UTC', :format => 'JSON' }.merge(options)
|
115
|
+
options = { :date => 'recent', :timezone => 'UTC', :format => 'JSON', :'max-results' => 100 }.merge(options)
|
107
116
|
canned_response = File.new(HISTORY_JSON_PATH)
|
108
117
|
stub_request(:get, "https://api.hipchat.com/v2/room/Hipchat/history").with(:query => {:auth_token => "blah",
|
109
118
|
:room_id => "Hipchat",
|
110
119
|
:date => options[:date],
|
111
120
|
:timezone => options[:timezone],
|
121
|
+
:'max-results' => options[:'max-results'],
|
112
122
|
:format => options[:format]}).to_return(canned_response)
|
113
123
|
end
|
114
124
|
|
@@ -156,7 +166,7 @@ shared_context "HipChatV2" do
|
|
156
166
|
:headers => {"Accept" => "application/json",
|
157
167
|
"Content-Type" => "application/json"}).to_return(
|
158
168
|
:status => 204,
|
159
|
-
:body => "",
|
169
|
+
:body => "",
|
160
170
|
:headers => {})
|
161
171
|
end
|
162
172
|
|
@@ -177,8 +187,25 @@ shared_context "HipChatV2" do
|
|
177
187
|
def mock_successful_user_send(message)
|
178
188
|
stub_request(:post, "https://api.hipchat.com/v2/user/12345678/message").with(
|
179
189
|
:query => {:auth_token => "blah"},
|
180
|
-
:body => {:message => "Equal bytes for everyone"
|
190
|
+
:body => {:message => "Equal bytes for everyone",
|
191
|
+
:message_format => "text"},
|
181
192
|
:headers => {'Accept' => 'application/json',
|
182
193
|
'Content-Type' => 'application/json'}).to_return(:status => 200, :body => "", :headers => {})
|
183
194
|
end
|
195
|
+
|
196
|
+
def mock_successful_user_history()
|
197
|
+
canned_response = File.new(HISTORY_JSON_PATH)
|
198
|
+
url = 'https://api.hipchat.com/v2/user/12345678/history/latest'
|
199
|
+
stub_request(:get, url).with(:query => { :auth_token => "blah" },
|
200
|
+
:headers => { 'Accept' => 'application/json',
|
201
|
+
'Content-Type' => 'application/json' }).to_return(canned_response)
|
202
|
+
end
|
203
|
+
|
204
|
+
def mock_successful_user_send_file(message, file)
|
205
|
+
stub_request(:post, "https://api.hipchat.com/v2/user/12345678/share/file").with(
|
206
|
+
:query => {:auth_token => "blah"},
|
207
|
+
:body => "--sendfileboundary\nContent-Type: application/json; charset=UTF-8\nContent-Disposition: attachment; name=\"metadata\"\n\n{\"message\":\"Equal bytes for everyone\"}\n--sendfileboundary\nContent-Type: ; charset=UTF-8\nContent-Transfer-Encoding: base64\nContent-Disposition: attachment; name=\"file\"; filename=\"#{File.basename(file)}\"\n\ndGhlIGNvbnRlbnQ=\n\n--sendfileboundary--",
|
208
|
+
:headers => {'Accept' => 'application/json',
|
209
|
+
'Content-Type' => 'multipart/related; boundary=sendfileboundary'}).to_return(:status => 200, :body => "", :headers => {})
|
210
|
+
end
|
184
211
|
end
|
metadata
CHANGED
@@ -1,125 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hipchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HipChat/Atlassian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mimemagic
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ~>
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '3.0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ~>
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '3.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rr
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - '>='
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - '>='
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ~>
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '1.3'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ~>
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '1.3'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - '>='
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - '>='
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: webmock
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - '>='
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - '>='
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rdoc
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - '>'
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: 2.4.2
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- -
|
122
|
+
- - '>'
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: 2.4.2
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: coveralls
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- -
|
129
|
+
- - '>='
|
116
130
|
- !ruby/object:Gem::Version
|
117
131
|
version: '0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- -
|
136
|
+
- - '>='
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
139
|
description: Ruby library to interact with HipChat
|
@@ -129,12 +143,12 @@ executables: []
|
|
129
143
|
extensions: []
|
130
144
|
extra_rdoc_files: []
|
131
145
|
files:
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
135
|
-
-
|
136
|
-
-
|
137
|
-
-
|
146
|
+
- .coveralls.yml
|
147
|
+
- .document
|
148
|
+
- .gitignore
|
149
|
+
- .ruby-gemset
|
150
|
+
- .ruby-version
|
151
|
+
- .travis.yml
|
138
152
|
- Gemfile
|
139
153
|
- LICENSE
|
140
154
|
- README.textile
|
@@ -148,6 +162,7 @@ files:
|
|
148
162
|
- lib/hipchat/chef.rb
|
149
163
|
- lib/hipchat/client.rb
|
150
164
|
- lib/hipchat/errors.rb
|
165
|
+
- lib/hipchat/file_helper.rb
|
151
166
|
- lib/hipchat/rails3_tasks.rb
|
152
167
|
- lib/hipchat/railtie.rb
|
153
168
|
- lib/hipchat/room.rb
|
@@ -170,17 +185,17 @@ require_paths:
|
|
170
185
|
- lib
|
171
186
|
required_ruby_version: !ruby/object:Gem::Requirement
|
172
187
|
requirements:
|
173
|
-
- -
|
188
|
+
- - '>='
|
174
189
|
- !ruby/object:Gem::Version
|
175
190
|
version: 1.9.3
|
176
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
192
|
requirements:
|
178
|
-
- -
|
193
|
+
- - '>='
|
179
194
|
- !ruby/object:Gem::Version
|
180
195
|
version: '0'
|
181
196
|
requirements: []
|
182
197
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.
|
198
|
+
rubygems_version: 2.0.14
|
184
199
|
signing_key:
|
185
200
|
specification_version: 4
|
186
201
|
summary: Ruby library to interact with HipChat
|