summaryrefslogtreecommitdiff
path: root/spec/gitlab_net_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/gitlab_net_spec.rb')
-rw-r--r--spec/gitlab_net_spec.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb
index 5e6e4de..17fb56d 100644
--- a/spec/gitlab_net_spec.rb
+++ b/spec/gitlab_net_spec.rb
@@ -26,6 +26,11 @@ describe GitlabNet, vcr: true do
gitlab_net.check
end
end
+
+ it "raises an exception if the connection fails" do
+ Net::HTTP.any_instance.stub(:request).and_raise(StandardError)
+ expect { gitlab_net.check }.to raise_error(GitlabNet::ApiUnreachableError)
+ end
end
describe :discover do
@@ -42,6 +47,13 @@ describe GitlabNet, vcr: true do
gitlab_net.discover('key-126')
end
end
+
+ it "raises an exception if the connection fails" do
+ VCR.use_cassette("discover-ok") do
+ Net::HTTP.any_instance.stub(:request).and_raise(StandardError)
+ expect { gitlab_net.discover('key-126') }.to raise_error(GitlabNet::ApiUnreachableError)
+ end
+ end
end
describe :broadcast_message do
@@ -110,6 +122,13 @@ describe GitlabNet, vcr: true do
end
end
end
+
+ it "raises an exception if the connection fails" do
+ Net::HTTP.any_instance.stub(:request).and_raise(StandardError)
+ expect {
+ gitlab_net.check_access('git-upload-pack', 'gitlab/gitlabhq.git', 'user-1', changes)
+ }.to raise_error(GitlabNet::ApiUnreachableError)
+ end
end
describe :host do
@@ -139,12 +158,13 @@ describe GitlabNet, vcr: true do
let(:user) { 'user' }
let(:password) { 'password' }
let(:url) { URI 'http://localhost/' }
- subject { gitlab_net.send :http_request_for, url }
+ subject { gitlab_net.send :http_request_for, :get, url }
before do
gitlab_net.send(:config).http_settings.stub(:[]).with('user') { user }
gitlab_net.send(:config).http_settings.stub(:[]).with('password') { password }
get.should_receive(:basic_auth).with(user, password).once
+ get.should_receive(:set_form_data).with(hash_including(secret_token: 'a123')).once
end
it { should_not be_nil }