diff options
author | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-03-28 20:14:48 +0300 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-04-06 12:53:34 +0300 |
commit | 0fc361c4dcf9b714fef8dc8a59e6856fd58f2425 (patch) | |
tree | 66d2ca44fde03213d9fb9da93e9e942fa44e4367 /spec/models/environment_spec.rb | |
parent | 49bdd8d63b577f079cdc47f7dd10ba83c677771a (diff) |
Use Gitaly for Environment#first_deployment_for
Diffstat (limited to 'spec/models/environment_spec.rb')
-rw-r--r-- | spec/models/environment_spec.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 9f0e7fbbe26..3ad3a25d873 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -100,12 +100,27 @@ describe Environment, models: true do let(:head_commit) { project.commit } let(:commit) { project.commit.parent } - it 'returns deployment id for the environment' do - expect(environment.first_deployment_for(commit)).to eq deployment1 + context 'Gitaly find_ref_name feature disables' do + it 'returns deployment id for the environment' do + expect(environment.first_deployment_for(commit)).to eq deployment1 + end + + it 'return nil when no deployment is found' do + expect(environment.first_deployment_for(head_commit)).to eq nil + end end - it 'return nil when no deployment is found' do - expect(environment.first_deployment_for(head_commit)).to eq nil + context 'Gitaly find_ref_name feature enabled' do + before do + allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:find_ref_name).and_return(true) + end + + it 'checks that GitalyClient is called' do + expect(Gitlab::GitalyClient::Ref).to receive(:find_ref_name).with(project.repository.raw_repository, commit.id, environment.ref_path) + + environment.first_deployment_for(commit) + end + end end |