-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Section 7.4.7: Add ability to edit and update users
- Loading branch information
Ryan Bigg
committed
Dec 7, 2014
1 parent
668ce24
commit 0f30994
Showing
4 changed files
with
67 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
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 @@ | ||
<h2>Editing a User</h2> | ||
|
||
<%= render "form" %> |
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 @@ | ||
<h2><%= @user %></h2> | ||
|
||
<%= link_to "Edit User", edit_admin_user_path(@user), class: "edit" %> |
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,33 @@ | ||
require "rails_helper" | ||
|
||
feature "Editing a user" do | ||
let!(:admin_user) { FactoryGirl.create(:user, :admin) } | ||
let!(:user) { FactoryGirl.create(:user) } | ||
|
||
before do | ||
login_as(admin_user) | ||
visit "/" | ||
click_link "Admin" | ||
click_link "Users" | ||
click_link user.email | ||
click_link "Edit User" | ||
end | ||
|
||
scenario "Updating a user's details" do | ||
fill_in "Email", with: "[email protected]" | ||
click_button "Update User" | ||
|
||
expect(page).to have_content("User has been updated.") | ||
|
||
expect(page).to have_content("[email protected]") | ||
expect(page).to_not have_content(user.email) | ||
end | ||
|
||
scenario "Toggling user's admin ability" do | ||
check "Is an admin?" | ||
click_button "Update User" | ||
|
||
expect(page).to have_content("User has been updated.") | ||
expect(page).to have_content("#{user.email} (Admin)") | ||
end | ||
end |