From 590b1cf44d6d50baeb6d783ee69cfc33ab4e69b4 Mon Sep 17 00:00:00 2001 From: Hugo Leeney Date: Thu, 7 Feb 2013 18:09:19 +0000 Subject: [PATCH] half finished edit user --- app/controllers/users_controller.rb | 4 ++++ app/views/users/edit.html.erb | 21 +++++++++++++++++++++ spec/requests/authentication_pages_spec.rb | 1 + spec/requests/user_pages_spec.rb | 17 +++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 app/views/users/edit.html.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5788994..0940b71 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -18,4 +18,8 @@ def create render 'new' end end + + def edit + @user = User.find(params[:id]) + end end diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb new file mode 100644 index 0000000..87099bf --- /dev/null +++ b/app/views/users/edit.html.erb @@ -0,0 +1,21 @@ +<% provide(:title, "Edit user") %> +

Update your profile

+ +
+
+ <%= 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 %> + change +
+
diff --git a/spec/requests/authentication_pages_spec.rb b/spec/requests/authentication_pages_spec.rb index b3a78d2..aaa0f0c 100644 --- a/spec/requests/authentication_pages_spec.rb +++ b/spec/requests/authentication_pages_spec.rb @@ -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 diff --git a/spec/requests/user_pages_spec.rb b/spec/requests/user_pages_spec.rb index fb9c684..ac8dfa6 100644 --- a/spec/requests/user_pages_spec.rb +++ b/spec/requests/user_pages_spec.rb @@ -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