-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class RatingsController < ApplicationController | ||
before_action :find_case | ||
|
||
# GET /ratings or /ratings.json | ||
def index | ||
@ratings = @case.ratings.includes([ :query, :user ]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
json.rating_id rating.id | ||
json.query_text rating.query.query_text | ||
json.doc_id rating.doc_id | ||
json.rating rating.rating | ||
json.user_name rating&.user&.fullname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> | ||
<h1 class="h2">Ratings for Case <%= @case.case_name %></h1> | ||
<div class="btn-toolbar mb-2 mb-md-0"> | ||
<div class="btn-group me-2"> | ||
<%= link_to "Back to Case #{@case.case_name}", case_path(@case), class: "btn btn-sm btn-outline-secondary" %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<table class="table table-hover table-sm"> | ||
<thead> | ||
<tr> | ||
<th>Rating ID</th> | ||
<th>Query</th> | ||
<th>Doc ID</th> | ||
<th>Rating</th> | ||
<th>User</th> | ||
<th>Created At</th> | ||
<th>Updated At</th> | ||
|
||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @ratings.each do |rating| %> | ||
<tr> | ||
<td><%= rating.id %></td> | ||
<td><%= rating.query.query_text %></td> | ||
<td><%= rating.doc_id %></td> | ||
<td><%= rating.rating %></td> | ||
<td><%= rating&.user&.fullname %></td> | ||
<td> | ||
<%= rating.created_at %> | ||
</td> | ||
<td> | ||
<%= rating.updated_at %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
json.array! @ratings, partial: 'ratings/rating', as: :rating |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class RatingsControllerTest < ActionDispatch::IntegrationTest | ||
let(:user) { users(:random) } | ||
setup do | ||
@case = cases(:import_ratings_case) | ||
end | ||
|
||
test 'should get index' do | ||
# get the login page | ||
|
||
get case_ratings_url(@case) | ||
assert_equal 302, status | ||
follow_redirect! | ||
|
||
login_user | ||
get case_ratings_url(@case) | ||
assert_response :success | ||
end | ||
|
||
def login_user | ||
# We don't actually want to load up scores... | ||
Bullet.enable = false | ||
# post the login and follow through to the home page | ||
post '/users/login', params: { user: { email: user.email, password: 'password' } } | ||
follow_redirect! | ||
assert_equal 200, status | ||
assert_equal '/', path | ||
|
||
Bullet.enable = true | ||
end | ||
end |