BigW Consortium Gitlab

profile.rb 6.61 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
    click_button 'Update profile settings'
17 18 19
    @user.reload
  end

Jerome Dalbert committed
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

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

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

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

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

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

  step 'I should see my gravatar' do
Robert Speicher committed
56
    expect(@user.avatar?).to eq 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
  end
Dmitriy Zaporozhets committed
62

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

157
  step 'I click on my profile picture' do
Annabel Dunstone committed
158
    find(:css, '.side-nav-toggle').click
159
    find(:css, '.sidebar-user').click
160 161 162
  end

  step 'I should see my user page' do
Dmitriy Zaporozhets committed
163
    page.within ".cover-block" do
164
      expect(page).to have_content current_user.name
Dmitriy Zaporozhets committed
165
      expect(page).to have_content current_user.username
166 167
    end
  end
168 169

  step 'I have group with projects' do
170
    @group = create(:group)
171 172 173
    @group.add_owner(current_user)
    @project = create(:project, namespace: @group)
    @event   = create(:closed_issue_event, project: @project)
174

175 176 177 178
    @project.team << [current_user, :master]
  end

  step 'I should see groups I belong to' do
Dmitriy Zaporozhets committed
179 180 181 182 183 184 185
    page.within ".content" do
      click_link "Groups"
    end

    page.within "#groups" do
      expect(page).to have_content @group.name
    end
186
  end
Valery Sizov committed
187 188

  step 'I should see application form' do
189
    expect(page).to have_content "Add new application"
Valery Sizov committed
190 191 192 193 194
  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'
195
    click_on "Save application"
Valery Sizov committed
196 197 198
  end

  step 'I see application' do
199 200 201
    expect(page).to have_content "Application: test"
    expect(page).to have_content "Application Id"
    expect(page).to have_content "Secret"
Valery Sizov committed
202 203 204 205 206 207 208
  end

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

  step 'I see edit application form' do
209
    expect(page).to have_content "Edit application"
Valery Sizov committed
210 211 212
  end

  step 'I change name of application and submit' do
213
    expect(page).to have_content "Edit application"
Valery Sizov committed
214
    fill_in :doorkeeper_application_name, with: 'test_changed'
215
    click_on "Save application"
Valery Sizov committed
216 217 218
  end

  step 'I see that application was changed' do
219 220 221
    expect(page).to have_content "test_changed"
    expect(page).to have_content "Application Id"
    expect(page).to have_content "Secret"
Valery Sizov committed
222 223 224
  end

  step 'I click to remove application' do
225
    page.within '.oauth-applications' do
Valery Sizov committed
226 227 228 229 230
      click_on "Destroy"
    end
  end

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