diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-08-17 17:05:00 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-08-18 16:30:25 +0200 |
commit | 938f3b2a0b4bdf2047caf8735312c80e2291b274 (patch) | |
tree | 583dcadb643a9e9a0dd4864f7779166d9af9ccc2 /spec/helpers | |
parent | ac73de508e21af95b473bfafc2ca2543b234430d (diff) | |
download | gitlab-ce-938f3b2a0b4bdf2047caf8735312c80e2291b274.tar.gz |
edit_blob_link can receive the blob to avoid access to the repository20454-edit-button-mr
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/blob_helper_spec.rb | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index 94972eed945..a43a7238c70 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -69,18 +69,40 @@ describe BlobHelper do end describe "#edit_blob_link" do - let(:project) { create(:project) } + let(:namespace) { create(:namespace, name: 'gitlab' )} + let(:project) { create(:project, namespace: namespace) } before do allow(self).to receive(:current_user).and_return(double) + allow(self).to receive(:can_collaborate_with_project?).and_return(true) end it 'verifies blob is text' do - expect(self).not_to receive(:blob_text_viewable?) + expect(helper).not_to receive(:blob_text_viewable?) button = edit_blob_link(project, 'refs/heads/master', 'README.md') expect(button).to start_with('<button') end + + it 'uses the passed blob instead retrieve from repository' do + blob = project.repository.blob_at('refs/heads/master', 'README.md') + + expect(project.repository).not_to receive(:blob_at) + + edit_blob_link(project, 'refs/heads/master', 'README.md', blob: blob) + end + + it 'returns a link with the proper route' do + link = edit_blob_link(project, 'master', 'README.md') + + expect(Capybara.string(link).find_link('Edit')[:href]).to eq('/gitlab/gitlabhq/edit/master/README.md') + end + + it 'returns a link with the passed link_opts on the expected route' do + link = edit_blob_link(project, 'master', 'README.md', link_opts: { mr_id: 10 }) + + expect(Capybara.string(link).find_link('Edit')[:href]).to eq('/gitlab/gitlabhq/edit/master/README.md?mr_id=10') + end end end |