summaryrefslogtreecommitdiff
path: root/spec/models/project_services/hipchat_service_spec.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-05-26 21:51:31 -0700
committerStan Hu <stanhu@gmail.com>2015-05-26 21:57:24 -0700
commit0c9463174ba5b73156ed786648fb782fe79947e9 (patch)
tree6f24948ead8d22eb48812b2070cd5f9c3f041073 /spec/models/project_services/hipchat_service_spec.rb
parentdfa1d96a1fa372b292c83424f62ae10d2c053fbd (diff)
downloadgitlab-ce-0c9463174ba5b73156ed786648fb782fe79947e9.tar.gz
Allow HipChat API version to be blank and default to v2
Closes #772
Diffstat (limited to 'spec/models/project_services/hipchat_service_spec.rb')
-rw-r--r--spec/models/project_services/hipchat_service_spec.rb31
1 files changed, 27 insertions, 4 deletions
diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb
index bbaf54488be..e88615e1a2e 100644
--- a/spec/models/project_services/hipchat_service_spec.rb
+++ b/spec/models/project_services/hipchat_service_spec.rb
@@ -32,21 +32,44 @@ describe HipchatService do
let(:project) { create(:project, name: 'project') }
let(:api_url) { 'https://hipchat.example.com/v2/room/123456/notification?auth_token=verySecret' }
let(:project_name) { project.name_with_namespace.gsub(/\s/, '') }
+ let(:token) { 'verySecret' }
+ let(:server_url) { 'https://hipchat.example.com'}
+ let(:push_sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) }
before(:each) do
hipchat.stub(
project_id: project.id,
project: project,
room: 123456,
- server: 'https://hipchat.example.com',
- token: 'verySecret'
+ server: server_url,
+ token: token
)
WebMock.stub_request(:post, api_url)
end
- context 'push events' do
- let(:push_sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) }
+ it 'should use v1 if version is provided' do
+ hipchat.stub(api_version: 'v1')
+ expect(HipChat::Client).to receive(:new).
+ with(token,
+ api_version: 'v1',
+ server_url: server_url).
+ and_return(
+ double(:hipchat_service).as_null_object)
+ hipchat.execute(push_sample_data)
+ end
+ it 'should use v2 as the version when nothing is provided' do
+ hipchat.stub(api_version: '')
+ expect(HipChat::Client).to receive(:new).
+ with(token,
+ api_version: 'v2',
+ server_url: server_url).
+ and_return(
+ double(:hipchat_service).as_null_object)
+ hipchat.execute(push_sample_data)
+ end
+
+ context 'push events' do
it "should call Hipchat API for push events" do
hipchat.execute(push_sample_data)