diff options
author | Robert Speicher <robert@gitlab.com> | 2017-02-07 19:14:19 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-02-07 19:14:19 +0000 |
commit | 58eae0961ea6e2147a288cda8a56a51303bbf13b (patch) | |
tree | 0bbd873650dfc889af8df7e197397959d774d411 /spec | |
parent | d3aaa1a2a0313b7132479d4211e406fde5bc9324 (diff) | |
parent | 0fdf54ddf5894ec1057b7351140fdce4f0df0ed1 (diff) | |
download | gitlab-ce-58eae0961ea6e2147a288cda8a56a51303bbf13b.tar.gz |
Merge branch 'route-map' into 'master'
Add 'View on [env]' link to blobs and individual files in diffs
See merge request !8867
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/projects/commit/cherry_pick_spec.rb (renamed from spec/features/projects/commits/cherry_pick_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/projects/compare_spec.rb (renamed from spec/features/compare_spec.rb) | 0 | ||||
-rw-r--r-- | spec/features/projects/view_on_env_spec.rb | 140 | ||||
-rw-r--r-- | spec/finders/environments_finder_spec.rb | 110 | ||||
-rw-r--r-- | spec/helpers/commits_helper_spec.rb | 19 | ||||
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 16 | ||||
-rw-r--r-- | spec/lib/gitlab/route_map_spec.rb | 90 | ||||
-rw-r--r-- | spec/models/environment_spec.rb | 45 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 16 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 170 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 36 |
11 files changed, 541 insertions, 101 deletions
diff --git a/spec/features/projects/commits/cherry_pick_spec.rb b/spec/features/projects/commit/cherry_pick_spec.rb index 7baf7913424..7baf7913424 100644 --- a/spec/features/projects/commits/cherry_pick_spec.rb +++ b/spec/features/projects/commit/cherry_pick_spec.rb diff --git a/spec/features/compare_spec.rb b/spec/features/projects/compare_spec.rb index 43eb4000e58..43eb4000e58 100644 --- a/spec/features/compare_spec.rb +++ b/spec/features/projects/compare_spec.rb diff --git a/spec/features/projects/view_on_env_spec.rb b/spec/features/projects/view_on_env_spec.rb new file mode 100644 index 00000000000..ce5c5f21167 --- /dev/null +++ b/spec/features/projects/view_on_env_spec.rb @@ -0,0 +1,140 @@ +require 'spec_helper' + +describe 'View on environment', js: true do + include WaitForAjax + + let(:branch_name) { 'feature' } + let(:file_path) { 'files/ruby/feature.rb' } + let(:project) { create(:project, :repository) } + let(:user) { project.creator } + + before do + project.add_master(user) + end + + context 'when the branch has a route map' do + let(:route_map) do + <<-MAP.strip_heredoc + - source: /files/(.*)\\..*/ + public: '\\1' + MAP + end + + before do + Files::CreateService.new( + project, + user, + start_branch: branch_name, + target_branch: branch_name, + commit_message: "Add .gitlab/route-map.yml", + file_path: '.gitlab/route-map.yml', + file_content: route_map + ).execute + + # Update the file so that we still have a commit that will have a file on the environment + Files::UpdateService.new( + project, + user, + start_branch: branch_name, + target_branch: branch_name, + commit_message: "Update feature", + file_path: file_path, + file_content: "# Noop" + ).execute + end + + context 'and an active deployment' do + let(:sha) { project.commit(branch_name).sha } + let(:environment) { create(:environment, project: project, name: 'review/feature', external_url: 'http://feature.review.example.com') } + let!(:deployment) { create(:deployment, environment: environment, ref: branch_name, sha: sha) } + + context 'when visiting the diff of a merge request for the branch' do + let(:merge_request) { create(:merge_request, :simple, source_project: project, source_branch: branch_name) } + + before do + login_as(user) + + visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request) + + wait_for_ajax + end + + it 'has a "View on env" button' do + within '.diffs' do + expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature') + end + end + end + + context 'when visiting a comparison for the branch' do + before do + login_as(user) + + visit namespace_project_compare_path(project.namespace, project, from: 'master', to: branch_name) + + wait_for_ajax + end + + it 'has a "View on env" button' do + expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature') + end + end + + context 'when visiting a comparison for the commit' do + before do + login_as(user) + + visit namespace_project_compare_path(project.namespace, project, from: 'master', to: sha) + + wait_for_ajax + end + + it 'has a "View on env" button' do + expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature') + end + end + + context 'when visiting a blob on the branch' do + before do + login_as(user) + + visit namespace_project_blob_path(project.namespace, project, File.join(branch_name, file_path)) + + wait_for_ajax + end + + it 'has a "View on env" button' do + expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature') + end + end + + context 'when visiting a blob on the commit' do + before do + login_as(user) + + visit namespace_project_blob_path(project.namespace, project, File.join(sha, file_path)) + + wait_for_ajax + end + + it 'has a "View on env" button' do + expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature') + end + end + + context 'when visiting the commit' do + before do + login_as(user) + + visit namespace_project_commit_path(project.namespace, project, sha) + + wait_for_ajax + end + + it 'has a "View on env" button' do + expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature') + end + end + end + end +end diff --git a/spec/finders/environments_finder_spec.rb b/spec/finders/environments_finder_spec.rb new file mode 100644 index 00000000000..0c063f6d5ee --- /dev/null +++ b/spec/finders/environments_finder_spec.rb @@ -0,0 +1,110 @@ +require 'spec_helper' + +describe EnvironmentsFinder do + describe '#execute' do + let(:project) { create(:project, :repository) } + let(:user) { project.creator } + let(:environment) { create(:environment, project: project) } + + before do + project.add_master(user) + end + + context 'tagged deployment' do + before do + create(:deployment, environment: environment, ref: '1.0', tag: true, sha: project.commit.id) + end + + it 'returns environment when with_tags is set' do + expect(described_class.new(project, user, ref: 'master', commit: project.commit, with_tags: true).execute) + .to contain_exactly(environment) + end + + it 'does not return environment when no with_tags is set' do + expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute) + .to be_empty + end + + it 'does not return environment when commit is not part of deployment' do + expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute) + .to be_empty + end + end + + context 'branch deployment' do + before do + create(:deployment, environment: environment, ref: 'master', sha: project.commit.id) + end + + it 'returns environment when ref is set' do + expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute) + .to contain_exactly(environment) + end + + it 'does not environment when ref is different' do + expect(described_class.new(project, user, ref: 'feature', commit: project.commit).execute) + .to be_empty + end + + it 'does not return environment when commit is not part of deployment' do + expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute) + .to be_empty + end + + it 'returns environment when commit constraint is not set' do + expect(described_class.new(project, user, ref: 'master').execute) + .to contain_exactly(environment) + end + end + + context 'commit deployment' do + before do + create(:deployment, environment: environment, ref: 'master', sha: project.commit.id) + end + + it 'returns environment' do + expect(described_class.new(project, user, commit: project.commit).execute) + .to contain_exactly(environment) + end + end + + context 'recently updated' do + context 'when last deployment to environment is the most recent one' do + before do + create(:deployment, environment: environment, ref: 'feature') + end + + it 'finds recently updated environment' do + expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute) + .to contain_exactly(environment) + end + end + + context 'when last deployment to environment is not the most recent' do + before do + create(:deployment, environment: environment, ref: 'feature') + create(:deployment, environment: environment, ref: 'master') + end + + it 'does not find environment' do + expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute) + .to be_empty + end + end + + context 'when there are two environments that deploy to the same branch' do + let(:second_environment) { create(:environment, project: project) } + + before do + create(:deployment, environment: environment, ref: 'feature') + create(:deployment, environment: second_environment, ref: 'feature') + end + + it 'finds both environments' do + expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute) + .to contain_exactly(environment, second_environment) + end + end + end + end +end diff --git a/spec/helpers/commits_helper_spec.rb b/spec/helpers/commits_helper_spec.rb index 727c25ff529..a2c008790f9 100644 --- a/spec/helpers/commits_helper_spec.rb +++ b/spec/helpers/commits_helper_spec.rb @@ -26,4 +26,23 @@ describe CommitsHelper do not_to include('onmouseover="alert(1)"') end end + + describe '#view_on_environment_button' do + let(:project) { create(:empty_project) } + let(:environment) { create(:environment, external_url: 'http://example.com') } + let(:path) { 'source/file.html' } + let(:sha) { RepoHelpers.sample_commit.id } + + before do + allow(environment).to receive(:external_url_for).with(path, sha).and_return('http://example.com/file.html') + end + + it 'returns a link tag linking to the file in the environment' do + html = helper.view_on_environment_button(sha, path, environment) + node = Nokogiri::HTML.parse(html).at_css('a') + + expect(node[:title]).to eq('View on example.com') + expect(node[:href]).to eq('http://example.com/file.html') + end + end end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 3031559c613..b142b3a2781 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -55,6 +55,22 @@ describe Gitlab::Database, lib: true do end end + describe '.nulls_first_order' do + context 'when using PostgreSQL' do + before { expect(described_class).to receive(:postgresql?).and_return(true) } + + it { expect(described_class.nulls_first_order('column', 'ASC')).to eq 'column ASC NULLS FIRST'} + it { expect(described_class.nulls_first_order('column', 'DESC')).to eq 'column DESC NULLS FIRST'} + end + + context 'when using MySQL' do + before { expect(described_class).to receive(:postgresql?).and_return(false) } + + it { expect(described_class.nulls_first_order('column', 'ASC')).to eq 'column ASC'} + it { expect(described_class.nulls_first_order('column', 'DESC')).to eq 'column IS NULL, column DESC'} + end + end + describe '#true_value' do it 'returns correct value for PostgreSQL' do expect(described_class).to receive(:postgresql?).and_return(true) diff --git a/spec/lib/gitlab/route_map_spec.rb b/spec/lib/gitlab/route_map_spec.rb new file mode 100644 index 00000000000..459fa8a63a9 --- /dev/null +++ b/spec/lib/gitlab/route_map_spec.rb @@ -0,0 +1,90 @@ +require 'spec_helper' + +describe Gitlab::RouteMap, lib: true do + describe '#initialize' do + context 'when the data is not YAML' do + it 'raises an error' do + expect { described_class.new('"') }. + to raise_error(Gitlab::RouteMap::FormatError, /valid YAML/) + end + end + + context 'when the data is not a YAML array' do + it 'raises an error' do + expect { described_class.new(YAML.dump('foo')) }. + to raise_error(Gitlab::RouteMap::FormatError, /an array/) + end + end + + context 'when an entry is not a hash' do + it 'raises an error' do + expect { described_class.new(YAML.dump(['foo'])) }. + to raise_error(Gitlab::RouteMap::FormatError, /a hash/) + end + end + + context 'when an entry does not have a source key' do + it 'raises an error' do + expect { described_class.new(YAML.dump([{ 'public' => 'index.html' }])) }. + to raise_error(Gitlab::RouteMap::FormatError, /source key/) + end + end + + context 'when an entry does not have a public key' do + it 'raises an error' do + expect { described_class.new(YAML.dump([{ 'source' => '/index\.html/' }])) }. + to raise_error(Gitlab::RouteMap::FormatError, /public key/) + end + end + + context 'when an entry source does not start and end with a slash' do + it 'raises an error' do + expect { described_class.new(YAML.dump([{ 'source' => 'index.html', 'public' => 'index.html' }])) }. + to raise_error(Gitlab::RouteMap::FormatError, /a slash/) + end + end + + context 'when an entry source is not a valid regex' do + it 'raises an error' do + expect { described_class.new(YAML.dump([{ 'source' => '/[/', 'public' => 'index.html' }])) }. + to raise_error(Gitlab::RouteMap::FormatError, /regular expression/) + end + end + + context 'when all is good' do + it 'returns a route map' do + route_map = described_class.new(YAML.dump([{ 'source' => '/index\.html/', 'public' => 'index.html' }])) + + expect(route_map.public_path_for_source_path('index.html')).to eq('index.html') + end + end + end + + describe '#public_path_for_source_path' do + subject do + described_class.new(<<-'MAP'.strip_heredoc) + # Blogposts + - source: /source/posts/([0-9]{4})-([0-9]{2})-([0-9]{2})-(.+?)\..*/ # source/posts/2017-01-30-around-the-world-in-6-releases.html.md.erb + public: '\1/\2/\3/\4/' # 2017/01/30/around-the-world-in-6-releases/ + + # HTML files + - source: /source/(.+?\.html).*/ # source/index.html.haml + public: '\1' # index.html + + # Other files + - source: /source/(.*)/ # source/images/blogimages/around-the-world-in-6-releases-cover.png + public: '\1' # images/blogimages/around-the-world-in-6-releases-cover.png + MAP + end + + it 'returns the public path for a provided source path' do + expect(subject.public_path_for_source_path('source/posts/2017-01-30-around-the-world-in-6-releases.html.md.erb')).to eq('2017/01/30/around-the-world-in-6-releases/') + + expect(subject.public_path_for_source_path('source/index.html.haml')).to eq('index.html') + + expect(subject.public_path_for_source_path('source/images/blogimages/around-the-world-in-6-releases-cover.png')).to eq('images/blogimages/around-the-world-in-6-releases-cover.png') + + expect(subject.public_path_for_source_path('.gitlab/route-map.yml')).to be_nil + end + end +end diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 8b57d8600fe..960f29f3805 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -7,8 +7,6 @@ describe Environment, models: true do it { is_expected.to belong_to(:project) } it { is_expected.to have_many(:deployments) } - it { is_expected.to delegate_method(:last_deployment).to(:deployments).as(:last) } - it { is_expected.to delegate_method(:stop_action).to(:last_deployment) } it { is_expected.to delegate_method(:manual_actions).to(:last_deployment) } @@ -22,6 +20,20 @@ describe Environment, models: true do it { is_expected.to validate_length_of(:external_url).is_at_most(255) } it { is_expected.to validate_uniqueness_of(:external_url).scoped_to(:project_id) } + describe '.order_by_last_deployed_at' do + let(:project) { create(:project) } + let!(:environment1) { create(:environment, project: project) } + let!(:environment2) { create(:environment, project: project) } + let!(:environment3) { create(:environment, project: project) } + let!(:deployment1) { create(:deployment, environment: environment1) } + let!(:deployment2) { create(:deployment, environment: environment2) } + let!(:deployment3) { create(:deployment, environment: environment1) } + + it 'returns the environments in order of having been last deployed' do + expect(project.environments.order_by_last_deployed_at.to_a).to eq([environment3, environment2, environment1]) + end + end + describe '#nullify_external_url' do it 'replaces a blank url with nil' do env = build(:environment, external_url: "") @@ -323,4 +335,33 @@ describe Environment, models: true do end end end + + describe '#external_url_for' do + let(:source_path) { 'source/file.html' } + let(:sha) { RepoHelpers.sample_commit.id } + + before do + environment.external_url = 'http://example.com' + end + + context 'when the public path is not known' do + before do + allow(project).to receive(:public_path_for_source_path).with(source_path, sha).and_return(nil) + end + + it 'returns nil' do + expect(environment.external_url_for(source_path, sha)).to be_nil + end + end + + context 'when the public path is known' do + before do + allow(project).to receive(:public_path_for_source_path).with(source_path, sha).and_return('file.html') + end + + it 'returns the full external URL' do + expect(environment.external_url_for(source_path, sha)).to eq('http://example.com/file.html') + end + end + end end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 32ed1e96749..e1e99300489 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1005,10 +1005,16 @@ describe MergeRequest, models: true do end end - describe "#environments" do + describe "#environments_for" do let(:project) { create(:project, :repository) } + let(:user) { project.creator } let(:merge_request) { create(:merge_request, source_project: project) } + before do + merge_request.source_project.add_master(user) + merge_request.target_project.add_master(user) + end + context 'with multiple environments' do let(:environments) { create_list(:environment, 3, project: project) } @@ -1018,7 +1024,7 @@ describe MergeRequest, models: true do end it 'selects deployed environments' do - expect(merge_request.environments).to contain_exactly(environments.first) + expect(merge_request.environments_for(user)).to contain_exactly(environments.first) end end @@ -1042,7 +1048,7 @@ describe MergeRequest, models: true do end it 'selects deployed environments' do - expect(merge_request.environments).to contain_exactly(source_environment) + expect(merge_request.environments_for(user)).to contain_exactly(source_environment) end context 'with environments on target project' do @@ -1053,7 +1059,7 @@ describe MergeRequest, models: true do end it 'selects deployed environments' do - expect(merge_request.environments).to contain_exactly(source_environment, target_environment) + expect(merge_request.environments_for(user)).to contain_exactly(source_environment, target_environment) end end end @@ -1064,7 +1070,7 @@ describe MergeRequest, models: true do end it 'returns an empty array' do - expect(merge_request.environments).to be_empty + expect(merge_request.environments_for(user)).to be_empty end end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index d7e6da02261..2129bcbd74d 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1716,100 +1716,6 @@ describe Project, models: true do end end - describe '#environments_for' do - let(:project) { create(:project, :repository) } - let(:environment) { create(:environment, project: project) } - - context 'tagged deployment' do - before do - create(:deployment, environment: environment, ref: '1.0', tag: true, sha: project.commit.id) - end - - it 'returns environment when with_tags is set' do - expect(project.environments_for('master', commit: project.commit, with_tags: true)) - .to contain_exactly(environment) - end - - it 'does not return environment when no with_tags is set' do - expect(project.environments_for('master', commit: project.commit)) - .to be_empty - end - - it 'does not return environment when commit is not part of deployment' do - expect(project.environments_for('master', commit: project.commit('feature'))) - .to be_empty - end - end - - context 'branch deployment' do - before do - create(:deployment, environment: environment, ref: 'master', sha: project.commit.id) - end - - it 'returns environment when ref is set' do - expect(project.environments_for('master', commit: project.commit)) - .to contain_exactly(environment) - end - - it 'does not environment when ref is different' do - expect(project.environments_for('feature', commit: project.commit)) - .to be_empty - end - - it 'does not return environment when commit is not part of deployment' do - expect(project.environments_for('master', commit: project.commit('feature'))) - .to be_empty - end - - it 'returns environment when commit constraint is not set' do - expect(project.environments_for('master')) - .to contain_exactly(environment) - end - end - end - - describe '#environments_recently_updated_on_branch' do - let(:project) { create(:project, :repository) } - let(:environment) { create(:environment, project: project) } - - context 'when last deployment to environment is the most recent one' do - before do - create(:deployment, environment: environment, ref: 'feature') - end - - it 'finds recently updated environment' do - expect(project.environments_recently_updated_on_branch('feature')) - .to contain_exactly(environment) - end - end - - context 'when last deployment to environment is not the most recent' do - before do - create(:deployment, environment: environment, ref: 'feature') - create(:deployment, environment: environment, ref: 'master') - end - - it 'does not find environment' do - expect(project.environments_recently_updated_on_branch('feature')) - .to be_empty - end - end - - context 'when there are two environments that deploy to the same branch' do - let(:second_environment) { create(:environment, project: project) } - - before do - create(:deployment, environment: environment, ref: 'feature') - create(:deployment, environment: second_environment, ref: 'feature') - end - - it 'finds both environments' do - expect(project.environments_recently_updated_on_branch('feature')) - .to contain_exactly(environment, second_environment) - end - end - end - describe '#deployment_variables' do context 'when project has no deployment service' do let(:project) { create(:empty_project) } @@ -1858,6 +1764,82 @@ describe Project, models: true do it { expect(Project.inside_path(path)).to eq([project1]) } end + describe '#route_map_for' do + let(:project) { create(:project) } + let(:route_map) do + <<-MAP.strip_heredoc + - source: /source/(.*)/ + public: '\\1' + MAP + end + + before do + project.repository.commit_file(User.last, '.gitlab/route-map.yml', route_map, message: 'Add .gitlab/route-map.yml', branch_name: 'master', update: false) + end + + context 'when there is a .gitlab/route-map.yml at the commit' do + context 'when the route map is valid' do + it 'returns a route map' do + map = project.route_map_for(project.commit.sha) + expect(map).to be_a_kind_of(Gitlab::RouteMap) + end + end + + context 'when the route map is invalid' do + let(:route_map) { 'INVALID' } + + it 'returns nil' do + expect(project.route_map_for(project.commit.sha)).to be_nil + end + end + end + + context 'when there is no .gitlab/route-map.yml at the commit' do + it 'returns nil' do + expect(project.route_map_for(project.commit.parent.sha)).to be_nil + end + end + end + + describe '#public_path_for_source_path' do + let(:project) { create(:project) } + let(:route_map) do + Gitlab::RouteMap.new(<<-MAP.strip_heredoc) + - source: /source/(.*)/ + public: '\\1' + MAP + end + let(:sha) { project.commit.id } + + context 'when there is a route map' do + before do + allow(project).to receive(:route_map_for).with(sha).and_return(route_map) + end + + context 'when the source path is mapped' do + it 'returns the public path' do + expect(project.public_path_for_source_path('source/file.html', sha)).to eq('file.html') + end + end + + context 'when the source path is not mapped' do + it 'returns nil' do + expect(project.public_path_for_source_path('file.html', sha)).to be_nil + end + end + end + + context 'when there is no route map' do + before do + allow(project).to receive(:route_map_for).with(sha).and_return(nil) + end + + it 'returns nil' do + expect(project.public_path_for_source_path('source/file.html', sha)).to be_nil + end + end + end + def enable_lfs allow(Gitlab.config.lfs).to receive(:enabled).and_return(true) end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 53b98ba05f8..9bfa6409607 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1782,4 +1782,40 @@ describe Repository, models: true do repository.refresh_method_caches(%i(readme license)) end end + + describe '#gitlab_ci_yml_for' do + before do + repository.commit_file(User.last, '.gitlab-ci.yml', 'CONTENT', message: 'Add .gitlab-ci.yml', branch_name: 'master', update: false) + end + + context 'when there is a .gitlab-ci.yml at the commit' do + it 'returns the content' do + expect(repository.gitlab_ci_yml_for(repository.commit.sha)).to eq('CONTENT') + end + end + + context 'when there is no .gitlab-ci.yml at the commit' do + it 'returns nil' do + expect(repository.gitlab_ci_yml_for(repository.commit.parent.sha)).to be_nil + end + end + end + + describe '#route_map_for' do + before do + repository.commit_file(User.last, '.gitlab/route-map.yml', 'CONTENT', message: 'Add .gitlab/route-map.yml', branch_name: 'master', update: false) + end + + context 'when there is a .gitlab/route-map.yml at the commit' do + it 'returns the content' do + expect(repository.route_map_for(repository.commit.sha)).to eq('CONTENT') + end + end + + context 'when there is no .gitlab/route-map.yml at the commit' do + it 'returns nil' do + expect(repository.route_map_for(repository.commit.parent.sha)).to be_nil + end + end + end end |