Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-17 12:41:53 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-17 12:41:53 +0300
commit4a0fa27017e3bdf33a61d198f692419359cd6c05 (patch)
tree6c610193350fe34de75c12d9896bd079425c199a /spec/models
parentbbe0e58aebbb804cb884662be9e7f0f40db9eacd (diff)
parent9f7c7c857b97c8124ed9af36218c3cad2c6a7fc3 (diff)
Merge branch 'master' into remove-satellites
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/project_services/flowdock_service_spec.rb12
-rw-r--r--spec/models/project_services/hipchat_service_spec.rb8
-rw-r--r--spec/models/repository_spec.rb20
-rw-r--r--spec/models/service_spec.rb10
4 files changed, 46 insertions, 4 deletions
diff --git a/spec/models/project_services/flowdock_service_spec.rb b/spec/models/project_services/flowdock_service_spec.rb
index 7e5b15cb09e..16296607a94 100644
--- a/spec/models/project_services/flowdock_service_spec.rb
+++ b/spec/models/project_services/flowdock_service_spec.rb
@@ -39,15 +39,19 @@ describe FlowdockService do
token: 'verySecret'
)
@sample_data = Gitlab::PushDataBuilder.build_sample(project, user)
- @api_url = 'https://api.flowdock.com/v1/git/verySecret'
+ @api_url = 'https://api.flowdock.com/v1/messages'
WebMock.stub_request(:post, @api_url)
end
it "should call FlowDock API" do
@flowdock_service.execute(@sample_data)
- expect(WebMock).to have_requested(:post, @api_url).with(
- body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/
- ).once
+ @sample_data[:commits].each do |commit|
+ # One request to Flowdock per new commit
+ next if commit[:id] == @sample_data[:before]
+ expect(WebMock).to have_requested(:post, @api_url).with(
+ body: /#{commit[:id]}.*#{project.path}/
+ ).once
+ end
end
end
end
diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb
index 4707673269a..65d16beef91 100644
--- a/spec/models/project_services/hipchat_service_spec.rb
+++ b/spec/models/project_services/hipchat_service_spec.rb
@@ -47,6 +47,14 @@ describe HipchatService do
WebMock.stub_request(:post, api_url)
end
+ it 'should test and return errors' do
+ allow(hipchat).to receive(:execute).and_raise(StandardError, 'no such room')
+ result = hipchat.test(push_sample_data)
+
+ expect(result[:success]).to be_falsey
+ expect(result[:result].to_s).to eq('no such room')
+ end
+
it 'should use v1 if version is provided' do
allow(hipchat).to receive(:api_version).and_return('v1')
expect(HipChat::Client).to receive(:new).
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index d96244f23e0..05e51532eb8 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -34,6 +34,14 @@ describe Repository do
end
end
+ describe :merged_to_root_ref? do
+ context 'merged branch' do
+ subject { repository.merged_to_root_ref?('improve/awesome') }
+
+ it { is_expected.to be_truthy }
+ end
+ end
+
describe :can_be_merged? do
context 'mergeable branches' do
subject { repository.can_be_merged?('0b4bc9a49b562e85de7cc9e834518ea6828729b9', 'master') }
@@ -46,6 +54,18 @@ describe Repository do
it { is_expected.to be_falsey }
end
+
+ context 'non merged branch' do
+ subject { repository.merged_to_root_ref?('fix') }
+
+ it { is_expected.to be_falsey }
+ end
+
+ context 'non existent branch' do
+ subject { repository.merged_to_root_ref?('non_existent_branch') }
+
+ it { is_expected.to be_nil }
+ end
end
describe "search_files" do
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index ca11758ee06..a213ffe6c4b 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -46,6 +46,16 @@ describe Service do
describe :can_test do
it { expect(@testable).to eq(true) }
end
+
+ describe :test do
+ let(:data) { 'test' }
+
+ it 'test runs execute' do
+ expect(@service).to receive(:execute).with(data)
+
+ @service.test(data)
+ end
+ end
end
describe "With commits" do