-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a way to edit existing volunteer notes
- Loading branch information
Showing
6 changed files
with
96 additions
and
4 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,13 @@ | ||
<%= form_with(model: @note, local: true, url: volunteer_note_path(@volunteer, @note)) do |form| %> | ||
<h3>Update Volunteer Note</h3> | ||
|
||
<div class="form-group"> | ||
<%= form.text_area :content, | ||
rows: 5, | ||
placeholder: t("volunteers.edit.notes_placeholder"), | ||
class: "form-control" | ||
%> | ||
</div> | ||
|
||
<%= form.submit t("notes.update"), class: "btn btn-primary", id: "note-submit" %> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "/volunteers/notes", type: :request do | ||
let(:organization) { create(:casa_org) } | ||
let(:admin) { create(:casa_admin, casa_org_id: organization.id) } | ||
let(:volunteer) { create(:volunteer, :with_assigned_supervisor, casa_org_id: organization.id) } | ||
let(:note) { volunteer.notes.create(creator: admin, content: "Good job.") } | ||
|
||
describe "PATCH /update" do | ||
subject(:request) { patch volunteer_note_path(volunteer, note), params: params } | ||
|
||
context "when logged in as an admin" do | ||
before do | ||
sign_in admin | ||
request | ||
end | ||
|
||
context "with valid params" do | ||
let(:params) { {note: {content: "Very nice!"}} } | ||
|
||
it "returns success response" do | ||
expect(response).to redirect_to(edit_volunteer_path(volunteer)) | ||
expect(note.reload.content).to eq "Very nice!" | ||
end | ||
end | ||
end | ||
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,29 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "volunteers/notes/edit", type: :system do | ||
let(:organization) { create(:casa_org) } | ||
let(:admin) { create(:casa_admin, casa_org_id: organization.id) } | ||
let(:volunteer) { create(:volunteer, :with_assigned_supervisor, casa_org_id: organization.id) } | ||
let(:note) { volunteer.notes.create(creator: admin, content: "Good job.") } | ||
|
||
context "when logged in as an admin" do | ||
before do | ||
sign_in admin | ||
visit edit_volunteer_note_path(volunteer, note) | ||
end | ||
|
||
scenario "editing an existing note" do | ||
expect(page).to have_text("Good job.") | ||
|
||
fill_in("note[content]", with: "Great job!") | ||
|
||
click_on("Update Note") | ||
|
||
expect(page.current_path).to eq edit_volunteer_path(volunteer) | ||
|
||
expect(page).to have_text("Great job!") | ||
|
||
expect(note.reload.content).to eq "Great job!" | ||
end | ||
end | ||
end |