2018-02-12 14:17:19 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'User edit profile' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
visit(profile_path)
|
|
|
|
end
|
|
|
|
|
2018-07-31 04:21:53 -04:00
|
|
|
def submit_settings
|
|
|
|
click_button 'Update profile settings'
|
2019-02-01 11:24:11 -05:00
|
|
|
wait_for_requests if respond_to?(:wait_for_requests)
|
2018-07-31 04:21:53 -04:00
|
|
|
end
|
|
|
|
|
2018-02-12 14:17:19 -05:00
|
|
|
it 'changes user profile' do
|
|
|
|
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'
|
|
|
|
fill_in 'user_organization', with: 'GitLab'
|
2018-07-31 04:21:53 -04:00
|
|
|
submit_settings
|
2018-02-12 14:17:19 -05:00
|
|
|
|
|
|
|
expect(user.reload).to have_attributes(
|
|
|
|
skype: 'testskype',
|
|
|
|
linkedin: 'testlinkedin',
|
|
|
|
twitter: 'testtwitter',
|
|
|
|
website_url: 'testurl',
|
|
|
|
bio: 'I <3 GitLab',
|
|
|
|
organization: 'GitLab'
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(find('#user_location').value).to eq 'Ukraine'
|
|
|
|
expect(page).to have_content('Profile was successfully updated')
|
|
|
|
end
|
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
it 'shows an error if the full name contains an emoji', :js do
|
|
|
|
simulate_input('#user_name', 'Martin 😀')
|
|
|
|
submit_settings
|
|
|
|
|
|
|
|
page.within('.qa-full-name') do
|
|
|
|
expect(page).to have_css '.gl-field-error-outline'
|
|
|
|
expect(find('.gl-field-error')).not_to have_selector('.hidden')
|
|
|
|
expect(find('.gl-field-error')).to have_content('Using emojis in names seems fun, but please try to set a status message instead')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-12 14:17:19 -05:00
|
|
|
context 'user avatar' do
|
|
|
|
before do
|
|
|
|
attach_file(:user_avatar, Rails.root.join('spec', 'fixtures', 'banana_sample.gif'))
|
2018-07-31 04:21:53 -04:00
|
|
|
submit_settings
|
2018-02-12 14:17:19 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'changes user avatar' do
|
|
|
|
expect(page).to have_link('Remove avatar')
|
|
|
|
|
|
|
|
user.reload
|
|
|
|
expect(user.avatar).to be_instance_of AvatarUploader
|
|
|
|
expect(user.avatar.url).to eq "/uploads/-/system/user/avatar/#{user.id}/banana_sample.gif"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes user avatar' do
|
|
|
|
click_link 'Remove avatar'
|
|
|
|
|
|
|
|
user.reload
|
|
|
|
|
|
|
|
expect(user.avatar?).to eq false
|
|
|
|
expect(page).not_to have_link('Remove avatar')
|
|
|
|
expect(page).to have_link('gravatar.com')
|
|
|
|
end
|
|
|
|
end
|
2018-07-24 10:16:09 -04:00
|
|
|
|
2018-07-31 04:21:53 -04:00
|
|
|
context 'user status', :js do
|
2019-02-01 11:24:11 -05:00
|
|
|
def visit_user
|
|
|
|
visit user_path(user)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
def select_emoji(emoji_name, is_modal = false)
|
|
|
|
emoji_menu_class = is_modal ? '.js-modal-status-emoji-menu' : '.js-status-emoji-menu'
|
2018-07-31 04:21:53 -04:00
|
|
|
toggle_button = find('.js-toggle-emoji-menu')
|
|
|
|
toggle_button.click
|
2018-10-04 04:19:51 -04:00
|
|
|
emoji_button = find(%Q{#{emoji_menu_class} .js-emoji-btn gl-emoji[data-name="#{emoji_name}"]})
|
2018-07-31 04:21:53 -04:00
|
|
|
emoji_button.click
|
|
|
|
end
|
2018-07-24 10:16:09 -04:00
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
context 'profile edit form' do
|
|
|
|
it 'shows the user status form' do
|
|
|
|
expect(page).to have_content('Current status')
|
|
|
|
end
|
2018-07-24 10:16:09 -04:00
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
it 'adds emoji to user status' do
|
|
|
|
emoji = 'biohazard'
|
|
|
|
select_emoji(emoji)
|
|
|
|
submit_settings
|
2018-07-24 10:16:09 -04:00
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
within('.cover-status') do
|
|
|
|
expect(page).to have_emoji(emoji)
|
|
|
|
end
|
2018-07-31 04:21:53 -04:00
|
|
|
end
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
it 'adds message to user status' do
|
|
|
|
message = 'I have something to say'
|
|
|
|
fill_in 'js-status-message-field', with: message
|
|
|
|
submit_settings
|
2018-07-31 04:21:53 -04:00
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
within('.cover-status') do
|
|
|
|
expect(page).to have_emoji('speech_balloon')
|
|
|
|
expect(page).to have_content message
|
|
|
|
end
|
2018-07-31 04:21:53 -04:00
|
|
|
end
|
2018-07-24 10:16:09 -04:00
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
it 'adds message and emoji to user status' do
|
|
|
|
emoji = 'tanabata_tree'
|
|
|
|
message = 'Playing outside'
|
|
|
|
select_emoji(emoji)
|
|
|
|
fill_in 'js-status-message-field', with: message
|
|
|
|
submit_settings
|
2018-07-31 04:21:53 -04:00
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
within('.cover-status') do
|
|
|
|
expect(page).to have_emoji(emoji)
|
|
|
|
expect(page).to have_content message
|
|
|
|
end
|
2018-07-31 04:21:53 -04:00
|
|
|
end
|
2018-07-24 10:16:09 -04:00
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
it 'clears the user status' do
|
|
|
|
user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread')
|
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
within('.cover-status') do
|
|
|
|
expect(page).to have_emoji(user_status.emoji)
|
|
|
|
expect(page).to have_content user_status.message
|
|
|
|
end
|
|
|
|
|
|
|
|
visit(profile_path)
|
|
|
|
click_button 'js-clear-user-status-button'
|
|
|
|
submit_settings
|
2018-07-31 04:21:53 -04:00
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
2018-10-06 07:43:14 -04:00
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
expect(page).not_to have_selector '.cover-status'
|
2018-07-31 04:21:53 -04:00
|
|
|
end
|
2018-07-24 10:16:09 -04:00
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
it 'displays a default emoji if only message is entered' do
|
|
|
|
message = 'a status without emoji'
|
|
|
|
fill_in 'js-status-message-field', with: message
|
2018-07-24 10:16:09 -04:00
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
within('.js-toggle-emoji-menu') do
|
|
|
|
expect(page).to have_emoji('speech_balloon')
|
|
|
|
end
|
|
|
|
end
|
2018-07-24 10:16:09 -04:00
|
|
|
end
|
2018-08-28 04:12:53 -04:00
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
context 'user menu' do
|
2018-12-31 08:58:20 -05:00
|
|
|
let(:issue) { create(:issue, project: project)}
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
def open_user_status_modal
|
|
|
|
find('.header-user-dropdown-toggle').click
|
|
|
|
|
|
|
|
page.within ".header-user" do
|
|
|
|
click_button 'Set status'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_user_status_in_modal
|
|
|
|
page.within "#set-user-status-modal" do
|
|
|
|
click_button 'Set status'
|
|
|
|
end
|
2019-02-01 11:24:11 -05:00
|
|
|
wait_for_requests
|
2018-10-04 04:19:51 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit root_path(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the "Set status" menu item in the user menu' do
|
|
|
|
find('.header-user-dropdown-toggle').click
|
|
|
|
|
|
|
|
page.within ".header-user" do
|
|
|
|
expect(page).to have_content('Set status')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the "Edit status" menu item in the user menu' do
|
|
|
|
user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread')
|
|
|
|
visit root_path(user)
|
|
|
|
|
|
|
|
find('.header-user-dropdown-toggle').click
|
|
|
|
|
|
|
|
page.within ".header-user" do
|
|
|
|
expect(page).to have_emoji(user_status.emoji)
|
|
|
|
expect(page).to have_content user_status.message
|
|
|
|
expect(page).to have_content('Edit status')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows user status modal' do
|
|
|
|
open_user_status_modal
|
|
|
|
|
|
|
|
expect(page.find('#set-user-status-modal')).to be_visible
|
|
|
|
expect(page).to have_content('Set a status')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds emoji to user status' do
|
|
|
|
emoji = 'biohazard'
|
|
|
|
open_user_status_modal
|
|
|
|
select_emoji(emoji, true)
|
|
|
|
set_user_status_in_modal
|
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
within('.cover-status') do
|
|
|
|
expect(page).to have_emoji(emoji)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-31 08:58:20 -05:00
|
|
|
it 'does not update the awards panel emoji' do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
visit(project_issue_path(project, issue))
|
|
|
|
|
|
|
|
emoji = 'biohazard'
|
|
|
|
open_user_status_modal
|
|
|
|
select_emoji(emoji, true)
|
|
|
|
|
|
|
|
expect(page.all('.award-control .js-counter')).to all(have_content('0'))
|
|
|
|
end
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
it 'adds message to user status' do
|
|
|
|
message = 'I have something to say'
|
|
|
|
open_user_status_modal
|
|
|
|
find('.js-status-message-field').native.send_keys(message)
|
|
|
|
set_user_status_in_modal
|
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
within('.cover-status') do
|
|
|
|
expect(page).to have_emoji('speech_balloon')
|
|
|
|
expect(page).to have_content message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds message and emoji to user status' do
|
|
|
|
emoji = 'tanabata_tree'
|
|
|
|
message = 'Playing outside'
|
|
|
|
open_user_status_modal
|
|
|
|
select_emoji(emoji, true)
|
|
|
|
find('.js-status-message-field').native.send_keys(message)
|
|
|
|
set_user_status_in_modal
|
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
within('.cover-status') do
|
|
|
|
expect(page).to have_emoji(emoji)
|
|
|
|
expect(page).to have_content message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'clears the user status with the "X" button' do
|
|
|
|
user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread')
|
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
|
|
|
wait_for_requests
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
within('.cover-status') do
|
|
|
|
expect(page).to have_emoji(user_status.emoji)
|
|
|
|
expect(page).to have_content user_status.message
|
|
|
|
end
|
|
|
|
|
|
|
|
find('.header-user-dropdown-toggle').click
|
|
|
|
|
|
|
|
page.within ".header-user" do
|
|
|
|
click_button 'Edit status'
|
|
|
|
end
|
|
|
|
|
|
|
|
find('.js-clear-user-status-button').click
|
|
|
|
set_user_status_in_modal
|
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
|
|
|
wait_for_requests
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
expect(page).not_to have_selector '.cover-status'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'clears the user status with the "Remove status" button' do
|
|
|
|
user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread')
|
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
|
|
|
wait_for_requests
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
within('.cover-status') do
|
|
|
|
expect(page).to have_emoji(user_status.emoji)
|
|
|
|
expect(page).to have_content user_status.message
|
|
|
|
end
|
|
|
|
|
|
|
|
find('.header-user-dropdown-toggle').click
|
|
|
|
|
|
|
|
page.within ".header-user" do
|
|
|
|
click_button 'Edit status'
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within "#set-user-status-modal" do
|
|
|
|
click_button 'Remove status'
|
|
|
|
end
|
|
|
|
|
2019-02-01 11:24:11 -05:00
|
|
|
visit_user
|
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
expect(page).not_to have_selector '.cover-status'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays a default emoji if only message is entered' do
|
|
|
|
message = 'a status without emoji'
|
|
|
|
open_user_status_modal
|
|
|
|
find('.js-status-message-field').native.send_keys(message)
|
2018-08-28 04:12:53 -04:00
|
|
|
|
2018-10-04 04:19:51 -04:00
|
|
|
within('.js-toggle-emoji-menu') do
|
|
|
|
expect(page).to have_emoji('speech_balloon')
|
|
|
|
end
|
2018-08-28 04:12:53 -04:00
|
|
|
end
|
|
|
|
end
|
2018-07-24 10:16:09 -04:00
|
|
|
end
|
2018-02-12 14:17:19 -05:00
|
|
|
end
|