profile.rb 4.6 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
D
Dmitriy Zaporozhets 已提交
6
    page.should have_content "Profile settings"
7 8
  end

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

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

S
Steven Thonus 已提交
23 24 25 26 27 28 29 30 31 32 33
  step 'I change my avatar' do
    attach_file(:user_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png'))
    click_button "Save changes"
    @user.reload
  end

  step 'I should see new avatar' do
    @user.avatar.should be_instance_of AttachmentUploader
    @user.avatar.url.should == "/uploads/user/avatar/#{ @user.id }/gitlab_logo.png"
  end

34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
  step 'I should see the "Remove avatar" button' do
    page.should have_link("Remove avatar")
  end

  step 'I have an avatar' do
    attach_file(:user_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png'))
    click_button "Save changes"
    @user.reload
  end

  step 'I remove my avatar' do
    click_link "Remove avatar"
    @user.reload
  end

  step 'I should see my gravatar' do
    @user.avatar?.should be_false
  end

  step 'I should not see the "Remove avatar" button' do
    page.should_not have_link("Remove avatar")
  end

57 58
  step 'I try change my password w/o old one' do
    within '.update-password' do
59 60
      fill_in "user_password", with: "22233344"
      fill_in "user_password_confirmation", with: "22233344"
61 62 63 64
      click_button "Save"
    end
  end

65
  step 'I change my password' do
66
    within '.update-password' do
67 68 69
      fill_in "user_current_password", with: "12345678"
      fill_in "user_password", with: "22233344"
      fill_in "user_password_confirmation", with: "22233344"
70 71
      click_button "Save"
    end
72 73
  end

74
  step 'I unsuccessfully change my password' do
75
    within '.update-password' do
76
      fill_in "user_current_password", with: "12345678"
77 78 79 80
      fill_in "user_password", with: "password"
      fill_in "user_password_confirmation", with: "confirmation"
      click_button "Save"
    end
81 82
  end

83 84 85 86
  step "I should see a missing password error message" do
    page.should have_content "You must provide a valid current password"
  end

87
  step "I should see a password error message" do
D
Dmitriy Zaporozhets 已提交
88
    page.should have_content "Password confirmation doesn't match"
89 90
  end

91
  step 'I reset my token' do
92 93 94 95
    within '.update-token' do
      @old_token = @user.private_token
      click_button "Reset"
    end
96 97
  end

98
  step 'I should see new token' do
99 100 101
    find("#token").value.should_not == @old_token
    find("#token").value.should == @user.reload.private_token
  end
R
randx 已提交
102

103
  step 'I have activity' do
104
    create(:closed_issue_event, author: current_user)
R
randx 已提交
105 106
  end

107
  step 'I should see my activity' do
R
randx 已提交
108 109
    page.should have_content "#{current_user.name} closed issue"
  end
110

111
  step "I change my application theme" do
112 113 114
    within '.application-theme' do
      choose "Violet"
    end
115 116
  end

117
  step "I change my code preview theme" do
118
    within '.code-preview-theme' do
119
      choose "Solarized dark"
120
    end
121 122
  end

123
  step "I should see the theme change immediately" do
124 125 126 127
    page.should have_selector('body.ui_color')
    page.should_not have_selector('body.ui_basic')
  end

128
  step "I should receive feedback that the changes were saved" do
D
Dmitriy Zaporozhets 已提交
129
    page.should have_content("saved")
130
  end
131 132 133 134 135

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

136 137 138 139 140
  step "I am not an ldap user" do
    current_user.update_attributes(extern_uid: nil,  provider: '')
    current_user.ldap_user?.should be_false
  end

141 142 143 144 145 146 147 148 149 150 151 152 153
  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
154

D
Dmitriy Zaporozhets 已提交
155 156 157 158
  step 'I should be redirected to password page' do
    current_path.should == edit_profile_password_path
  end

159
  step 'I should be redirected to account page' do
D
Dmitriy Zaporozhets 已提交
160
    current_path.should == profile_account_path
161 162
  end

163 164 165 166 167 168 169 170 171 172 173
  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
174
end