Skip to content

Commit 592c339

Browse files
committed
Add extra scenarios to the edit user feature
1 parent a21506e commit 592c339

File tree

2 files changed

+85
-4
lines changed

2 files changed

+85
-4
lines changed

features/step_definitions/user_steps.rb

+45-2
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,50 @@ def sign_in
121121
sign_in
122122
end
123123

124-
When /^I edit my account details$/ do
124+
When(/^I save the edit form$/) do
125+
click_button "Update"
126+
end
127+
128+
When /^I edit my account name$/ do
125129
click_link "Edit account"
126130
fill_in "user_name", :with => "newname"
127131
fill_in "user_current_password", :with => @visitor[:password]
128-
click_button "Update"
132+
end
133+
134+
When /^I edit my email address$/ do
135+
click_link "Edit account"
136+
fill_in "user_email", :with => "[email protected]"
137+
fill_in "user_current_password", :with => @visitor[:password]
138+
end
139+
140+
When(/^I don't enter my current password$/) do
141+
fill_in "user_current_password", :with => ""
142+
end
143+
144+
When(/^I edit my email address with an invalid email$/) do
145+
click_link "Edit account"
146+
fill_in "user_email", :with => "notanemail"
147+
fill_in "user_current_password", :with => @visitor[:password]
148+
end
149+
150+
When(/^I edit my password$/) do
151+
click_link "Edit account"
152+
fill_in "user_password", :with => "newpassword"
153+
fill_in "user_password_confirmation", :with => "newpassword"
154+
fill_in "user_current_password", :with => @visitor[:password]
155+
end
156+
157+
When(/^I edit my password with missing confirmation$/) do
158+
click_link "Edit account"
159+
fill_in "user_password", :with => "newpassword"
160+
fill_in "user_current_password", :with => @visitor[:password]
161+
end
162+
163+
When(/^I edit my password with missmatched confirmation$/) do
164+
click_link "Edit account"
165+
fill_in "user_password", :with => "newpassword"
166+
fill_in "user_password_confirmation", :with => "newpassword123"
167+
fill_in "user_current_password", :with => @visitor[:password]
129168
end
130169

131170
When /^I look at the list of users$/ do
@@ -185,6 +224,10 @@ def sign_in
185224
page.should have_content "You updated your account successfully."
186225
end
187226

227+
Then(/^I should see a current password missing message$/) do
228+
page.should have_content "Current password can't be blank"
229+
end
230+
188231
Then /^I should see my name$/ do
189232
create_user
190233
page.should have_content @user[:name]

features/users/user_edit.feature

+40-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,45 @@ Feature: Edit User
33
I want to edit my user profile
44
so I can change my username
55

6-
Scenario: I sign in and edit my account
6+
Scenario: I sign in and edit my name
77
Given I am logged in
8-
When I edit my account details
8+
When I edit my account name
9+
And I save the edit form
910
Then I should see an account edited message
11+
12+
Scenario: I sign in and edit my email address
13+
Given I am logged in
14+
When I edit my email address
15+
And I save the edit form
16+
Then I should see an account edited message
17+
18+
Scenario: I edit my account without current password
19+
Given I am logged in
20+
When I edit my email address
21+
And I don't enter my current password
22+
And I save the edit form
23+
Then I should see a current password missing message
24+
25+
Scenario: I sign in and edit with invalid email
26+
Given I am logged in
27+
When I edit my email address with an invalid email
28+
And I save the edit form
29+
Then I should see an invalid email message
30+
31+
Scenario: I sign in and edit my password
32+
Given I am logged in
33+
When I edit my password
34+
And I save the edit form
35+
Then I should see an account edited message
36+
37+
Scenario: I sign in and edit my password with missing confirmation
38+
Given I am logged in
39+
When I edit my password with missing confirmation
40+
And I save the edit form
41+
Then I should see a mismatched password message
42+
43+
Scenario: I sign in and edit my password with mismatched confirmation
44+
Given I am logged in
45+
When I edit my password with missmatched confirmation
46+
And I save the edit form
47+
Then I should see a mismatched password message

0 commit comments

Comments
 (0)