Skip to content

Commit

Permalink
Merge pull request #7931 from saraycp/apidocs_to_bootstrap
Browse files Browse the repository at this point in the history
Migrate apidocs to Bootstrap
  • Loading branch information
hennevogel committed Jul 19, 2019
2 parents 9aad3e7 + 19b73f0 commit 60cdd82
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/api/app/controllers/webui/apidocs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class Webui::ApidocsController < Webui::WebuiController
def index
filename = File.expand_path(CONFIG['apidocs_location']) + '/index.html'
if File.exist?(filename)
render file: filename, formats: [:html]
@filename = File.expand_path(CONFIG['apidocs_location']) + '/index.html'
if File.exist?(@filename)
return if switch_to_webui2
render file: @filename, formats: [:html]
else
logger.error "Unable to load apidocs index file from #{CONFIG['apidocs_location']}. Did you create the apidocs?"
flash[:error] = 'Unable to load API documentation.'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
= render partial: 'webui/main/breadcrumb_items'

%li.breadcrumb-item.active{ 'aria-current' => 'page' }
API Documentation

3 changes: 3 additions & 0 deletions src/api/app/views/webui2/webui/apidocs/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.card
.card-body
= render file: @filename, formats: [:html]
29 changes: 29 additions & 0 deletions src/api/spec/bootstrap/features/webui/apidocs_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'browser_helper'

RSpec.feature 'Apidocs', type: :feature, js: true do
let(:user) { create(:confirmed_user) }
let(:tmp_dir) { Dir.mktmpdir }
let(:tmp_file) { "#{tmp_dir}/index.html" }

before do
login user
File.open(tmp_file, 'w') do |f|
f.write('<html><head></head><body><h1>API Documentation</h1></body></html>')
end
CONFIG['apidocs_location'] = tmp_dir
visit apidocs_index_path
end

after do
File.delete(tmp_file)
Dir.rmdir(tmp_dir)
end

scenario 'is wrapped by a Bootstrap class' do
expect(page).to have_css('#content > .card')
end

scenario 'includes the file content' do
expect(page).to have_content('API Documentation')
end
end

0 comments on commit 60cdd82

Please sign in to comment.