Permalink
Browse files

Man, it's a PITA trying to test a data-method delete via capybara. I …

…just won't want to deal with capybara-webket or selenium today.
  • Loading branch information...
1 parent 75fd355 commit eb4ddb6b13162e6889d64fe75c104925c1338ae7 Evan Light committed Aug 31, 2012
Showing with 13 additions and 1 deletion.
  1. +6 −0 app/controllers/users_controller.rb
  2. +4 −0 app/presenters/user_presenter.rb
  3. +2 −0 app/views/users/edit.html.haml
  4. +1 −1 config/routes.rb
View
6 app/controllers/users_controller.rb
@@ -17,6 +17,12 @@ def update
end
end
+ def destroy
+ current_user.destroy
+ flash[:notice] = "kthxbai"
+ redirect_to root_path
+ end
+
private
def find_user
@user = User.where("_id" => params[:id]).first
View
4 app/presenters/user_presenter.rb
@@ -56,6 +56,10 @@ def pairing_preference
end
end
+ def delete_my_account_link
+ link_to "Delete my account", user_path(current_user), :method => :delete, :confirm => "Are you sure that you want to delete your account?"
+ end
+
def pairing_preference_options
User::REMOTE_LOCAL_PREFERENCES.map do |pref|
View
2 app/views/users/edit.html.haml
@@ -18,6 +18,8 @@
= f.text_area :interests
%p
= f.submit
+ %p
+ = delete_my_account_link
:javascript
$('#user_interests').tagify({addTagPrompt: 'add tags'});
$('form').submit( function() {
View
2 config/routes.rb
@@ -7,7 +7,7 @@
root :to => "home#index"
- resources :users, only: [:edit, :update, :show] do
+ resources :users, only: [:edit, :update, :show, :destroy] do
resource :availability, module: :user
end
end

0 comments on commit eb4ddb6

Please sign in to comment.