Skip to content

Commit

Permalink
algorithm metric controller tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JPrevost committed Sep 23, 2024
1 parent 59f9ac0 commit 6e6c915
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/views/report/algorithm_metrics.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<p><i class="fa fa-exclamation-circle fa-lg"></i> Percentage match is not accurate for Terms that match multiple algorithms. The actual percentage match will be lower than the reported value. At this time, the error is not believed to be significant based on the currently low volume of Terms that match multiple algorithms. This may change as we develop new algorithms to a point where we need to address this discrepancy.</p>
</div>

<% if params[:type] == 'aggregate' %>
<h3>Aggregate Algorithm Metrics</h3>
<% else %>
<h3>Monthly Algorithm Metrics</h3>
<% end %>

<table class="table">
<tr>
<% if params[:type] == 'aggregate' %>
Expand Down
69 changes: 69 additions & 0 deletions test/controllers/report_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
require 'test_helper'

class ReportControllerTest < ActionDispatch::IntegrationTest
test 'report index is not accessible without authentication' do
get '/report'

assert_redirected_to '/'
follow_redirect!

assert_select 'div.alert', text: 'Please sign in to continue', count: 1
end

test 'report index is accessible to admins when authenticated' do
sign_in users(:admin)

get '/report'

assert_response :success
end

test 'report index url is accessible to basic users when authenticated' do
sign_in users(:basic)

get '/report'

assert_response :success
end

test 'algorithm metrics report is not accessible without authentication' do
get '/report/algorithm_metrics'

assert_redirected_to '/'
follow_redirect!

assert_select 'div.alert', text: 'Please sign in to continue', count: 1
end

test 'algorithm metrics report is accessible to admins when authenticated' do
sign_in users(:admin)

get '/report/algorithm_metrics'

assert_response :success
end

test 'algorithm metrics report is accessible to basic users when authenticated' do
sign_in users(:basic)

get '/report/algorithm_metrics'

assert_response :success
end

test 'algorithm metrics can show monthly data' do
sign_in users(:basic)

get '/report/algorithm_metrics'

assert_select 'h3', text: 'Monthly Algorithm Metrics', count: 1
end

test 'algorithm metrics can show aggregate data' do
sign_in users(:basic)

get '/report/algorithm_metrics?type=aggregate'

assert_select 'h3', text: 'Aggregate Algorithm Metrics', count: 1
end
end

0 comments on commit 6e6c915

Please sign in to comment.