Skip to content

Commit

Permalink
Adds blank reporting page
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-bernhardt committed Oct 1, 2021
1 parent fff0764 commit ac0de4d
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/controllers/report_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ class ReportController < ApplicationController

include ThesisHelper

def files
term = params[:graduation] ? params[:graduation].to_s : 'all'
report = Report.new
theses = Thesis.all
@terms = report.extract_terms theses
subset = filter_theses_by_term theses
end

def index
report = Report.new
@terms = Thesis.pluck(:grad_date).uniq.sort
Expand Down
1 change: 1 addition & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def processor

can :manage, :submitter

can :files, Report
can :index, Report
can :term, Report

Expand Down
14 changes: 14 additions & 0 deletions app/views/report/files.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%= content_for(:title, "Thesis Reporting | MIT Libraries") %>

<div class="layout-3q1q layout-band">
<div class="col3q">
<h3 class="title title-page">Files without purpose</h3>

<%= render 'shared/defined_terms_filter' %>

</div>

<aside class="content-sup col1q-r">
<%= render 'shared/report_submenu' %>
</aside>
</div>
3 changes: 3 additions & 0 deletions app/views/shared/_report_submenu.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<% if can?(:select, Thesis) %>
<li><%= link_to("Theses with co-authors", thesis_deduplicate_path) %></li>
<% end %>
<% if can?(:files, Report) %>
<li><%= link_to("Files without purpose", report_files_path) %></li>
<% end %>
</ul>
</nav>
</div>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
end

get 'report', to: 'report#index', as: 'report_index'
get 'report/files', to: 'report#files', as: 'report_files'
get 'report/term', to: 'report#term', as: 'report_term'
get 'thesis/confirm', to: 'thesis#confirm', as: 'thesis_confirm'
get 'thesis/deduplicate', to: 'thesis#deduplicate', as: 'thesis_deduplicate'
Expand Down
48 changes: 48 additions & 0 deletions test/controllers/report_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,52 @@ class ReportControllerTest < ActionDispatch::IntegrationTest
assert_select '.card-overall .message', text: '2 thesis records', count: 1
assert_response :success
end

# ~~~~~~~~~~~~~~~~~~~~ Files without purpose report ~~~~~~~~~~~~~~~~~~~~~~~~
test 'files report exists' do
sign_in users(:admin)
get report_files_path
assert_response :success
end

test 'anonymous users are prompted to log in by files report' do
# Note that nobody is signed in.
get report_files_path
assert_response :redirect
end

test 'basic users cannot see files report' do
sign_in users(:basic)
get report_files_path
assert_redirected_to '/'
follow_redirect!
assert_select 'div.alert', text: 'Not authorized.', count: 1
end

test 'submitters cannot see files report' do
sign_in users(:transfer_submitter)
get report_files_path
assert_redirected_to '/'
follow_redirect!
assert_select 'div.alert', text: 'Not authorized.', count: 1
end

test 'processors can see files report' do
sign_in users(:processor)
get report_files_path
assert_response :success
end

test 'thesis_admins can see files report' do
sign_in users(:thesis_admin)
get report_files_path
assert_response :success
end

test 'admins can see files report' do
sign_in users(:admin)
get report_files_path
assert_response :success
end

end

0 comments on commit ac0de4d

Please sign in to comment.