Skip to content

Commit

Permalink
half finished edit user
Browse files Browse the repository at this point in the history
  • Loading branch information
saft committed Feb 7, 2013
1 parent 807abf8 commit 590b1cf
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ def create
render 'new'
end
end

def edit
@user = User.find(params[:id])
end
end
21 changes: 21 additions & 0 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<% provide(:title, "Edit user") %>
<h1>Update your profile</h1>

<div class="row">
<div class="span6 offset3">
<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages' %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation, "Confirm Password" %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Save changes", class: "btn btn-large btn-primary" %>
<% end %>
<% gravatar_for @user %>
<a href="http://gravatar.com/emails">change</a>
</div>
</div>
1 change: 1 addition & 0 deletions spec/requests/authentication_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
end
it { should have_selector('title', text: user.name) }
it { should have_link('Profile', href: user_path(user)) }
it { should have_link('Settings', href: user_path(user)) }
it { should have_link('Sign out', href: signout_path) }
it { should_not have_link('Sign in', href: signin_path) }
describe "followed by signout" do
Expand Down
17 changes: 17 additions & 0 deletions spec/requests/user_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,21 @@
end
end
end

describe "edit" do
let(:user) { FactoryGirl.create(:user) }
before { visit edit_user_path(user) }

describe "page" do
it { should have_selector('title', text: "Edit user") }
it { should have_selector('h1', text: "Update your profile") }
it { should have_link('change', href: 'http://gravatar.com/emails') }
end

describe "with invalid information" do
before { click_button "Save changes" }
it { should have_content('error') }
end
end

end

0 comments on commit 590b1cf

Please sign in to comment.