profile.rb 6.6 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
  step 'I change my avatar' do
30
    attach_file(:user_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
S
Steven Thonus 已提交
31 32 33 34 35
    click_button "Save changes"
    @user.reload
  end

  step 'I should see new avatar' do
36
    expect(@user.avatar).to be_instance_of AvatarUploader
G
Gabriel Mazetto 已提交
37
    expect(@user.avatar.url).to eq "/uploads/user/avatar/#{@user.id}/banana_sample.gif"
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
  end

  step 'I have an avatar' do
45
    attach_file(:user_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
46 47 48 49 50 51 52 53 54 55
    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
R
Robert Speicher 已提交
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
D
Dmitriy Zaporozhets 已提交
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 72 73 74
      click_button "Save"
    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 81
      click_button "Save"
    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 89 90
      fill_in "user_password_confirmation", with: "confirmation"
      click_button "Save"
    end
91 92
  end

93
  step "I should see a missing password error message" do
R
Robert Speicher 已提交
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
R
Robert Speicher 已提交
101 102
      expect(page).to have_content "Password confirmation doesn't match"
    end
103 104
  end

105
  step 'I reset my token' do
106
    page.within '.update-token' do
107 108 109
      @old_token = @user.private_token
      click_button "Reset"
    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
R
randx 已提交
116

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

121
  step 'I should see my activity' do
V
Valery Sizov 已提交
122
    expect(page).to have_content "Signed in with standard authentication"
R
randx 已提交
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
R
Robert Speicher 已提交
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

D
Dmitriy Zaporozhets 已提交
149
  step 'I should be redirected to password page' do
150
    expect(current_path).to eq edit_profile_password_path
D
Dmitriy Zaporozhets 已提交
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
158
    find(:css, '.sidebar-user').click
159 160 161
  end

  step 'I should see my user page' do
D
Dmitriy Zaporozhets 已提交
162
    page.within ".cover-block" do
163
      expect(page).to have_content current_user.name
D
Dmitriy Zaporozhets 已提交
164
      expect(page).to have_content current_user.username
165 166
    end
  end
167 168 169 170 171 172

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

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

  step 'I should see groups I belong to' do
D
Dmitriy Zaporozhets 已提交
178 179 180 181 182 183 184
    page.within ".content" do
      click_link "Groups"
    end

    page.within "#groups" do
      expect(page).to have_content @group.name
    end
185
  end
V
Valery Sizov 已提交
186 187 188 189 190 191

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

  step 'I should see application form' do
192
    expect(page).to have_content "New Application"
V
Valery Sizov 已提交
193 194 195 196 197 198 199 200 201
  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
202 203 204
    expect(page).to have_content "Application: test"
    expect(page).to have_content "Application Id"
    expect(page).to have_content "Secret"
V
Valery Sizov 已提交
205 206 207 208 209 210 211
  end

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

  step 'I see edit application form' do
212
    expect(page).to have_content "Edit application"
V
Valery Sizov 已提交
213 214 215
  end

  step 'I change name of application and submit' do
216
    expect(page).to have_content "Edit application"
V
Valery Sizov 已提交
217 218 219 220 221
    fill_in :doorkeeper_application_name, with: 'test_changed'
    click_on "Submit"
  end

  step 'I see that application was changed' do
222 223 224
    expect(page).to have_content "test_changed"
    expect(page).to have_content "Application Id"
    expect(page).to have_content "Secret"
V
Valery Sizov 已提交
225 226 227
  end

  step 'I click to remove application' do
228
    page.within '.oauth-applications' do
V
Valery Sizov 已提交
229 230 231 232 233
      click_on "Destroy"
    end
  end

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