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

5
  step 'I should see my profile info' do
6
    expect(page).to have_content "This information will appear on your profile"
7 8
  end

J
Jerome Dalbert 已提交
9
  step 'I change my profile info' do
10 11 12 13 14 15 16
    fill_in 'user_skype', with: 'testskype'
    fill_in 'user_linkedin', with: 'testlinkedin'
    fill_in 'user_twitter', with: 'testtwitter'
    fill_in 'user_website_url', with: 'testurl'
    fill_in 'user_location', with: 'Ukraine'
    fill_in 'user_bio', with: 'I <3 GitLab'
    click_button 'Save changes'
17 18 19
    @user.reload
  end

J
Jerome Dalbert 已提交
20
  step 'I should see new profile info' do
21 22 23 24 25
    expect(@user.skype).to eq 'testskype'
    expect(@user.linkedin).to eq 'testlinkedin'
    expect(@user.twitter).to eq 'testtwitter'
    expect(@user.website_url).to eq 'testurl'
    expect(@user.bio).to eq 'I <3 GitLab'
26
    expect(find('#user_location').value).to eq 'Ukraine'
27 28
  end

S
Steven Thonus 已提交
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
36 37
    expect(@user.avatar).to be_instance_of AvatarUploader
    expect(@user.avatar.url).to eq "/uploads/user/avatar/#{ @user.id }/gitlab_logo.png"
S
Steven Thonus 已提交
38 39
  end

40
  step 'I should see the "Remove avatar" button' do
41
    expect(page).to have_link("Remove avatar")
42 43 44 45 46 47 48 49 50 51 52 53 54 55
  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
56
    expect(@user.avatar?).to be_false
57 58 59
  end

  step 'I should not see the "Remove avatar" button' do
60
    expect(page).not_to have_link("Remove avatar")
61 62
  end

63
  step 'I try change my password w/o old one' do
64
    page.within '.update-password' do
65
      fill_in "user_password", with: "22233344"
66
      fill_in "user_password_confirmation", with: "22233344"
67 68 69 70
      click_button "Save"
    end
  end

71
  step 'I change my password' do
72
    page.within '.update-password' do
73
      fill_in "user_current_password", with: "12345678"
74
      fill_in "user_password", with: "22233344"
75
      fill_in "user_password_confirmation", with: "22233344"
76 77
      click_button "Save"
    end
78 79
  end

80
  step 'I unsuccessfully change my password' do
81
    page.within '.update-password' do
82
      fill_in "user_current_password", with: "12345678"
83
      fill_in "user_password", with: "password"
84 85 86
      fill_in "user_password_confirmation", with: "confirmation"
      click_button "Save"
    end
87 88
  end

89
  step "I should see a missing password error message" do
90
    expect(page).to have_content "You must provide a valid current password"
91 92
  end

93
  step "I should see a password error message" do
94
    expect(page).to have_content "Password confirmation doesn't match"
95 96
  end

97
  step 'I reset my token' do
98
    page.within '.update-token' do
99 100 101
      @old_token = @user.private_token
      click_button "Reset"
    end
102 103
  end

104
  step 'I should see new token' do
105 106
    expect(find("#token").value).not_to eq @old_token
    expect(find("#token").value).to eq @user.reload.private_token
107
  end
R
randx 已提交
108

109
  step 'I have activity' do
110
    create(:closed_issue_event, author: current_user)
R
randx 已提交
111 112
  end

113
  step 'I should see my activity' do
114
    expect(page).to have_content "#{current_user.name} closed issue"
R
randx 已提交
115
  end
116

117
  step "I change my application theme" do
118
    page.within '.application-theme' do
119 120
      choose "Violet"
    end
121 122
  end

123
  step "I change my code preview theme" do
124
    page.within '.code-preview-theme' do
125
      choose "Solarized dark"
126
    end
127 128
  end

129
  step "I should see the theme change immediately" do
130 131
    expect(page).to have_selector('body.ui_color')
    expect(page).not_to have_selector('body.ui_basic')
132 133
  end

134
  step "I should receive feedback that the changes were saved" do
135
    expect(page).to have_content("saved")
136
  end
137 138 139 140 141

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

142
  step "I am not an ldap user" do
143
    current_user.identities.delete
144
    expect(current_user.ldap_user?).to be_false
145 146
  end

147
  step 'I redirected to expired password page' do
148
    expect(current_path).to eq new_profile_password_path
149 150 151
  end

  step 'I submit new password' do
152
    fill_in :user_current_password, with: '12345678'
153
    fill_in :user_password, with: '12345678'
154 155 156 157 158
    fill_in :user_password_confirmation, with: '12345678'
    click_button "Set new password"
  end

  step 'I redirected to sign in page' do
159
    expect(current_path).to eq new_user_session_path
160
  end
161

D
Dmitriy Zaporozhets 已提交
162
  step 'I should be redirected to password page' do
163
    expect(current_path).to eq edit_profile_password_path
D
Dmitriy Zaporozhets 已提交
164 165
  end

166
  step 'I should be redirected to account page' do
167
    expect(current_path).to eq profile_account_path
168 169
  end

170
  step 'I click on my profile picture' do
171
    find(:css, '.sidebar-user').click
172 173 174
  end

  step 'I should see my user page' do
175
    expect(page).to have_content "User Activity"
176

177
    page.within '.navbar-gitlab' do
178
      expect(page).to have_content current_user.name
179 180
    end
  end
181 182 183 184 185 186

  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)
187

188 189 190 191
    @project.team << [current_user, :master]
  end

  step 'I should see groups I belong to' do
192
    expect(page).to have_css('.profile-groups-avatars', visible: true)
193
  end
V
Valery Sizov 已提交
194 195 196 197 198 199

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

  step 'I should see application form' do
200
    expect(page).to have_content "New application"
V
Valery Sizov 已提交
201 202 203 204 205 206 207 208 209
  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
210 211 212
    expect(page).to have_content "Application: test"
    expect(page).to have_content "Application Id"
    expect(page).to have_content "Secret"
V
Valery Sizov 已提交
213 214 215 216 217 218 219
  end

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

  step 'I see edit application form' do
220
    expect(page).to have_content "Edit application"
V
Valery Sizov 已提交
221 222 223
  end

  step 'I change name of application and submit' do
224
    expect(page).to have_content "Edit application"
V
Valery Sizov 已提交
225 226 227 228 229
    fill_in :doorkeeper_application_name, with: 'test_changed'
    click_on "Submit"
  end

  step 'I see that application was changed' do
230 231 232
    expect(page).to have_content "test_changed"
    expect(page).to have_content "Application Id"
    expect(page).to have_content "Secret"
V
Valery Sizov 已提交
233 234 235
  end

  step 'I click to remove application' do
236
    page.within '.oauth-applications' do
V
Valery Sizov 已提交
237 238 239 240 241
      click_on "Destroy"
    end
  end

  step "I see that application is removed" do
242
    expect(page.find(".oauth-applications")).not_to have_content "test_changed"
V
Valery Sizov 已提交
243
  end
244
end