profile.rb 3.8 KB
Newer Older
1
class Profile < Spinach::FeatureSteps
N
Nihad Abbasov 已提交
2 3
  include SharedAuthentication
  include SharedPaths
4

5
  step 'I should see my profile info' do
6 7 8 9 10
    page.should have_content "Profile"
    page.should have_content @user.name
    page.should have_content @user.email
  end

11
  step 'I change my contact info' do
12 13 14
    fill_in "user_skype", with: "testskype"
    fill_in "user_linkedin", with: "testlinkedin"
    fill_in "user_twitter", with: "testtwitter"
15
    click_button "Save changes"
16 17 18
    @user.reload
  end

19
  step 'I should see new contact info' do
20 21 22 23 24
    @user.skype.should == 'testskype'
    @user.linkedin.should == 'testlinkedin'
    @user.twitter.should == 'testtwitter'
  end

25 26 27 28 29 30 31 32
  step 'I try change my password w/o old one' do
    within '.update-password' do
      fill_in "user_password", with: "222333"
      fill_in "user_password_confirmation", with: "222333"
      click_button "Save"
    end
  end

33
  step 'I change my password' do
34
    within '.update-password' do
35
      fill_in "user_current_password", with: "123456"
36 37
      fill_in "user_password", with: "222333"
      fill_in "user_password_confirmation", with: "222333"
38 39
      click_button "Save"
    end
40 41
  end

42
  step 'I unsuccessfully change my password' do
43
    within '.update-password' do
44
      fill_in "user_current_password", with: "123456"
45 46 47 48
      fill_in "user_password", with: "password"
      fill_in "user_password_confirmation", with: "confirmation"
      click_button "Save"
    end
49 50
  end

51 52 53 54
  step "I should see a missing password error message" do
    page.should have_content "You must provide a valid current password"
  end

55
  step "I should see a password error message" do
56 57 58
    page.should have_content "Password doesn't match confirmation"
  end

59
  step 'I should be redirected to sign in page' do
60 61 62
    current_path.should == new_user_session_path
  end

63
  step 'I reset my token' do
64 65 66 67
    within '.update-token' do
      @old_token = @user.private_token
      click_button "Reset"
    end
68 69
  end

70
  step 'I should see new token' do
71 72 73
    find("#token").value.should_not == @old_token
    find("#token").value.should == @user.reload.private_token
  end
R
randx 已提交
74

75
  step 'I have activity' do
76
    create(:closed_issue_event, author: current_user)
R
randx 已提交
77 78
  end

79
  step 'I should see my activity' do
R
randx 已提交
80 81
    page.should have_content "#{current_user.name} closed issue"
  end
82

83
  step "I change my application theme" do
84 85 86
    within '.application-theme' do
      choose "Violet"
    end
87 88
  end

89
  step "I change my code preview theme" do
90
    within '.code-preview-theme' do
91
      choose "Solarized dark"
92
    end
93 94
  end

95
  step "I should see the theme change immediately" do
96 97 98 99
    page.should have_selector('body.ui_color')
    page.should_not have_selector('body.ui_basic')
  end

100
  step "I should receive feedback that the changes were saved" do
D
Dmitriy Zaporozhets 已提交
101
    page.should have_content("saved")
102
  end
103 104 105 106 107

  step 'my password is expired' do
    current_user.update_attributes(password_expires_at: Time.now - 1.hour)
  end

108 109 110 111 112
  step "I am not an ldap user" do
    current_user.update_attributes(extern_uid: nil,  provider: '')
    current_user.ldap_user?.should be_false
  end

113 114 115 116 117 118 119 120 121 122 123 124 125
  step 'I redirected to expired password page' do
    current_path.should == new_profile_password_path
  end

  step 'I submit new password' do
    fill_in :user_password, with: '12345678'
    fill_in :user_password_confirmation, with: '12345678'
    click_button "Set new password"
  end

  step 'I redirected to sign in page' do
    current_path.should == new_user_session_path
  end
126

127 128 129 130
  step 'I should be redirected to account page' do
    current_path.should == account_profile_path
  end

131 132 133 134 135 136 137 138 139 140 141
  step 'I click on my profile picture' do
    click_link 'profile-pic'
  end

  step 'I should see my user page' do
    page.should have_content "User Activity"

    within '.navbar-gitlab' do
      page.should have_content current_user.name
    end
  end
142
end