summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/gitlab_net_spec.rb20
-rw-r--r--spec/gitlab_post_receive_spec.rb3
-rw-r--r--spec/vcr_cassettes/broadcast_message-none.yml38
-rw-r--r--spec/vcr_cassettes/broadcast_message-ok.yml38
4 files changed, 99 insertions, 0 deletions
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb
index d431ac7..5e6e4de 100644
--- a/spec/gitlab_net_spec.rb
+++ b/spec/gitlab_net_spec.rb
@@ -44,6 +44,26 @@ describe GitlabNet, vcr: true do
end
end
+ describe :broadcast_message do
+ context "broadcast message exists" do
+ it 'should return message' do
+ VCR.use_cassette("broadcast_message-ok") do
+ result = gitlab_net.broadcast_message
+ result["message"].should == "Message"
+ end
+ end
+ end
+
+ context "broadcast message doesn't exist" do
+ it 'should return nil' do
+ VCR.use_cassette("broadcast_message-none") do
+ result = gitlab_net.broadcast_message
+ result.should == nil
+ end
+ end
+ end
+ end
+
describe :check_access do
context 'ssh key with access to project' do
it 'should allow pull access for dev.gitlab.org' do
diff --git a/spec/gitlab_post_receive_spec.rb b/spec/gitlab_post_receive_spec.rb
index 50c6f0a..dc84e4a 100644
--- a/spec/gitlab_post_receive_spec.rb
+++ b/spec/gitlab_post_receive_spec.rb
@@ -9,10 +9,13 @@ describe GitlabPostReceive do
before do
GitlabConfig.any_instance.stub(repos_path: repository_path)
+ Kernel.stub(system: true)
+ GitlabNet.any_instance.stub(broadcast_message: { "message" => "test " * 10 + "message " * 10 })
end
describe :initialize do
it { gitlab_post_receive.repo_path.should == repo_path }
it { gitlab_post_receive.changes.should == 'wow' }
+ it { gitlab_post_receive.exec }
end
end
diff --git a/spec/vcr_cassettes/broadcast_message-none.yml b/spec/vcr_cassettes/broadcast_message-none.yml
new file mode 100644
index 0000000..f94adc4
--- /dev/null
+++ b/spec/vcr_cassettes/broadcast_message-none.yml
@@ -0,0 +1,38 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: https://dev.gitlab.org/api/v3/internal/broadcast_message
+ body:
+ encoding: US-ASCII
+ string: secret_token=a123
+ headers:
+ Accept-Encoding:
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
+ Accept:
+ - "*/*"
+ User-Agent:
+ - Ruby
+ response:
+ status:
+ code: 404
+ message: Not Found
+ headers:
+ Server:
+ - nginx/1.1.19
+ Date:
+ - Sat, 07 Feb 2015 16:45:35 GMT
+ Content-Type:
+ - application/json
+ Content-Length:
+ - '27'
+ Connection:
+ - keep-alive
+ Status:
+ - 200 OK
+ body:
+ encoding: UTF-8
+ string: '{"message":"404 Not Found"}'
+ http_version:
+ recorded_at: Sat, 07 Feb 2015 16:45:35 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/broadcast_message-ok.yml b/spec/vcr_cassettes/broadcast_message-ok.yml
new file mode 100644
index 0000000..470d988
--- /dev/null
+++ b/spec/vcr_cassettes/broadcast_message-ok.yml
@@ -0,0 +1,38 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: https://dev.gitlab.org/api/v3/internal/broadcast_message
+ body:
+ encoding: US-ASCII
+ string: secret_token=a123
+ headers:
+ Accept-Encoding:
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
+ Accept:
+ - "*/*"
+ User-Agent:
+ - Ruby
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Server:
+ - nginx/1.1.19
+ Date:
+ - Sat, 07 Feb 2015 16:44:35 GMT
+ Content-Type:
+ - application/json
+ Content-Length:
+ - '118'
+ Connection:
+ - keep-alive
+ Status:
+ - 200 OK
+ body:
+ encoding: UTF-8
+ string: '{"message":"Message","starts_at":"2015-02-07T15:35:00.000Z","ends_at":"2015-02-07T16:35:00.000Z","color":"","font":""}'
+ http_version:
+ recorded_at: Sat, 07 Feb 2015 16:44:35 GMT
+recorded_with: VCR 2.4.0