Commit bfd24d73 authored by Zac Wood's avatar Zac Wood

Added tests for Search controller

parent 0a501963
class SearchController < ApplicationController
def index
crn = params[:crn]
@sections = Section.find_by_crn(crn)
render json: @sections
if params.key?(:crn)
crn = params[:crn]
@sections = Section.find_by_crn(crn)
render json: @sections
else
render status: 404
end
end
end
require 'test_helper'
class SearchControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get search_index_url
test "should get index and search by crn" do
get url_for controller: 'search', action: 'index', crn: 'MyString'
assert_response :success
end
test "should 404 without crn" do
get url_for controller: 'search', action: 'index'
assert_response :missing
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment