profile.rb 7.24 KB
Newer Older
1
class Spinach::Features::Profile < Spinach::FeatureSteps
Nihad Abbasov's avatar
Nihad Abbasov committed
2 3
  include SharedAuthentication
  include SharedPaths
4

5
  step 'I should see my profile info' do
6
    page.should have_content "Profile settings"
7 8
  end

Jerome Dalbert's avatar
Jerome Dalbert committed
9
  step 'I change my profile info' do
10 11 12
    fill_in "user_skype", with: "testskype"
    fill_in "user_linkedin", with: "testlinkedin"
    fill_in "user_twitter", with: "testtwitter"
Jerome Dalbert's avatar
Jerome Dalbert committed
13
    fill_in "user_website_url", with: "testurl"
14
    click_button "Save changes"
15 16 17
    @user.reload
  end

Jerome Dalbert's avatar
Jerome Dalbert committed
18
  step 'I should see new profile info' do
19 20 21
    @user.skype.should == 'testskype'
    @user.linkedin.should == 'testlinkedin'
    @user.twitter.should == 'testtwitter'
Jerome Dalbert's avatar
Jerome Dalbert committed
22
    @user.website_url.should == 'testurl'
23 24
  end

25 26 27 28 29 30 31 32 33 34 35
  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

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
  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

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

67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
  step 'I try to set a weak password' do
    within '.update-password' do
      fill_in "user_password_profile", with: "22233344"
    end
  end

  step 'I try to set a short password' do
    within '.update-password' do
      fill_in "user_password_profile", with: "short"
    end
  end

  step 'I try to set a strong password' do
    within '.update-password' do
      fill_in "user_password_profile", with: "Itulvo9z8uud%$"
    end
  end

85
  step 'I change my password' do
86
    within '.update-password' do
87
      fill_in "user_current_password", with: "12345678"
88
      fill_in "user_password_profile", with: "22233344"
89
      fill_in "user_password_confirmation", with: "22233344"
90 91
      click_button "Save"
    end
92 93
  end

94
  step 'I unsuccessfully change my password' do
95
    within '.update-password' do
96
      fill_in "user_current_password", with: "12345678"
97
      fill_in "user_password_profile", with: "password"
98 99 100
      fill_in "user_password_confirmation", with: "confirmation"
      click_button "Save"
    end
101 102
  end

103 104 105 106
  step "I should see a missing password error message" do
    page.should have_content "You must provide a valid current password"
  end

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
  step 'I should see the input field yellow' do
    page.should have_css 'div.has-warning'
  end

  step 'I should see the input field green' do
    page.should have_css 'div.has-success'
  end

  step 'I should see the input field red' do
    page.should have_css 'div.has-error'
  end

  step 'I should see the password error message' do
    page.should have_content 'Your password is too short'
  end

123
  step "I should see a password error message" do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
124
    page.should have_content "Password confirmation doesn't match"
125 126
  end

127
  step 'I reset my token' do
128 129 130 131
    within '.update-token' do
      @old_token = @user.private_token
      click_button "Reset"
    end
132 133
  end

134
  step 'I should see new token' do
135 136 137
    find("#token").value.should_not == @old_token
    find("#token").value.should == @user.reload.private_token
  end
randx's avatar
randx committed
138

139
  step 'I have activity' do
140
    create(:closed_issue_event, author: current_user)
randx's avatar
randx committed
141 142
  end

143
  step 'I should see my activity' do
randx's avatar
randx committed
144 145
    page.should have_content "#{current_user.name} closed issue"
  end
146

147
  step "I change my application theme" do
148 149 150
    within '.application-theme' do
      choose "Violet"
    end
151 152
  end

153
  step "I change my code preview theme" do
154
    within '.code-preview-theme' do
155
      choose "Solarized dark"
156
    end
157 158
  end

159
  step "I should see the theme change immediately" do
160 161 162 163
    page.should have_selector('body.ui_color')
    page.should_not have_selector('body.ui_basic')
  end

164
  step "I should receive feedback that the changes were saved" do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
165
    page.should have_content("saved")
166
  end
167 168 169 170 171

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

172
  step "I am not an ldap user" do
173
    current_user.identities.delete
174 175 176
    current_user.ldap_user?.should be_false
  end

177 178 179 180 181
  step 'I redirected to expired password page' do
    current_path.should == new_profile_password_path
  end

  step 'I submit new password' do
182
    fill_in :user_current_password, with: '12345678'
183
    fill_in :user_password_profile, with: '12345678'
184 185 186 187 188 189 190
    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
191

192 193 194 195
  step 'I should be redirected to password page' do
    current_path.should == edit_profile_password_path
  end

196
  step 'I should be redirected to account page' do
197
    current_path.should == profile_account_path
198 199
  end

200 201 202 203 204 205 206 207 208 209 210
  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
211 212 213 214 215 216

  step 'I have group with projects' do
    @group   = create(:group)
    @group.add_owner(current_user)
    @project = create(:project, namespace: @group)
    @event   = create(:closed_issue_event, project: @project)
217

218 219 220 221 222 223
    @project.team << [current_user, :master]
  end

  step 'I should see groups I belong to' do
    page.should have_css('.profile-groups-avatars', visible: true)
  end
Valery Sizov's avatar
Valery Sizov committed
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273

  step 'I click on new application button' do
    click_on 'New Application'
  end

  step 'I should see application form' do
    page.should have_content "New application"
  end

  step 'I fill application form out and submit' do
    fill_in :doorkeeper_application_name, with: 'test'
    fill_in :doorkeeper_application_redirect_uri, with: 'https://test.com'
    click_on "Submit"
  end

  step 'I see application' do
    page.should have_content "Application: test"
    page.should have_content "Application Id"
    page.should have_content "Secret"
  end

  step 'I click edit' do
    click_on "Edit"
  end

  step 'I see edit application form' do
    page.should have_content "Edit application"
  end

  step 'I change name of application and submit' do
    page.should have_content "Edit application"
    fill_in :doorkeeper_application_name, with: 'test_changed'
    click_on "Submit"
  end

  step 'I see that application was changed' do
    page.should have_content "test_changed"
    page.should have_content "Application Id"
    page.should have_content "Secret"
  end

  step 'I click to remove application' do
    within '.oauth-applications' do
      click_on "Destroy"
    end
  end

  step "I see that application is removed" do
    page.find(".oauth-applications").should_not have_content "test_changed"
  end
274
end