-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a basic edit profile page. First, last and email can be edited. Passwords can't be updated from this page yet.
- Loading branch information
Anthony M
committed
Dec 8, 2020
1 parent
dbb1d5b
commit 2fef380
Showing
2 changed files
with
69 additions
and
0 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,35 @@ | ||
<div class="sign-up" id="clearance"> | ||
<h2>Edit Profile</h2> | ||
|
||
<% if current_user.errors.present? %> | ||
<div class="errors"> | ||
Please fill out all fields | ||
</div> | ||
<% end %> | ||
|
||
|
||
<div class="form"> | ||
<%= form_for current_user, url: user_path, method: "put" do |form| %> | ||
|
||
<div class="form-field"> | ||
<%= form.label :first_name %> | ||
<%= form.text_field :first_name %> | ||
</div> | ||
|
||
<div class="form-field"> | ||
<%= form.label :last_name %> | ||
<%= form.text_field :last_name %> | ||
</div> | ||
|
||
<div class="form-field"> | ||
<%= form.label :email %> | ||
<%= form.text_field :email %> | ||
</div> | ||
|
||
<div class="form-field"> | ||
<%= form.submit %> | ||
</div> | ||
|
||
<% end %> | ||
</div> | ||
</div> |
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 "rails_helper" | ||
|
||
RSpec.describe "User edits their profile" do | ||
context "as a signed in user" do | ||
it "updates their profile" do | ||
user = create(:user) | ||
first_name = "new" | ||
last_name = "name" | ||
email = "new@example.com" | ||
|
||
visit edit_user_path(as: user) | ||
fill_in :user_first_name, with: first_name | ||
fill_in :user_last_name, with: last_name | ||
fill_in :user_email, with: email | ||
click_on "Update User" | ||
|
||
user.reload | ||
|
||
expect(user.first_name).to eq first_name | ||
expect(user.last_name).to eq last_name | ||
expect(user.email).to eq email | ||
end | ||
end | ||
|
||
context "without an authenticated session" do | ||
it "redirects to the sign in page" do | ||
visit edit_user_path | ||
|
||
expect(current_path).to eq sign_in_path | ||
end | ||
end | ||
end |