BigW Consortium Gitlab

profile.rb 6.45 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/-/system/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 have activity' do
108
    create(:closed_issue_event, author: current_user)
randx committed
109 110
  end

111
  step 'I should see my activity' do
112
    expect(page).to have_content "Signed in with standard authentication"
randx committed
113
  end
114

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

119
  step "I am not an ldap user" do
120
    current_user.identities.delete
Robert Speicher committed
121
    expect(current_user.ldap_user?).to eq false
122 123
  end

124
  step 'I redirected to expired password page' do
125
    expect(current_path).to eq new_profile_password_path
126 127 128
  end

  step 'I submit new password' do
129
    fill_in :user_current_password, with: '12345678'
130
    fill_in :user_password, with: '12345678'
131 132 133 134 135
    fill_in :user_password_confirmation, with: '12345678'
    click_button "Set new password"
  end

  step 'I redirected to sign in page' do
136
    expect(current_path).to eq new_user_session_path
137
  end
138

139
  step 'I should be redirected to password page' do
140
    expect(current_path).to eq edit_profile_password_path
141 142
  end

143
  step 'I should be redirected to account page' do
144
    expect(current_path).to eq profile_account_path
145 146
  end

147
  step 'I click on my profile picture' do
148 149 150 151 152
    find(:css, '.header-user-dropdown-toggle').click

    page.within ".header-user" do
      click_link "Profile"
    end
153 154 155
  end

  step 'I should see my user page' do
Dmitriy Zaporozhets committed
156
    page.within ".cover-block" do
157
      expect(page).to have_content current_user.name
Dmitriy Zaporozhets committed
158
      expect(page).to have_content current_user.username
159 160
    end
  end
161 162

  step 'I have group with projects' do
163
    @group = create(:group)
164
    @group.add_owner(current_user)
165
    @project = create(:project, :repository, namespace: @group)
166
    @event   = create(:closed_issue_event, project: @project)
167

168 169 170 171
    @project.team << [current_user, :master]
  end

  step 'I should see groups I belong to' do
Dmitriy Zaporozhets committed
172 173 174 175 176 177 178
    page.within ".content" do
      click_link "Groups"
    end

    page.within "#groups" do
      expect(page).to have_content @group.name
    end
179
  end
Valery Sizov committed
180 181

  step 'I should see application form' do
182
    expect(page).to have_content "Add new application"
Valery Sizov committed
183 184 185 186 187
  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'
188
    click_on "Save application"
Valery Sizov committed
189 190 191
  end

  step 'I see application' do
192 193 194
    expect(page).to have_content "Application: test"
    expect(page).to have_content "Application Id"
    expect(page).to have_content "Secret"
Valery Sizov committed
195 196 197 198 199 200 201
  end

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

  step 'I see edit application form' do
202
    expect(page).to have_content "Edit application"
Valery Sizov committed
203 204 205
  end

  step 'I change name of application and submit' do
206
    expect(page).to have_content "Edit application"
Valery Sizov committed
207
    fill_in :doorkeeper_application_name, with: 'test_changed'
208
    click_on "Save application"
Valery Sizov committed
209 210 211
  end

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

  step 'I click to remove application' do
218
    page.within '.oauth-applications' do
Valery Sizov committed
219 220 221 222 223
      click_on "Destroy"
    end
  end

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