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,6 +16,13 @@ Feature: Profile
16 Then I change my password 16 Then I change my password
17 And I should be redirected to sign in page 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 Scenario: I unsuccessfully change my password 26 Scenario: I unsuccessfully change my password
20 Given I visit profile account page 27 Given I visit profile account page
21 When I unsuccessfully change my password 28 When I unsuccessfully change my password
features/steps/profile/profile.rb
@@ -2,13 +2,13 @@ class Profile < Spinach::FeatureSteps @@ -2,13 +2,13 @@ class Profile < Spinach::FeatureSteps
2 include SharedAuthentication 2 include SharedAuthentication
3 include SharedPaths 3 include SharedPaths
4 4
5 - Then 'I should see my profile info' do 5 + step 'I should see my profile info' do
6 page.should have_content "Profile" 6 page.should have_content "Profile"
7 page.should have_content @user.name 7 page.should have_content @user.name
8 page.should have_content @user.email 8 page.should have_content @user.email
9 end 9 end
10 10
11 - Then 'I change my contact info' do 11 + step 'I change my contact info' do
12 fill_in "user_skype", with: "testskype" 12 fill_in "user_skype", with: "testskype"
13 fill_in "user_linkedin", with: "testlinkedin" 13 fill_in "user_linkedin", with: "testlinkedin"
14 fill_in "user_twitter", with: "testtwitter" 14 fill_in "user_twitter", with: "testtwitter"
@@ -16,13 +16,13 @@ class Profile < Spinach::FeatureSteps @@ -16,13 +16,13 @@ class Profile < Spinach::FeatureSteps
16 @user.reload 16 @user.reload
17 end 17 end
18 18
19 - And 'I should see new contact info' do 19 + step 'I should see new contact info' do
20 @user.skype.should == 'testskype' 20 @user.skype.should == 'testskype'
21 @user.linkedin.should == 'testlinkedin' 21 @user.linkedin.should == 'testlinkedin'
22 @user.twitter.should == 'testtwitter' 22 @user.twitter.should == 'testtwitter'
23 end 23 end
24 24
25 - Then 'I change my password' do 25 + step 'I change my password' do
26 within '.update-password' do 26 within '.update-password' do
27 fill_in "user_password", with: "222333" 27 fill_in "user_password", with: "222333"
28 fill_in "user_password_confirmation", with: "222333" 28 fill_in "user_password_confirmation", with: "222333"
@@ -30,7 +30,7 @@ class Profile < Spinach::FeatureSteps @@ -30,7 +30,7 @@ class Profile < Spinach::FeatureSteps
30 end 30 end
31 end 31 end
32 32
33 - When 'I unsuccessfully change my password' do 33 + step 'I unsuccessfully change my password' do
34 within '.update-password' do 34 within '.update-password' do
35 fill_in "user_password", with: "password" 35 fill_in "user_password", with: "password"
36 fill_in "user_password_confirmation", with: "confirmation" 36 fill_in "user_password_confirmation", with: "confirmation"
@@ -38,52 +38,70 @@ class Profile < Spinach::FeatureSteps @@ -38,52 +38,70 @@ class Profile < Spinach::FeatureSteps
38 end 38 end
39 end 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 page.should have_content "Password doesn't match confirmation" 42 page.should have_content "Password doesn't match confirmation"
43 end 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 current_path.should == new_user_session_path 46 current_path.should == new_user_session_path
47 end 47 end
48 48
49 - Then 'I reset my token' do 49 + step 'I reset my token' do
50 within '.update-token' do 50 within '.update-token' do
51 @old_token = @user.private_token 51 @old_token = @user.private_token
52 click_button "Reset" 52 click_button "Reset"
53 end 53 end
54 end 54 end
55 55
56 - And 'I should see new token' do 56 + step 'I should see new token' do
57 find("#token").value.should_not == @old_token 57 find("#token").value.should_not == @old_token
58 find("#token").value.should == @user.reload.private_token 58 find("#token").value.should == @user.reload.private_token
59 end 59 end
60 60
61 - Given 'I have activity' do 61 + step 'I have activity' do
62 create(:closed_issue_event, author: current_user) 62 create(:closed_issue_event, author: current_user)
63 end 63 end
64 64
65 - Then 'I should see my activity' do 65 + step 'I should see my activity' do
66 page.should have_content "#{current_user.name} closed issue" 66 page.should have_content "#{current_user.name} closed issue"
67 end 67 end
68 68
69 - When "I change my application theme" do 69 + step "I change my application theme" do
70 within '.application-theme' do 70 within '.application-theme' do
71 choose "Violet" 71 choose "Violet"
72 end 72 end
73 end 73 end
74 74
75 - When "I change my code preview theme" do 75 + step "I change my code preview theme" do
76 within '.code-preview-theme' do 76 within '.code-preview-theme' do
77 choose "Solarized dark" 77 choose "Solarized dark"
78 end 78 end
79 end 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 page.should have_selector('body.ui_color') 82 page.should have_selector('body.ui_color')
83 page.should_not have_selector('body.ui_basic') 83 page.should_not have_selector('body.ui_basic')
84 end 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 page.should have_content("Saved") 87 page.should have_content("Saved")
88 end 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 end 107 end