2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe 'profiles/show' do
|
2023-04-23 21:23:45 +05:30
|
|
|
let_it_be(:user_status) { create(:user_status, clear_status_at: 8.hours.from_now) }
|
|
|
|
let_it_be(:user) { user_status.user }
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
assign(:user, user)
|
|
|
|
allow(controller).to receive(:current_user).and_return(user)
|
2019-12-26 22:10:19 +05:30
|
|
|
allow(view).to receive(:experiment_enabled?)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the profile page is opened' do
|
|
|
|
it 'displays the correct elements' do
|
|
|
|
render
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
expect(rendered).to have_field('user_name', with: user.name)
|
|
|
|
expect(rendered).to have_field('user_id', with: user.id)
|
2022-10-11 01:57:18 +05:30
|
|
|
|
|
|
|
expectd_link = help_page_path('user/profile/index', anchor: 'change-the-email-displayed-on-your-commits')
|
|
|
|
expected_link_html = "<a href=\"#{expectd_link}\" target=\"_blank\" " \
|
|
|
|
"rel=\"noopener noreferrer\">#{_('Learn more.')}</a>"
|
|
|
|
expect(rendered.include?(expected_link_html)).to eq(true)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2023-04-23 21:23:45 +05:30
|
|
|
|
|
|
|
it 'renders required hidden inputs for set status form' do
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_field(
|
|
|
|
'user[status][emoji]',
|
|
|
|
with: user_status.emoji,
|
|
|
|
type: :hidden
|
|
|
|
)
|
|
|
|
expect(rendered).to have_field(
|
|
|
|
'user[status][message]',
|
|
|
|
with: user_status.message,
|
|
|
|
type: :hidden
|
|
|
|
)
|
|
|
|
expect(rendered).to have_field(
|
|
|
|
'user[status][availability]',
|
|
|
|
with: user_status.availability,
|
|
|
|
type: :hidden
|
|
|
|
)
|
|
|
|
expect(rendered).to have_field(
|
|
|
|
'user[status][clear_status_after]',
|
|
|
|
with: user_status.clear_status_at.to_s(:iso8601),
|
|
|
|
type: :hidden
|
|
|
|
)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|