profile.rb 6.4 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
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 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
R
Robert Speicher 已提交
90 91 92
    page.within ".flash-container" do
      expect(page).to have_content "You must provide a valid current password"
    end
93 94
  end

95
  step "I should see a password error message" do
R
Robert Speicher 已提交
96 97 98
    page.within '.alert' do
      expect(page).to have_content "Password confirmation doesn't match"
    end
99 100
  end

101
  step 'I reset my token' do
102
    page.within '.update-token' do
103 104 105
      @old_token = @user.private_token
      click_button "Reset"
    end
106 107
  end

108
  step 'I should see new token' do
109 110
    expect(find("#token").value).not_to eq @old_token
    expect(find("#token").value).to eq @user.reload.private_token
111
  end
R
randx 已提交
112

113
  step 'I have activity' do
114
    create(:closed_issue_event, author: current_user)
R
randx 已提交
115 116
  end

117
  step 'I should see my activity' do
118
    expect(page).to have_content "#{current_user.name} closed issue"
R
randx 已提交
119
  end
120

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

125
  step "I am not an ldap user" do
126
    current_user.identities.delete
R
Robert Speicher 已提交
127
    expect(current_user.ldap_user?).to eq false
128 129
  end

130
  step 'I redirected to expired password page' do
131
    expect(current_path).to eq new_profile_password_path
132 133 134
  end

  step 'I submit new password' do
135
    fill_in :user_current_password, with: '12345678'
136
    fill_in :user_password, with: '12345678'
137 138 139 140 141
    fill_in :user_password_confirmation, with: '12345678'
    click_button "Set new password"
  end

  step 'I redirected to sign in page' do
142
    expect(current_path).to eq new_user_session_path
143
  end
144

D
Dmitriy Zaporozhets 已提交
145
  step 'I should be redirected to password page' do
146
    expect(current_path).to eq edit_profile_password_path
D
Dmitriy Zaporozhets 已提交
147 148
  end

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

153
  step 'I click on my profile picture' do
154
    find(:css, '.sidebar-user').click
155 156 157
  end

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

160
    page.within '.navbar-gitlab' do
161
      expect(page).to have_content current_user.name
162 163
    end
  end
164 165 166 167 168 169

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

171 172 173 174
    @project.team << [current_user, :master]
  end

  step 'I should see groups I belong to' do
175
    expect(page).to have_css('.profile-groups-avatars', visible: true)
176
  end
V
Valery Sizov 已提交
177 178 179 180 181 182

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

  step 'I should see application form' do
183
    expect(page).to have_content "New Application"
V
Valery Sizov 已提交
184 185 186 187 188 189 190 191 192
  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
193 194 195
    expect(page).to have_content "Application: test"
    expect(page).to have_content "Application Id"
    expect(page).to have_content "Secret"
V
Valery Sizov 已提交
196 197 198 199 200 201 202
  end

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

  step 'I see edit application form' do
203
    expect(page).to have_content "Edit application"
V
Valery Sizov 已提交
204 205 206
  end

  step 'I change name of application and submit' do
207
    expect(page).to have_content "Edit application"
V
Valery Sizov 已提交
208 209 210 211 212
    fill_in :doorkeeper_application_name, with: 'test_changed'
    click_on "Submit"
  end

  step 'I see that application was changed' do
213 214 215
    expect(page).to have_content "test_changed"
    expect(page).to have_content "Application Id"
    expect(page).to have_content "Secret"
V
Valery Sizov 已提交
216 217 218
  end

  step 'I click to remove application' do
219
    page.within '.oauth-applications' do
V
Valery Sizov 已提交
220 221 222 223 224
      click_on "Destroy"
    end
  end

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