Skip to content

Commit

Permalink
create index html and json views for job runs
Browse files Browse the repository at this point in the history
  • Loading branch information
peetucket committed Sep 21, 2018
1 parent 8748081 commit 8e95665
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ gem 'sqlite3'
gem 'turbolinks' # improves speed of following links in web application
gem 'uglifier' # compressor for JavaScript assets
gem "simple_form" # rails form that handles errors internally and easily integrated w/ Bootstrap
gem 'kaminari' # pagination

# Stanford gems
gem 'assembly-image'
Expand Down
13 changes: 13 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,18 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.1.0)
kaminari (1.1.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.1.1)
kaminari-activerecord (= 1.1.1)
kaminari-core (= 1.1.1)
kaminari-actionview (1.1.1)
actionview
kaminari-core (= 1.1.1)
kaminari-activerecord (1.1.1)
activerecord
kaminari-core (= 1.1.1)
kaminari-core (1.1.1)
link_header (0.0.8)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand Down Expand Up @@ -536,6 +548,7 @@ DEPENDENCIES
honeybadger (~> 3.1)
jbuilder
jquery-rails
kaminari
listen
modsulator
nokogiri
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/job_runs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
class JobRunsController < ApplicationController
def index
@job_runs = JobRun.order('created_at desc').page params[:page]
end

def show
@job_run = JobRun.find(params[:id])
end
Expand Down
26 changes: 26 additions & 0 deletions app/views/job_runs/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<h2>Job Run History</h2>

<%= paginate @job_runs %>

<table class="table">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Type</th>
<th scope="col">Creator</th>
<th scope="col">Created At</th>
</tr>
</thead>
<tbody>
<% @job_runs.each do |job_run| %>
<tr>
<td><%=link_to job_run.id,job_run%></td>
<td><%=job_run.job_type%></td>
<td><%=job_run.bundle_context.user.sunet_id%></td>
<td><%=job_run.created_at.to_formatted_s(:long)%></td>
</tr>
</tbody>
<% end %>
</table>

<%= paginate @job_runs %>
4 changes: 4 additions & 0 deletions app/views/job_runs/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
json.array! @job_runs do |job_run|
json.merge! job_run.attributes
json.sunet_id job_run.bundle_context.user.sunet_id
end
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
devise_for :users, skip: :all
root to: "bundle_contexts#index"
resources :bundle_contexts
resources :job_runs, only: [:show]
resources :job_runs, only: [:show, :index]
end
5 changes: 5 additions & 0 deletions spec/views/job_runs/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RSpec.describe 'job_runs/index.html.erb', type: :view do
it 'displays a list of job_runs' do
skip 'gimme factories'
end
end
10 changes: 10 additions & 0 deletions spec/views/job_runs/index.json.jbuilder_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RSpec.describe 'job_runs/index.json.jbuilder' do
it 'renders a list of job_runs' do
render
json = JSON.parse(rendered)
# expect(json).to match a_hash_including(
# 'rows' => Array,
# )
skip 'gimme factories'
end
end

0 comments on commit 8e95665

Please sign in to comment.