diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-04-15 12:45:31 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-04-15 12:45:31 -0400 |
commit | 3052e894207303bf9fed972aa60d3a655a6c58d9 (patch) | |
tree | 382f089e6e5ba89287bcf5aea6e86e853cf2d307 /spec | |
parent | e24cb79f3196052395829b35d51693dc9de5afbe (diff) | |
download | gitlab-ce-3052e894207303bf9fed972aa60d3a655a6c58d9.tar.gz |
Re-fix image rendering for help pages
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/help_controller_spec.rb | 61 | ||||
-rw-r--r-- | spec/features/help_pages_spec.rb | 2 |
2 files changed, 62 insertions, 1 deletions
diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb new file mode 100644 index 00000000000..93535ced7ae --- /dev/null +++ b/spec/controllers/help_controller_spec.rb @@ -0,0 +1,61 @@ +require 'spec_helper' + +describe HelpController do + let(:user) { create(:user) } + + before do + sign_in(user) + end + + describe 'GET #show' do + context 'for Markdown formats' do + context 'when requested file exists' do + before do + get :show, category: 'ssh', file: 'README', format: :md + end + + it 'assigns to @markdown' do + expect(assigns[:markdown]).not_to be_empty + end + + it 'renders HTML' do + expect(response).to render_template('show.html.haml') + expect(response.content_type).to eq 'text/html' + end + end + + context 'when requested file is missing' do + it 'renders not found' do + get :show, category: 'foo', file: 'bar', format: :md + expect(response).to be_not_found + end + end + end + + context 'for image formats' do + context 'when requested file exists' do + it 'renders the raw file' do + get :show, category: 'workflow/protected_branches', + file: 'protected_branches1', format: :png + expect(response).to be_success + expect(response.content_type).to eq 'image/png' + expect(response.headers['Content-Disposition']).to match(/^inline;/) + end + end + + context 'when requested file is missing' do + it 'renders not found' do + get :show, category: 'foo', file: 'bar', format: :png + expect(response).to be_not_found + end + end + end + + context 'for other formats' do + it 'always renders not found' do + get :show, category: 'ssh', file: 'README', format: :foo + expect(response).to be_not_found + end + end + end +end diff --git a/spec/features/help_pages_spec.rb b/spec/features/help_pages_spec.rb index 41088ce8271..8c6b669ce78 100644 --- a/spec/features/help_pages_spec.rb +++ b/spec/features/help_pages_spec.rb @@ -6,7 +6,7 @@ describe 'Help Pages', feature: true do login_as :user end it 'replace the variable $your_email with the email of the user' do - visit help_page_path(category: 'ssh', file: 'README.md') + visit help_page_path('ssh', 'README') expect(page).to have_content("ssh-keygen -t rsa -C \"#{@user.email}\"") end end |