-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds minimally functional page for assistant instructions (#45)
- Loading branch information
Showing
17 changed files
with
102 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class Assistants::InstructionsController < ApplicationController | ||
before_action :set_assistant | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
@assistant.update!(assistant_params) | ||
redirect_to @assistant, notice: "Instructions have been saved." | ||
end | ||
|
||
private | ||
|
||
def set_assistant | ||
@assistant = Assistant.find(params[:assistant_id]) | ||
end | ||
|
||
def assistant_params | ||
params.require(:assistant).permit(:instructions) | ||
end | ||
end |
Empty file.
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 @@ | ||
Your assistant <%= @assistant.name %> has the following instructions: | ||
|
||
<%= form_for @assistant, url: assistant_instructions_path(@assistant) do |f| %> | ||
<%= f.text_area :instructions, rows: 10, class: "w-auto mx-20" %> | ||
<br> | ||
<%= f.submit "Update", class: "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded" %> | ||
<% 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
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
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 |
---|---|---|
|
@@ -33,5 +33,3 @@ | |
|
||
# Allow puma to be restarted by `bin/rails restart` command. | ||
plugin :tmp_restart | ||
|
||
plugin :solid_queue |
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
Empty file.
22 changes: 22 additions & 0 deletions
22
test/controllers/assistants/instructions_controller_test.rb
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,22 @@ | ||
require "test_helper" | ||
|
||
class Assistants::InstructionsControllerTest < ActionDispatch::IntegrationTest | ||
setup do | ||
@assistant = assistants(:samantha) | ||
login_as assistants(:samantha).user | ||
end | ||
|
||
test "it shows the instructions" do | ||
get assistant_instructions_url(@assistant) | ||
assert_response :success | ||
end | ||
|
||
test "it updates the instructions" do | ||
new_instructions = "New instructions" | ||
patch assistant_instructions_url(@assistant), params: {assistant: {instructions: new_instructions }} | ||
assert_redirected_to assistant_url(@assistant) | ||
|
||
@assistant.reload | ||
assert_equal new_instructions, @assistant.instructions | ||
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,2 @@ | ||
chat_with_samantha: | ||
user: keith |
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 @@ | ||
note_from_samantha: | ||
chat: chat_with_samantha | ||
content: Hi, how are you? |
Empty file.
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ class UserTest < ActiveSupport::TestCase | |
person = Person.new(email: "[email protected]", personable: user) | ||
assert_raises(ActiveRecord::RecordInvalid) { person.save! } | ||
end | ||
j | ||
|
||
test "should not save user without password confirmation" do | ||
user = User.new(password: "password") | ||
person = Person.new(email: "[email protected]", personable: user) | ||
|
@@ -22,4 +22,9 @@ class UserTest < ActiveSupport::TestCase | |
person = Person.new(email: "[email protected]", personable: user) | ||
assert person.save! | ||
end | ||
|
||
test "it can validate a password" do | ||
user = users(:keith) | ||
assert user.authenticate("secret") | ||
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,17 @@ | ||
require "application_system_test_case" | ||
|
||
class AssistantsInstructionsTest < ApplicationSystemTestCase | ||
setup do | ||
@assistant = assistants(:samantha) | ||
end | ||
|
||
test "should update Assistant" do | ||
login_as @assistant.user | ||
visit assistant_instructions_url(@assistant) | ||
|
||
fill_in "assistant[instructions]", with: "Updated Instructions" | ||
click_on "Update" | ||
|
||
assert_text "Instructions have been saved." | ||
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