Skip to content

Commit

Permalink
fix issue RailsApps#39 (and add tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielKehoe committed Dec 10, 2012
1 parent fcf96f9 commit 053c04f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def update_stripe
def cancel_subscription
unless customer_id.nil?
customer = Stripe::Customer.retrieve(customer_id)
unless customer.nil? or customer.deleted
unless customer.nil? or customer.respond_to?('deleted')
if customer.subscription.status == 'active'
customer.cancel_subscription
end
Expand Down
10 changes: 10 additions & 0 deletions features/step_definitions/user_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ def sign_in
click_button "Update"
end

When /^I delete my account$/ do
click_link "Edit account"
click_link "Cancel my account"
page.driver.browser.switch_to.alert.accept
end

When /^I follow the subscribe for silver path$/ do
visit '/users/sign_up/?plan=silver'
end
Expand Down Expand Up @@ -205,6 +211,10 @@ def sign_in
page.should have_content "You updated your account successfully."
end

Then /^I should see an account deleted message$/ do
page.should have_content "account was successfully cancelled"
end

Then /^I should see my name$/ do
create_user
page.should have_content @user[:name]
Expand Down
30 changes: 30 additions & 0 deletions features/users/user_delete.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Feature: Edit User
As a registered user of the website
I want to delete my user profile
so I can close my account

@javascript
Scenario: I sign in and delete my account
Given I am logged in
When I delete my account
Then I should see an account deleted message

@javascript
Scenario: I create a new subscription and delete my account
Given: I am on the home page
When I follow the subscribe for silver path
Then I should see "Silver Subscription Plan"
Given I fill in the following:
| Name | Testy ShortLived |
| Email | short@testing.com |
| user_password | secret_password |
| user_password_confirmation | secret_password |
| Credit Card Number | 4242424242424242 |
| card_code | 111 |
Then I select "5 - May" as the "month"
And I select "2015" as the "year"
When I press "Sign up"
Then I should be on the "content silver" page
And I should see a successful sign up message
When I delete my account
Then I should see an account deleted message

0 comments on commit 053c04f

Please sign in to comment.