summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-26 09:54:48 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-26 09:54:48 +0300
commitd32ef77b6fe5c97fa739e491db430b9b885cf0c2 (patch)
treee2438bd007c2c55ee62930369c066bf982782d06
parentda1c546af9bc4281958a6e8cc4cf24bc531350eb (diff)
parente6793da4a8596ba8424f5b0f6e985993577a0624 (diff)
downloadgitlab-ci-d32ef77b6fe5c97fa739e491db430b9b885cf0c2.tar.gz
Merge pull request #443 from Aigeruth/coverage/models_network
Add tests for Network model.
-rw-r--r--spec/models/network_spec.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/models/network_spec.rb b/spec/models/network_spec.rb
new file mode 100644
index 0000000..c0e92e2
--- /dev/null
+++ b/spec/models/network_spec.rb
@@ -0,0 +1,54 @@
+require 'spec_helper'
+
+describe Network do
+ let(:network) { Network.new }
+
+ describe :enable_ci do
+ subject { network.enable_ci '', '', '', '' }
+
+ context 'on success' do
+ before do
+ response = double
+ response.stub(:code) { 200 }
+ network.class.stub(:put) { response }
+ end
+
+ it { should be_true }
+ end
+
+ context 'on failure' do
+ before do
+ response = double
+ response.stub(:code) { 404 }
+ network.class.stub(:put) { response }
+ end
+
+ it { should be_nil }
+ end
+ end
+
+ describe :disable_ci do
+ let(:response) { double }
+ subject { network.disable_ci '', '', '' }
+
+ context 'on success' do
+ let(:parsed_response) { 'parsed' }
+ before do
+ response.stub(:code) { 200 }
+ response.stub(:parsed_response) { parsed_response }
+ network.class.stub(:delete) { response }
+ end
+
+ it { should equal(parsed_response) }
+ end
+
+ context 'on failure' do
+ before do
+ response.stub(:code) { 404 }
+ network.class.stub(:delete) { response }
+ end
+
+ it { should be_nil }
+ end
+ end
+end