debian-mirror-gitlab/features/steps/profile/profile.rb

234 lines
6.6 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Spinach::Features::Profile < Spinach::FeatureSteps
2014-09-02 18:07:02 +05:30
include SharedAuthentication
include SharedPaths
step 'I should see my profile info' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "This information will appear on your profile"
2014-09-02 18:07:02 +05:30
end
step 'I change my profile info' do
2015-09-11 14:41:01 +05:30
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'
2016-06-02 11:05:42 +05:30
click_button 'Update profile settings'
2014-09-02 18:07:02 +05:30
@user.reload
end
step 'I should see new profile info' do
2015-09-11 14:41:01 +05:30
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'
expect(find('#user_location').value).to eq 'Ukraine'
2014-09-02 18:07:02 +05:30
end
step 'I change my avatar' do
2015-09-11 14:41:01 +05:30
attach_file(:user_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
2016-06-02 11:05:42 +05:30
click_button "Update profile settings"
2014-09-02 18:07:02 +05:30
@user.reload
end
step 'I should see new avatar' do
2015-09-11 14:41:01 +05:30
expect(@user.avatar).to be_instance_of AvatarUploader
2015-12-23 02:04:40 +05:30
expect(@user.avatar.url).to eq "/uploads/user/avatar/#{@user.id}/banana_sample.gif"
2014-09-02 18:07:02 +05:30
end
step 'I should see the "Remove avatar" button' do
2015-09-11 14:41:01 +05:30
expect(page).to have_link("Remove avatar")
2014-09-02 18:07:02 +05:30
end
step 'I have an avatar' do
2015-09-11 14:41:01 +05:30
attach_file(:user_avatar, File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif'))
2016-06-02 11:05:42 +05:30
click_button "Update profile settings"
2014-09-02 18:07:02 +05:30
@user.reload
end
step 'I remove my avatar' do
click_link "Remove avatar"
@user.reload
end
step 'I should see my gravatar' do
2015-09-11 14:41:01 +05:30
expect(@user.avatar?).to eq false
2014-09-02 18:07:02 +05:30
end
step 'I should not see the "Remove avatar" button' do
2015-09-11 14:41:01 +05:30
expect(page).not_to have_link("Remove avatar")
end
2015-11-26 14:37:03 +05:30
2015-09-11 14:41:01 +05:30
step 'I should see the gravatar host link' do
expect(page).to have_link("gravatar.com")
2014-09-02 18:07:02 +05:30
end
step 'I try change my password w/o old one' do
2015-09-11 14:41:01 +05:30
page.within '.update-password' do
2014-09-02 18:07:02 +05:30
fill_in "user_password", with: "22233344"
fill_in "user_password_confirmation", with: "22233344"
2016-06-02 11:05:42 +05:30
click_button "Save password"
2014-09-02 18:07:02 +05:30
end
end
step 'I change my password' do
2015-09-11 14:41:01 +05:30
page.within '.update-password' do
2014-09-02 18:07:02 +05:30
fill_in "user_current_password", with: "12345678"
fill_in "user_password", with: "22233344"
fill_in "user_password_confirmation", with: "22233344"
2016-06-02 11:05:42 +05:30
click_button "Save password"
2014-09-02 18:07:02 +05:30
end
end
step 'I unsuccessfully change my password' do
2015-09-11 14:41:01 +05:30
page.within '.update-password' do
2014-09-02 18:07:02 +05:30
fill_in "user_current_password", with: "12345678"
fill_in "user_password", with: "password"
fill_in "user_password_confirmation", with: "confirmation"
2016-06-02 11:05:42 +05:30
click_button "Save password"
2014-09-02 18:07:02 +05:30
end
end
step "I should see a missing password error message" do
2015-09-11 14:41:01 +05:30
page.within ".flash-container" do
expect(page).to have_content "You must provide a valid current password"
end
2014-09-02 18:07:02 +05:30
end
step "I should see a password error message" do
2016-04-02 18:10:28 +05:30
page.within '.alert-danger' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Password confirmation doesn't match"
end
2014-09-02 18:07:02 +05:30
end
step 'I reset my token' do
2016-06-02 11:05:42 +05:30
page.within '.private-token' do
2014-09-02 18:07:02 +05:30
@old_token = @user.private_token
2016-06-02 11:05:42 +05:30
click_button "Reset private token"
2014-09-02 18:07:02 +05:30
end
end
step 'I should see new token' do
2015-09-11 14:41:01 +05:30
expect(find("#token").value).not_to eq @old_token
expect(find("#token").value).to eq @user.reload.private_token
2014-09-02 18:07:02 +05:30
end
step 'I have activity' do
create(:closed_issue_event, author: current_user)
end
step 'I should see my activity' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Signed in with standard authentication"
2014-09-02 18:07:02 +05:30
end
step 'my password is expired' do
current_user.update_attributes(password_expires_at: Time.now - 1.hour)
end
step "I am not an ldap user" do
2015-04-26 12:48:37 +05:30
current_user.identities.delete
2015-09-11 14:41:01 +05:30
expect(current_user.ldap_user?).to eq false
2014-09-02 18:07:02 +05:30
end
step 'I redirected to expired password page' do
2015-09-11 14:41:01 +05:30
expect(current_path).to eq new_profile_password_path
2014-09-02 18:07:02 +05:30
end
step 'I submit new password' do
fill_in :user_current_password, with: '12345678'
fill_in :user_password, with: '12345678'
fill_in :user_password_confirmation, with: '12345678'
click_button "Set new password"
end
step 'I redirected to sign in page' do
2015-09-11 14:41:01 +05:30
expect(current_path).to eq new_user_session_path
2014-09-02 18:07:02 +05:30
end
step 'I should be redirected to password page' do
2015-09-11 14:41:01 +05:30
expect(current_path).to eq edit_profile_password_path
2014-09-02 18:07:02 +05:30
end
step 'I should be redirected to account page' do
2015-09-11 14:41:01 +05:30
expect(current_path).to eq profile_account_path
2014-09-02 18:07:02 +05:30
end
step 'I click on my profile picture' do
find(:css, '.side-nav-toggle').click
2015-09-11 14:41:01 +05:30
find(:css, '.sidebar-user').click
2014-09-02 18:07:02 +05:30
end
step 'I should see my user page' do
2015-11-26 14:37:03 +05:30
page.within ".cover-block" do
2015-09-11 14:41:01 +05:30
expect(page).to have_content current_user.name
2015-11-26 14:37:03 +05:30
expect(page).to have_content current_user.username
2014-09-02 18:07:02 +05:30
end
end
step 'I have group with projects' do
2016-06-02 11:05:42 +05:30
@group = create(:group)
2014-09-02 18:07:02 +05:30
@group.add_owner(current_user)
@project = create(:project, namespace: @group)
@event = create(:closed_issue_event, project: @project)
@project.team << [current_user, :master]
end
step 'I should see groups I belong to' do
2015-11-26 14:37:03 +05:30
page.within ".content" do
click_link "Groups"
end
page.within "#groups" do
expect(page).to have_content @group.name
end
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I should see application form' do
2016-06-02 11:05:42 +05:30
expect(page).to have_content "Add new application"
2015-04-26 12:48:37 +05:30
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'
2016-06-02 11:05:42 +05:30
click_on "Save application"
2015-04-26 12:48:37 +05:30
end
step 'I see application' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Application: test"
expect(page).to have_content "Application Id"
expect(page).to have_content "Secret"
2015-04-26 12:48:37 +05:30
end
step 'I click edit' do
click_on "Edit"
end
step 'I see edit application form' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Edit application"
2015-04-26 12:48:37 +05:30
end
step 'I change name of application and submit' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Edit application"
2015-04-26 12:48:37 +05:30
fill_in :doorkeeper_application_name, with: 'test_changed'
2016-06-02 11:05:42 +05:30
click_on "Save application"
2015-04-26 12:48:37 +05:30
end
step 'I see that application was changed' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "test_changed"
expect(page).to have_content "Application Id"
expect(page).to have_content "Secret"
2015-04-26 12:48:37 +05:30
end
step 'I click to remove application' do
2015-09-11 14:41:01 +05:30
page.within '.oauth-applications' do
2015-04-26 12:48:37 +05:30
click_on "Destroy"
end
end
step "I see that application is removed" do
2015-09-11 14:41:01 +05:30
expect(page.find(".oauth-applications")).not_to have_content "test_changed"
2015-04-26 12:48:37 +05:30
end
2014-09-02 18:07:02 +05:30
end