Commit 6c0fd9f29ad92b0f4b1cdea82a33d485622d0fd5

Authored by Dmitriy Zaporozhets
1 parent 318b50a0

Add scenario for expired password

features/profile/profile.feature
... ... @@ -16,6 +16,13 @@ Feature: Profile
16 16 Then I change my password
17 17 And I should be redirected to sign in page
18 18  
  19 + Scenario: My password is expired
  20 + Given my password is expired
  21 + And I visit profile account page
  22 + Then I redirected to expired password page
  23 + And I submit new password
  24 + And I redirected to sign in page
  25 +
19 26 Scenario: I unsuccessfully change my password
20 27 Given I visit profile account page
21 28 When I unsuccessfully change my password
... ...
features/steps/profile/profile.rb
... ... @@ -2,13 +2,13 @@ class Profile < Spinach::FeatureSteps
2 2 include SharedAuthentication
3 3 include SharedPaths
4 4  
5   - Then 'I should see my profile info' do
  5 + step 'I should see my profile info' do
6 6 page.should have_content "Profile"
7 7 page.should have_content @user.name
8 8 page.should have_content @user.email
9 9 end
10 10  
11   - Then 'I change my contact info' do
  11 + step 'I change my contact info' do
12 12 fill_in "user_skype", with: "testskype"
13 13 fill_in "user_linkedin", with: "testlinkedin"
14 14 fill_in "user_twitter", with: "testtwitter"
... ... @@ -16,13 +16,13 @@ class Profile < Spinach::FeatureSteps
16 16 @user.reload
17 17 end
18 18  
19   - And 'I should see new contact info' do
  19 + step 'I should see new contact info' do
20 20 @user.skype.should == 'testskype'
21 21 @user.linkedin.should == 'testlinkedin'
22 22 @user.twitter.should == 'testtwitter'
23 23 end
24 24  
25   - Then 'I change my password' do
  25 + step 'I change my password' do
26 26 within '.update-password' do
27 27 fill_in "user_password", with: "222333"
28 28 fill_in "user_password_confirmation", with: "222333"
... ... @@ -30,7 +30,7 @@ class Profile < Spinach::FeatureSteps
30 30 end
31 31 end
32 32  
33   - When 'I unsuccessfully change my password' do
  33 + step 'I unsuccessfully change my password' do
34 34 within '.update-password' do
35 35 fill_in "user_password", with: "password"
36 36 fill_in "user_password_confirmation", with: "confirmation"
... ... @@ -38,52 +38,70 @@ class Profile < Spinach::FeatureSteps
38 38 end
39 39 end
40 40  
41   - Then "I should see a password error message" do
  41 + step "I should see a password error message" do
42 42 page.should have_content "Password doesn't match confirmation"
43 43 end
44 44  
45   - And 'I should be redirected to sign in page' do
  45 + step 'I should be redirected to sign in page' do
46 46 current_path.should == new_user_session_path
47 47 end
48 48  
49   - Then 'I reset my token' do
  49 + step 'I reset my token' do
50 50 within '.update-token' do
51 51 @old_token = @user.private_token
52 52 click_button "Reset"
53 53 end
54 54 end
55 55  
56   - And 'I should see new token' do
  56 + step 'I should see new token' do
57 57 find("#token").value.should_not == @old_token
58 58 find("#token").value.should == @user.reload.private_token
59 59 end
60 60  
61   - Given 'I have activity' do
  61 + step 'I have activity' do
62 62 create(:closed_issue_event, author: current_user)
63 63 end
64 64  
65   - Then 'I should see my activity' do
  65 + step 'I should see my activity' do
66 66 page.should have_content "#{current_user.name} closed issue"
67 67 end
68 68  
69   - When "I change my application theme" do
  69 + step "I change my application theme" do
70 70 within '.application-theme' do
71 71 choose "Violet"
72 72 end
73 73 end
74 74  
75   - When "I change my code preview theme" do
  75 + step "I change my code preview theme" do
76 76 within '.code-preview-theme' do
77 77 choose "Solarized dark"
78 78 end
79 79 end
80 80  
81   - Then "I should see the theme change immediately" do
  81 + step "I should see the theme change immediately" do
82 82 page.should have_selector('body.ui_color')
83 83 page.should_not have_selector('body.ui_basic')
84 84 end
85 85  
86   - Then "I should receive feedback that the changes were saved" do
  86 + step "I should receive feedback that the changes were saved" do
87 87 page.should have_content("Saved")
88 88 end
  89 +
  90 + step 'my password is expired' do
  91 + current_user.update_attributes(password_expires_at: Time.now - 1.hour)
  92 + end
  93 +
  94 + step 'I redirected to expired password page' do
  95 + current_path.should == new_profile_password_path
  96 + end
  97 +
  98 + step 'I submit new password' do
  99 + fill_in :user_password, with: '12345678'
  100 + fill_in :user_password_confirmation, with: '12345678'
  101 + click_button "Set new password"
  102 + end
  103 +
  104 + step 'I redirected to sign in page' do
  105 + current_path.should == new_user_session_path
  106 + end
89 107 end
... ...