BigW Consortium Gitlab

profile.rb 6.74 KB
Newer Older
1
class Spinach::Features::Profile < Spinach::FeatureSteps
Nihad Abbasov committed
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

Jerome Dalbert committed
9
  step 'I change my profile info' do
10 11 12 13 14 15
    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'
16
    fill_in 'user_organization', with: 'GitLab'
17
    click_button 'Update profile settings'
18 19 20
    @user.reload
  end

Jerome Dalbert committed
21
  step 'I should see new profile info' do
22 23 24 25 26
    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'
27
    expect(@user.organization).to eq 'GitLab'
28
    expect(find('#user_location').value).to eq 'Ukraine'
29 30
  end

31
  step 'I change my avatar' do
32 33 34
    attach_file(:user_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
    click_button "Update profile settings"
    @user.reload
35 36 37
  end

  step 'I should see new avatar' do
38
    expect(@user.avatar).to be_instance_of AvatarUploader
39
    expect(@user.avatar.url).to eq "/uploads/user/avatar/#{@user.id}/banana_sample.gif"
40 41
  end

42
  step 'I should see the "Remove avatar" button' do
43
    expect(page).to have_link("Remove avatar")
44 45 46
  end

  step 'I have an avatar' do
47 48 49
    attach_file(:user_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
    click_button "Update profile settings"
    @user.reload
50 51 52 53 54 55 56 57
  end

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

  step 'I should see my gravatar' do
Robert Speicher committed
58
    expect(@user.avatar?).to eq false
59 60 61
  end

  step 'I should not see the "Remove avatar" button' do
62
    expect(page).not_to have_link("Remove avatar")
63
  end
Dmitriy Zaporozhets committed
64

65 66 67
  step 'I should see the gravatar host link' do
    expect(page).to have_link("gravatar.com")
  end
68

69
  step 'I try change my password w/o old one' do
70
    page.within '.update-password' do
71
      fill_in "user_password", with: "22233344"
72
      fill_in "user_password_confirmation", with: "22233344"
73
      click_button "Save password"
74 75 76
    end
  end

77
  step 'I change my password' do
78
    page.within '.update-password' do
79
      fill_in "user_current_password", with: "12345678"
80
      fill_in "user_password", with: "22233344"
81
      fill_in "user_password_confirmation", with: "22233344"
82
      click_button "Save password"
83
    end
84 85
  end

86
  step 'I unsuccessfully change my password' do
87
    page.within '.update-password' do
88
      fill_in "user_current_password", with: "12345678"
89
      fill_in "user_password", with: "password"
90
      fill_in "user_password_confirmation", with: "confirmation"
91
      click_button "Save password"
92
    end
93 94
  end

95
  step "I should see a missing password error message" do
Robert Speicher committed
96 97 98
    page.within ".flash-container" do
      expect(page).to have_content "You must provide a valid current password"
    end
99 100
  end

101
  step "I should see a password error message" do
102
    page.within '.alert-danger' do
Robert Speicher committed
103 104
      expect(page).to have_content "Password confirmation doesn't match"
    end
105 106
  end

107
  step 'I reset my token' do
Phil Hughes committed
108
    page.within '.private-token' do
109
      @old_token = @user.private_token
Phil Hughes committed
110
      click_button "Reset private token"
111
    end
112 113
  end

114
  step 'I should see new token' do
115 116
    expect(find("#token").value).not_to eq @old_token
    expect(find("#token").value).to eq @user.reload.private_token
117
  end
randx committed
118

119
  step 'I have activity' do
120
    create(:closed_issue_event, author: current_user)
randx committed
121 122
  end

123
  step 'I should see my activity' do
124
    expect(page).to have_content "Signed in with standard authentication"
randx committed
125
  end
126

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

131
  step "I am not an ldap user" do
132
    current_user.identities.delete
Robert Speicher committed
133
    expect(current_user.ldap_user?).to eq false
134 135
  end

136
  step 'I redirected to expired password page' do
137
    expect(current_path).to eq new_profile_password_path
138 139 140
  end

  step 'I submit new password' do
141
    fill_in :user_current_password, with: '12345678'
142
    fill_in :user_password, with: '12345678'
143 144 145 146 147
    fill_in :user_password_confirmation, with: '12345678'
    click_button "Set new password"
  end

  step 'I redirected to sign in page' do
148
    expect(current_path).to eq new_user_session_path
149
  end
150

151
  step 'I should be redirected to password page' do
152
    expect(current_path).to eq edit_profile_password_path
153 154
  end

155
  step 'I should be redirected to account page' do
156
    expect(current_path).to eq profile_account_path
157 158
  end

159
  step 'I click on my profile picture' do
160 161 162 163 164
    find(:css, '.header-user-dropdown-toggle').click

    page.within ".header-user" do
      click_link "Profile"
    end
165 166 167
  end

  step 'I should see my user page' do
Dmitriy Zaporozhets committed
168
    page.within ".cover-block" do
169
      expect(page).to have_content current_user.name
Dmitriy Zaporozhets committed
170
      expect(page).to have_content current_user.username
171 172
    end
  end
173 174

  step 'I have group with projects' do
175
    @group = create(:group)
176 177 178
    @group.add_owner(current_user)
    @project = create(:project, namespace: @group)
    @event   = create(:closed_issue_event, project: @project)
179

180 181 182 183
    @project.team << [current_user, :master]
  end

  step 'I should see groups I belong to' do
Dmitriy Zaporozhets committed
184 185 186 187 188 189 190
    page.within ".content" do
      click_link "Groups"
    end

    page.within "#groups" do
      expect(page).to have_content @group.name
    end
191
  end
Valery Sizov committed
192 193

  step 'I should see application form' do
194
    expect(page).to have_content "Add new application"
Valery Sizov committed
195 196 197 198 199
  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'
200
    click_on "Save application"
Valery Sizov committed
201 202 203
  end

  step 'I see application' do
204 205 206
    expect(page).to have_content "Application: test"
    expect(page).to have_content "Application Id"
    expect(page).to have_content "Secret"
Valery Sizov committed
207 208 209 210 211 212 213
  end

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

  step 'I see edit application form' do
214
    expect(page).to have_content "Edit application"
Valery Sizov committed
215 216 217
  end

  step 'I change name of application and submit' do
218
    expect(page).to have_content "Edit application"
Valery Sizov committed
219
    fill_in :doorkeeper_application_name, with: 'test_changed'
220
    click_on "Save application"
Valery Sizov committed
221 222 223
  end

  step 'I see that application was changed' do
224 225 226
    expect(page).to have_content "test_changed"
    expect(page).to have_content "Application Id"
    expect(page).to have_content "Secret"
Valery Sizov committed
227 228 229
  end

  step 'I click to remove application' do
230
    page.within '.oauth-applications' do
Valery Sizov committed
231 232 233 234 235
      click_on "Destroy"
    end
  end

  step "I see that application is removed" do
236
    expect(page.find(".oauth-applications")).not_to have_content "test_changed"
Valery Sizov committed
237
  end
238
end