diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-04-13 19:50:40 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-04-27 20:23:26 +0300 |
commit | 7cc4546bc97316e40da367c3894b5e4cf7a155ea (patch) | |
tree | 93ac3c2db5697256611dfa1b12fcafe038b32acd /spec/features/projects/blobs/blob_show_spec.rb | |
parent | 796acbe1e05f934c02bc0ca9fca1747aab49267c (diff) |
Add specs
Diffstat (limited to 'spec/features/projects/blobs/blob_show_spec.rb')
-rw-r--r-- | spec/features/projects/blobs/blob_show_spec.rb | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/spec/features/projects/blobs/blob_show_spec.rb b/spec/features/projects/blobs/blob_show_spec.rb index 7cfa5b9716f..9fbb17b3707 100644 --- a/spec/features/projects/blobs/blob_show_spec.rb +++ b/spec/features/projects/blobs/blob_show_spec.rb @@ -4,19 +4,48 @@ feature 'File blob', feature: true do include TreeHelper let(:project) { create(:project, :public, :test_repo) } - let(:merge_request) { create(:merge_request, source_project: project, source_branch: 'feature', target_branch: 'master') } - let(:branch) { 'master' } - let(:file_path) { project.repository.ls_files(project.repository.root_ref)[1] } - - context 'anonymous' do - context 'from blob file path' do - before do - visit namespace_project_blob_path(project.namespace, project, tree_join(branch, file_path)) - end - - it 'updates content' do - expect(page).to have_link 'Edit' - end + + def visit_blob(path, fragment = nil) + visit namespace_project_blob_path(project.namespace, project, tree_join('master', path), anchor: fragment) + end + + context 'text files' do + it 'shows rendered output for SVG' do + visit_blob('files/images/wm.svg') + + expect(page).to have_selector('.blob-viewer[data-type="rich"]') + end + + it 'switches to code view' do + visit_blob('files/images/wm.svg') + + first('.js-blob-viewer-switcher').click + + expect(page).to have_selector('.blob-viewer[data-type="rich"]', visible: false) + expect(page).to have_selector('.blob-viewer[data-type="simple"]') + end + + it 'opens raw mode when linking to a line in SVG file' do + visit_blob('files/images/wm.svg', 'L1') + + expect(page).to have_selector('#LC1.hll') + expect(page).to have_selector('.blob-viewer[data-type="simple"]') + end + + it 'opens raw mode when linking to a line in MD file' do + visit_blob('README.md', 'L1') + + expect(page).to have_selector('#LC1.hll') + expect(page).to have_selector('.blob-viewer[data-type="simple"]') + end + end + + context 'binary files' do + it 'does not show view toggle buttons in toolbar' do + visit_blob('Gemfile.zip') + + expect(first('.file-actions .btn-group')).to have_selector('.btn', count: 1) + expect(first('.file-actions .btn-group .btn')[:title]).to eq('Download blob') end end end |