Add controller test
This commit is contained in:
@@ -7,9 +7,10 @@ class Admin::PromptSandboxesController < AdminController
|
||||
end
|
||||
|
||||
def create
|
||||
cookies[:prompt] = params[:prompt]
|
||||
day = Time.zone.parse(params[:day])
|
||||
redirect_to admin_prompt_sandbox_path(day: day.to_date)
|
||||
@prompt = params[:prompt]
|
||||
cookies[:prompt] = @prompt
|
||||
@summary, @summarizable_content = summarize(@day_timeline, @prompt)
|
||||
render :show
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
require "test_helper"
|
||||
|
||||
class Admin::PromptSandboxesControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in_as :kevin
|
||||
end
|
||||
|
||||
test "show renders the form with default prompt" do
|
||||
get admin_prompt_sandbox_path
|
||||
|
||||
assert_response :success
|
||||
assert_select "form[action=?]", admin_prompt_sandbox_path
|
||||
assert_select "textarea[name=?]", "prompt"
|
||||
assert_select "input[type=submit]"
|
||||
end
|
||||
|
||||
test "create processes prompt and renders show with summary" do
|
||||
test_prompt = "Test prompt for summarization"
|
||||
|
||||
post admin_prompt_sandbox_path, params: { prompt: test_prompt }
|
||||
|
||||
assert_response :success
|
||||
assert_select "form[action=?]", admin_prompt_sandbox_path
|
||||
assert_select "textarea[name=?]", "prompt"
|
||||
assert_select "input[type=submit]"
|
||||
# The summary should be rendered outside the form
|
||||
assert_match /summary/, response.body.downcase
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
require "test_helper"
|
||||
|
||||
class Events::ActivitySummariesControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in_as :kevin
|
||||
end
|
||||
|
||||
test "create" do
|
||||
assert_difference -> { Event::ActivitySummary.count }, +1 do
|
||||
perform_enqueued_jobs only: User::DayTimeline::SummarizeJob do
|
||||
post events_activity_summaries_path(day: Date.current)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user